Documentation
¶
Index ¶
- func Module() fx.Option
- type Client
- type EntClients
- type IClient
- type SentryClient
- func (c *SentryClient) Close() error
- func (c *SentryClient) Reader(ctx context.Context) *ent.Client
- func (c *SentryClient) TxFromContext(ctx context.Context) *ent.Tx
- func (c *SentryClient) WithTx(ctx context.Context, fn func(context.Context) error) error
- func (c *SentryClient) Writer(ctx context.Context) *ent.Client
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps ent.Client to provide transaction management and read/write routing
func (*Client) Reader ¶ added in v1.0.32
Reader returns the appropriate client for read operations. Intelligently routes to ensure consistency when needed.
Use this for: Get, List, Count, Query operations
func (*Client) TxFromContext ¶
TxFromContext returns the transaction from context if it exists
type EntClients ¶ added in v1.0.32
EntClients holds both writer and reader ENT clients
func NewEntClients ¶ added in v1.0.32
func NewEntClients(config *config.Configuration, logger *logger.Logger) (*EntClients, error)
NewEntClients creates both writer and reader Ent clients
type IClient ¶
type IClient interface {
// WithTx wraps the given function in a transaction
WithTx(ctx context.Context, fn func(context.Context) error) error
// TxFromContext returns the transaction from context if it exists
TxFromContext(ctx context.Context) *ent.Tx
// Writer returns the writer client for write operations.
// Always routes to the primary database (writer endpoint).
//
// Routing:
// - Inside transaction: returns transaction client (writer)
// - Outside transaction: returns writer client
//
// Use for: Create, Update, Delete, Save, Exec operations
Writer(ctx context.Context) *ent.Client
// Reader returns the appropriate client for read operations.
// Intelligently routes based on context to ensure consistency when needed.
//
// Routing:
// - Inside transaction: returns transaction client (writer) for read-your-writes consistency
// - Force writer flag set: returns writer client for read-after-write consistency
// - Otherwise: returns reader client (read replica if available)
//
// Use for: Get, List, Count, Query operations
Reader(ctx context.Context) *ent.Client
// Close closes the database connection
Close() error
}
IClient defines the interface for postgres client operations
func NewSentryClient ¶ added in v1.0.17
NewSentryClient creates a new Sentry-instrumented Postgres client
type SentryClient ¶ added in v1.0.17
type SentryClient struct {
// contains filtered or unexported fields
}
SentryClient wraps the standard postgres client with Sentry monitoring
func (*SentryClient) Close ¶ added in v1.0.32
func (c *SentryClient) Close() error
Close closes the database connection
func (*SentryClient) Reader ¶ added in v1.0.32
func (c *SentryClient) Reader(ctx context.Context) *ent.Client
Reader returns the appropriate client for read operations
func (*SentryClient) TxFromContext ¶ added in v1.0.17
func (c *SentryClient) TxFromContext(ctx context.Context) *ent.Tx
TxFromContext returns the transaction from context if it exists