Documentation
¶
Index ¶
- func Module() fx.Option
- func NewEntClient(config *config.Configuration, logger *logger.Logger) (*ent.Client, error)
- type Client
- type DB
- func (db *DB) BeginTx(ctx context.Context) (context.Context, *Tx, error)
- func (db *DB) Close()
- func (db *DB) CommitTx(ctx context.Context) error
- func (db *DB) GetQuerier(ctx context.Context) Querier
- func (db *DB) NamedExecContext(ctx context.Context, query string, arg interface{}) (sql.Result, error)
- func (db *DB) NamedQueryContext(ctx context.Context, query string, arg interface{}) (*sqlx.Rows, error)
- func (db *DB) RollbackTx(ctx context.Context) error
- func (db *DB) WithTx(ctx context.Context, fn func(ctx context.Context) error) error
- type IClient
- type Querier
- type QueryTracer
- type SentryClient
- type TracedQuerier
- func (tq *TracedQuerier) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (tq *TracedQuerier) NamedExec(query string, arg interface{}) (sql.Result, error)
- func (tq *TracedQuerier) NamedQuery(query string, arg interface{}) (*sqlx.Rows, error)
- func (tq *TracedQuerier) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- type Tx
- type TxKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewEntClient ¶
NewEntClient creates a new Ent client
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps ent.Client to provide transaction management
func (*Client) Querier ¶
Querier returns the current transaction client if in a transaction, or the regular client
func (*Client) TxFromContext ¶
TxFromContext returns the transaction from context if it exists
type DB ¶
DB wraps sqlx.DB to provide transaction management
func (*DB) GetQuerier ¶
GetQuerier returns either the transaction from context or the base DB
func (*DB) NamedExecContext ¶
func (db *DB) NamedExecContext(ctx context.Context, query string, arg interface{}) (sql.Result, error)
NamedExecContext is a helper method that wraps NamedExec with context
func (*DB) NamedQueryContext ¶
func (db *DB) NamedQueryContext(ctx context.Context, query string, arg interface{}) (*sqlx.Rows, error)
NamedQueryContext is a helper method that wraps NamedQuery with context
func (*DB) RollbackTx ¶
RollbackTx rolls back the current transaction level
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
// Querier returns the current transaction client if in a transaction, or the regular client
Querier(ctx context.Context) *ent.Client
}
IClient defines the interface for postgres client operations
func NewSentryClient ¶ added in v1.0.17
NewSentryClient creates a new Sentry-instrumented Postgres client
type Querier ¶
type Querier interface {
ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
NamedExec(query string, arg interface{}) (sql.Result, error)
NamedQuery(query string, arg interface{}) (*sqlx.Rows, error)
PrepareNamed(query string) (*sqlx.NamedStmt, error)
Preparex(query string) (*sqlx.Stmt, error)
}
Querier interface defines all database operations Both *sqlx.DB and *sqlx.Tx implement these methods
type QueryTracer ¶
type QueryTracer struct {
// contains filtered or unexported fields
}
QueryTracer wraps database operations with tracing and logging
func NewQueryTracer ¶
func NewQueryTracer(logger *logger.Logger, query string, params interface{}, txID string) *QueryTracer
NewQueryTracer creates a new query tracer
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) Querier ¶ added in v1.0.17
func (c *SentryClient) Querier(ctx context.Context) *ent.Client
Querier returns the current transaction client if in a transaction, or the regular client This method wraps the client without any span tracking for now as there is no value in just getting postgress query client getting called we have added a repository layer that will add the span tracking
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
type TracedQuerier ¶
type TracedQuerier struct {
Querier
// contains filtered or unexported fields
}
TracedQuerier wraps a Querier with tracing
func NewTracedQuerier ¶
func NewTracedQuerier(q Querier, logger *logger.Logger, txID string) *TracedQuerier
NewTracedQuerier creates a new traced querier
func (*TracedQuerier) ExecContext ¶
func (tq *TracedQuerier) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
ExecContext traces ExecContext calls
func (*TracedQuerier) NamedExec ¶
func (tq *TracedQuerier) NamedExec(query string, arg interface{}) (sql.Result, error)
NamedExec traces NamedExec calls
func (*TracedQuerier) NamedQuery ¶
func (tq *TracedQuerier) NamedQuery(query string, arg interface{}) (*sqlx.Rows, error)
NamedQuery traces NamedQuery calls
func (*TracedQuerier) QueryContext ¶
func (tq *TracedQuerier) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
QueryContext traces QueryContext calls