Documentation ¶
Index ¶
- Constants
- func ConfigureDatabaseConnection(dbConn *core_database.DatabaseConn)
- func GenerateRandomString(n int) string
- func MigrateSchemas(db *core_database.DatabaseConn, logger core_logging.ILog, ...) error
- type CmplxTx
- type Db
- func (db *Db) ArchiveBusinessAccount(ctx context.Context, id uint32) error
- func (db *Db) ArchiveBusinessAccounts(ctx context.Context, ids []uint32) ([]bool, error)
- func (db *Db) CreateBusinessAccount(ctx context.Context, account *proto.BusinessAccount, authnid uint32) (*proto.BusinessAccount, error)
- func (db *Db) DistributedTxCreateAccount(ctx context.Context, email, password string, childSpan opentracing.Span) (*uint32, error)
- func (db *Db) DistributedTxLockAccount(ctx context.Context, id uint32, childSpan opentracing.Span, token string) error
- func (db *Db) DistributedTxUnlockAccount(ctx context.Context, id uint32, childSpan opentracing.Span, token string) error
- func (db *Db) DistributedTxUpdateAccountEmail(ctx context.Context, id uint32, email string, childSpan opentracing.Span, ...) error
- func (db *Db) GetBusinessAccount(ctx context.Context, id uint32) (*proto.BusinessAccount, error)
- func (db *Db) GetBusinessAccounts(ctx context.Context, ids []uint32) ([]*proto.BusinessAccount, error)
- func (db *Db) GetBusinessByEmail(ctx context.Context, email string) *proto.BusinessAccount
- func (db *Db) GetBusinessById(ctx context.Context, id uint32) *proto.BusinessAccount
- func (db *Db) GetPaginatedBusinessAccounts(ctx context.Context, limit int64) ([]*proto.BusinessAccount, error)
- func (db *Db) PerformRetryableOperation(f func() error) error
- func (db *Db) PreloadTx(tx *gorm.DB) *gorm.DB
- func (db *Db) SetBusinessAccountStatusAndSave(ctx context.Context, businessAccount *proto.BusinessAccount, ...) error
- func (db *Db) UpdateBusinessAccount(ctx context.Context, id uint32, account *proto.BusinessAccount) (*proto.BusinessAccount, error)
- type IDatabase
- type IDbOperations
- type Tx
Constants ¶
const (
DB_CONNECTION_ATTEMPT = "DB_CONNECTION_ATTEMPT"
)
database operation types
Variables ¶
This section is empty.
Functions ¶
func ConfigureDatabaseConnection ¶
func ConfigureDatabaseConnection(dbConn *core_database.DatabaseConn)
ConfigureDatabaseConnection configures a database connection
func GenerateRandomString ¶
func MigrateSchemas ¶
func MigrateSchemas(db *core_database.DatabaseConn, logger core_logging.ILog, models ...interface{}) error
MigrateSchemas creates or updates a given set of model based on a schema if it does not exist or migrates the model schemas to the latest version
Types ¶
type Db ¶
type Db struct { Conn *core_database.DatabaseConn Logger core_logging.ILog TracingEngine *core_tracing.TracingEngine MetricsEngine *core_metrics.CoreMetricsEngine AuthenticationHandlerServiceBaseEndpoint string Saga *saga.SagaCoordinator MaxConnectionAttempts int MaxRetriesPerOperation int RetryTimeOut time.Duration OperationSleepInterval time.Duration }
Db witholds connection to a postgres database as well as a logging handler
func New ¶
func New(ctx context.Context, connectionString string, tracingEngine *core_tracing.TracingEngine, metricsEngine *core_metrics.CoreMetricsEngine, logger core_logging.ILog, svcEndpoint string) (*Db, error)
New creates a database connection and returns the connection object
func Setup ¶
func Setup(ctx context.Context, connectionString string, tracingEngine *core_tracing.TracingEngine, metricsEngine *core_metrics.CoreMetricsEngine, logger core_logging.ILog, svcEndpoint string) *Db
Setup sets up database connection prior to testing
func (*Db) ArchiveBusinessAccount ¶
DeleteBusinessAccount archives a business account by id
func (*Db) ArchiveBusinessAccounts ¶
DeleteBusinessAccounts deletes a set of business accounts by ids
func (*Db) CreateBusinessAccount ¶
func (db *Db) CreateBusinessAccount(ctx context.Context, account *proto.BusinessAccount, authnid uint32) (*proto.BusinessAccount, error)
CreateBusinessAccount creates a business account and saves it to the database
func (*Db) DistributedTxCreateAccount ¶
func (db *Db) DistributedTxCreateAccount(ctx context.Context, email, password string, childSpan opentracing.Span) (*uint32, error)
DistributedTxCreateAccount creates the account record in a distributed transaction
func (*Db) DistributedTxLockAccount ¶
func (db *Db) DistributedTxLockAccount(ctx context.Context, id uint32, childSpan opentracing.Span, token string) error
DistributedTxLockAccount locks an account in a distributed transaction
func (*Db) DistributedTxUnlockAccount ¶
func (db *Db) DistributedTxUnlockAccount(ctx context.Context, id uint32, childSpan opentracing.Span, token string) error
DistributedTxUnlockAccount unlocks an account in a distributed transaction
func (*Db) DistributedTxUpdateAccountEmail ¶
func (db *Db) DistributedTxUpdateAccountEmail(ctx context.Context, id uint32, email string, childSpan opentracing.Span, token string) error
DistributedTxUpdateAccountEmail updates the account record's email entry in a distributed transaction
func (*Db) GetBusinessAccount ¶
GetBusinessAccount gets a singular business account
func (*Db) GetBusinessAccounts ¶
func (db *Db) GetBusinessAccounts(ctx context.Context, ids []uint32) ([]*proto.BusinessAccount, error)
GetBusinessAccount gets a set of business accounts by ids
func (*Db) GetBusinessByEmail ¶
GetBusinessByEmail gets a business account by email from the backend database
func (*Db) GetBusinessById ¶
GetBusinessById gets a business account by id from the backend database
func (*Db) GetPaginatedBusinessAccounts ¶
func (*Db) PerformRetryableOperation ¶
func (*Db) SetBusinessAccountStatusAndSave ¶
func (db *Db) SetBusinessAccountStatusAndSave(ctx context.Context, businessAccount *proto.BusinessAccount, activateAccount bool) error
SetBusinessAccountStatusAndSave updates the active status of a business account in the backend database
func (*Db) UpdateBusinessAccount ¶
func (db *Db) UpdateBusinessAccount(ctx context.Context, id uint32, account *proto.BusinessAccount) (*proto.BusinessAccount, error)
UpdateBusinessAccount updates a business account
type IDatabase ¶
type IDatabase interface { }
IDatabase provides an interface which any database tied to this service should implement
type IDbOperations ¶
type IDbOperations interface { // CreateBusinessAccount creates a business account CreateBusinessAccount(ctx context.Context, account *proto.BusinessAccount) (*proto.BusinessAccount, error) // UpdateBusinessAccount updates a business account by Id UpdateBusinessAccount(ctx context.Context, id uint32, account *proto.BusinessAccount) (*proto.BusinessAccount, error) // DeleteBusinessAccount deletes a business account by Id ArchiveBusinessAccount(ctx context.Context, id uint32) (bool, error) // DeleteBusinessAccounts deletes a set of business accounts by Id ArchiveBusinessAccounts(ctx context.Context, ids []uint32) ([]bool, error) // GetBusinessAccount gets a business account by id GetBusinessAccount(ctx context.Context, id uint32) (*proto.BusinessAccount, error) // GetBusinessAccounts gets a set of business accounts by id GetBusinessAccounts(ctx context.Context, ids []uint32) ([]*proto.BusinessAccount, error) }