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

deployment

package
v1.11.3 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoScaleConfig

type AutoScaleConfig struct {
	MinReplicas    int           `json:"min_replicas"`
	MaxReplicas    int           `json:"max_replicas"`
	TargetCPU      int           `json:"target_cpu_percent,omitempty"`
	TargetMemory   int           `json:"target_memory_percent,omitempty"`
	TargetQPS      int           `json:"target_qps,omitempty"`
	ScaleDownDelay time.Duration `json:"scale_down_delay,omitempty"`
}

自动缩放配置自动缩放 。

type DeployOptions

type DeployOptions struct {
	Name      string
	AgentID   string
	Target    DeploymentTarget
	Replicas  int
	Config    DeploymentConfig
	Resources ResourceConfig
	Metadata  map[string]string
}

部署选项配置部署 。

type Deployer

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

部署人员管理代理部署。

func NewDeployer

func NewDeployer(logger *zap.Logger) *Deployer

新部署者创建了新的部署者.

func (*Deployer) Delete

func (d *Deployer) Delete(ctx context.Context, deploymentID string) error

删除一个部署。

func (*Deployer) Deploy

func (d *Deployer) Deploy(ctx context.Context, opts DeployOptions) (*Deployment, error)

向指定目标部署特工。

func (*Deployer) ExportManifest

func (d *Deployer) ExportManifest(deploymentID string) ([]byte, error)

按 K8s 显示的“出口管理”出口部署。

func (*Deployer) GetDeployment

func (d *Deployer) GetDeployment(deploymentID string) (*Deployment, error)

得到部署返回一个部署的ID。

func (*Deployer) GetDeploymentsByAgent added in v1.0.0

func (d *Deployer) GetDeploymentsByAgent(agentID string) []*Deployment

GetDeploymentsByAgent returns all deployments for a given agent ID.

func (*Deployer) ListDeployments

func (d *Deployer) ListDeployments() []*Deployment

列表调度返回所有部署 。

func (*Deployer) RegisterProvider

func (d *Deployer) RegisterProvider(target DeploymentTarget, provider DeploymentProvider)

提供人员登记部署提供者。

func (*Deployer) Scale

func (d *Deployer) Scale(ctx context.Context, deploymentID string, replicas int) error

缩放一个部署。

func (*Deployer) SetCallbacks added in v1.0.0

func (d *Deployer) SetCallbacks(cb DeploymentEventCallbacks)

SetCallbacks configures lifecycle event hooks.

func (*Deployer) Update

func (d *Deployer) Update(ctx context.Context, deploymentID string, config DeploymentConfig) error

更新现有部署。

type Deployment

type Deployment struct {
	ID          string            `json:"id"`
	Name        string            `json:"name"`
	AgentID     string            `json:"agent_id"`
	Target      DeploymentTarget  `json:"target"`
	Status      DeploymentStatus  `json:"status"`
	Endpoint    string            `json:"endpoint,omitempty"`
	Replicas    int               `json:"replicas"`
	Config      DeploymentConfig  `json:"config"`
	Resources   ResourceConfig    `json:"resources"`
	CreatedAt   time.Time         `json:"created_at"`
	UpdatedAt   time.Time         `json:"updated_at"`
	Metadata    map[string]string `json:"metadata,omitempty"`
	HealthCheck *HealthCheck      `json:"health_check,omitempty"`
}

部署是部署的代理人实例。

type DeploymentConfig

type DeploymentConfig struct {
	Image       string            `json:"image,omitempty"`
	Port        int               `json:"port"`
	Environment map[string]string `json:"environment,omitempty"`
	Secrets     []SecretRef       `json:"secrets,omitempty"`
	AutoScale   *AutoScaleConfig  `json:"auto_scale,omitempty"`
	Timeout     time.Duration     `json:"timeout,omitempty"`
}

部署配置包含部署配置。

type DeploymentEventCallbacks added in v1.0.0

type DeploymentEventCallbacks struct {
	OnDeploy func(d *Deployment)
	OnDelete func(deploymentID string)
	OnScale  func(deploymentID string, from, to int)
}

DeploymentEventCallbacks holds optional lifecycle event hooks.

type DeploymentProvider

type DeploymentProvider interface {
	Deploy(ctx context.Context, deployment *Deployment) error
	Update(ctx context.Context, deployment *Deployment) error
	Delete(ctx context.Context, deploymentID string) error
	GetStatus(ctx context.Context, deploymentID string) (*Deployment, error)
	Scale(ctx context.Context, deploymentID string, replicas int) error
	GetLogs(ctx context.Context, deploymentID string, lines int) ([]string, error)
}

