Help us shape the future of Go! Take the 2026 Go Developer Survey

manager

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
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 (*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

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 (*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) GetLogs

func (m *ContainerManager) GetLogs(ctx context.Context, id int64, tail int) (string, error)

func (*ContainerManager) GetMaxConcurrency

func (s *ContainerManager) GetMaxConcurrency() int

func (*ContainerManager) OnEvent

如果容器运行太快,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 CreateQueueStatus struct {
	ActiveCount    int64
	PendingCount   int64
	MaxConcurrency int
	MaxPending     int
}

type ImageManager

type ImageManager struct {
	// contains filtered or unexported fields
}

type OutboxCreateRequestEvent

type OutboxCreateRequestEvent struct {
	OutboxID   int64
	RawPayload []byte
}

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

type OutboxDeleteRequestEvent struct {
	OutboxID   int64
	RawPayload []byte
}

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 OutboxRecreateRequestEvent

type OutboxRecreateRequestEvent struct {
	OutboxID   int64
	RawPayload []byte
}

type OutboxStartRequestEvent

type OutboxStartRequestEvent struct {
	OutboxID   int64
	RawPayload []byte
}

OutboxStartRequestEvent is published to the event bus when a ContainerStartRequest outbox event is picked up.

type OutboxStopRequestEvent

type OutboxStopRequestEvent struct {
	OutboxID   int64
	RawPayload []byte
}

OutboxStopRequestEvent is published to the event bus when a ContainerStopRequest outbox event is picked up.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL