postgres

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AdvisoryLockClassID_EthBroadcaster int32 = 0
	AdvisoryLockClassID_JobSpawner     int32 = 1
	AdvisoryLockClassID_EthConfirmer   int32 = 2

	// ORM takes lock on 1027321974924625846 which splits into ClassID 239192036, ObjID 2840971190
	AdvisoryLockClassID_ORM int32 = 239192036

	AdvisoryLockObjectID_EthConfirmer int32 = 0
)

NOTE: All advisory lock class IDs used by the Chainlink application MUST be kept here to avoid accidental re-use

View Source
const (
	ChannelJobCreated   = "insert_on_jobs"
	ChannelRunStarted   = "pipeline_run_started"
	ChannelRunCompleted = "pipeline_run_completed"

	// Postgres channel to listen for new eth_txes
	ChannelInsertOnEthTx = "insert_on_eth_txes"
)

Variables

View Source
var (
	DefaultSqlTxOptions = sql.TxOptions{

		Isolation: sql.LevelReadCommitted,
	}
)

Functions

func GormTransaction

func GormTransaction(ctx context.Context, db *gorm.DB, fc func(tx *gorm.DB) error, txOptss ...sql.TxOptions) (err error)

func IsRecordNotFound

func IsRecordNotFound(err error) bool

func IsSerializationAnomaly

func IsSerializationAnomaly(err error) bool

func NewEventBroadcaster

func NewEventBroadcaster(uri string, minReconnectInterval time.Duration, maxReconnectDuration time.Duration) *eventBroadcaster

Types

type AdvisoryLocker

type AdvisoryLocker interface {
	TryLock(ctx context.Context, classID int32, objectID int32) (err error)
	Unlock(ctx context.Context, classID int32, objectID int32) error
	WithAdvisoryLock(ctx context.Context, classID int32, objectID int32, f func() error) error
	Close() error
}

func NewAdvisoryLock

func NewAdvisoryLock(uri string) AdvisoryLocker

type Event

type Event struct {
	Channel string
	Payload string
}

type EventBroadcaster

type EventBroadcaster interface {
	Start() error
	Stop() error
	Subscribe(channel, payloadFilter string) (Subscription, error)
	Notify(channel string, payload string) error
	NotifyInsideGormTx(tx *gorm.DB, channel string, payload string) error
}

EventBroadcaster opaquely manages a collection of Postgres event listeners and broadcasts events to subscribers (with an optional payload filter).

type NullAdvisoryLocker

type NullAdvisoryLocker struct {
	// contains filtered or unexported fields
}

func (*NullAdvisoryLocker) Close

func (n *NullAdvisoryLocker) Close() error

func (*NullAdvisoryLocker) TryLock

func (*NullAdvisoryLocker) TryLock(ctx context.Context, classID int32, objectID int32) (err error)

func (*NullAdvisoryLocker) Unlock

func (*NullAdvisoryLocker) Unlock(ctx context.Context, classID int32, objectID int32) error

func (*NullAdvisoryLocker) WithAdvisoryLock

func (*NullAdvisoryLocker) WithAdvisoryLock(ctx context.Context, classID int32, objectID int32, f func() error) error

type Subscription

type Subscription interface {
	Events() <-chan Event
	Close()
	// contains filtered or unexported methods
}

Subscription represents a subscription to a Postgres event channel

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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