Documentation ¶
Index ¶
- Variables
- func NewOrmLogWrapper(logger *logger.Logger, logAllQueries bool, slowThreshold time.Duration) *ormLogWrapper
- type Connection
- type LockingStrategy
- type ORM
- func (orm *ORM) AuthorizedUserWithSession(sessionID string, sessionDuration time.Duration) (models.User, error)
- func (orm *ORM) BridgeTypes(offset int, limit int) ([]models.BridgeType, int, error)
- func (orm *ORM) ClearNonCurrentSessions(sessionID string) error
- func (orm *ORM) Close() error
- func (orm *ORM) CountOf(t interface{}) (int, error)
- func (orm *ORM) CreateBridgeType(bt *models.BridgeType) error
- func (orm *ORM) CreateExternalInitiator(externalInitiator *models.ExternalInitiator) error
- func (orm *ORM) CreateSession(sr models.SessionRequest) (string, error)
- func (orm *ORM) DeleteBridgeType(bt *models.BridgeType) error
- func (orm *ORM) DeleteExternalInitiator(name string) error
- func (orm *ORM) DeleteUser() error
- func (orm *ORM) DeleteUserSession(sessionID string) error
- func (orm *ORM) EthTransactionsWithAttempts(offset, limit int) ([]bulletprooftxmanager.EthTx, int, error)
- func (orm *ORM) EthTxAttempts(offset, limit int) ([]bulletprooftxmanager.EthTxAttempt, int, error)
- func (orm *ORM) ExternalInitiatorsSorted(offset int, limit int) ([]models.ExternalInitiator, int, error)
- func (orm *ORM) FindBridge(name models.TaskType) (bt models.BridgeType, err error)
- func (orm *ORM) FindEthTxAttempt(hash common.Hash) (*bulletprooftxmanager.EthTxAttempt, error)
- func (orm *ORM) FindExternalInitiator(eia *auth.Token) (*models.ExternalInitiator, error)
- func (orm *ORM) FindExternalInitiatorByName(iname string) (exi models.ExternalInitiator, err error)
- func (orm *ORM) FindUser() (models.User, error)
- func (orm *ORM) MustEnsureAdvisoryLock() error
- func (orm *ORM) MustSQLDB() *sql.DB
- func (orm *ORM) RawDBWithAdvisoryLock(fn func(*gorm.DB) error) error
- func (orm *ORM) SaveUser(user *models.User) error
- func (orm *ORM) SetLogging(enabled bool)
- func (orm *ORM) Unscoped() *ORM
- func (orm *ORM) UpdateBridgeType(bt *models.BridgeType, btr *models.BridgeTypeRequest) error
- type PostgresLockingStrategy
- type SortType
Constants ¶
This section is empty.
Variables ¶
var ( // ErrorNotFound is returned when finding a single value fails. ErrorNotFound = gorm.ErrRecordNotFound // ErrNoAdvisoryLock is returned when an advisory lock can't be acquired. ErrNoAdvisoryLock = errors.New("can't acquire advisory lock") // ErrReleaseLockFailed is returned when releasing the advisory lock fails. ErrReleaseLockFailed = errors.New("advisory lock release failed") // ErrOptimisticUpdateConflict is returned when a record update failed // because another update occurred while the model was in memory and the // differences must be reconciled. ErrOptimisticUpdateConflict = errors.New("conflict while updating record") )
Functions ¶
Types ¶
type Connection ¶ added in v0.8.5
type Connection struct {
// contains filtered or unexported fields
}
Connection manages all of the possible database connection setup and config.
func NewConnection ¶ added in v0.8.5
func NewConnection(dialect dialects.DialectName, uri string, advisoryLockID int64, lockRetryInterval time.Duration, maxOpenConns, maxIdleConns int) (Connection, error)
NewConnection returns a Connection which holds all of the configuration necessary for managing the database connection.
type LockingStrategy ¶
type LockingStrategy interface { Lock(timeout models.Duration) error Unlock(timeout models.Duration) error }
LockingStrategy employs the locking and unlocking of an underlying resource for exclusive access, usually a file or database.
func NewLockingStrategy ¶
func NewLockingStrategy(ct Connection) (LockingStrategy, error)
NewLockingStrategy returns the locking strategy for a particular dialect to ensure exlusive access to the orm.
func NewPostgresLockingStrategy ¶
func NewPostgresLockingStrategy(ct Connection) (LockingStrategy, error)
NewPostgresLockingStrategy returns a new instance of the PostgresLockingStrategy.
type ORM ¶
ORM contains the database object used by Chainlink.
func NewORM ¶
func NewORM(uri string, timeout models.Duration, shutdownSignal gracefulpanic.Signal, dialect dialects.DialectName, advisoryLockID int64, lockRetryInterval time.Duration, maxOpenConns, maxIdleConns int) (*ORM, error)
NewORM initializes the orm with the configured uri
func (*ORM) AuthorizedUserWithSession ¶
func (orm *ORM) AuthorizedUserWithSession(sessionID string, sessionDuration time.Duration) (models.User, error)
AuthorizedUserWithSession will return the one API user if the Session ID exists and hasn't expired, and update session's LastUsed field.
func (*ORM) BridgeTypes ¶
BridgeTypes returns bridge types ordered by name filtered limited by the passed params.
func (*ORM) ClearNonCurrentSessions ¶
ClearNonCurrentSessions removes all sessions but the id passed in.
func (*ORM) CreateBridgeType ¶
func (orm *ORM) CreateBridgeType(bt *models.BridgeType) error
CreateBridgeType saves the bridge type.
func (*ORM) CreateExternalInitiator ¶
func (orm *ORM) CreateExternalInitiator(externalInitiator *models.ExternalInitiator) error
CreateExternalInitiator inserts a new external initiator
func (*ORM) CreateSession ¶
func (orm *ORM) CreateSession(sr models.SessionRequest) (string, error)
CreateSession will check the password in the SessionRequest against the hashed API User password in the db.
func (*ORM) DeleteBridgeType ¶
func (orm *ORM) DeleteBridgeType(bt *models.BridgeType) error
DeleteBridgeType removes the bridge type
func (*ORM) DeleteExternalInitiator ¶
DeleteExternalInitiator removes an external initiator
func (*ORM) DeleteUser ¶
DeleteUser will delete the API User in the db.
func (*ORM) DeleteUserSession ¶
DeleteUserSession will erase the session ID for the sole API User.
func (*ORM) EthTransactionsWithAttempts ¶ added in v0.9.6
func (orm *ORM) EthTransactionsWithAttempts(offset, limit int) ([]bulletprooftxmanager.EthTx, int, error)
EthTransactionsWithAttempts returns all eth transactions with at least one attempt limited by passed parameters. Attempts are sorted by created_at.
func (*ORM) EthTxAttempts ¶ added in v0.9.6
func (orm *ORM) EthTxAttempts(offset, limit int) ([]bulletprooftxmanager.EthTxAttempt, int, error)
EthTxAttempts returns the last tx attempts sorted by created_at descending.
func (*ORM) ExternalInitiatorsSorted ¶ added in v0.10.11
func (orm *ORM) ExternalInitiatorsSorted(offset int, limit int) ([]models.ExternalInitiator, int, error)
ExternalInitiatorsSorted returns many ExternalInitiators sorted by Name from the store adhering to the passed parameters.
func (*ORM) FindBridge ¶
FindBridge looks up a Bridge by its Name.
func (*ORM) FindEthTxAttempt ¶ added in v0.9.6
func (orm *ORM) FindEthTxAttempt(hash common.Hash) (*bulletprooftxmanager.EthTxAttempt, error)
FindEthTxAttempt returns an individual EthTxAttempt
func (*ORM) FindExternalInitiator ¶
FindExternalInitiator finds an external initiator given an authentication request
func (*ORM) FindExternalInitiatorByName ¶ added in v0.6.6
func (orm *ORM) FindExternalInitiatorByName(iname string) (exi models.ExternalInitiator, err error)
FindExternalInitiatorByName finds an external initiator given an authentication request
func (*ORM) MustEnsureAdvisoryLock ¶ added in v0.8.2
MustEnsureAdvisoryLock sends a shutdown signal to the ORM if it an advisory lock cannot be acquired.
func (*ORM) RawDBWithAdvisoryLock ¶ added in v0.10.3
func (*ORM) SetLogging ¶ added in v0.6.1
SetLogging turns on SQL statement logging
func (*ORM) Unscoped ¶
Unscoped returns a new instance of this ORM that includes soft deleted items.
func (*ORM) UpdateBridgeType ¶
func (orm *ORM) UpdateBridgeType(bt *models.BridgeType, btr *models.BridgeTypeRequest) error
UpdateBridgeType updates the bridge type.
type PostgresLockingStrategy ¶
type PostgresLockingStrategy struct {
// contains filtered or unexported fields
}
PostgresLockingStrategy uses a postgres advisory lock to ensure exclusive access.