deployjob

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildUnit

func BuildUnit(namespace, service, description, executablePath, envPath, secretPath, raftPath string) string

GPTMAXXING

func Copy

func Copy(ctx context.Context, dst io.Writer, src io.Reader) (int, error)

GPTmaxxing

func Deploy

func Deploy(log *slog.Logger, ctx context.Context, cfg DeployConfig) error

func ExtractTarGzStrip

func ExtractTarGzStrip(src, dest string) error

func New

func New(ctx context.Context, out notifier.Topic, deps *Dependencies, host *entity.Host) *integration

func NewNotifierLogger

func NewNotifierLogger(topic notifier.Topic) slog.Handler

Logger with up-to-date state information todo: optimize / or use another library; to store the log in memory (not render immedaitely)

func RandomPort

func RandomPort() uint16

func ServiceFileExists

func ServiceFileExists(ctx context.Context, conn *dbus.Conn, name string) (bool, error)

Types

type DAG

type DAG struct {
	// Vertices contains job
	Vertices []Job `json:"vertices"`

	// Edges contain vertices index; always len(Edges) == len(Vertices)*2
	Edges []uint8 `json:"edges"`
}

type Dependencies

type Dependencies struct {
	HostConfig HostConfig

	// host specific configuration
	HostConfigUsecase *mycontent_base.Handler[*entity.Host]

	// service configuration (to be installed on the host)
	ServiceDefinitionUsecase *mycontent_base.Handler[*entity.ServiceDefinition]

	// archive / artifact repository storing build & archive information
	RepositoryUsecase *mycontent_base.Handler[*entity.Repository]

	// store service's env
	EnvUsecase *mycontent_base.Handler[*entity.Env]

	// store service's secret
	SecretUsecase *mycontent_base.Handler[*entity.Secret]

	RoutingUsecase *mycontent_base.Handler[*entity.Routing]

	BuildUsecase *mycontent_base.Handler[*entity.BuildArtifact]

	JobUsecase *mycontent_base.Handler[*entity.DeploymentJob]

	// attachment
	BuildArtifactUsecase *mycontent_base.HandlerWithAttachment

	// deploy job client
	RaftJobUsecase *deployjob.Client
}

Dependencies in the integration side (not inside raft)

type DeployConfig

type DeployConfig struct {
	Namespace     string
	ServiceID     string
	BuildID       string // e.g. "20260215-abc123"
	EnvVersion    string
	SecretVersion string
	BaseDir       string        // default: /opt
	BinPath       string        // e.g. "bin/myapp"
	Timeout       time.Duration // optional
}

type HostConfig

type HostConfig struct {
	LocalClickhouseConfig LocalClickhouseConfig `json:"local_clickhouse_config"`
}

type HostDeploymentJobState

type HostDeploymentJobState struct {
	ConfigurationStatus  entity.HostConfigurationStatus  `json:"configuration_status"`
	RestartServiceStatus entity.HostRestartServiceStatus `json:"restart_service_status"`
}

Local host state

type Job

type Job interface {
	GetName() string
	GetRetryCount() uint8
	GetStatus() Status
	GetDAG() DAG
	GetCurrentSteps() uint8
	GetTotalSteps() uint8
	GetURL() string

	Execute() error // intentional no return value; it should be a side effect that represented by JobStatus
}

Trying to make job generic Not specific to this usecase, TODO: move to common library All prefixed with Get.. to make it easy for each implementation expose their state with the name without prefix

type LocalClickhouseConfig

type LocalClickhouseConfig struct {
	Address  string `json:"address"`
	Username string `json:"username"`
	Password string `json:"password"`
}

type Log

type Log map[string]any

type Status

type Status string
const (
	StatusPending    Status = "pending"
	StatusInProgress Status = "in_progress"
	StatusRetrying   Status = "retrying"
	StatusFailed     Status = "failed"
	StatusCancelled  Status = "cancelled"
	StatusSuccess    Status = "success"
	StatusInvalid    Status = "invalid"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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