Documentation ¶
Index ¶
- Variables
- func NewOrmLogWrapper(logger *logger.Logger, logAllQueries bool, slowThreshold time.Duration) *ormLogWrapper
- type ConfigReader
- type Connection
- type LockingStrategy
- type ORM
- func (orm *ORM) AnyJobWithType(taskTypeName string) (bool, error)
- func (orm *ORM) ArchiveJob(ID models.JobID) error
- 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) 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) DeleteBridgeType(bt *models.BridgeType) error
- func (orm *ORM) DeleteExternalInitiator(name string) error
- func (orm *ORM) DeleteFluxMonitorRoundsBackThrough(aggregator common.Address, roundID uint32) error
- func (orm *ORM) DeleteJobSpecError(ID int64) 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) FindBridgesByNames(names []string) ([]models.BridgeType, error)
- func (orm *ORM) FindEthTaskRunTxByTaskRunID(taskRunID uuid.UUID) (*bulletprooftxmanager.EthTaskRunTx, 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) FindInitiator(ID int64) (initr models.Initiator, err error)
- func (orm *ORM) FindJobIDsWithBridge(bridgeName string) ([]models.JobID, error)
- func (orm *ORM) FindJobRun(id uuid.UUID) (jr models.JobRun, err error)
- func (orm *ORM) FindJobRunIncludingArchived(id uuid.UUID) (jr models.JobRun, err error)
- func (orm *ORM) FindJobSpec(id models.JobID) (job models.JobSpec, err error)
- func (orm *ORM) FindJobSpecError(jobID models.JobID, description string) (*models.JobSpecError, error)
- func (orm *ORM) FindJobSpecUnscoped(id models.JobID) (job models.JobSpec, err error)
- func (orm *ORM) FindJobWithErrors(id models.JobID) (models.JobSpec, error)
- func (orm *ORM) FindLatestNodeVersion() (*models.NodeVersion, error)
- func (orm *ORM) FindOrCreateFluxMonitorRoundStats(aggregator common.Address, roundID uint32) (stats models.FluxMonitorRoundStats, err error)
- func (orm *ORM) FindServiceAgreement(id string) (sa models.ServiceAgreement, err error)
- func (orm *ORM) FindUser() (models.User, error)
- func (orm *ORM) IdempotentInsertEthTaskRunTx(meta models.EthTxMeta, fromAddress common.Address, toAddress common.Address, ...) error
- func (orm *ORM) JobRunsCountFor(jobSpecID models.JobID) (int, error)
- func (orm *ORM) JobRunsCountForGivenStatus(jobSpecID models.JobID, status string) (int, error)
- func (orm *ORM) JobRunsFor(jobSpecID models.JobID, limit ...int) ([]models.JobRun, error)
- func (orm *ORM) JobRunsSorted(sort SortType, offset int, limit int) ([]models.JobRun, int, error)
- func (orm *ORM) JobRunsSortedFor(id models.JobID, order SortType, offset int, limit int) ([]models.JobRun, int, int, int, error)
- func (orm *ORM) Jobs(cb func(*models.JobSpec) bool, initrTypes ...string) error
- func (orm *ORM) JobsSorted(sort SortType, offset int, limit int) ([]models.JobSpec, int, error)
- func (orm *ORM) LinkEarnedFor(spec *models.JobSpec) (*assets.Link, error)
- func (orm *ORM) MarkRan(i models.Initiator, ran bool) error
- func (orm *ORM) MostRecentFluxMonitorRoundID(aggregator common.Address) (uint32, error)
- func (orm *ORM) MustEnsureAdvisoryLock() error
- func (orm *ORM) MustSQLDB() *sql.DB
- func (orm *ORM) PendingBridgeType(jr models.JobRun) (bt models.BridgeType, err error)
- func (orm *ORM) RawDBWithAdvisoryLock(fn func(*gorm.DB) error) error
- func (orm *ORM) RemoveUnstartedTransactions() error
- func (orm *ORM) SaveJobRun(run *models.JobRun) error
- func (orm *ORM) SaveUser(user *models.User) error
- func (orm *ORM) SetLogging(enabled bool)
- func (orm *ORM) Transaction(fc func(tx *gorm.DB) error) (err 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) UpdateFluxMonitorRoundStats(aggregator common.Address, roundID uint32, jobRunID uuid.UUID) error
- func (orm *ORM) UpsertErrorFor(jobID models.JobID, description string)
- func (orm *ORM) UpsertNodeVersion(version models.NodeVersion) 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 ConfigReader ¶ added in v0.6.6
type ConfigReader interface { AllowOrigins() string BlockBackfillDepth() uint64 BridgeResponseURL() *url.URL CertFile() string ChainID() *big.Int ClientNodeURL() string CreateProductionLogger() *logger.Logger DatabaseMaximumTxDuration() time.Duration DatabaseTimeout() models.Duration DatabaseURL() url.URL DefaultHTTPAllowUnrestrictedNetworkAccess() bool DefaultHTTPLimit() int64 DefaultHTTPTimeout() models.Duration DefaultMaxHTTPAttempts() uint Dev() bool EnableExperimentalAdapters() bool EthBalanceMonitorBlockDelay() uint16 EthFinalityDepth() uint EthGasBumpPercent() uint16 EthGasBumpThreshold() uint64 EthGasBumpTxDepth() uint16 EthGasBumpWei() *big.Int EthGasLimitDefault() uint64 EthGasLimitMultiplier() float32 EthGasPriceDefault() *big.Int EthHeadTrackerHistoryDepth() uint EthHeadTrackerMaxBufferSize() uint EthLogBackfillBatchSize() uint32 EthMaxGasPriceWei() *big.Int EthNonceAutoSync() bool EthRPCDefaultBatchSize() uint32 EthTxReaperInterval() time.Duration EthTxReaperThreshold() time.Duration EthTxResendAfterThreshold() time.Duration EthereumSecondaryURLs() []url.URL EthereumURL() string ExplorerAccessKey() string ExplorerSecret() string ExplorerURL() *url.URL FeatureExternalInitiators() bool FeatureFluxMonitor() bool FeatureOffchainReporting() bool BlockHistoryEstimatorBlockDelay() uint16 BlockHistoryEstimatorBlockHistorySize() uint16 BlockHistoryEstimatorTransactionPercentile() uint16 InsecureSkipVerify() bool JSONConsole() bool KeeperDefaultTransactionQueueDepth() uint32 KeeperRegistryCheckGasOverhead() uint64 KeeperRegistryPerformGasOverhead() uint64 KeeperRegistrySyncInterval() time.Duration KeeperMinimumRequiredConfirmations() uint64 KeeperMaximumGracePeriod() int64 KeyFile() string LinkContractAddress() string LogLevel() config.LogLevel LogSQLStatements() bool LogToDisk() bool MaximumServiceDuration() models.Duration MigrateDatabase() bool MinIncomingConfirmations() uint32 MinRequiredOutgoingConfirmations() uint64 MinimumContractPayment() *assets.Link MinimumRequestExpiration() uint64 MinimumServiceDuration() models.Duration OCRTraceLogging() bool OperatorContractAddress() common.Address Port() uint16 ReaperExpiration() models.Duration RootDir() string SecureCookies() bool SessionOptions() sessions.Options SessionSecret() ([]byte, error) SessionTimeout() models.Duration SetEthGasPriceDefault(value *big.Int) error TLSCertPath() string TLSDir() string TLSHost() string TLSKeyPath() string TLSPort() uint16 TLSRedirect() bool TriggerFallbackDBPollInterval() time.Duration }
ConfigReader represents just the read side of the config
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) 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, job_runs and its initiator. It is idempotent, subsequent runs will do nothing and return no error
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) 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) DeleteBridgeType ¶
func (orm *ORM) DeleteBridgeType(bt *models.BridgeType) error
DeleteBridgeType removes the bridge type
func (*ORM) DeleteExternalInitiator ¶
DeleteExternalInitiator removes an external initiator
func (*ORM) DeleteFluxMonitorRoundsBackThrough ¶ added in v0.8.7
DeleteFluxMonitorRoundsBackThrough deletes all the RoundStat records for a given oracle address starting from the most recent round back through the given round
func (*ORM) DeleteJobSpecError ¶ added in v0.8.9
DeleteJobSpecError removes a JobSpecError
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) FindBridgesByNames ¶ added in v0.8.2
func (orm *ORM) FindBridgesByNames(names []string) ([]models.BridgeType, error)
FindBridgesByNames finds multiple bridges by their names.
func (*ORM) FindEthTaskRunTxByTaskRunID ¶ added in v0.8.7
func (orm *ORM) FindEthTaskRunTxByTaskRunID(taskRunID uuid.UUID) (*bulletprooftxmanager.EthTaskRunTx, error)
FindEthTaskRunTxByTaskRunID finds the EthTaskRunTx with its EthTxes and EthTxAttempts preloaded
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) FindInitiator ¶
FindInitiator returns the single initiator defined by the passed ID.
func (*ORM) FindJobIDsWithBridge ¶ added in v0.10.3
func (*ORM) FindJobRun ¶
FindJobRun looks up a JobRun by its ID.
func (*ORM) FindJobRunIncludingArchived ¶ added in v0.10.0
func (*ORM) FindJobSpec ¶ added in v0.9.7
FindJob looks up a JobSpec by its ID.
func (*ORM) FindJobSpecError ¶ added in v0.8.9
func (orm *ORM) FindJobSpecError(jobID models.JobID, description string) (*models.JobSpecError, error)
FindJobSpecError looks for a JobSpecError record with the given jobID and description
func (*ORM) FindJobSpecUnscoped ¶ added in v0.10.0
func (*ORM) FindJobWithErrors ¶ added in v0.8.9
FindJobWithErrors looks up a Job by its ID and preloads JobSpecErrors.
func (*ORM) FindLatestNodeVersion ¶ added in v0.10.4
func (orm *ORM) FindLatestNodeVersion() (*models.NodeVersion, error)
FindLatestNodeVersion looks up the latest node version
func (*ORM) FindOrCreateFluxMonitorRoundStats ¶ added in v0.8.7
func (orm *ORM) FindOrCreateFluxMonitorRoundStats(aggregator common.Address, roundID uint32) (stats models.FluxMonitorRoundStats, err error)
FindOrCreateFluxMonitorRoundStats find the round stats record for a given oracle on a given round, or creates it if no record exists
func (*ORM) FindServiceAgreement ¶
func (orm *ORM) FindServiceAgreement(id string) (sa models.ServiceAgreement, err error)
FindServiceAgreement looks up a ServiceAgreement by its ID.
func (*ORM) IdempotentInsertEthTaskRunTx ¶ added in v0.8.7
func (orm *ORM) IdempotentInsertEthTaskRunTx(meta models.EthTxMeta, fromAddress common.Address, toAddress common.Address, encodedPayload []byte, gasLimit uint64) error
IdempotentInsertEthTaskRunTx creates both eth_task_run_transaction and eth_tx in one hit It can be called multiple times without error as long as the outcome would have resulted in the same database state
func (*ORM) JobRunsCountFor ¶
JobRunsCountFor returns the current number of runs for the job
func (*ORM) JobRunsCountForGivenStatus ¶ added in v0.10.5
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 models.JobID, order SortType, offset int, limit int) ([]models.JobRun, int, int, 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) LinkEarnedFor ¶ added in v0.6.6
LinkEarnedFor shows the total link earnings for a job
func (*ORM) MostRecentFluxMonitorRoundID ¶ added in v0.8.7
MostRecentFluxMonitorRoundID finds roundID of the most recent round that the provided oracle address submitted to
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) PendingBridgeType ¶
PendingBridgeType returns the bridge type of the current pending task, or error if not pending bridge.
func (*ORM) RawDBWithAdvisoryLock ¶ added in v0.10.3
func (*ORM) RemoveUnstartedTransactions ¶ added in v0.9.3
func (*ORM) SaveJobRun ¶
SaveJobRun updates UpdatedAt for a JobRun and updates its status, finished at and run results. It auto-inserts run results if none are existing already for the given jobrun/taskruns.
func (*ORM) SetLogging ¶ added in v0.6.1
SetLogging turns on SQL statement logging
func (*ORM) Transaction ¶ added in v0.8.7
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.
func (*ORM) UpdateFluxMonitorRoundStats ¶ added in v0.8.13
func (orm *ORM) UpdateFluxMonitorRoundStats(aggregator common.Address, roundID uint32, jobRunID uuid.UUID) error
UpdateFluxMonitorRoundStats trys to create a RoundStat record for the given oracle at the given round. If one already exists, it increments the num_submissions column.
func (*ORM) UpsertErrorFor ¶ added in v0.8.9
UpsertErrorFor upserts a JobSpecError record, incrementing the occurrences counter by 1 if the record is found
func (*ORM) UpsertNodeVersion ¶ added in v0.10.4
func (orm *ORM) UpsertNodeVersion(version models.NodeVersion) error
UpsertNodeVersion inserts a new NodeVersion
type PostgresLockingStrategy ¶
type PostgresLockingStrategy struct {
// contains filtered or unexported fields
}
PostgresLockingStrategy uses a postgres advisory lock to ensure exclusive access.