storage

package
v0.0.0-...-7a6fcb1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

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) AddOrder

func (r *Repository) AddOrder(ctx context.Context, order domain.Order) (domain.Order, error)

func (*Repository) AddRefund

func (r *Repository) AddRefund(ctx context.Context, refund domain.Refund) (domain.Refund, error)

func (*Repository) AddTopUp

func (r *Repository) AddTopUp(ctx context.Context, topUp domain.TopUp) (domain.TopUp, error)

func (*Repository) AddTransfer

func (r *Repository) AddTransfer(ctx context.Context, transfer trans.Transfer) (trans.Transfer, error)

func (*Repository) AddTransferTransaction

func (r *Repository) AddTransferTransaction(ctx context.Context, transaction transtxn.TransferTransaction) (transtxn.TransferTransaction, error)

func (*Repository) DB

func (r *Repository) DB(ctx context.Context) *gorm.DB

func (*Repository) GetOrder

func (r *Repository) GetOrder(ctx context.Context, orderID uint64) (domain.Order, error)

func (*Repository) GetRefund

func (r *Repository) GetRefund(ctx context.Context, refundID uint64) (domain.Refund, error)

func (*Repository) GetTopUp

func (r *Repository) GetTopUp(ctx context.Context, topUpID uint64) (domain.TopUp, error)

func (*Repository) TxnExec

func (r *Repository) TxnExec(ctx context.Context, f func(ctxWithTxn context.Context) (interface{}, error)) (interface{}, error)

func (*Repository) UpdateCardRequest

func (r *Repository) UpdateCardRequest(ctx context.Context, request gateway.CardRequest) (gateway.CardRequest, error)

func (*Repository) UpdateOrder

func (r *Repository) UpdateOrder(ctx context.Context, order domain.Order) (domain.Order, error)

func (*Repository) UpdateRefund

func (r *Repository) UpdateRefund(ctx context.Context, refund domain.Refund) (domain.Refund, error)

func (*Repository) UpdateTopUp

func (r *Repository) UpdateTopUp(ctx context.Context, topUp domain.TopUp) (domain.TopUp, error)

func (*Repository) UpdateTransfer

func (r *Repository) UpdateTransfer(ctx context.Context, transfer trans.Transfer) (trans.Transfer, error)

func (*Repository) UpdateTransferTransaction

func (r *Repository) UpdateTransferTransaction(ctx context.Context, transaction transtxn.TransferTransaction) (transtxn.TransferTransaction, error)

Jump to

Keyboard shortcuts

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