Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MongoStepBufferTTL ¶ added in v0.2.0
MongoStepBufferTTL resolves the configured TTL for live step buffers. Invalid values fall back to the default so service startup remains safe.
func PostgresDSNFromEnv ¶ added in v0.9.0
func PostgresDSNFromEnv() string
PostgresDSNFromEnv reads a configured DSN or builds one from split environment variables, escaping credentials so reserved characters remain valid.
Types ¶
type MongoDBConnection ¶
type MongoDBConnection struct {
Client *mongo.Client
Database *mongo.Database
// contains filtered or unexported fields
}
MongoDBConnection wraps a MongoDB client and database
func ConnectMongoDB ¶
func ConnectMongoDB(uri string, logger *slog.Logger) (*MongoDBConnection, error)
ConnectMongoDB connects to MongoDB using the provided URI The URI should be in the format: mongodb://[user:pass@]host[:port]/database[?options] or mongodb+srv://... for Atlas clusters
func ConnectMongoDBFromEnv ¶
func ConnectMongoDBFromEnv(logger *slog.Logger) (*MongoDBConnection, error)
ConnectMongoDBFromEnv reads MONGODB_URI or MONGO_URI env variable and connects to MongoDB. Returns (nil, nil) if no MongoDB URI is configured.
func (*MongoDBConnection) Close ¶
func (m *MongoDBConnection) Close(ctx context.Context) error
Close closes the MongoDB connection
func (*MongoDBConnection) Collection ¶
func (m *MongoDBConnection) Collection(name string) *mongo.Collection
Collection returns a collection handle for the specified collection name
func (*MongoDBConnection) EnsureLiveStepBufferIndexes ¶ added in v0.2.0
func (m *MongoDBConnection) EnsureLiveStepBufferIndexes(ctx context.Context) error
EnsureLiveStepBufferIndexes creates the TTL and run sweep indexes required by the standalone live step buffer collection.
func (*MongoDBConnection) LiveStepBuffersCollection ¶ added in v0.2.0
func (m *MongoDBConnection) LiveStepBuffersCollection() *mongo.Collection
LiveStepBuffersCollection returns the live_step_buffers collection handle used for the standalone active-step-buffer contract.
type PostgresConfig ¶ added in v0.4.0
type PostgresConnection ¶ added in v0.2.0
PostgresConnection wraps a GORM DB connection to PostgreSQL.
func ConnectPostgres ¶ added in v0.2.0
func ConnectPostgres(dsn string, logger *slog.Logger) (*PostgresConnection, error)
ConnectPostgres opens a GORM connection to PostgreSQL using the provided DSN and verifies the connection.
func ConnectPostgresFromEnv ¶ added in v0.2.0
func ConnectPostgresFromEnv(logger *slog.Logger) (*PostgresConnection, error)
ConnectPostgresFromEnv reads PostgreSQL connection settings from the environment and opens a connection. Returns (nil, nil) if none are set so callers can treat Postgres as optional.
func ConnectPostgresWithConfig ¶ added in v0.4.0
func ConnectPostgresWithConfig(cfg PostgresConfig, logger *slog.Logger) (*PostgresConnection, error)
func (*PostgresConnection) Close ¶ added in v0.2.0
func (p *PostgresConnection) Close() error
Close releases the underlying database connection pool.