pgnotifier

package
v0.0.0-...-0ade494 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2022 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WaitingState   = "waiting"
	ExecutingState = "executing"
	SucceededState = "succeeded"
	FailedState    = "failed"
	AbortedState   = "aborted"
)

Variables

This section is empty.

Functions

func CheckForPGNotifierEnvVars

func CheckForPGNotifierEnvVars() bool

CheckForPGNotifierEnvVars Checks if all the required Env Variables for PG Notifier are present

func GetCurrentSQLTimestamp

func GetCurrentSQLTimestamp() string

GetCurrentSQLTimestamp to get sql complaint current datetime string

func GetPGNotifierConnectionString

func GetPGNotifierConnectionString() string

GetPGNotifierConnectionString Returns PG Notifier DB Connection Configuration

func Init

func Init()

Types

type ClaimResponseT

type ClaimResponseT struct {
	Payload json.RawMessage
	Err     error
}

type ClaimT

type ClaimT struct {
	ID        int64
	BatchID   string
	Status    string
	Workspace string
	Payload   json.RawMessage
	Attempt   int
}

type JobPayload

type JobPayload json.RawMessage

type PgNotifierT

type PgNotifierT struct {
	URI string
	// contains filtered or unexported fields
}

func New

func New(workspaceIdentifier, fallbackConnectionInfo string) (notifier PgNotifierT, err error)

New Given default connection info return pg notifiew object from it

func (PgNotifierT) ClearJobs

func (notifier PgNotifierT) ClearJobs(ctx context.Context) (err error)

func (PgNotifierT) GetDBHandle

func (notifier PgNotifierT) GetDBHandle() *sql.DB

func (*PgNotifierT) Publish

func (notifier *PgNotifierT) Publish(jobs []JobPayload, schema *whUtils.SchemaT, priority int) (ch chan []ResponseT, err error)

func (*PgNotifierT) RunMaintenanceWorker

func (notifier *PgNotifierT) RunMaintenanceWorker(ctx context.Context) error

RunMaintenanceWorker (blocking - to be called from go routine) retriggers zombie jobs which were left behind by dead workers in executing state

func (*PgNotifierT) Subscribe

func (notifier *PgNotifierT) Subscribe(ctx context.Context, workerId string, jobsBufferSize int) chan ClaimT

func (*PgNotifierT) UpdateClaimedEvent

func (notifier *PgNotifierT) UpdateClaimedEvent(claim *ClaimT, response *ClaimResponseT)

type ResponseT

type ResponseT struct {
	JobID  int64
	Status string
	Output json.RawMessage
	Error  string
}

Jump to

Keyboard shortcuts

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