Documentation
¶
Index ¶
- Variables
- func Batch(chunkSize uint, cb func(offset, limit uint) (uint, error)) error
- type DialectName
- type FileLockingStrategy
- type LockingStrategy
- type ORM
- func (orm *ORM) AddTxAttempt(tx *models.Tx, etx *types.Transaction, blkNum uint64) (*models.TxAttempt, error)
- func (orm *ORM) AllSyncEvents(cb func(*models.SyncEvent) error) error
- func (orm *ORM) AnyJobWithType(taskTypeName string) (bool, error)
- func (orm *ORM) ArchiveJob(ID string) error
- func (orm *ORM) Archived(ID string) bool
- 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) BulkDeleteRuns(bulkQuery *models.BulkDeleteRunRequest) error
- func (orm *ORM) ClearNonCurrentSessions(sessionID string) error
- func (orm *ORM) ClearSessions() error
- func (orm *ORM) ClobberDiskKeyStoreWithDBKeys(keysDir string) error
- func (orm *ORM) Close() error
- func (orm *ORM) CreateBridgeType(bt *models.BridgeType) error
- func (orm *ORM) CreateExternalInitiator(externalInitiator *models.ExternalInitiator) error
- func (orm *ORM) CreateHead(n *models.Head) error
- func (orm *ORM) CreateInitiator(initr *models.Initiator) error
- func (orm *ORM) CreateJob(job *models.JobSpec) error
- func (orm *ORM) CreateJobRun(run *models.JobRun) error
- func (orm *ORM) CreateServiceAgreement(sa *models.ServiceAgreement) error
- func (orm *ORM) CreateSession(sr models.SessionRequest) (string, error)
- func (orm *ORM) CreateTx(surrogateID null.String, ethTx *types.Transaction, from *common.Address, ...) (*models.Tx, error)
- func (orm *ORM) DeleteBridgeType(bt *models.BridgeType) error
- func (orm *ORM) DeleteExternalInitiator(accessKey string) error
- func (orm *ORM) DeleteJobRun(ID string) error
- func (orm *ORM) DeleteStaleSessions(before time.Time) error
- func (orm *ORM) DeleteTransaction(ethtx *models.Tx) error
- func (orm *ORM) DeleteUser() (models.User, error)
- func (orm *ORM) DeleteUserSession(sessionID string) error
- func (orm *ORM) DialectName() DialectName
- func (orm *ORM) FindBridge(name models.TaskType) (models.BridgeType, error)
- func (orm *ORM) FindExternalInitiator(eia *models.ExternalInitiatorAuthentication) (*models.ExternalInitiator, error)
- func (orm *ORM) FindInitiator(ID uint) (models.Initiator, error)
- func (orm *ORM) FindJob(id string) (models.JobSpec, error)
- func (orm *ORM) FindJobRun(id string) (models.JobRun, error)
- func (orm *ORM) FindServiceAgreement(id string) (models.ServiceAgreement, error)
- func (orm *ORM) FindTx(ID uint64) (*models.Tx, error)
- func (orm *ORM) FindTxAttempt(hash common.Hash) (*models.TxAttempt, error)
- func (orm *ORM) FindTxByAttempt(hash common.Hash) (*models.Tx, *models.TxAttempt, error)
- func (orm *ORM) FindUser() (models.User, error)
- func (orm *ORM) FirstOrCreateKey(k *models.Key) error
- func (orm *ORM) GetLastNonce(address common.Address) (uint64, error)
- func (orm *ORM) JobRunsCountFor(jobSpecID string) (int, error)
- func (orm *ORM) JobRunsFor(jobSpecID string, limit ...int) ([]models.JobRun, error)
- func (orm *ORM) JobRunsSorted(sort SortType, offset int, limit int) ([]models.JobRun, int, error)
- func (orm *ORM) JobRunsSortedFor(id string, order SortType, offset int, limit int) ([]models.JobRun, int, error)
- func (orm *ORM) Jobs(cb func(models.JobSpec) bool) error
- func (orm *ORM) JobsSorted(sort SortType, offset int, limit int) ([]models.JobSpec, int, error)
- func (orm *ORM) Keys() ([]*models.Key, error)
- func (orm *ORM) LastHead() (*models.Head, error)
- func (orm *ORM) MarkRan(i *models.Initiator, ran bool) error
- func (orm *ORM) MarkTxSafe(tx *models.Tx, txAttempt *models.TxAttempt) error
- func (orm *ORM) PendingBridgeType(jr models.JobRun) (models.BridgeType, error)
- func (orm *ORM) SaveJobRun(run *models.JobRun) error
- func (orm *ORM) SaveSession(session *models.Session) error
- func (orm *ORM) SaveUser(user *models.User) error
- func (orm *ORM) Sessions(offset, limit int) ([]models.Session, error)
- func (orm *ORM) SetLogging(enabled bool)
- func (orm *ORM) Transactions(offset, limit int) ([]models.Tx, int, error)
- func (orm *ORM) TxAttempts(offset, limit int) ([]models.TxAttempt, int, error)
- func (orm *ORM) TxFrom(from common.Address) ([]models.Tx, error)
- func (orm *ORM) Unscoped() *ORM
- func (orm *ORM) UnscopedJobRunsWithStatus(cb func(*models.JobRun), statuses ...models.RunStatus) error
- func (orm *ORM) UpdateBridgeType(bt *models.BridgeType, btr *models.BridgeTypeRequest) error
- func (orm *ORM) UpdateTx(tx *models.Tx, ethTx *types.Transaction, from *common.Address, sentAt uint64) error
- func (orm *ORM) Where(field string, value interface{}, instance interface{}) error
- type PostgresLockingStrategy
- type SortType
Constants ¶
This section is empty.
Variables ¶
var ( // ErrorNotFound is returned when finding a single value fails. ErrorNotFound = gorm.ErrRecordNotFound )
Functions ¶
Types ¶
type DialectName ¶
type DialectName string
DialectName is a compiler enforced type used that maps to gorm's dialect names.
const ( // DialectPostgres represents the postgres dialect. DialectPostgres DialectName = "postgres" // DialectSqlite represents the sqlite dialect. DialectSqlite = "sqlite3" )
func DeduceDialect ¶
func DeduceDialect(path string) (DialectName, error)
DeduceDialect returns the appropriate dialect for the passed connection string.
type FileLockingStrategy ¶
type FileLockingStrategy struct {
// contains filtered or unexported fields
}
FileLockingStrategy uses a file lock on disk to ensure exclusive access.
type LockingStrategy ¶
LockingStrategy employs the locking and unlocking of an underlying resource for exclusive access, usually a file or database.
func NewFileLockingStrategy ¶
func NewFileLockingStrategy(dbpath string) (LockingStrategy, error)
NewFileLockingStrategy creates a new instance of FileLockingStrategy at the passed path.
func NewLockingStrategy ¶
func NewLockingStrategy(dialect DialectName, dbpath string) (LockingStrategy, error)
NewLockingStrategy returns the locking strategy for a particular dialect to ensure exlusive access to the orm.
func NewPostgresLockingStrategy ¶
func NewPostgresLockingStrategy(path string) (LockingStrategy, error)
NewPostgresLockingStrategy returns a new instance of the PostgresLockingStrategy.
type ORM ¶
ORM contains the database object used by Chainlink.
func (*ORM) AddTxAttempt ¶
func (orm *ORM) AddTxAttempt( tx *models.Tx, etx *types.Transaction, blkNum uint64, ) (*models.TxAttempt, error)
AddTxAttempt creates a new transaction attempt and stores it in the database.
func (*ORM) AllSyncEvents ¶
AllSyncEvents returns all sync events
func (*ORM) AnyJobWithType ¶
AnyJobWithType returns true if there is at least one job associated with the type name specified and false otherwise
func (*ORM) ArchiveJob ¶
ArchiveJob soft deletes the job and its associated job runs.
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) BulkDeleteRuns ¶
func (orm *ORM) BulkDeleteRuns(bulkQuery *models.BulkDeleteRunRequest) error
BulkDeleteRuns removes JobRuns and their related records: TaskRuns and RunResults.
TaskRuns are removed by ON DELETE CASCADE when the JobRuns are deleted, but RunResults are not using foreign keys because multiple foreign keys on a record creates an ambiguity with gorm.
func (*ORM) ClearNonCurrentSessions ¶
ClearNonCurrentSessions removes all sessions but the id passed in.
func (*ORM) ClearSessions ¶
ClearSessions removes all sessions.
func (*ORM) ClobberDiskKeyStoreWithDBKeys ¶
ClobberDiskKeyStoreWithDBKeys writes all keys stored in the orm to the keys folder on disk, deleting anything there prior.
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) CreateHead ¶ added in v0.6.1
CreateHead creates a head record that tracks which block heads we've observed in the HeadTracker
func (*ORM) CreateInitiator ¶
CreateInitiator saves the initiator.
func (*ORM) CreateJobRun ¶
CreateJobRun inserts a new JobRun
func (*ORM) CreateServiceAgreement ¶
func (orm *ORM) CreateServiceAgreement(sa *models.ServiceAgreement) error
CreateServiceAgreement saves a Service Agreement, its JobSpec and its associations to the database.
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) CreateTx ¶
func (orm *ORM) CreateTx( surrogateID null.String, ethTx *types.Transaction, from *common.Address, sentAt uint64, ) (*models.Tx, error)
CreateTx returns a transaction by its surrogate key, if it exists, or creates it and its attempts
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) DeleteJobRun ¶
DeleteJobRun deletes the job run and corresponding task runs.
func (*ORM) DeleteStaleSessions ¶
DeleteStaleSessions deletes all sessions before the passed time.
func (*ORM) DeleteTransaction ¶
DeleteTransaction deletes a transaction an all of its attempts.
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) DialectName ¶
func (orm *ORM) DialectName() DialectName
func (*ORM) FindBridge ¶
FindBridge looks up a Bridge by its Name.
func (*ORM) FindExternalInitiator ¶
func (orm *ORM) FindExternalInitiator(eia *models.ExternalInitiatorAuthentication) (*models.ExternalInitiator, error)
FindExternalInitiator finds an external initiator given an authentication request
func (*ORM) FindInitiator ¶
FindInitiator returns the single initiator defined by the passed ID.
func (*ORM) FindJobRun ¶
FindJobRun looks up a JobRun by its ID.
func (*ORM) FindServiceAgreement ¶
func (orm *ORM) FindServiceAgreement(id string) (models.ServiceAgreement, error)
FindServiceAgreement looks up a ServiceAgreement by its ID.
func (*ORM) FindTxAttempt ¶
FindTxAttempt returns an individual TxAttempt
func (*ORM) FindTxByAttempt ¶
FindTxByAttempt returns the specific transaction attempt with the hash.
func (*ORM) FirstOrCreateKey ¶
FirstOrCreateKey returns the first key found or creates a new one in the orm.
func (*ORM) GetLastNonce ¶
GetLastNonce retrieves the last known nonce in the database for an account
func (*ORM) JobRunsCountFor ¶
JobRunsCountFor returns the current number of runs for the job
func (*ORM) JobRunsFor ¶
JobRunsFor fetches all JobRuns with a given Job ID, sorted by their created at time.
func (*ORM) JobRunsSorted ¶
JobRunsSorted returns job runs ordered and filtered by the passed params.
func (*ORM) JobRunsSortedFor ¶
func (orm *ORM) JobRunsSortedFor(id string, order SortType, offset int, limit int) ([]models.JobRun, int, error)
JobRunsSortedFor returns job runs for a specific job spec ordered and filtered by the passed params.
func (*ORM) JobsSorted ¶
JobsSorted returns many JobSpecs sorted by CreatedAt from the store adhering to the passed parameters.
func (*ORM) MarkTxSafe ¶
MarkTxSafe updates the database for the given transaction and attempt to show that the transaction has not just been confirmed, but has met the minimum number of outgoing confirmations to be deemed safely written on the blockchain.
func (*ORM) PendingBridgeType ¶
PendingBridgeType returns the bridge type of the current pending task, or error if not pending bridge.
func (*ORM) SaveJobRun ¶
SaveJobRun updates UpdatedAt for a JobRun and saves it
func (*ORM) SaveSession ¶
SaveSession saves the session.
func (*ORM) SetLogging ¶ added in v0.6.1
SetLogging turns on SQL statement logging
func (*ORM) Transactions ¶
Transactions returns all transactions limited by passed parameters.
func (*ORM) TxAttempts ¶
TxAttempts returns the last tx attempts sorted by sent at descending.
func (*ORM) Unscoped ¶
Unscoped returns a new instance of this ORM that includes soft deleted items.
func (*ORM) UnscopedJobRunsWithStatus ¶
func (orm *ORM) UnscopedJobRunsWithStatus(cb func(*models.JobRun), statuses ...models.RunStatus) error
UnscopedJobRunsWithStatus passes all JobRuns to a callback, one by one, including those that were soft deleted.
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.
func (*PostgresLockingStrategy) Lock ¶
func (s *PostgresLockingStrategy) Lock(timeout time.Duration) error
Lock uses a blocking postgres advisory lock that times out at the passed timeout.
func (*PostgresLockingStrategy) Unlock ¶
func (s *PostgresLockingStrategy) Unlock() error
Unlock unlocks the locked postgres advisory lock.