A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://pkg.go.dev/github.com/riverqueue/river/rivertype below:

rivertype package - github.com/riverqueue/river/rivertype - Go Packages

Package rivertype stores some of the lowest level River primitives so they can be shared amongst a number of packages including the top-level river package, database drivers, and internal utilities.

MetadataKeyOutput is the metadata key used to store recorded job output.

ErrJobRunning is returned when a job is attempted to be deleted while it's running.

ErrNotFound is returned when a query by ID does not match any existing rows. For example, attempting to cancel a job that doesn't exist will return this error.

JobCancel wraps err and can be returned from a Worker's Work method to cancel the job at the end of execution. Regardless of whether or not the job has any remaining attempts, this will ensure the job does not execute again.

This function primarily exists for cross module compatibility. Users should use river.JobCancel instead.

type AttemptError struct {
	
	At time.Time `json:"at"`

	
	
	Attempt int `json:"attempt"`

	
	
	Error string `json:"error"`

	
	
	Trace string `json:"trace"`
}

AttemptError is an error from a single job attempt that failed due to an error or a panic.

type Hook interface {
	
	
	
	
	IsHook() bool
}

Hook is an arbitrary interface for a plugin "hook" which will execute some arbitrary code at a predefined step in the job lifecycle.

This interface is left purposely non-specific. Hook structs should embed river.HookDefaults to inherit an IsHook implementation, then implement one of the more specific hook interfaces like HookInsertBegin or HookWorkBegin. A hook struct may also implement multiple specific hook interfaces which are logically related and benefit from being grouped together.

Hooks differ from middleware in that they're invoked at a specific lifecycle phase, but finish immediately instead of wrapping an inner call like a middleware does. One of the main ramifications of this different is that a hook cannot modify context in any useful way to pass down into the stack. Like a normal function, any changes it makes to its context are discarded on return.

All else equal, hooks should generally be preferred over middleware because they don't add anything to the call stack. Call stacks that get overly deep can become a bit of an operational nightmare because they get hard to read.

In a language with more specific type capabilities, this interface would be a union type. In Go we implement it somewhat awkwardly so that we can get future extensibility, but also some typing guarantees to prevent misuse (i.e. if Hook was an empty interface, then any object could be passed as a hook, but having a single function to implement forces the caller to make some token motions in the direction of implementing hooks).

List of hook interfaces that may be implemented: - HookInsertBegin - HookWorkBegin

More operation-specific interfaces may be added in future versions.

HookInsertBegin is an interface to a hook that runs before job insertion.

HookWorkBegin is an interface to a hook that runs after a job has been locked for work and before it's worked.

HookWorkEnd is an interface to a hook that runs after a job has been worked.

type JobArgs interface {
	
	
	Kind() string
}

JobArgs is an interface that should be implemented by the arguments to a job. This definition duplicates the JobArgs interface in the river package so that it can be used in other packages without creating a circular dependency.

type JobCancelError struct {
	
}

JobCancelError is the error type returned by JobCancel. It should not be initialized directly, but is returned from the JobCancel function and can be used for test assertions.

JobInsertMiddleware provides an interface for middleware that integrations can use to encapsulate common logic around job insertion.

Implementations should embed river.JobMiddlewareDefaults to inherit default implementations for phases where no custom code is needed, and for forward compatibility in case new functions are added to this interface.

type JobInsertResult struct {
	
	
	Job *JobRow

	
	
	
	UniqueSkippedAsDuplicate bool
}

JobInsertResult is the result of a job insert, containing the inserted job along with some other useful metadata.

JobRow contains the properties of a job that are persisted to the database. Use of `Job[T]` will generally be preferred in user-facing code like worker interfaces.

Output returns the previously recorded output for the job, if any. The return value is a raw JSON payload from the output that was recorded by the job, or nil if no output was recorded.

JobSnoozeError is the error type returned by JobSnooze. It should not be initialized directly, but is returned from the [JobSnooze] function and can be used for test assertions.