部署提供方定义了部署后端的接口.

type DeploymentStatus

type DeploymentStatus string

部署状况是部署状况。

const (
	StatusPending   DeploymentStatus = "pending"
	StatusDeploying DeploymentStatus = "deploying"
	StatusRunning   DeploymentStatus = "running"
	StatusFailed    DeploymentStatus = "failed"
	StatusStopped   DeploymentStatus = "stopped"
	StatusScaling   DeploymentStatus = "scaling"
)

type DeploymentTarget

type DeploymentTarget string

部署 目标定义了部署目标类型.

const (
	TargetKubernetes DeploymentTarget = "kubernetes"
	TargetCloudRun   DeploymentTarget = "cloud_run"
	TargetLambda     DeploymentTarget = "lambda"
	TargetLocal      DeploymentTarget = "local"
)

type DockerProvider added in v1.0.0

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

DockerProvider manages agents as Docker containers. It uses exec.Command("docker", ...) — no Docker SDK dependency.

func NewDockerProvider added in v1.0.0

func NewDockerProvider(logger *zap.Logger) *DockerProvider

NewDockerProvider creates a new Docker provider.

func (*DockerProvider) Delete added in v1.0.0

func (p *DockerProvider) Delete(ctx context.Context, deploymentID string) error

Delete stops and removes the Docker container.

func (*DockerProvider) Deploy added in v1.0.0

func (p *DockerProvider) Deploy(ctx context.Context, d *Deployment) error

Deploy starts a Docker container for the deployment.

func (*DockerProvider) GetLogs added in v1.0.0

func (p *DockerProvider) GetLogs(ctx context.Context, deploymentID string, lines int) ([]string, error)

GetLogs returns recent log lines from the Docker container.

func (*DockerProvider) GetStatus added in v1.0.0

func (p *DockerProvider) GetStatus(ctx context.Context, deploymentID string) (*Deployment, error)

GetStatus inspects the Docker container state.

func (*DockerProvider) Scale added in v1.0.0

func (p *DockerProvider) Scale(_ context.Context, deploymentID string, replicas int) error

Scale is not supported for single Docker containers.

func (*DockerProvider) Update added in v1.0.0

func (p *DockerProvider) Update(ctx context.Context, d *Deployment) error

Update stops the old container and starts a new one.

type HealthCheck

type HealthCheck struct {
	Path             string        `json:"path"`
	Port             int           `json:"port"`
	Interval         time.Duration `json:"interval"`
	Timeout          time.Duration `json:"timeout"`
	FailureThreshold int           `json:"failure_threshold"`
}

健康检查定义了健康检查配置.

type LocalProvider added in v1.0.0

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

LocalProvider manages agents as local OS processes.

func NewLocalProvider added in v1.0.0

func NewLocalProvider(logger *zap.Logger) *LocalProvider

NewLocalProvider creates a new local process provider.

func (*LocalProvider) Delete added in v1.0.0

func (p *LocalProvider) Delete(_ context.Context, deploymentID string) error

Delete stops and removes a local process.

func (*LocalProvider) Deploy added in v1.0.0

func (p *LocalProvider) Deploy(ctx context.Context, d *Deployment) error

Deploy starts a local process for the deployment.

func (*LocalProvider) GetLogs added in v1.0.0

func (p *LocalProvider) GetLogs(_ context.Context, deploymentID string, lines int) ([]string, error)

GetLogs returns recent output from the process stdout/stderr.

func (*LocalProvider) GetStatus added in v1.0.0

func (p *LocalProvider) GetStatus(_ context.Context, deploymentID string) (*Deployment, error)

GetStatus checks if the local process is still running.

func (*LocalProvider) Scale added in v1.0.0

func (p *LocalProvider) Scale(_ context.Context, deploymentID string, replicas int) error

Scale is not supported for local processes.

func (*LocalProvider) Update added in v1.0.0

func (p *LocalProvider) Update(ctx context.Context, d *Deployment) error

Update restarts the local process with new configuration.

type ResourceConfig

type ResourceConfig struct {
	CPURequest    string `json:"cpu_request,omitempty"`
	CPULimit      string `json:"cpu_limit,omitempty"`
	MemoryRequest string `json:"memory_request,omitempty"`
	MemoryLimit   string `json:"memory_limit,omitempty"`
	GPUCount      int    `json:"gpu_count,omitempty"`
}

资源Config定义了资源限制.

type SecretRef

type SecretRef struct {
	Name string `json:"name"`
	Key  string `json:"key"`
	Env  string `json:"env"`
}

秘密参考文件提到一个秘密

Jump to

Keyboard shortcuts

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