Refactor interfaces to use a runner manager and an environment manager.
See https://gitlab.hpi.de/codeocean/codemoon/poseidon/-/issues/44.
This commit is contained in:
59
environment/manager.go
Normal file
59
environment/manager.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package environment
|
||||
|
||||
import (
|
||||
"gitlab.hpi.de/codeocean/codemoon/poseidon/nomad"
|
||||
"gitlab.hpi.de/codeocean/codemoon/poseidon/runner"
|
||||
)
|
||||
|
||||
// Manager encapsulates API calls to the executor API for creation and deletion of execution environments.
|
||||
type Manager interface {
|
||||
// Load fetches all already created execution environments from the executor and registers them at the runner manager.
|
||||
// It should be called during the startup process (e.g. on creation of the Manager).
|
||||
Load()
|
||||
|
||||
// Create creates a new execution environment on the executor.
|
||||
Create(
|
||||
id string,
|
||||
prewarmingPoolSize uint,
|
||||
cpuLimit uint,
|
||||
memoryLimit uint,
|
||||
image string,
|
||||
networkAccess bool,
|
||||
exposedPorts []uint16,
|
||||
)
|
||||
|
||||
// Delete remove the execution environment with the given id from the executor.
|
||||
Delete(id string)
|
||||
}
|
||||
|
||||
func NewNomadEnvironmentManager(runnerManager runner.Manager, apiClient nomad.ExecutorApi) *NomadEnvironmentManager {
|
||||
environmentManager := &NomadEnvironmentManager{runnerManager, apiClient}
|
||||
environmentManager.Load()
|
||||
return environmentManager
|
||||
}
|
||||
|
||||
type NomadEnvironmentManager struct {
|
||||
runnerManager runner.Manager
|
||||
api nomad.ExecutorApi
|
||||
}
|
||||
|
||||
func (m *NomadEnvironmentManager) Create(
|
||||
id string,
|
||||
prewarmingPoolSize uint,
|
||||
cpuLimit uint,
|
||||
memoryLimit uint,
|
||||
image string,
|
||||
networkAccess bool,
|
||||
exposedPorts []uint16,
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
func (m *NomadEnvironmentManager) Delete(id string) {
|
||||
|
||||
}
|
||||
|
||||
func (m *NomadEnvironmentManager) Load() {
|
||||
// ToDo: remove create default execution environment for debugging purposes
|
||||
m.runnerManager.RegisterEnvironment(runner.EnvironmentId(0), "python", 5)
|
||||
}
|
Reference in New Issue
Block a user