JobState is the state of a job. Jobs start their lifecycle as either JobStateAvailable or JobStateScheduled, and if all goes well, transition to JobStateCompleted after they're worked.

const (
	
	
	JobStateAvailable JobState = "available"

	
	
	
	
	
	JobStateCancelled JobState = "cancelled"

	
	
	
	
	
	JobStateCompleted JobState = "completed"

	
	
	
	
	
	
	JobStateDiscarded JobState = "discarded"

	
	
	
	JobStatePending JobState = "pending"

	
	
	
	
	
	
	
	
	
	JobStateRetryable JobState = "retryable"

	
	
	
	
	
	
	
	JobStateRunning JobState = "running"

	
	
	
	
	
	JobStateScheduled JobState = "scheduled"
)

JobStates returns all possible job states.

func UniqueOptsByStateDefault() []JobState

UniqueOptsByStateDefault is the set of job states that are used to determine uniqueness unless unique job states have been overridden with UniqueOpts.ByState. So for example, with this default set a new unique job may be inserted even if another job already exists, as long as that other job is set `cancelled` or `discarded`.

type Middleware interface {
	
	
	
	
	IsMiddleware() bool
}

Middleware is an arbitrary interface for a struct which will execute some arbitrary code at a predefined step in the job lifecycle.

This interface is left purposely non-specific. Middleware structs should embed river.MiddlewareDefaults to inherit an IsMiddleware implementation, then implement a more specific hook interface like JobInsertMiddleware or WorkerMiddleware. A middleware struct may also implement multiple specific hook interfaces which are logically related and benefit from being grouped together.

Hooks differ from middleware in that they're invoked at a specific lifecycle phase, but finish immediately instead of wrapping an inner call like a middleware does. One of the main ramifications of this different is that a hook cannot modify context in any useful way to pass down into the stack. Like a normal function, any changes it makes to its context are discarded on return.

Middleware differs from hooks in that they wrap a specific lifecycle phase, staying on the callstack for the duration of the step while they call into a doInner function that executes the step and the rest of the middleware stack. The main ramification of this difference is that middleware can modify context for the step and any other middleware inner relative to it.

All else equal, hooks should generally be preferred over middleware because they don't add anything to the call stack. Call stacks that get overly deep can become a bit of an operational nightmare because they get hard to read.

In a language with more specific type capabilities, this interface would be a union type. In Go we implement it somewhat awkwardly so that we can get future extensibility, but also some typing guarantees to prevent misuse (i.e. if Hook was an empty interface, then any object could be passed as a hook, but having a single function to implement forces the caller to make some token motions in the direction of implementing hooks).

List of middleware interfaces that may be implemented: - JobInsertMiddleware - WorkerMiddleware

More operation-specific interfaces may be added in future versions.

type PeriodicJobHandle ΒΆ added in v0.2.0
type PeriodicJobHandle int

PeriodicJobHandle is a reference to a dynamically added periodic job (returned by the use of `Client.PeriodicJobs().Add()`) which can be used to subsequently remove the periodic job with `Remove()`.

Queue is a configuration for a queue that is currently (or recently was) in use by a client.

TimeGenerator generates a current time in UTC. In test environments it's implemented by riverinternaltest.timeStub which lets the current time be stubbed. Otherwise, it's implemented as UnStubbableTimeGenerator which doesn't allow stubbing.

type UnknownJobKindError struct {
	
	Kind string
}

UnknownJobKindError is returned when a Client fetches and attempts to work a job that has not been registered on the Client's Workers bundle (using AddWorker).

Error returns the error string.

Is implements the interface used by errors.Is to determine if errors are equivalent. It returns true for any other UnknownJobKindError without regard to the Kind string so it is possible to detect this type of error with:

errors.Is(err, &UnknownJobKindError{})

WorkerMiddleware provides an interface for middleware that integrations can use to encapsulate common logic when a job is worked.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4