Documentation
¶
Index ¶
- Constants
- func ConfigStoreIDEnvVars(bp *schema.Blueprint) map[string]string
- func DetectContentType(objectKey string, data []byte) string
- func HandlerScopeJSON(bp *schema.Blueprint) (string, error)
- func LoadAndMergeConfig(configDir string, secretsDir string, storeName string) (map[string]string, error)
- func LoadConfigYAML(filePath string) (map[string]string, error)
- func ResolveConfigDir(appDir string, mode string) string
- func ResolveSecretsDir(appDir string, mode string) string
- func ResolveSeedDir(appDir string, mode string) string
- func ResourceConfigValues(bp *schema.Blueprint) map[string]string
- func ResourceLinksJSON(bp *schema.Blueprint) (string, error)
- func ResourcesConfigStoreEnvVars() map[string]string
- func RunHooks(ctx context.Context, scripts []string, serviceEndpoints map[string]string, ...) error
- type BucketProvisioner
- type ConfigResourceInfo
- type ConfigSeedResult
- type ConfigSeeder
- type DatastoreProvisioner
- type DynamoDBProvisioner
- type DynamoDBSeeder
- type HookLine
- type HookOutputFunc
- type IndexDefinition
- type KeyField
- type MinIOProvisioner
- type MinIOUploader
- type NoSQLSeeder
- type NoSQLTableSeed
- type ProvisionResult
- type SQLDatabaseSeed
- type SQLSeeder
- type SeedConfig
- type SeedResult
- type StorageBucketSeed
- type StorageUploader
- type TableDefinition
- type ValkeyConfigSeeder
Constants ¶
const HandlerScopeFilename = "handler-scope.json"
HandlerScopeFilename is the file the CLI writes so a handler can resolve which of the application's resources it actually uses.
The resource links file describes what each resource is, which is a property of the application and identical for every handler. This file records which of those a given handler touches, which is a property of the handler.
One bundle serves every function, so the resource links file necessarily describes the whole application. With nothing else to go on, the SDK's resource layers took it as their scope and every handler initialised every resource type present anywhere in the app. A handler using nothing but its own config still resolved the internal resources namespace, and failed at cold start on `Config namespace "resources" not registered`.
const ResourcesConfigStoreID = "resources"
ResourcesConfigStoreID is the Valkey key used for the "resources" config namespace. The SDK's resource layers (datastore, bucket, queue, topic, cache, sql-database) read connection credentials from this namespace.
Variables ¶
This section is empty.
Functions ¶
func ConfigStoreIDEnvVars ¶
ConfigStoreIDEnvVars generates the environment variables that tell the runtime where to find each config store in Valkey.
func DetectContentType ¶
DetectContentType determines the MIME type for an object by extension, falling back to http.DetectContentType for unrecognised extensions.
func HandlerScopeJSON ¶
HandlerScopeJSON maps each handler's id to the resources it uses.
Keyed by handler id, the value of spec.handler such as "app-module.StatsController.check", because that is what reaches the running function as CELERITY_HANDLER_ID and so the only thing a handler can identify itself by at cold start.
An entry with an empty list is meaningful and is written, recording that the handler reaches nothing and so must not initialise anything. That differs from having no entry at all, which happens for an older bundle or a handler whose id could not be determined. The SDK treats a missing entry as the whole application being in scope, degrading to the behaviour that existed before this file rather than to a handler that silently reaches nothing.
func LoadAndMergeConfig ¶
func LoadAndMergeConfig(configDir string, secretsDir string, storeName string) (map[string]string, error)
LoadAndMergeConfig reads config and secrets YAML files for a given store name, merges them (secrets override config), and returns the combined map.
func LoadConfigYAML ¶
LoadConfigYAML reads a YAML file containing flat key-value pairs and returns them as a map. Returns an empty map if the file does not exist.
func ResolveConfigDir ¶
ResolveConfigDir determines the config directory based on the command mode. For "test" mode, it prefers config/test/ and falls back to config/local/. For "run" mode (or any other), it uses config/local/.
func ResolveSecretsDir ¶
ResolveSecretsDir determines the secrets directory based on the command mode. For "test" mode, it prefers secrets/test/ and falls back to secrets/local/. For "run" mode (or any other), it uses secrets/local/.
func ResolveSeedDir ¶
ResolveSeedDir determines the seed directory based on the command mode. For "test" mode, it prefers seed/test/ and falls back to seed/local/. For "run" mode (or any other), it uses seed/local/.
func ResourceConfigValues ¶
ResourceConfigValues generates all resource credential config keys for the "resources" config namespace. This includes cache, datastore, bucket, queue, topic, and SQL database resources.
func ResourceLinksJSON ¶
ResourceLinksJSON generates the CELERITY_RESOURCE_LINKS JSON string from a blueprint. This env var tells the SDK about the resource topology so each resource layer (datastore, bucket, queue, topic, cache, sql-database) can discover and initialise its resources.
The output maps resource names to {type, configKey} objects:
{"usersDatastore": {"type":"datastore","configKey":"users"}, ...}
The configKey is derived from spec.name (falling back to the resource name).
func ResourcesConfigStoreEnvVars ¶
ResourcesConfigStoreEnvVars returns the environment variables needed to register the "resources" config namespace in the SDK's ConfigService.
func RunHooks ¶
func RunHooks( ctx context.Context, scripts []string, serviceEndpoints map[string]string, onOutput HookOutputFunc, logger *zap.Logger, ) error
RunHooks executes post-setup hook scripts from the seed directory. Each script receives service endpoint environment variables so hooks can interact with running local services. Output is streamed line-by-line through the onOutput callback.
Types ¶
type BucketProvisioner ¶
BucketProvisioner creates storage buckets.
type ConfigResourceInfo ¶
ConfigResourceInfo describes a config resource extracted from the blueprint.
func CollectConfigResources ¶
func CollectConfigResources(bp *schema.Blueprint) []ConfigResourceInfo
CollectConfigResources extracts celerity/config resources from a blueprint and returns their resource names and spec.name values.
type ConfigSeedResult ¶
ConfigSeedResult tracks what was seeded for TUI reporting.
type ConfigSeeder ¶
type ConfigSeeder interface {
SeedConfig(ctx context.Context, storeID string, values map[string]string) error
Close() error
}
ConfigSeeder loads config and secrets YAML files into a Valkey store.
type DatastoreProvisioner ¶
type DatastoreProvisioner interface {
ProvisionTable(ctx context.Context, table TableDefinition) error
}
DatastoreProvisioner creates tables/buckets from blueprint resource definitions.
type DynamoDBProvisioner ¶
type DynamoDBProvisioner struct {
// contains filtered or unexported fields
}
DynamoDBProvisioner provisions DynamoDB tables in DynamoDB Local.
func NewDynamoDBProvisioner ¶
func NewDynamoDBProvisioner(endpoint string, logger *zap.Logger) *DynamoDBProvisioner
NewDynamoDBProvisioner creates a provisioner targeting a DynamoDB Local endpoint.
func (*DynamoDBProvisioner) ProvisionTable ¶
func (p *DynamoDBProvisioner) ProvisionTable(ctx context.Context, table TableDefinition) error
type DynamoDBSeeder ¶
type DynamoDBSeeder struct {
// contains filtered or unexported fields
}
DynamoDBSeeder implements NoSQLSeeder for DynamoDB Local.
func NewDynamoDBSeeder ¶
func NewDynamoDBSeeder(endpoint string, logger *zap.Logger) *DynamoDBSeeder
NewDynamoDBSeeder creates a seeder targeting a DynamoDB Local endpoint.
type HookOutputFunc ¶
type HookOutputFunc func(line HookLine)
HookOutputFunc is called for each line of output from a hook script.
type IndexDefinition ¶
IndexDefinition describes a secondary index.
type MinIOProvisioner ¶
type MinIOProvisioner struct {
// contains filtered or unexported fields
}
MinIOProvisioner provisions MinIO buckets.
func NewMinIOProvisioner ¶
func NewMinIOProvisioner(endpoint string, accessKey string, secretKey string, logger *zap.Logger) (*MinIOProvisioner, error)
NewMinIOProvisioner creates a provisioner targeting a MinIO endpoint.
func (*MinIOProvisioner) ProvisionBucket ¶
func (p *MinIOProvisioner) ProvisionBucket(ctx context.Context, bucketName string) error
type MinIOUploader ¶
type MinIOUploader struct {
// contains filtered or unexported fields
}
MinIOUploader implements StorageUploader for MinIO.
func NewMinIOUploader ¶
func NewMinIOUploader(endpoint string, accessKey string, secretKey string, logger *zap.Logger) (*MinIOUploader, error)
NewMinIOUploader creates an uploader targeting a MinIO endpoint.
type NoSQLSeeder ¶
type NoSQLSeeder interface {
PutItem(ctx context.Context, tableName string, itemJSON []byte) error
}
NoSQLSeeder inserts records into a NoSQL datastore.
type NoSQLTableSeed ¶
NoSQLTableSeed represents seed data for a single NoSQL table.
type ProvisionResult ¶
ProvisionResult tracks what was provisioned for TUI reporting.
func ProvisionFromBlueprint ¶
func ProvisionFromBlueprint( ctx context.Context, bp *schema.Blueprint, datastoreProvisioner DatastoreProvisioner, bucketProvisioner BucketProvisioner, streamEnabledTables map[string]bool, logger *zap.Logger, ) (*ProvisionResult, error)
ProvisionFromBlueprint reads the blueprint and provisions tables and buckets for local development. streamEnabledTables is a set of datastore resource names that should have change streams enabled (e.g. DynamoDB Streams) because a consumer is linked to them.
type SQLDatabaseSeed ¶
type SQLDatabaseSeed struct {
DatabaseName string
Files []string // .sql files, sorted alphabetically
}
SQLDatabaseSeed represents seed data for a single SQL database. Each subdirectory in sql/ maps to a database name (matching celerity/sqlDatabase spec.name).
type SeedConfig ¶
type SeedConfig struct {
NoSQL []NoSQLTableSeed
SQL []SQLDatabaseSeed
Storage []StorageBucketSeed
Hooks []string
}
SeedConfig describes all seed data discovered in a convention directory.
func LoadSeedConfig ¶
func LoadSeedConfig(seedDir string) (*SeedConfig, error)
LoadSeedConfig discovers seed data in the given directory following the Celerity convention structure: nosql/, sql/, buckets/, hooks/. Returns nil if the directory does not exist.
type SeedResult ¶
SeedResult tracks what was seeded for TUI reporting.
func ExecuteSeed ¶
func ExecuteSeed( ctx context.Context, cfg *SeedConfig, nosqlSeeder NoSQLSeeder, storageUploader StorageUploader, sqlSeeder SQLSeeder, logger *zap.Logger, ) (*SeedResult, error)
ExecuteSeed applies seed data from a loaded SeedConfig to the running services.
type StorageBucketSeed ¶
StorageBucketSeed represents seed data for a single storage bucket.
type StorageUploader ¶
type StorageUploader interface {
Upload(ctx context.Context, bucketName string, objectKey string, data []byte) error
}
StorageUploader uploads files to an object store bucket.
type TableDefinition ¶
type TableDefinition struct {
Name string
PartitionKey KeyField
SortKey *KeyField
Indexes []IndexDefinition
Fields map[string]string
StreamEnabled bool
}
TableDefinition describes a NoSQL table to provision.
type ValkeyConfigSeeder ¶
type ValkeyConfigSeeder struct {
// contains filtered or unexported fields
}
ValkeyConfigSeeder implements ConfigSeeder using a Valkey (Redis-compatible) backend.
func NewValkeyConfigSeeder ¶
func NewValkeyConfigSeeder(endpoint string, logger *zap.Logger) (*ValkeyConfigSeeder, error)
NewValkeyConfigSeeder creates a new Valkey config seeder. The endpoint must be a redis:// URL (e.g. "redis://localhost:6379") as produced by the compose generator's runtime env vars.
func (*ValkeyConfigSeeder) Close ¶
func (s *ValkeyConfigSeeder) Close() error
Close closes the Valkey client connection.
func (*ValkeyConfigSeeder) SeedConfig ¶
func (s *ValkeyConfigSeeder) SeedConfig(ctx context.Context, storeID string, values map[string]string) error
SeedConfig merges a config map into the JSON-encoded value in Valkey. If the key already exists, new values are merged into the existing data (new keys are added, existing keys are overwritten). If the key does not exist, it is created with the provided values. The storeID is used as the Valkey key, matching the convention expected by the SDK config local backends.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package dynamoconv provides pure conversion functions between Go types and DynamoDB attribute values.
|
Package dynamoconv provides pure conversion functions between Go types and DynamoDB attribute values. |