steps

package
v0.4.19 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: MIT Imports: 6 Imported by: 6

Documentation

Index

Constants

View Source
const MetadataSettingsSlug = "settings"

Variables

View Source
var ErrMissingClientAPIKey = errors.New("missing client settings api key")
View Source
var ErrMissingClientSettings = errors.New("missing client settings")

Functions

This section is empty.

Types

type NewStepFunc added in v0.4.1

type NewStepFunc[T any, U any] func() (Step[T, U], error)

func (NewStepFunc[T, U]) NewStep added in v0.4.1

func (f NewStepFunc[T, U]) NewStep() (Step[T, U], error)

type Step

type Step[T any, U any] interface {
	// Start gets called multiple times for the same Step, once per incoming value,
	// since StepResult is also the list monad (ie., supports multiple values)
	Start(ctx context.Context, input T) (StepResult[U], error)
	AddPublishedTopic(publisher message.Publisher, topic string) error
}

Step is the generalization of a lambda function, with cancellation and closing to allow it to own resources.

type StepFactory

type StepFactory[T any, U any] interface {
	NewStep() (Step[T, U], error)
}

type StepMetadata added in v0.4.1

type StepMetadata struct {
	StepID     uuid.UUID `json:"step_id"`
	Type       string    `json:"type"`
	InputType  string    `json:"input_type"`
	OutputType string    `json:"output_type"`

	Metadata map[string]interface{} `json:"meta"`
}

func (StepMetadata) MarshalZerologObject added in v0.4.13

func (sm StepMetadata) MarshalZerologObject(e *zerolog.Event)

func (*StepMetadata) ToMap added in v0.4.1

func (sm *StepMetadata) ToMap() map[string]interface{}

type StepResult added in v0.2.4

type StepResult[T any] interface {
	Return() []helpers.Result[T]
	GetChannel() <-chan helpers.Result[T]
	// Cancel can't fail
	Cancel()
	GetMetadata() *StepMetadata
}

func Bind added in v0.2.4

func Bind[T any, U any](
	ctx context.Context,
	m StepResult[T],
	step Step[T, U],
) StepResult[U]

Bind is the monadic bind operator for StepResult. It takes a step result, a step (which is just a lambda turned into a struct) iterates over the results in the StepResult, and starts the Step for each value.

type StepResultImpl added in v0.2.24

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

func NewStepResult added in v0.2.4

func NewStepResult[T any](
	value <-chan helpers.Result[T],
	options ...StepResultOption[T],
) *StepResultImpl[T]

func Reject added in v0.2.4

func Reject[T any](err error, options ...StepResultOption[T]) *StepResultImpl[T]

func Resolve added in v0.2.4

func Resolve[T any](value T, options ...StepResultOption[T]) *StepResultImpl[T]

func ResolveNone added in v0.2.4

func ResolveNone[T any](options ...StepResultOption[T]) *StepResultImpl[T]

func (*StepResultImpl[T]) Cancel added in v0.4.1

func (m *StepResultImpl[T]) Cancel()

func (*StepResultImpl[T]) GetChannel added in v0.2.24

func (m *StepResultImpl[T]) GetChannel() <-chan helpers.Result[T]

func (*StepResultImpl[T]) GetMetadata added in v0.4.1

func (m *StepResultImpl[T]) GetMetadata() *StepMetadata

func (*StepResultImpl[T]) Return added in v0.2.24

func (m *StepResultImpl[T]) Return() []helpers.Result[T]

type StepResultOption added in v0.4.1

type StepResultOption[T any] func(*StepResultImpl[T])

func WithCancel added in v0.4.1

func WithCancel[T any](cancel func()) StepResultOption[T]

func WithMetadata added in v0.4.1

func WithMetadata[T any](metadata *StepMetadata) StepResultOption[T]

func WithMetadataFunc added in v0.4.1

func WithMetadataFunc[T any](metadataFunc func() *StepMetadata) StepResultOption[T]

Jump to

Keyboard shortcuts

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