eventhandler

package
v1.5.0-dev14 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: Apache-2.0 Imports: 13 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 models.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 models.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 models.JobEvent) error

function that implements the JobEventHandler interface

func (JobEventHandlerFunc) HandleJobEvent

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

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 NewTracer

func NewTracer(path string) (*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 models.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 models.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