Documentation
¶
Index ¶
- Constants
- type ComposeConfig
- type ComposeHealth
- type ComposeManager
- func (cm *ComposeManager) Down(ctx context.Context) error
- func (cm *ComposeManager) HasServices() bool
- func (cm *ComposeManager) IsRunning(ctx context.Context) bool
- func (cm *ComposeManager) Logs(ctx context.Context, service string, tail int) (string, error)
- func (cm *ComposeManager) NetworkName() string
- func (cm *ComposeManager) UnhealthyServices(ctx context.Context) []string
- func (cm *ComposeManager) Up(ctx context.Context, output io.Writer) error
- type ComposeService
- type HealthCheck
- type PortMapping
- type ServiceDependency
- type ServiceMapping
- type StubServiceInfo
Constants ¶
const ( ResourceTypeDatastore = "celerity/datastore" ResourceTypeBucket = "celerity/bucket" ResourceTypeQueue = "celerity/queue" ResourceTypeTopic = "celerity/topic" ResourceTypeConfig = "celerity/config" ResourceTypeCache = "celerity/cache" ResourceTypeSqlDatabase = "celerity/sqlDatabase" ResourceTypeVPC = "celerity/vpc" ResourceTypeSchedule = "celerity/schedule" ResourceTypeConsumer = "celerity/consumer" ResourceTypeAPI = "celerity/api" )
Resource type constants matching the blueprint spec.
const ( DeployTargetAWS = "aws" DeployTargetAWSServerless = "aws-serverless" DeployTargetGCloud = "gcloud" DeployTargetGCloudServerless = "gcloud-serverless" DeployTargetAzure = "azure" DeployTargetAzureServerless = "azure-serverless" )
Deploy target constants.
const ( ServiceNameDatastore = "datastore" ServiceNameSqlDatabase = "sql-database" ServiceNameStorage = "storage" ServiceNameValkey = "valkey" ServiceNameLocalEvents = "local-events" ServiceNameDevAuth = "dev-auth" ServiceNameStubs = "stubs" )
ServiceName constants for compose services. Used by both the compose generator and the seed package for host endpoint mapping.
const ( EnvDatastoreEndpoint = "CELERITY_LOCAL_DATASTORE_ENDPOINT" EnvSqlDatabaseEndpoint = "CELERITY_LOCAL_SQL_DATABASE_ENDPOINT" EnvBucketEndpoint = "CELERITY_LOCAL_BUCKET_ENDPOINT" EnvBucketAccessKey = "CELERITY_LOCAL_BUCKET_ACCESS_KEY" EnvBucketSecretKey = "CELERITY_LOCAL_BUCKET_SECRET_KEY" EnvQueueEndpoint = "CELERITY_LOCAL_QUEUE_ENDPOINT" EnvTopicEndpoint = "CELERITY_LOCAL_TOPIC_ENDPOINT" EnvConfigEndpoint = "CELERITY_LOCAL_CONFIG_ENDPOINT" EnvCacheEndpoint = "CELERITY_LOCAL_CACHE_ENDPOINT" EnvDevAuthBaseURL = "CELERITY_DEV_AUTH_BASE_URL" EnvStubsAPIURL = "CELERITY_STUBS_API_URL" )
Runtime environment variable names set by compose services.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ComposeConfig ¶
type ComposeConfig struct {
Services map[string]*ComposeService
RuntimeEnvVars map[string]string
// HostEnvVars contains the same endpoints as RuntimeEnvVars but rewritten
// for host access (localhost with host-mapped ports). Use these when
// connecting from the host machine (seeding, test runners) rather than
// from within the Docker network.
HostEnvVars map[string]string
ProjectName string
FilePath string
StreamEnabledTables map[string]bool
// StubServices holds loaded stub service configs for the orchestrator
// to seed config values and load mountebank imposters after compose up.
StubServices []StubServiceInfo
}
ComposeConfig represents the generated Docker Compose configuration.
func GenerateComposeConfig ¶
func GenerateComposeConfig( bp *schema.Blueprint, deployTarget string, projectName string, appDir string, portOffset int, localAuth bool, logger *zap.Logger, ) (*ComposeConfig, error)
GenerateComposeConfig generates a Docker Compose configuration from a blueprint. It inspects blueprint resource types, maps each to a local emulator service, deduplicates shared services (e.g. Valkey), writes the compose file, and returns the resulting config including runtime environment variables.
portOffset shifts all host port mappings by the given amount. Use 0 for dev run (default ports) and a positive value (e.g. 100) for dev test so both can run simultaneously without port conflicts.
type ComposeHealth ¶
type ComposeHealth struct {
Test []string `yaml:"test"`
Interval string `yaml:"interval"`
Timeout string `yaml:"timeout"`
Retries int `yaml:"retries"`
StartPeriod string `yaml:"start_period"`
}
ComposeHealth is the YAML-serialisable health check for compose files.
type ComposeManager ¶
type ComposeManager struct {
// contains filtered or unexported fields
}
ComposeManager wraps the Docker Compose CLI for managing the local dependency stack.
func NewComposeManager ¶
func NewComposeManager(projectName string, appDir string, logger *zap.Logger) (*ComposeManager, error)
NewComposeManager creates a compose manager for the given project. appDir is the root directory of the Celerity app.
func (*ComposeManager) Down ¶
func (cm *ComposeManager) Down(ctx context.Context) error
Down tears down the compose stack.
func (*ComposeManager) HasServices ¶
func (cm *ComposeManager) HasServices() bool
HasServices returns true if the generated compose file exists and contains at least one service.
func (*ComposeManager) IsRunning ¶
func (cm *ComposeManager) IsRunning(ctx context.Context) bool
IsRunning checks if the compose stack is already up.
func (*ComposeManager) Logs ¶
Logs fetches the logs from a specific service in the compose stack. It returns the combined stdout/stderr output as a string. If tail > 0, only the last N lines are returned.
func (*ComposeManager) NetworkName ¶
func (cm *ComposeManager) NetworkName() string
NetworkName returns the Docker network name created by compose. Docker Compose names networks as <project>_default.
func (*ComposeManager) UnhealthyServices ¶
func (cm *ComposeManager) UnhealthyServices(ctx context.Context) []string
UnhealthyServices returns the names of services that are in an unhealthy state.
type ComposeService ¶
type ComposeService struct {
Image string `yaml:"image"`
Ports []string `yaml:"ports,omitempty"`
Environment map[string]string `yaml:"environment,omitempty"`
Command []string `yaml:"command,omitempty"`
Volumes []string `yaml:"volumes,omitempty"`
HealthCheck *ComposeHealth `yaml:"healthcheck,omitempty"`
DependsOn map[string]ServiceDependency `yaml:"depends_on,omitempty"`
}
ComposeService represents a single service in the compose file.
type HealthCheck ¶
type HealthCheck struct {
Test []string
Interval string
Timeout string
Retries int
StartPeriod string
}
HealthCheck defines a Docker Compose health check.
type PortMapping ¶
PortMapping maps a host port to a container port.
type ServiceDependency ¶
type ServiceDependency struct {
Condition string `yaml:"condition"`
}
ServiceDependency describes a service dependency with a condition.
type ServiceMapping ¶
type ServiceMapping struct {
ResourceType string
ServiceName string
Image string
Ports []PortMapping
Environment map[string]string
Command []string
HealthCheck *HealthCheck
RuntimeEnvVars map[string]string
}
ServiceMapping defines how a blueprint resource type maps to a local Docker Compose service.
type StubServiceInfo ¶
type StubServiceInfo struct {
Name string
Port int // Container port (used for Docker-internal URLs)
HostPort int // Host-mapped port (container port + offset)
ConfigKey string
ConfigNamespace string
}
StubServiceInfo carries the information needed to seed config values and load mountebank imposters for a stub service.