ctxutil

package
v0.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFoundInContext = errors.New("not found in context")

Functions

This section is empty.

Types

type DerivationFunc

type DerivationFunc[T any] func(current T) (next T, err error)

type Loader

type Loader[T any] interface {
	Load(ctx ValueContainer) (T, error)
}

type LoaderFunc

type LoaderFunc[T any] func(ctx ValueContainer) (T, error)

type Propagator

type Propagator[T any] interface {
	workflow.ContextPropagator
}

type Provider

type Provider[T any] interface {
	Loader[T]
	Saver[T]
	WorkflowSaver[T]
}

type Saver

type Saver[T any] interface {
	Save(ctx context.Context, v T) context.Context
}

type Store

type Store[T any, K any] struct {
	// contains filtered or unexported fields
}

func NewStore

func NewStore[T any, K any]() *Store[T, K]

func (*Store[T, K]) Derive

func (s *Store[T, K]) Derive(ctx ValueContainer, derive DerivationFunc[T]) (T, error)

func (*Store[T, K]) Load

func (s *Store[T, K]) Load(ctx ValueContainer) (r T, err error)

func (*Store[T, K]) LoadOrDefault

func (s *Store[T, K]) LoadOrDefault(ctx ValueContainer, defaultValue T) (r T, err error)

func (*Store[T, K]) LoadOrDefaultFunc

func (s *Store[T, K]) LoadOrDefaultFunc(ctx ValueContainer, defaultValueFunc func() (T, error)) (r T, err error)

func (*Store[T, K]) Save

func (s *Store[T, K]) Save(ctx context.Context, v T) context.Context

func (*Store[T, K]) SaveToWorkflow

func (s *Store[T, K]) SaveToWorkflow(ctx workflow.Context, v T) workflow.Context

type ValueContainer

type ValueContainer interface {
	Value(any) any
}

type WorkflowPropagator

type WorkflowPropagator[T any] struct {
	// contains filtered or unexported fields
}

func NewPropagator

func NewPropagator[T any](key string, provider Provider[T]) *WorkflowPropagator[T]

func (*WorkflowPropagator[T]) Extract

Extract extracts context information from headers and returns a context

func (*WorkflowPropagator[T]) ExtractToWorkflow

func (p *WorkflowPropagator[T]) ExtractToWorkflow(ctx workflow.Context, reader workflow.HeaderReader) (workflow.Context, error)

ExtractToWorkflow extracts context information from headers and returns a workflow context

func (*WorkflowPropagator[T]) Inject

func (p *WorkflowPropagator[T]) Inject(ctx context.Context, writer workflow.HeaderWriter) (err error)

Inject injects information from a Go Context into headers

func (*WorkflowPropagator[T]) InjectFromWorkflow

func (p *WorkflowPropagator[T]) InjectFromWorkflow(ctx workflow.Context, writer workflow.HeaderWriter) (err error)

InjectFromWorkflow injects information from workflow context into headers

type WorkflowSaver

type WorkflowSaver[T any] interface {
	SaveToWorkflow(ctx workflow.Context, v T) workflow.Context
}

Jump to

Keyboard shortcuts

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