compose

package
v0.2.13 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package compose implements the local Docker Compose cloud provider. It satisfies chinit's mandatory Provider ports (metadata, secrets, config bundles) and optional fleet-coordination ports (ordinal leases, lease listing, node status, role specs, refresh locks) using local files and container environment so full systemd-enabled ClickHouse clusters can run and be tested under Docker Compose without cloud infrastructure.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(cfg port.Config) port.Provider

New builds the Docker Compose provider.

Types

type FileLeaseStore

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

FileLeaseStore coordinates ordinal leases, node statuses, and refresh locks across Docker Compose containers via a flock-guarded JSON file.

func NewFileLeaseStore

func NewFileLeaseStore() *FileLeaseStore

NewFileLeaseStore constructs a lease store backed by CHINIT_COMPOSE_LEASE_FILE or /var/lib/chinit-cluster/leases.json.

func (*FileLeaseStore) AcquireRefreshLock

func (s *FileLeaseStore) AcquireRefreshLock(_ context.Context, req port.RefreshLockRequest) (bool, error)

AcquireRefreshLock takes a per-role refresh lock if unheld or expired.

func (*FileLeaseStore) ClaimOrdinal

func (s *FileLeaseStore) ClaimOrdinal(ctx context.Context, req port.ClaimRequest) (int, error)

ClaimOrdinal claims the first free or expired ordinal in [0, req.Count) (or the exact ordinal req.Count-1 when req.ExactOrdinal is true).

func (*FileLeaseStore) ClaimTask

func (s *FileLeaseStore) ClaimTask(_ context.Context, req port.FleetTaskClaim) (bool, error)

ClaimTask transitions a pending task owned by req.Executor to executing.

func (*FileLeaseStore) CompleteTask

func (s *FileLeaseStore) CompleteTask(_ context.Context, req port.FleetTaskVerdict) (bool, error)

CompleteTask marks an executing task as done if epoch and target match.

func (*FileLeaseStore) FailTask

func (s *FileLeaseStore) FailTask(_ context.Context, req port.FleetTaskVerdict) (bool, error)

FailTask marks an executing task as failed if epoch and target match.

func (*FileLeaseStore) HeartbeatTask

func (s *FileLeaseStore) HeartbeatTask(_ context.Context, req port.FleetTaskHeartbeat) (bool, error)

HeartbeatTask updates the executing task's heartbeat if epoch and target match.

func (*FileLeaseStore) ListActiveClaims

func (s *FileLeaseStore) ListActiveClaims(_ context.Context, req port.ListClaimsRequest) ([]port.Claim, error)

ListActiveClaims returns every non-expired lease row in req.Table.

func (*FileLeaseStore) ListFleetTasks

func (s *FileLeaseStore) ListFleetTasks(_ context.Context, req port.FleetTaskList) ([]port.FleetTask, error)

ListFleetTasks returns fleet tasks filtered by table and optional target.

func (*FileLeaseStore) ListStatus

ListStatus returns node status rows from req.Table.

func (*FileLeaseStore) PublishStatus

func (s *FileLeaseStore) PublishStatus(_ context.Context, req port.NodeStatusPublish) error

PublishStatus writes or updates a node's fleet status row while preserving its cordoned flag.

func (*FileLeaseStore) ReleaseLease

func (s *FileLeaseStore) ReleaseLease(_ context.Context, req port.ReleaseRequest) error

ReleaseLease removes the lease row when owned by req.InstanceID.

func (*FileLeaseStore) ReleaseRefreshLock

func (s *FileLeaseStore) ReleaseRefreshLock(_ context.Context, req port.RefreshLockRequest) error

ReleaseRefreshLock releases the per-role refresh lock held by req.Holder.

func (*FileLeaseStore) RenewLease

func (s *FileLeaseStore) RenewLease(_ context.Context, req port.RenewRequest) error

RenewLease extends the lease if still owned by req.InstanceID.

func (*FileLeaseStore) RetryTask

func (s *FileLeaseStore) RetryTask(_ context.Context, req port.FleetTaskVerdict) (bool, error)

RetryTask re-dispatches a stale or failed task if retries remain.

