cloudcompute

package
v0.0.0-...-00760b4 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: MIT Imports: 17 Imported by: 0

README

Cloud Compute Docker Provider

The cloud compute docker provider is intended to support local development of plugins.

//create a provider with a job execution concurrency of 4:
computeProvider := NewDockerComputeProvider(DockerComputeProviderConfig{
	Concurrency: 4,
})

//create a provider with a secrets manager
sm := NewSecretManager("")

sm.AddSecret("arn:local:secretsmanager:secret:prod/CloudCompute/ASDFASDF:AWS_ACCESS_KEY_ID::", "ASFASDFASDFASDF")
sm.AddSecret("arn:local:secretsmanager:secret:prod/CloudCompute/ASDFASDF:AWS_SECRET_ACCESS_KEY::", "ASDFFASDFASDFASDF")

computeProvider2 := NewDockerComputeProvider(DockerComputeProviderConfig{
    Concurrency:    1,
    SecretsManager: sm,
})

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KvpToEnv

func KvpToEnv(kvp []KeyValuePair) []string

Types

type DockerComputeManager

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

func NewDockerComputeManager

func NewDockerComputeManager(config DockerComputeManagerConfig) *DockerComputeManager

func (*DockerComputeManager) AddJob

func (dcm *DockerComputeManager) AddJob(djob *DockerJob)

func (*DockerComputeManager) StartMonitor

func (dcm *DockerComputeManager) StartMonitor(interval int, monitorFunc MonitorFunction)

func (*DockerComputeManager) TerminateJobs

func (dcm *DockerComputeManager) TerminateJobs(input TerminateJobInput)

type DockerComputeManagerConfig

type DockerComputeManagerConfig struct {
	Concurrency               int
	DockerPullProgressFactory DockerPullProgressFactory
}

type DockerComputeProvider

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

func NewDockerComputeProvider

func NewDockerComputeProvider(config DockerComputeProviderConfig) *DockerComputeProvider

NewDockerComputeProvider creates a new DockerComputeProvider based on the given configuration.

func (*DockerComputeProvider) JobLog

func (dcp *DockerComputeProvider) JobLog(submittedJobId string, token *string) (JobLogOutput, error)

func (*DockerComputeProvider) RegisterPlugin

func (dcp *DockerComputeProvider) RegisterPlugin(plugin *Plugin) (PluginRegistrationOutput, error)

RegisterPlugin registers a plugin with the DockerComputeProvider.

func (*DockerComputeProvider) Status

func (dcp *DockerComputeProvider) Status(jobQueue string, query JobsSummaryQuery) error

Status retrieves and returns job summaries based on the query.

func (*DockerComputeProvider) SubmitJob

func (dcp *DockerComputeProvider) SubmitJob(job *Job) error

SubmitJob submits a job for execution.

func (*DockerComputeProvider) TerminateJobs

func (dcp *DockerComputeProvider) TerminateJobs(input TerminateJobInput) error

TerminateJobs terminates jobs based on the provided input.

func (*DockerComputeProvider) UnregisterPlugin

func (dcp *DockerComputeProvider) UnregisterPlugin(nameAndRevision string) error

type DockerComputeProviderConfig

type DockerComputeProviderConfig struct {
	//number of concurrent containers to allow on the host
	Concurrency int

	//starts a monitor job which provides job summary counts similar to the AWS Batch dashboard.
	//If the value provided is greater than 0, the monitor will start using the value as a monitoring interval in seconds
	StartMonitor int

	//optional monitor function.  The default monitor will print the status counts to StdOut
	MonitorFunction MonitorFunction

	//optional in memory secrets manager if a secrets mock is necessary
	SecretsManager SecretsManager

	//docker pull progress ui instance generator
	DockerPullProgressFactory DockerPullProgressFactory
}

DockerComputeProviderConfig holds the configuration for DockerComputeProvider.

type DockerEvent

type DockerEvent struct {
	ID             string `json:"id"`
	Status         string `json:"status"`
	Error          string `json:"error"`
	Progress       string `json:"progress"`
	ProgressDetail struct {
		Current int64 `json:"current"`
		Total   int64 `json:"total"`
	} `json:"progressDetail"`
}

type DockerJob

type DockerJob struct {
	Job    *Job
	Plugin *Plugin
	Status JobStatus
	Log    string

	SecretsManager SecretsManager
	// contains filtered or unexported fields
}

type DockerJobRunner

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

func NewRunner

func NewRunner(job *DockerJob) (*DockerJobRunner, error)

