Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions server/cmd/api/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"log/slog"
"os"
"sync"
"sync/atomic"
"time"

"github.com/kernel/kernel-images/server/lib/cdpmonitor"
Expand Down Expand Up @@ -86,6 +87,28 @@ type ApiService struct {
// or mutate its runtime flags and policies.
chromiumConfigMu sync.Mutex

browserLocationMu sync.Mutex
browserLocationApplyMu sync.Mutex
browserLocationReconcile func(context.Context, browserLocationBundle)
browserLocation struct {
activeEpoch string
browserGeneration uint64
accepted *browserLocationBundle
applied *browserLocationBundle
components browserLocationComponents
lastError string
cancel context.CancelFunc
acceptedCount atomic.Uint64
appliedCount atomic.Uint64
retries atomic.Uint64
stale atomic.Uint64
conflicts atomic.Uint64
epochRejects atomic.Uint64
failures atomic.Uint64
convergenceMs atomic.Uint64
lastAttempt time.Time
}

// inputMu serializes input-related operations (mouse, keyboard, screenshot)
inputMu sync.Mutex

Expand Down Expand Up @@ -205,6 +228,10 @@ func New(
lifecycleCancel: cancel,
}
s.playwrightExecutors = newPlaywrightExecutorManager(cdpPlaywrightExecutorTabs{withCDP: s.withCDPClient})
if err := s.initializeBrowserLocation(); err != nil {
cancel()
return nil, err
}
return s, nil
}

Expand Down
Loading
Loading