func (*FileLeaseStore) SetCordon

SetCordon sets or clears the cordoned flag on a node status row.

func (*FileLeaseStore) SubmitTask

func (s *FileLeaseStore) SubmitTask(_ context.Context, req port.FleetTaskSubmit) (bool, error)

SubmitTask creates or re-submits a fleet task row.

func (*FileLeaseStore) WithPath

func (s *FileLeaseStore) WithPath(path string) *FileLeaseStore

WithPath overrides the lease file path (tests).

type FileSecretSource

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

FileSecretSource resolves secret values from mounted files on disk.

func NewFileSecretSource

func NewFileSecretSource() *FileSecretSource

NewFileSecretSource constructs a secret source rooted at CHINIT_COMPOSE_SECRETS_DIR or /etc/chinit/secrets.

func (*FileSecretSource) GetSecretValue

func (s *FileSecretSource) GetSecretValue(_ context.Context, req port.SecretRequest) (string, error)

GetSecretValue reads a secret file by name, optionally extracting a JSON field when req.Field is set.

func (*FileSecretSource) WithDir

func (s *FileSecretSource) WithDir(dir string) *FileSecretSource

WithDir overrides the secrets directory (tests).

type LocalBundleSource

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

LocalBundleSource copies the configuration bundle from a mounted directory and enforces the same SHA-256 verification contract as S3/Blob sources.

func NewLocalBundleSource

func NewLocalBundleSource() *LocalBundleSource

NewLocalBundleSource constructs a bundle source rooted at CHINIT_COMPOSE_BUNDLE_DIR or /etc/chinit/bundle.

func (*LocalBundleSource) FetchBundle

func (b *LocalBundleSource) FetchBundle(_ context.Context, bundle model.ConfigBundle, destDir string) ([]string, error)

FetchBundle copies bundle files into destDir and verifies bundle.SHA256 when pinned.

func (*LocalBundleSource) FetchRoleSpec

func (b *LocalBundleSource) FetchRoleSpec(_ context.Context, req port.RoleSpecRequest) ([]byte, bool, error)

FetchRoleSpec reads a role-specific chinit.yaml from the bundle root when present.

func (*LocalBundleSource) WithDir

func (b *LocalBundleSource) WithDir(dir string) *LocalBundleSource

WithDir overrides the bundle source directory (tests).

type MetadataSource

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

MetadataSource resolves container instance metadata from an optional JSON file, environment variables, and local network/hostname probes.

func NewMetadataSource

func NewMetadataSource(region string) *MetadataSource

NewMetadataSource constructs a Docker Compose metadata source.

func (*MetadataSource) Get

Get returns instance metadata for the container.

func (*MetadataSource) WithMetadata

func (m *MetadataSource) WithMetadata(meta port.InstanceMetadata) *MetadataSource

WithMetadata pins fixed metadata (used by conformance and unit tests).

type Provider

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

Provider is the Docker Compose entry in chinit's provider registry. It satisfies mandatory Provider ports using mounted container files and optional coordination ports (OrdinalClaimer, LeaseLister, StatusPublisher, RoleSpecSource, RefreshLock) using a shared flock-guarded JSON store.

func (*Provider) AcquireRefreshLock

func (p *Provider) AcquireRefreshLock(ctx context.Context, req port.RefreshLockRequest) (bool, error)

AcquireRefreshLock takes the per-role refresh lock.

func (*Provider) ClaimOrdinal

func (p *Provider) ClaimOrdinal(ctx context.Context, req port.ClaimRequest) (int, error)

ClaimOrdinal acquires an ordinal lease in the shared Compose lease file.

func (*Provider) ClaimTask

func (p *Provider) ClaimTask(ctx context.Context, req port.FleetTaskClaim) (bool, error)

ClaimTask implements port.FleetTaskStore.

func (*Provider) CompleteTask

func (p *Provider) CompleteTask(ctx context.Context, req port.FleetTaskVerdict) (bool, error)

CompleteTask implements port.FleetTaskStore.

func (*Provider) FailTask

func (p *Provider) FailTask(ctx context.Context, req port.FleetTaskVerdict) (bool, error)

FailTask implements port.FleetTaskStore.

