Documentation
¶
Index ¶
- func IsMongoDBURI(dsn string) bool
- func MongoStepBufferTTL(logger *slog.Logger) time.Duration
- type MongoDBConnection
- func (m *MongoDBConnection) Close(ctx context.Context) error
- func (m *MongoDBConnection) Collection(name string) *mongo.Collection
- func (m *MongoDBConnection) DatabaseName() string
- func (m *MongoDBConnection) EnsureLiveStepBufferIndexes(ctx context.Context) error
- func (m *MongoDBConnection) LiveStepBuffersCollection() *mongo.Collection
- func (m *MongoDBConnection) RawMessagesCollection() *mongo.Collection
- func (m *MongoDBConnection) TestRunsCollection() *mongo.Collection
- type PostgresConnection
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsMongoDBURI ¶
IsMongoDBURI checks if the provided DSN is a MongoDB URI
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) DatabaseName ¶ added in v0.1.1
func (m *MongoDBConnection) DatabaseName() string
DatabaseName returns the name of the connected database.
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.
func (*MongoDBConnection) RawMessagesCollection ¶ added in v0.1.1
func (m *MongoDBConnection) RawMessagesCollection() *mongo.Collection
RawMessagesCollection returns the raw_messages collection handle used for message retention.
func (*MongoDBConnection) TestRunsCollection ¶
func (m *MongoDBConnection) TestRunsCollection() *mongo.Collection
TestRunsCollection returns the test_runs collection handle
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, verifies the connection, and runs AutoMigrate to ensure the schema is up to date.
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 (*PostgresConnection) Close ¶ added in v0.2.0
func (p *PostgresConnection) Close() error
Close releases the underlying database connection pool.