func (*DockerJobRunner) Close

func (dr *DockerJobRunner) Close()

func (*DockerJobRunner) Run

func (dr *DockerJobRunner) Run() error

func (*DockerJobRunner) Terminate

func (dr *DockerJobRunner) Terminate() error

type DockerMonitorWriter

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

Custom writer that formats output with job ID

func (*DockerMonitorWriter) Write

func (cw *DockerMonitorWriter) Write(p []byte) (n int, err error)

type DockerPullProgress

type DockerPullProgress interface {
	Update(msg DockerEvent)
	Close()
}

type DockerPullProgressFactory

type DockerPullProgressFactory interface {
	New() DockerPullProgress
}

type DockerRunMonitor

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

func NewDockerRunMonitor

func NewDockerRunMonitor(dr *DockerJobRunner, containerId string) *DockerRunMonitor

func (*DockerRunMonitor) Wait

func (drm *DockerRunMonitor) Wait()

type EnvironmentSecretManager

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

func (*EnvironmentSecretManager) AddSecret

func (sm *EnvironmentSecretManager) AddSecret(key string, val string)

func (*EnvironmentSecretManager) GetSecret

func (sm *EnvironmentSecretManager) GetSecret(key string) string

type InMemoryJobQueue

type InMemoryJobQueue struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*InMemoryJobQueue) Add

func (jq *InMemoryJobQueue) Add(job *DockerJob)

func (*InMemoryJobQueue) GetJob

func (jq *InMemoryJobQueue) GetJob(id uuid.UUID) *DockerJob

func (*InMemoryJobQueue) GetNextRunnable

func (jq *InMemoryJobQueue) GetNextRunnable() *DockerJob

func (*InMemoryJobQueue) Jobs

func (jq *InMemoryJobQueue) Jobs(statuses ...JobStatus) []*DockerJob

func (*InMemoryJobQueue) UpdateJobs

func (jq *InMemoryJobQueue) UpdateJobs() []uuid.UUID

type InMemoryPluginRegistry

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

func (*InMemoryPluginRegistry) Deregister

func (pr *InMemoryPluginRegistry) Deregister(name string) error

func (*InMemoryPluginRegistry) Get

func (pr *InMemoryPluginRegistry) Get(name string) (*Plugin, error)

func (*InMemoryPluginRegistry) Register

func (pr *InMemoryPluginRegistry) Register(plugin *Plugin) error

type InMemorySecretsManager

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

func (*InMemorySecretsManager) AddSecret

func (sm *InMemorySecretsManager) AddSecret(key string, val string)

func (*InMemorySecretsManager) GetSecret

func (sm *InMemorySecretsManager) GetSecret(key string) string

type JobDeps

type JobDeps []*DockerJob

type JobQueue

type JobQueue interface {
	Add(job *DockerJob)

	//Gets the next runable job and sets the status to Starting
	GetNextRunnable() *DockerJob

	//Gets all jobs matching the set of statuses
	//Calling with no status argument will return all jobs
	Jobs(statuses ...JobStatus) []*DockerJob

	//Get a job by ID
	GetJob(jobId uuid.UUID) *DockerJob

	UpdateJobs() []uuid.UUID
}

func NewInMemoryJobQueue

func NewInMemoryJobQueue() JobQueue

type JobStatus

type JobStatus string
const (
	Submitted JobStatus = "SUBMITTED"
	Pending   JobStatus = "PENDING"
	Runnable  JobStatus = "RUNNABLE"
	Starting  JobStatus = "STARTING"
	Running   JobStatus = "RUNNING"
	Succeeded JobStatus = "SUCCEEDED"
	Failed    JobStatus = "FAILED"
)

type MonitorFunction

type MonitorFunction func(statuses map[JobStatus]int)

type PluginRegistry

type PluginRegistry interface {
	Register(plugin *Plugin) error
	Deregister(name string) error
	Get(name string) (*Plugin, error)
}

func NewInMemoryPluginRegistry

func NewInMemoryPluginRegistry() PluginRegistry

type SecretsManager

type SecretsManager interface {
	AddSecret(key string, val string)
	GetSecret(key string) string
}

func NewEnvironmentSecretsManager

func NewEnvironmentSecretsManager() SecretsManager

func NewInMemorySecretsManager

func NewInMemorySecretsManager(key string) SecretsManager

create a new in memory secret manager key is reserved for adding an encryption key should it be added later

Jump to

Keyboard shortcuts

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