Documentation ¶
Index ¶
- type Config
- type DuplicatedEntryError
- type NotFoundError
- type Repository
- func (r *Repository) AddCardRequest(ctx context.Context, request gateway.CardRequest) (gateway.CardRequest, error)
- func (r *Repository) AddOrder(ctx context.Context, order domain.Order) (domain.Order, error)
- func (r *Repository) AddRefund(ctx context.Context, refund domain.Refund) (domain.Refund, error)
- func (r *Repository) AddTopUp(ctx context.Context, topUp domain.TopUp) (domain.TopUp, error)
- func (r *Repository) AddTransfer(ctx context.Context, transfer trans.Transfer) (trans.Transfer, error)
- func (r *Repository) AddTransferTransaction(ctx context.Context, transaction transtxn.TransferTransaction) (transtxn.TransferTransaction, error)
- func (r *Repository) DB(ctx context.Context) *gorm.DB
- func (r *Repository) GetOrder(ctx context.Context, orderID uint64) (domain.Order, error)
- func (r *Repository) GetRefund(ctx context.Context, refundID uint64) (domain.Refund, error)
- func (r *Repository) GetTopUp(ctx context.Context, topUpID uint64) (domain.TopUp, error)
- func (r *Repository) TxnExec(ctx context.Context, f func(ctxWithTxn context.Context) (interface{}, error)) (interface{}, error)
- func (r *Repository) UpdateCardRequest(ctx context.Context, request gateway.CardRequest) (gateway.CardRequest, error)
- func (r *Repository) UpdateOrder(ctx context.Context, order domain.Order) (domain.Order, error)
- func (r *Repository) UpdateRefund(ctx context.Context, refund domain.Refund) (domain.Refund, error)
- func (r *Repository) UpdateTopUp(ctx context.Context, topUp domain.TopUp) (domain.TopUp, error)
- func (r *Repository) UpdateTransfer(ctx context.Context, transfer trans.Transfer) (trans.Transfer, error)
- func (r *Repository) UpdateTransferTransaction(ctx context.Context, transaction transtxn.TransferTransaction) (transtxn.TransferTransaction, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Name string `env:"DB_NAME" json:",omitempty"` User string `env:"DB_USER" json:",omitempty"` Host string `env:"DB_HOST, default=localhost" json:",omitempty"` Port string `env:"DB_PORT, default=5432" json:",omitempty"` SSLMode string `env:"DB_SSLMODE, default=require" json:",omitempty"` ConnectionTimeout int `env:"DB_CONNECT_TIMEOUT" json:",omitempty"` Password string `env:"DB_PASSWORD" json:"-"` // ignored by zap's JSON formatter SSLCertPath string `env:"DB_SSLCERT" json:",omitempty"` SSLKeyPath string `env:"DB_SSLKEY" json:",omitempty"` SSLRootCertPath string `env:"DB_SSLROOTCERT" json:",omitempty"` PoolMinConnections string `env:"DB_POOL_MIN_CONNS" json:",omitempty"` PoolMaxConnections string `env:"DB_POOL_MAX_CONNS" json:",omitempty"` PoolMaxConnLife time.Duration `env:"DB_POOL_MAX_CONN_LIFETIME, default=5m" json:",omitempty"` PoolMaxConnIdle time.Duration `env:"DB_POOL_MAX_CONN_IDLE_TIME, default=1m" json:",omitempty"` PoolHealthCheck time.Duration `env:"DB_POOL_HEALTH_CHECK_PERIOD, default=1m" json:",omitempty"` }
type DuplicatedEntryError ¶
type DuplicatedEntryError struct {
Field string
}
func (DuplicatedEntryError) Error ¶
func (e DuplicatedEntryError) Error() string
type NotFoundError ¶
type NotFoundError struct {
Field string
}
func (NotFoundError) Error ¶
func (e NotFoundError) Error() string
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
func NewRepository ¶
func NewRepository(ctx context.Context, config *Config, uidGenerator uid.Generator) (*Repository, error)
NewRepository sets up the database connections using the configuration in the process's environment variables. This should be called just once per port instance.
func (*Repository) AddCardRequest ¶
func (r *Repository) AddCardRequest(ctx context.Context, request gateway.CardRequest) (gateway.CardRequest, error)
func (*Repository) AddTransfer ¶
func (*Repository) AddTransferTransaction ¶
func (r *Repository) AddTransferTransaction(ctx context.Context, transaction transtxn.TransferTransaction) (transtxn.TransferTransaction, error)
func (*Repository) UpdateCardRequest ¶
func (r *Repository) UpdateCardRequest(ctx context.Context, request gateway.CardRequest) (gateway.CardRequest, error)
func (*Repository) UpdateOrder ¶
func (*Repository) UpdateRefund ¶
func (*Repository) UpdateTopUp ¶
func (*Repository) UpdateTransfer ¶
func (*Repository) UpdateTransferTransaction ¶
func (r *Repository) UpdateTransferTransaction(ctx context.Context, transaction transtxn.TransferTransaction) (transtxn.TransferTransaction, error)
Click to show internal directories.
Click to hide internal directories.