state

package
v0.0.0-...-984f6f0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Created

type Created struct{}

func (*Created) HandleEvent

func (s *Created) HandleEvent(ctx context.Context, event Event, eventCtx *EventCtx, o StateTransition)

func (*Created) String

func (s *Created) String() string

type Creating

type Creating struct{}

func (*Creating) HandleEvent

func (s *Creating) HandleEvent(ctx context.Context, event Event, eventCtx *EventCtx, o StateTransition)

func (*Creating) String

func (s *Creating) String() string

type Deleted

type Deleted struct{}

func (*Deleted) HandleEvent

func (s *Deleted) HandleEvent(ctx context.Context, event Event, eventCtx *EventCtx, o StateTransition)

func (*Deleted) String

func (s *Deleted) String() string

type Deleting

type Deleting struct{}

func (*Deleting) HandleEvent

func (s *Deleting) HandleEvent(ctx context.Context, event Event, eventCtx *EventCtx, o StateTransition)

func (*Deleting) String

func (s *Deleting) String() string

type Event

type Event string
const (
	CreateEvent           Event = "create"
	DeleteEvent           Event = "delete"
	ResolutionFailedEvent Event = "resolutionFailed"
	CreatedEvent          Event = "created"
	DeletedEvent          Event = "deleted"
	FailedEvent           Event = "failed"
)

type EventCtx

type EventCtx struct {
	EpIdx    int
	Message  string // used to indicate failures
	Hold     bool
	SameHost bool // inidcated this ep is on the same host as the peer ep
}

type Failed

type Failed struct{} // here we trigger an action on the other end

func (*Failed) HandleEvent

func (s *Failed) HandleEvent(ctx context.Context, event Event, eventCtx *EventCtx, o StateTransition)

func (*Failed) String

func (s *Failed) String() string

type ResolutionFailed

type ResolutionFailed struct{} // here we can either hold or trigger an action on the other end

func (*ResolutionFailed) HandleEvent

func (s *ResolutionFailed) HandleEvent(ctx context.Context, event Event, eventCtx *EventCtx, w StateTransition)

func (*ResolutionFailed) String

func (s *ResolutionFailed) String() string

type State

type State interface {
	String() string
	HandleEvent(ctx context.Context, event Event, eventCtx *EventCtx, w StateTransition)
}

type StateCtx

type StateCtx struct {
	State
	EventCtx
}

type StateTransition

type StateTransition interface {
	Transition(ctx context.Context, newState State, eventCtx *EventCtx, generatedEvents ...WorkerAction)
	GetAdditionalState(eventCtx *EventCtx) []StateCtx
}

type WorkerAction

type WorkerAction string
const (
	WorkerActionCreate WorkerAction = "create"
	WorkerActionDelete WorkerAction = "delete"
)

type WorkerEvent

type WorkerEvent struct {
	Action   WorkerAction
	Req      any
	EventCtx *EventCtx
}

Jump to

Keyboard shortcuts

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