func (*Provider) FetchBundle

func (p *Provider) FetchBundle(ctx context.Context, bundle model.ConfigBundle, destDir string) ([]string, error)

FetchBundle copies the bundle from mounted local files or the test override.

func (*Provider) FetchRoleSpec

func (p *Provider) FetchRoleSpec(ctx context.Context, req port.RoleSpecRequest) ([]byte, bool, error)

FetchRoleSpec reads a role-specific chinit.yaml from the local bundle dir.

func (*Provider) GetSecretValue

func (p *Provider) GetSecretValue(ctx context.Context, req port.SecretRequest) (string, error)

GetSecretValue resolves a secret from mounted files or the test override.

func (*Provider) HeartbeatTask

func (p *Provider) HeartbeatTask(ctx context.Context, req port.FleetTaskHeartbeat) (bool, error)

HeartbeatTask implements port.FleetTaskStore.

func (*Provider) ListActiveClaims

func (p *Provider) ListActiveClaims(ctx context.Context, req port.ListClaimsRequest) ([]port.Claim, error)

ListActiveClaims returns active leases in the shared Compose lease file.

func (*Provider) ListFleetTasks

func (p *Provider) ListFleetTasks(ctx context.Context, req port.FleetTaskList) ([]port.FleetTask, error)

ListFleetTasks implements port.FleetTaskStore.

func (*Provider) ListStatus

func (p *Provider) ListStatus(ctx context.Context, req port.NodeStatusList) ([]port.NodeStatus, error)

ListStatus reads fleet status rows.

func (*Provider) Metadata

func (p *Provider) Metadata(ctx context.Context) (port.InstanceMetadata, error)

Metadata returns container instance metadata.

func (*Provider) Name

func (p *Provider) Name() string

Name is the registry key.

func (*Provider) PublishStatus

func (p *Provider) PublishStatus(ctx context.Context, req port.NodeStatusPublish) error

PublishStatus writes a node status row.

func (*Provider) ReleaseLease

func (p *Provider) ReleaseLease(ctx context.Context, req port.ReleaseRequest) error

ReleaseLease releases an ordinal lease in the shared Compose lease file.

func (*Provider) ReleaseRefreshLock

func (p *Provider) ReleaseRefreshLock(ctx context.Context, req port.RefreshLockRequest) error

ReleaseRefreshLock releases the per-role refresh lock.

func (*Provider) RenewLease

func (p *Provider) RenewLease(ctx context.Context, req port.RenewRequest) error

RenewLease extends an ordinal lease in the shared Compose lease file.

func (*Provider) RetryTask

func (p *Provider) RetryTask(ctx context.Context, req port.FleetTaskVerdict) (bool, error)

RetryTask implements port.FleetTaskStore.

func (*Provider) SetCordon

func (p *Provider) SetCordon(ctx context.Context, req port.NodeCordonRequest) error

SetCordon updates a node's cordoned flag.

func (*Provider) SubmitTask

func (p *Provider) SubmitTask(ctx context.Context, req port.FleetTaskSubmit) (bool, error)

SubmitTask implements port.FleetTaskStore.

func (*Provider) WithBundle

func (p *Provider) WithBundle(c port.ConfigSource) *Provider

WithBundle overrides the config bundle fetcher (conformance tests).

func (*Provider) WithBundleDir

func (p *Provider) WithBundleDir(dir string) *Provider

WithBundleDir overrides the bundle directory (tests).

func (*Provider) WithLeaseFile

func (p *Provider) WithLeaseFile(path string) *Provider

WithLeaseFile overrides the lease file path (tests).

func (*Provider) WithMetadata

func (p *Provider) WithMetadata(meta port.InstanceMetadata) *Provider

WithMetadata pins fixed instance metadata (conformance/unit tests).

func (*Provider) WithSecrets

func (p *Provider) WithSecrets(s port.SecretSource) *Provider

WithSecrets overrides the secret source (conformance tests).

func (*Provider) WithSecretsDir

func (p *Provider) WithSecretsDir(dir string) *Provider

WithSecretsDir overrides the secrets directory (tests).

Jump to

Keyboard shortcuts

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