eventstate

package
v0.0.26 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2021 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FindFailureQuery

type FindFailureQuery struct {
	// HandlerNames defines the filter for the handler names in a query for unhandled events.
	HandlerNames []string
}

FindFailureQuery is a query messa

type FindUnhandledQuery

type FindUnhandledQuery struct {
	// HandlerNames defines the filter for the handler names in a query for unhandled events.
	HandlerNames []string
}

FindUnhandledQuery is a query messa

type HandleFailure

type HandleFailure struct {
	// EventID is an identifier of the related event.
	EventID string
	// HandlerName defines the name of the handler for which the handling failed.
	HandlerName string
	// Err keeps the error information.
	Err string
	// ErrCode keeps the code of the error.
	ErrCode cgerrors.ErrorCode
	// RetryNo is the number of the retries to handle given event.
	RetryNo int
	// Timestamp of the failure.
	Timestamp time.Time
}

HandleFailure contains the result of handling an event, with related error and number of retries.

type HandleSearcher

type HandleSearcher interface {
	// FindUnhandledEvents finds all unhandled events for given handler.
	FindUnhandledEvents(ctx context.Context, query FindUnhandledQuery) ([]Unhandled, error)

	// FindEventHandleFailures finds the handle failures for given handler name.
	FindEventHandleFailures(ctx context.Context, query FindFailureQuery) ([]HandleFailure, error)
}

HandleSearcher is an interface used to find event handle state.

type Handler

type Handler struct {
	// Name is the unique, human-readable name for the event handler.
	Name string
	// EventTypes defines the type of the event handled by given handler.
	EventTypes []string
}

Handler is a structure that defines an event handler with its unique name and matched event type.

type HandlerRegistry

type HandlerRegistry interface {
	// RegisterHandlers registers the information about event handler.
	// This function should be done during migration of the event handler.
	RegisterHandlers(ctx context.Context, eventHandlers ...Handler) error

	// ListHandlers list the handlers for the
	ListHandlers(ctx context.Context) ([]Handler, error)
}

HandlerRegistry is an interface used to register different handler state.

type StateHandler

type StateHandler interface {
	// StartHandling starts handling given event by the handler with a name = handlerName.
	StartHandling(ctx context.Context, eventID, handlerName string) error

	// FinishHandling finishes handling given event by the handlerName.
	FinishHandling(ctx context.Context, eventID, handlerName string) error

	// HandlingFailed finishes handling given event by the handlerName.
	HandlingFailed(ctx context.Context, eventID, handlerName string, handleErr error) error
}

StateHandler is an interface that allows to handle event state.

type Unhandled

type Unhandled struct {
	// EventUD is an identifier of the related event.
	EventID string
	// HandlerName defines the name of the handler where an event was not yet handled.
	HandlerName string
}

Unhandled is an event unhandled by the provided handler name.

Jump to

Keyboard shortcuts

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