database

package
v0.7.0-beta Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MongoStepBufferTTL added in v0.2.0

func MongoStepBufferTTL(logger *slog.Logger) time.Duration

MongoStepBufferTTL resolves the configured TTL for live step buffers. Invalid values fall back to the default so service startup remains safe.

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 PostgresConfig struct {
	DSN               string
	Env               string
	EnableAutoMigrate bool
}

type PostgresConnection added in v0.2.0

type PostgresConnection struct {
	DB *gorm.DB
	// contains filtered or unexported fields
}

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 POSTGRES_DSN (or DATABASE_URL as a fallback) from the environment and opens a connection. Returns (nil, nil) if neither variable is 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.

Jump to

Keyboard shortcuts

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