Documentation
¶
Index ¶
- Constants
- func RunOutboxDispatcher(dispatcher *OutboxDispatcher)
- type AppSessionEventHandler
- type ContainerCreateWorker
- type ContainerManager
- func (m *ContainerManager) CreateByTemplate(ctx context.Context, templateID int64, ownerType types.ContainerOwnerType, ...) (*types.ContainerInstance, error)
- func (m *ContainerManager) CreateQueueMaxPending() int
- func (m *ContainerManager) Delete(ctx context.Context, id int64) error
- func (m *ContainerManager) GetLogs(ctx context.Context, id int64, tail int) (string, error)
- func (s *ContainerManager) GetMaxConcurrency() int
- func (m *ContainerManager) OnEvent(e containerruntime.RuntimeEvent)
- func (m *ContainerManager) QueueStatus(ctx context.Context) (*CreateQueueStatus, error)
- func (m *ContainerManager) RecoverRuntimeMonitoring(ctx context.Context) (int, error)
- func (m *ContainerManager) RunRuntimeReconciler(ctx context.Context, interval time.Duration)
- func (m *ContainerManager) Start(ctx context.Context, id int64) error
- func (m *ContainerManager) Stop(ctx context.Context, id int64) error
- func (m *ContainerManager) StopByOwner(ctx context.Context, ownerType types.ContainerOwnerType, ownerID int64) error
- func (s *ContainerManager) TransitionContainerAndEnqueueOutbox(ctx context.Context, inst *types.ContainerInstance, to types.ContainerStatus, ...) error
- type ContainerRuntimeResolveInput
- type ContainerRuntimeResolver
- type CreateQueueStatus
- type ImageManager
- type OutboxCreateRequestEvent
- type OutboxDeleteRequestEvent
- type OutboxDispatcher
- type OutboxRecreateRequestEvent
- type OutboxStartRequestEvent
- type OutboxStopRequestEvent
Constants ¶
const ( // OutboxEventTypeCreateRequest is the outbox event type for container creation requests. OutboxEventTypeCreateRequest = "ContainerCreateRequest" // OutboxEventTypeStopRequest is the outbox event type for container stop requests. OutboxEventTypeStopRequest = "ContainerStopRequest" // OutboxEventTypeDeleteRequest is the outbox event type for container delete requests. OutboxEventTypeDeleteRequest = "ContainerDeleteRequest" // OutboxEventTypeStartRequest is the outbox event type for container start requests. OutboxEventTypeRecreateRequest = "AppSessionContainerRecreateRequest" OutboxEventTypeStartRequest = "ContainerStartRequest" )
Variables ¶
This section is empty.
Functions ¶
func RunOutboxDispatcher ¶
func RunOutboxDispatcher(dispatcher *OutboxDispatcher)
Types ¶
type AppSessionEventHandler ¶
type AppSessionEventHandler struct {
// contains filtered or unexported fields
}
AppSessionEventHandler listens for ContainerEvent on the event bus and synchronizes the corresponding AppSession status accordingly.
When a container transitions to creating/running/stopped/failed, this handler updates the owning AppSession's Status, StartedAt, and StoppedAt fields so that the AppSession reflects the actual container lifecycle.
Only containers with OwnerType == ContainerOwnerAppSession are processed; DAG nodes and services are ignored.
func NewAppSessionEventHandler ¶
func NewAppSessionEventHandler(repo interfaces.ContainerRepository, hub *realtime.Hub) *AppSessionEventHandler
func (*AppSessionEventHandler) Handle ¶
func (h *AppSessionEventHandler) Handle(evt event.Event)
type ContainerCreateWorker ¶
type ContainerCreateWorker struct {
// contains filtered or unexported fields
}
ContainerCreateWorker subscribes to OutboxCreateRequestEvent and ContainerEvent from the event bus. For creation requests it executes rt.Create + rt.Start, and updates the active create request count while the request is being handled.
func NewContainerCreateWorker ¶
func NewContainerCreateWorker( repo interfaces.ContainerRepository, projectRepo interfaces.ProjectRepository, analysisRepo interfaces.AnalysisRepository, workflowService interfaces.WorkflowService, reg *containerruntime.Registry, res ContainerRuntimeResolver, containerManager *ContainerManager, cfg *config.Config, ) *ContainerCreateWorker
NewContainerCreateWorker creates a new worker.
func (*ContainerCreateWorker) Handle ¶
func (w *ContainerCreateWorker) Handle(evt event.Event)
Handle dispatches events from the event bus. It handles four event types:
- OutboxCreateRequestEvent: executes deferred container creation
- OutboxStopRequestEvent: executes deferred container stop
- OutboxDeleteRequestEvent: executes deferred container delete
- OutboxStartRequestEvent: executes deferred container start
type ContainerManager ¶
type ContainerManager struct {
// contains filtered or unexported fields
}
func NewContainerManager ¶
func NewContainerManager( containerRepo interfaces.ContainerRepository, analysisRepo interfaces.AnalysisRepository, projectRepo interfaces.ProjectRepository, workflowService interfaces.WorkflowService, reg *containerruntime.Registry, bus event.Bus, res ContainerRuntimeResolver, img *ImageManager, cfg *config.Config, ) *ContainerManager
func (*ContainerManager) CreateByTemplate ¶
func (m *ContainerManager) CreateByTemplate( ctx context.Context, templateID int64, ownerType types.ContainerOwnerType, ownerID int64, name string, ) (*types.ContainerInstance, error)
return nil }
func (*ContainerManager) CreateQueueMaxPending ¶
func (m *ContainerManager) CreateQueueMaxPending() int
func (*ContainerManager) Delete ¶
func (m *ContainerManager) Delete(ctx context.Context, id int64) error
func (*ContainerManager) GetMaxConcurrency ¶
func (s *ContainerManager) GetMaxConcurrency() int
func (*ContainerManager) OnEvent ¶
func (m *ContainerManager) OnEvent(e containerruntime.RuntimeEvent)
如果容器运行太快,ContainerStarted与 ContainerExited可能会竞争
func (*ContainerManager) QueueStatus ¶
func (m *ContainerManager) QueueStatus(ctx context.Context) (*CreateQueueStatus, error)
func (*ContainerManager) RecoverRuntimeMonitoring ¶
func (m *ContainerManager) RecoverRuntimeMonitoring(ctx context.Context) (int, error)
func (*ContainerManager) RunRuntimeReconciler ¶
func (m *ContainerManager) RunRuntimeReconciler(ctx context.Context, interval time.Duration)
RunRuntimeReconciler periodically reconnects runtime monitoring.
func (*ContainerManager) Start ¶
func (m *ContainerManager) Start(ctx context.Context, id int64) error
func (*ContainerManager) Stop ¶
func (m *ContainerManager) Stop(ctx context.Context, id int64) error
func (*ContainerManager) StopByOwner ¶
func (m *ContainerManager) StopByOwner(ctx context.Context, ownerType types.ContainerOwnerType, ownerID int64) error
func (*ContainerManager) TransitionContainerAndEnqueueOutbox ¶
func (s *ContainerManager) TransitionContainerAndEnqueueOutbox(ctx context.Context, inst *types.ContainerInstance, to types.ContainerStatus, eventType string) error
type ContainerRuntimeResolveInput ¶
type ContainerRuntimeResolveInput struct {
Spec *types.ContainerSpec
Variables map[string]string
}
type ContainerRuntimeResolver ¶
type ContainerRuntimeResolver interface {
Resolve(ctx context.Context, in *ContainerRuntimeResolveInput) (*types.ContainerSpec, error)
}
func NewDefaultContainerRuntimeResolver ¶
func NewDefaultContainerRuntimeResolver() ContainerRuntimeResolver
type CreateQueueStatus ¶
type ImageManager ¶
type ImageManager struct {
// contains filtered or unexported fields
}
func NewImageManager ¶
func NewImageManager(repo interfaces.ContainerRepository, reg *containerruntime.Registry) *ImageManager
type OutboxCreateRequestEvent ¶
OutboxCreateRequestEvent is published to the event bus when a ContainerCreateRequest outbox event is picked up. Handlers that need to process deferred container creation subscribe to this.
type OutboxDeleteRequestEvent ¶
OutboxDeleteRequestEvent is published to the event bus when a ContainerDeleteRequest outbox event is picked up.
type OutboxDispatcher ¶
type OutboxDispatcher struct {
// contains filtered or unexported fields
}
func NewOutboxDispatcher ¶
func NewOutboxDispatcher(repo interfaces.ContainerRepository, bus event.Bus) *OutboxDispatcher
func (*OutboxDispatcher) Start ¶
func (d *OutboxDispatcher) Start(ctx context.Context)
type OutboxStartRequestEvent ¶
OutboxStartRequestEvent is published to the event bus when a ContainerStartRequest outbox event is picked up.
type OutboxStopRequestEvent ¶
OutboxStopRequestEvent is published to the event bus when a ContainerStopRequest outbox event is picked up.