@@ -41,22 +41,10 @@ type PortMapping struct {
41
41
Protocol string
42
42
}
43
43
44
- // Runtime defines the interface for container runtimes that manage workloads.
45
- //
46
- // A workload in ToolHive represents a complete deployment unit that may consist of:
47
- // - Primary MCP server container
48
- // - Sidecar containers (for logging, monitoring, proxying, etc.)
49
- // - Network configurations and port mappings
50
- // - Volume mounts and storage
51
- // - Service discovery and load balancing components
52
- // - Security policies and permission profiles
53
- //
54
- // This is a departure from simple container management, as modern deployments
55
- // often require orchestrating multiple interconnected components that work
56
- // together to provide a complete service.
57
- //
58
- //go:generate mockgen -destination=mocks/mock_runtime.go -package=mocks -source=types.go Runtime
59
- type Runtime interface {
44
+ // Deployer contains the methods to start and stop a workload.
45
+ // This is intended as a subset of the Runtime interface for
46
+ // the runner code.
47
+ type Deployer interface {
60
48
// DeployWorkload creates and starts a complete workload deployment.
61
49
// This includes the primary container, any required sidecars, networking setup,
62
50
// volume mounts, and service configuration. The workload is started as part
@@ -86,16 +74,45 @@ type Runtime interface {
86
74
isolateNetwork bool ,
87
75
) (string , int , error )
88
76
89
- // ListWorkloads lists all deployed workloads managed by this runtime.
90
- // Returns information about each workload including its components,
91
- // status, and resource usage.
92
- ListWorkloads (ctx context.Context ) ([]ContainerInfo , error )
93
-
94
77
// StopWorkload gracefully stops a running workload and all its components.
95
78
// This includes stopping the primary container, sidecars, and cleaning up
96
79
// any associated network resources. The workload remains available for restart.
97
80
StopWorkload (ctx context.Context , workloadID string ) error
98
81
82
+ // AttachToWorkload establishes a direct connection to the primary container
83
+ // of the workload for interactive communication. This is typically used
84
+ // for stdio transport where direct input/output streaming is required.
85
+ AttachToWorkload (ctx context.Context , workloadID string ) (io.WriteCloser , io.ReadCloser , error )
86
+
87
+ // IsWorkloadRunning checks if a workload is currently running and healthy.
88
+ // This verifies that the primary container is running and that any
89
+ // required sidecars are also operational.
90
+ IsWorkloadRunning (ctx context.Context , workloadID string ) (bool , error )
91
+ }
92
+
93
+ // Runtime defines the interface for container runtimes that manage workloads.
94
+ //
95
+ // A workload in ToolHive represents a complete deployment unit that may consist of:
96
+ // - Primary MCP server container
97
+ // - Sidecar containers (for logging, monitoring, proxying, etc.)
98
+ // - Network configurations and port mappings
99
+ // - Volume mounts and storage
100
+ // - Service discovery and load balancing components
101
+ // - Security policies and permission profiles
102
+ //
103
+ // This is a departure from simple container management, as modern deployments
104
+ // often require orchestrating multiple interconnected components that work
105
+ // together to provide a complete service.
106
+ //
107
+ //go:generate mockgen -destination=mocks/mock_runtime.go -package=mocks -source=types.go Runtime
108
+ type Runtime interface {
109
+ Deployer
110
+
111
+ // ListWorkloads lists all deployed workloads managed by this runtime.
112
+ // Returns information about each workload including its components,
113
+ // status, and resource usage.
114
+ ListWorkloads (ctx context.Context ) ([]ContainerInfo , error )
115
+
99
116
// RemoveWorkload completely removes a workload and all its components.
100
117
// This includes removing containers, cleaning up networks, volumes,
101
118
// and any other resources associated with the workload. This operation
@@ -108,21 +125,11 @@ type Runtime interface {
108
125
// main MCP server container.
109
126
GetWorkloadLogs (ctx context.Context , workloadID string , follow bool ) (string , error )
110
127
111
- // IsWorkloadRunning checks if a workload is currently running and healthy.
112
- // This verifies that the primary container is running and that any
113
- // required sidecars are also operational.
114
- IsWorkloadRunning (ctx context.Context , workloadID string ) (bool , error )
115
-
116
128
// GetWorkloadInfo retrieves detailed information about a workload.
117
129
// This includes status, resource usage, network configuration,
118
130
// and metadata about all components in the workload.
119
131
GetWorkloadInfo (ctx context.Context , workloadID string ) (ContainerInfo , error )
120
132
121
- // AttachToWorkload establishes a direct connection to the primary container
122
- // of the workload for interactive communication. This is typically used
123
- // for stdio transport where direct input/output streaming is required.
124
- AttachToWorkload (ctx context.Context , workloadID string ) (io.WriteCloser , io.ReadCloser , error )
125
-
126
133
// IsRunning checks the health of the container runtime.
127
134
// This is used to verify that the runtime is operational and can manage workloads.
128
135
IsRunning (ctx context.Context ) error
0 commit comments