container.go RawHistoryFolder
1// Package in defines input ports (interfaces) for use cases.
2// These interfaces define the contract between driving adapters (HTTP, CLI)
3// and the business logic (use cases).
4package in
5
6import (
7 "context"
8
9 "github.com/bnema/gordon/internal/domain"
10)
11
12// ContainerService defines the contract for container management operations.
13type ContainerService interface {
14 // Deploy creates and starts a container for the given route.
15 Deploy(ctx context.Context, route domain.Route) (*domain.Container, error)
16
17 // Stop stops a running container.
18 Stop(ctx context.Context, containerID string) error
19
20 // Remove removes a container, optionally forcing removal.
21 Remove(ctx context.Context, containerID string, force bool) error
22
23 // ReconcileRemovedRoute removes active route runtime containers after the
24 // route has been removed from configuration, preserving stateful resources.
25 ReconcileRemovedRoute(ctx context.Context, domain string) (*domain.CleanupReport, error)
26
27 // Get retrieves a container by domain name.
28 Get(ctx context.Context, domain string) (*domain.Container, bool)
29
30 // Restart restarts a running container for the given domain.
31 // If withAttachments is true, also restarts attachment containers.
32 Restart(ctx context.Context, domain string, withAttachments bool) error
33
34 // List returns all managed containers.
35 List(ctx context.Context) map[string]*domain.Container
36
37 // ListRoutesWithDetails returns routes with network and attachment info.
38 ListRoutesWithDetails(ctx context.Context) []domain.RouteInfo
39
40 // ListAttachments returns attachments for a domain.
41 ListAttachments(ctx context.Context, domain string) []domain.Attachment
42
43 // ListOrphanedAttachments returns running attachment containers no longer configured.
44 ListOrphanedAttachments(ctx context.Context) ([]domain.CleanupAttachment, error)
45
46 // CleanupOrphanedAttachments optionally stops/removes orphaned attachment containers.
47 // When owner is non-empty, cleanup is scoped to that attachment owner.
48 CleanupOrphanedAttachments(ctx context.Context, owner string, stop bool) (*domain.CleanupReport, error)
49
50 // ListNetworks returns Gordon-managed networks.
51 ListNetworks(ctx context.Context) ([]*domain.NetworkInfo, error)
52
53 // HealthCheck performs health checks on all containers.
54 HealthCheck(ctx context.Context) map[string]bool
55
56 // SyncContainers synchronizes containers with configured routes.
57 SyncContainers(ctx context.Context) error
58
59 // UpdateAttachments updates the attachment configuration in the container service.
60 // This is called after a config reload to propagate attachment changes without restart.
61 UpdateAttachments(attachments map[string][]string)
62
63 // AutoStart starts containers for the provided routes that aren't running.
64 AutoStart(ctx context.Context, routes []domain.Route) error
65
66 // Shutdown gracefully shuts down all managed containers.
67 Shutdown(ctx context.Context) error
68}