Add Run control event stream

This commit is contained in:
npc0-hue
2026-08-26 23:06:06 +08:00
parent 6369a8099a
commit 55a5d6de80
10 changed files with 274 additions and 3 deletions
+8
View File
@@ -86,6 +86,7 @@ type Core interface {
ListRunEndpoints(domain.RunEndpointFilter) ([]domain.RunEndpoint, error)
RegisterRunHello(domain.RunControlHello) (domain.RunControlHelloResult, error)
AcceptRunHeartbeat(domain.RunControlHeartbeat) (domain.RunControlHeartbeatResult, error)
SubscribeRunControlEvents(domain.RunControlStreamRequest) (RunControlEventSubscription, error)
AuthorizeRunRequestSignature(domain.RunRequestSignature) error
CreateServerInstance(domain.ServerInstance) (domain.ServerInstance, error)
CreateServerInstanceForSession(string, domain.ServerInstance) (domain.ServerInstance, error)
@@ -233,6 +234,10 @@ type CoreService struct {
controlMu sync.Mutex
runSessions map[string]domain.RunControlSession
runSessionSeq uint64
controlStreamMu sync.Mutex
controlStreamSeq map[string]uint64
controlStreamEvents map[string]domain.RunControlEvent
controlStreamWaiters map[string][]chan domain.RunControlEvent
jobMu sync.Mutex
jobWaitMu sync.Mutex
jobWaiters map[string][]chan struct{}
@@ -284,6 +289,9 @@ func newCoreServiceWithLogStore(store repo.Store, logStore LogBodyStore, now fun
now: now,
authSessions: map[string]string{},
runSessions: map[string]domain.RunControlSession{},
controlStreamSeq: map[string]uint64{},
controlStreamEvents: map[string]domain.RunControlEvent{},
controlStreamWaiters: map[string][]chan domain.RunControlEvent{},
jobWaiters: map[string][]chan struct{}{},
logStore: logStore,
logProjectionStates: map[string]map[string]pluginLogSequenceState{},