eventhandler

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainedJobEventHandler

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

An event handler implementation that chains multiple event handlers, and accepts a context provider to setup up the context once for all handlers.

func NewChainedJobEventHandler

func NewChainedJobEventHandler(contextProvider ContextProvider) *ChainedJobEventHandler

func (*ChainedJobEventHandler) AddHandlers

func (r *ChainedJobEventHandler) AddHandlers(handlers ...JobEventHandler)

func (*ChainedJobEventHandler) HandleJobEvent

func (r *ChainedJobEventHandler) HandleJobEvent(ctx context.Context, event model.JobEvent) (err error)

type ContextProvider

type ContextProvider interface {
	GetContext(ctx context.Context, jobID string) context.Context
}

Interface for a context provider that can be used to generate a context to be used to handle job events.

type JobEventHandler

type JobEventHandler interface {
	HandleJobEvent(ctx context.Context, event model.JobEvent) error
}

A job event handler is a component that is notified of events related to jobs.

type JobEventHandlerFunc

type JobEventHandlerFunc func(ctx context.Context, event model.JobEvent) error

function that implements the JobEventHandler interface

func (JobEventHandlerFunc) HandleJobEvent

func (f JobEventHandlerFunc) HandleJobEvent(ctx context.Context, event model.JobEvent) error

type NoopContextProvider

type NoopContextProvider struct{}

NoopContextProvider is a context provider that does not generate a new context, and simply returns the ctx passed in.

func NewNoopContextProvider

func NewNoopContextProvider() *NoopContextProvider

func (*NoopContextProvider) GetContext

func (t *NoopContextProvider) GetContext(ctx context.Context, _ string) context.Context

type Tracer

type Tracer struct {
	LogFile *os.File
	Logger  zerolog.Logger
}

Tracer is a JobEventHandler that will marshal the received event to a file-based log.

Note that we don't need any mutexes here because writing to an os.File is thread-safe (see https://github.com/rs/zerolog/blob/master/writer.go#L33)

func NewDefaultTracer

func NewDefaultTracer() *Tracer

Returns an eventhandler.Tracer that uses zerolog configured default output (e.g. stdout)

func NewTracer

func NewTracer() (*Tracer, error)

Returns an eventhandler.Tracer that writes to config.GetEventTracerPath(), or an error if the file can't be opened.

func NewTracerToFile

func NewTracerToFile(filename string) (*Tracer, error)

Returns an eventhandler.Tracer that writes to the specified filename, or an error if the file can't be opened.

func (*Tracer) HandleJobEvent

func (t *Tracer) HandleJobEvent(ctx context.Context, event model.JobEvent) error

HandleJobEvent implements JobEventHandler

func (*Tracer) Shutdown

func (t *Tracer) Shutdown() error

type TracerContextProvider

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

TracerContextProvider is a context provider that generates a context along with tracing information. It also implements JobEventHandler to end the local lifecycle context for a job when it is completed.

func NewTracerContextProvider

func NewTracerContextProvider(nodeID string) *TracerContextProvider

func (*TracerContextProvider) GetContext

func (t *TracerContextProvider) GetContext(ctx context.Context, jobID string) context.Context

func (*TracerContextProvider) HandleJobEvent

func (t *TracerContextProvider) HandleJobEvent(ctx context.Context, event model.JobEvent) error

func (*TracerContextProvider) Shutdown

func (t *TracerContextProvider) Shutdown() error

Directories

Path Synopsis
Package mock_system is a generated GoMock package.
Package mock_system is a generated GoMock package.

Jump to

Keyboard shortcuts

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