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 ¶
- func New(cfg port.Config) port.Provider
- type FileLeaseStore
- func (s *FileLeaseStore) AcquireRefreshLock(_ context.Context, req port.RefreshLockRequest) (bool, error)
- func (s *FileLeaseStore) ClaimOrdinal(ctx context.Context, req port.ClaimRequest) (int, error)
- func (s *FileLeaseStore) ClaimTask(_ context.Context, req port.FleetTaskClaim) (bool, error)
- func (s *FileLeaseStore) CompleteTask(_ context.Context, req port.FleetTaskVerdict) (bool, error)
- func (s *FileLeaseStore) FailTask(_ context.Context, req port.FleetTaskVerdict) (bool, error)
- func (s *FileLeaseStore) HeartbeatTask(_ context.Context, req port.FleetTaskHeartbeat) (bool, error)
- func (s *FileLeaseStore) ListActiveClaims(_ context.Context, req port.ListClaimsRequest) ([]port.Claim, error)
- func (s *FileLeaseStore) ListFleetTasks(_ context.Context, req port.FleetTaskList) ([]port.FleetTask, error)
- func (s *FileLeaseStore) ListStatus(_ context.Context, req port.NodeStatusList) ([]port.NodeStatus, error)
- func (s *FileLeaseStore) PublishStatus(_ context.Context, req port.NodeStatusPublish) error
- func (s *FileLeaseStore) ReleaseLease(_ context.Context, req port.ReleaseRequest) error
- func (s *FileLeaseStore) ReleaseRefreshLock(_ context.Context, req port.RefreshLockRequest) error
- func (s *FileLeaseStore) RenewLease(_ context.Context, req port.RenewRequest) error
- func (s *FileLeaseStore) RetryTask(_ context.Context, req port.FleetTaskVerdict) (bool, error)
- func (s *FileLeaseStore) SetCordon(_ context.Context, req port.NodeCordonRequest) error
- func (s *FileLeaseStore) SubmitTask(_ context.Context, req port.FleetTaskSubmit) (bool, error)
- func (s *FileLeaseStore) WithPath(path string) *FileLeaseStore
- type FileSecretSource
- type LocalBundleSource
- type MetadataSource
- type Provider
- func (p *Provider) AcquireRefreshLock(ctx context.Context, req port.RefreshLockRequest) (bool, error)
- func (p *Provider) ClaimOrdinal(ctx context.Context, req port.ClaimRequest) (int, error)
- func (p *Provider) ClaimTask(ctx context.Context, req port.FleetTaskClaim) (bool, error)
- func (p *Provider) CompleteTask(ctx context.Context, req port.FleetTaskVerdict) (bool, error)
- func (p *Provider) FailTask(ctx context.Context, req port.FleetTaskVerdict) (bool, error)
- func (p *Provider) FetchBundle(ctx context.Context, bundle model.ConfigBundle, destDir string) ([]string, error)
- func (p *Provider) FetchRoleSpec(ctx context.Context, req port.RoleSpecRequest) ([]byte, bool, error)
- func (p *Provider) GetSecretValue(ctx context.Context, req port.SecretRequest) (string, error)
- func (p *Provider) HeartbeatTask(ctx context.Context, req port.FleetTaskHeartbeat) (bool, error)
- func (p *Provider) ListActiveClaims(ctx context.Context, req port.ListClaimsRequest) ([]port.Claim, error)
- func (p *Provider) ListFleetTasks(ctx context.Context, req port.FleetTaskList) ([]port.FleetTask, error)
- func (p *Provider) ListStatus(ctx context.Context, req port.NodeStatusList) ([]port.NodeStatus, error)
- func (p *Provider) Metadata(ctx context.Context) (port.InstanceMetadata, error)
- func (p *Provider) Name() string
- func (p *Provider) PublishStatus(ctx context.Context, req port.NodeStatusPublish) error
- func (p *Provider) ReleaseLease(ctx context.Context, req port.ReleaseRequest) error
- func (p *Provider) ReleaseRefreshLock(ctx context.Context, req port.RefreshLockRequest) error
- func (p *Provider) RenewLease(ctx context.Context, req port.RenewRequest) error
- func (p *Provider) RetryTask(ctx context.Context, req port.FleetTaskVerdict) (bool, error)
- func (p *Provider) SetCordon(ctx context.Context, req port.NodeCordonRequest) error
- func (p *Provider) SubmitTask(ctx context.Context, req port.FleetTaskSubmit) (bool, error)
- func (p *Provider) WithBundle(c port.ConfigSource) *Provider
- func (p *Provider) WithBundleDir(dir string) *Provider
- func (p *Provider) WithLeaseFile(path string) *Provider
- func (p *Provider) WithMetadata(meta port.InstanceMetadata) *Provider
- func (p *Provider) WithSecrets(s port.SecretSource) *Provider
- func (p *Provider) WithSecretsDir(dir string) *Provider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ¶
func (s *FileLeaseStore) ListStatus(_ context.Context, req port.NodeStatusList) ([]port.NodeStatus, error)
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 ¶
func (s *FileLeaseStore) SetCordon(_ context.Context, req port.NodeCordonRequest) error
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 ¶
func (m *MetadataSource) Get(_ context.Context) (port.InstanceMetadata, error)
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 ¶
ClaimOrdinal acquires an ordinal lease in the shared Compose lease file.
func (*Provider) CompleteTask ¶
CompleteTask 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 ¶
GetSecretValue resolves a secret from mounted files or the test override.
func (*Provider) HeartbeatTask ¶
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) PublishStatus ¶
PublishStatus writes a node status row.
func (*Provider) ReleaseLease ¶
ReleaseLease releases an ordinal lease in the shared Compose lease file.
func (*Provider) ReleaseRefreshLock ¶
ReleaseRefreshLock releases the per-role refresh lock.
func (*Provider) RenewLease ¶
RenewLease extends an ordinal lease in the shared Compose lease file.
func (*Provider) SubmitTask ¶
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 ¶
WithBundleDir overrides the bundle directory (tests).
func (*Provider) WithLeaseFile ¶
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 ¶
WithSecretsDir overrides the secrets directory (tests).