action

package
v0.24.1 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package action provides a mechanism for triggering arbitrary actions within handlers by encoding the actions to perform within Dogma messages.

Index

Constants

View Source
const Action_Behavior_not_set_case case_Action_Behavior = 0
View Source
const Action_Destroy_case case_Action_Behavior = 6
View Source
const Action_End_case case_Action_Behavior = 7
View Source
const Action_ExecuteCommand_case case_Action_Behavior = 3
View Source
const Action_Fail_case case_Action_Behavior = 1
View Source
const Action_Log_case case_Action_Behavior = 2
View Source
const Action_RecordEvent_case case_Action_Behavior = 4
View Source
const Action_ScheduleTimeout_case case_Action_Behavior = 5

Variables

View Source
var File_github_com_dogmatiq_enginekit_enginetest_internal_action_action_proto protoreflect.FileDescriptor

Functions

func Map_Action_Behavior

func Map_Action_Behavior[T any](
	x *Action,
	caseFail func(string) T,
	caseLog func(string) T,
	caseExecuteCommand func(*anypb.Any) T,
	caseRecordEvent func(*anypb.Any) T,
	caseScheduleTimeout func(*ScheduleTimeoutDetails) T,
	caseDestroy func(*Empty) T,
	caseEnd func(*Empty) T,
	none func() T,
) T

Map_Action_Behavior maps x.Behavior to a value of type T by invoking one of the given functions.

It invokes the function that corresponds to the value of x.Behavior, and returns that function's result. It calls none() if x.Behavior is nil.

func MustMap_Action_Behavior added in v0.10.3

func MustMap_Action_Behavior[T any](
	x *Action,
	caseFail func(string) T,
	caseLog func(string) T,
	caseExecuteCommand func(*anypb.Any) T,
	caseRecordEvent func(*anypb.Any) T,
	caseScheduleTimeout func(*ScheduleTimeoutDetails) T,
	caseDestroy func(*Empty) T,
	caseEnd func(*Empty) T,
) T

MustMap_Action_Behavior maps x.Behavior to a value of type T by invoking one of the given functions.

It invokes the function that corresponds to the value of x.Behavior, and returns that function's result. It panics if x.Behavior is nil.

func MustSwitch_Action_Behavior added in v0.10.3

func MustSwitch_Action_Behavior(
	x *Action,
	caseFail func(string),
	caseLog func(string),
	caseExecuteCommand func(*anypb.Any),
	caseRecordEvent func(*anypb.Any),
	caseScheduleTimeout func(*ScheduleTimeoutDetails),
	caseDestroy func(*Empty),
	caseEnd func(*Empty),
)

MustSwitch_Action_Behavior invokes one of the given functions based on the value of x.Behavior.

It panics if x.Behavior is nil.

func Run

func Run(
	s Scope,
	m Actionable,
) error

Run runs the actions defined by m against the given scope.

func Switch_Action_Behavior

func Switch_Action_Behavior(
	x *Action,
	caseFail func(string),
	caseLog func(string),
	caseExecuteCommand func(*anypb.Any),
	caseRecordEvent func(*anypb.Any),
	caseScheduleTimeout func(*ScheduleTimeoutDetails),
	caseDestroy func(*Empty),
	caseEnd func(*Empty),
	none func(),
)

Switch_Action_Behavior invokes one of the given functions based on the value of x.Behavior.

It calls none() if x.Behavior is nil.

Types

type Action

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

func Destroy

func Destroy() []*Action

Destroy returns an action that causes the handler to destroy the aggregate instance.

func End

func End() []*Action

End returns an action that causes the handler to end the process instance.

func ExecuteCommand

func ExecuteCommand(c dogma.Command) []*Action

ExecuteCommand returns an action that causes the handler to execute a command message.

func Fail

func Fail(message string) []*Action

Fail returns an action that causes the handler to return an error.

func Log

func Log(message string) []*Action

Log returns an action that causes the handler to log a human-readable message.

func RecordEvent

func RecordEvent(e dogma.Message) []*Action

RecordEvent returns an action that causes the handler to record an event message.

func ScheduleTimeout

func ScheduleTimeout(t dogma.Timeout, at time.Time) []*Action

ScheduleTimeout returns an action that causes the handler to schedule a timeout message.

func Sequence

func Sequence(actions ...[]*Action) []*Action

Sequence returns a new set of actions.

func (*Action) ClearBehavior added in v0.23.0

func (x *Action) ClearBehavior()

func (*Action) ClearDestroy added in v0.23.0

func (x *Action) ClearDestroy()

func (*Action) ClearEnd added in v0.23.0

func (x *Action) ClearEnd()

func (*Action) ClearExecuteCommand added in v0.23.0

func (x *Action) ClearExecuteCommand()

func (*Action) ClearFail added in v0.23.0

func (x *Action) ClearFail()

func (*Action) ClearLog added in v0.23.0

func (x *Action) ClearLog()

func (*Action) ClearRecordEvent added in v0.23.0

func (x *Action) ClearRecordEvent()

func (*Action) ClearScheduleTimeout added in v0.23.0

func (x *Action) ClearScheduleTimeout()

func (*Action) GetDestroy

func (x *Action) GetDestroy() *Empty

func (*Action) GetEnd

func (x *Action) GetEnd() *Empty

func (*Action) GetExecuteCommand

func (x *Action) GetExecuteCommand() *anypb.Any

func (*Action) GetFail

func (x *Action) GetFail() string

func (*Action) GetLog

func (x *Action) GetLog() string

func (*Action) GetRecordEvent

func (x *Action) GetRecordEvent() *anypb.Any

func (*Action) GetScheduleTimeout

func (x *Action) GetScheduleTimeout() *ScheduleTimeoutDetails

func (*Action) HasBehavior added in v0.23.0

func (x *Action) HasBehavior() bool

func (*Action) HasDestroy added in v0.23.0

func (x *Action) HasDestroy() bool

func (*Action) HasEnd added in v0.23.0

func (x *Action) HasEnd() bool

func (*Action) HasExecuteCommand added in v0.23.0

func (x *Action) HasExecuteCommand() bool

func (*Action) HasFail added in v0.23.0

func (x *Action) HasFail() bool

func (*Action) HasLog added in v0.23.0

func (x *Action) HasLog() bool

func (*Action) HasRecordEvent added in v0.23.0

func (x *Action) HasRecordEvent() bool

func (*Action) HasScheduleTimeout added in v0.23.0

func (x *Action) HasScheduleTimeout() bool

func (*Action) MarshalBinary added in v0.18.0

func (x *Action) MarshalBinary() ([]byte, error)

MarshalBinary returns the binary representation of the message, equivalent to calling proto.Marshal(x).

It allows *Action to implement encoding.BinaryMarshaler.

func (*Action) ProtoMessage

func (*Action) ProtoMessage()

func (*Action) ProtoReflect

func (x *Action) ProtoReflect() protoreflect.Message

func (*Action) Reset

func (x *Action) Reset()

func (*Action) SetDestroy

func (x *Action) SetDestroy(v *Empty)

func (*Action) SetEnd

func (x *Action) SetEnd(v *Empty)

func (*Action) SetExecuteCommand

func (x *Action) SetExecuteCommand(v *anypb.Any)

func (*Action) SetFail

func (x *Action) SetFail(v string)

func (*Action) SetLog

func (x *Action) SetLog(v string)

func (*Action) SetRecordEvent

func (x *Action) SetRecordEvent(v *anypb.Any)

func (*Action) SetScheduleTimeout

func (x *Action) SetScheduleTimeout(v *ScheduleTimeoutDetails)

func (*Action) String

func (x *Action) String() string

func (*Action) TryGetDestroy added in v0.10.3

func (x *Action) TryGetDestroy() (v *Empty, ok bool)

TryGetDestroy returns the Destroy value if x.Behavior is set to Destroy. Otherwise, ok is false and v is the zero-value.

func (*Action) TryGetEnd added in v0.10.3

func (x *Action) TryGetEnd() (v *Empty, ok bool)

TryGetEnd returns the End value if x.Behavior is set to End. Otherwise, ok is false and v is the zero-value.

func (*Action) TryGetExecuteCommand added in v0.10.3

func (x *Action) TryGetExecuteCommand() (v *anypb.Any, ok bool)

TryGetExecuteCommand returns the ExecuteCommand value if x.Behavior is set to ExecuteCommand. Otherwise, ok is false and v is the zero-value.

func (*Action) TryGetFail added in v0.10.3

func (x *Action) TryGetFail() (v string, ok bool)

TryGetFail returns the Fail value if x.Behavior is set to Fail. Otherwise, ok is false and v is the zero-value.

func (*Action) TryGetLog added in v0.10.3

func (x *Action) TryGetLog() (v string, ok bool)

TryGetLog returns the Log value if x.Behavior is set to Log. Otherwise, ok is false and v is the zero-value.

func (*Action) TryGetRecordEvent added in v0.10.3

func (x *Action) TryGetRecordEvent() (v *anypb.Any, ok bool)

TryGetRecordEvent returns the RecordEvent value if x.Behavior is set to RecordEvent. Otherwise, ok is false and v is the zero-value.

func (*Action) TryGetScheduleTimeout added in v0.10.3

func (x *Action) TryGetScheduleTimeout() (v *ScheduleTimeoutDetails, ok bool)

TryGetScheduleTimeout returns the ScheduleTimeout value if x.Behavior is set to ScheduleTimeout. Otherwise, ok is false and v is the zero-value.

func (*Action) UnmarshalBinary added in v0.18.0

func (x *Action) UnmarshalBinary(data []byte) error

UnmarshalBinary populates x from its binary representation, equivalent to calling proto.Unmarshal(data, x).

It allows *Action to implement encoding.BinaryUnmarshaler.

func (*Action) WhichBehavior added in v0.23.0

func (x *Action) WhichBehavior() case_Action_Behavior

type ActionBuilder

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

func NewActionBuilder

func NewActionBuilder() *ActionBuilder

NewActionBuilder returns a builder that constructs Action messages.

func (*ActionBuilder) Build

func (b *ActionBuilder) Build() *Action

Build returns a new Action containing the values configured via the builder.

Each call returns a new message, such that future changes to the builder do not modify previously constructed messages.

func (*ActionBuilder) From

func (b *ActionBuilder) From(x *Action) *ActionBuilder

From configures the builder to use x as the prototype for new messages, then returns b.

It performs a shallow copy of x, such that any changes made via the builder do not modify x. It does not make a copy of the field values themselves.

func (*ActionBuilder) WithDestroy

func (b *ActionBuilder) WithDestroy(v *Empty) *ActionBuilder

WithDestroy configures the builder to set the Destroy field to v, then returns b.

func (*ActionBuilder) WithEnd

func (b *ActionBuilder) WithEnd(v *Empty) *ActionBuilder

WithEnd configures the builder to set the End field to v, then returns b.

func (*ActionBuilder) WithExecuteCommand

func (b *ActionBuilder) WithExecuteCommand(v *anypb.Any) *ActionBuilder

WithExecuteCommand configures the builder to set the ExecuteCommand field to v, then returns b.

func (*ActionBuilder) WithFail

func (b *ActionBuilder) WithFail(v string) *ActionBuilder

WithFail configures the builder to set the Fail field to v, then returns b.

func (*ActionBuilder) WithLog

func (b *ActionBuilder) WithLog(v string) *ActionBuilder

WithLog configures the builder to set the Log field to v, then returns b.

func (*ActionBuilder) WithRecordEvent

func (b *ActionBuilder) WithRecordEvent(v *anypb.Any) *ActionBuilder

WithRecordEvent configures the builder to set the RecordEvent field to v, then returns b.

func (*ActionBuilder) WithScheduleTimeout

func (b *ActionBuilder) WithScheduleTimeout(v *ScheduleTimeoutDetails) *ActionBuilder

WithScheduleTimeout configures the builder to set the ScheduleTimeout field to v, then returns b.

type Action_builder added in v0.23.0

type Action_builder struct {

	// Fields of oneof xxx_hidden_Behavior:
	Fail            *string
	Log             *string
	ExecuteCommand  *anypb.Any
	RecordEvent     *anypb.Any
	ScheduleTimeout *ScheduleTimeoutDetails
	Destroy         *Empty
	End             *Empty
	// contains filtered or unexported fields
}

func (Action_builder) Build added in v0.23.0

func (b0 Action_builder) Build() *Action

type Actionable

type Actionable interface {
	dogma.Message
	GetActions() []*Action
}

Actionable is a dogma message that provides a set of actions to execute.

type Empty

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

func (*Empty) MarshalBinary added in v0.18.0

func (x *Empty) MarshalBinary() ([]byte, error)

MarshalBinary returns the binary representation of the message, equivalent to calling proto.Marshal(x).

It allows *Empty to implement encoding.BinaryMarshaler.

func (*Empty) ProtoMessage

func (*Empty) ProtoMessage()

func (*Empty) ProtoReflect

func (x *Empty) ProtoReflect() protoreflect.Message

func (*Empty) Reset

func (x *Empty) Reset()

func (*Empty) String

func (x *Empty) String() string

func (*Empty) UnmarshalBinary added in v0.18.0

func (x *Empty) UnmarshalBinary(data []byte) error

UnmarshalBinary populates x from its binary representation, equivalent to calling proto.Unmarshal(data, x).

It allows *Empty to implement encoding.BinaryUnmarshaler.

type EmptyBuilder

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

func NewEmptyBuilder

func NewEmptyBuilder() *EmptyBuilder

NewEmptyBuilder returns a builder that constructs Empty messages.

func (*EmptyBuilder) Build

func (b *EmptyBuilder) Build() *Empty

Build returns a new Empty containing the values configured via the builder.

Each call returns a new message, such that future changes to the builder do not modify previously constructed messages.

func (*EmptyBuilder) From

func (b *EmptyBuilder) From(x *Empty) *EmptyBuilder

From configures the builder to use x as the prototype for new messages, then returns b.

It performs a shallow copy of x, such that any changes made via the builder do not modify x. It does not make a copy of the field values themselves.

type Empty_builder added in v0.23.0

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

func (Empty_builder) Build added in v0.23.0

func (b0 Empty_builder) Build() *Empty

type ScheduleTimeoutDetails

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

func (*ScheduleTimeoutDetails) ClearAt added in v0.23.0

func (x *ScheduleTimeoutDetails) ClearAt()

func (*ScheduleTimeoutDetails) ClearTimeout added in v0.23.0

func (x *ScheduleTimeoutDetails) ClearTimeout()

func (*ScheduleTimeoutDetails) GetAt

func (*ScheduleTimeoutDetails) GetTimeout

func (x *ScheduleTimeoutDetails) GetTimeout() *anypb.Any

func (*ScheduleTimeoutDetails) HasAt added in v0.23.0

func (x *ScheduleTimeoutDetails) HasAt() bool

func (*ScheduleTimeoutDetails) HasTimeout added in v0.23.0

func (x *ScheduleTimeoutDetails) HasTimeout() bool

func (*ScheduleTimeoutDetails) MarshalBinary added in v0.18.0

func (x *ScheduleTimeoutDetails) MarshalBinary() ([]byte, error)

MarshalBinary returns the binary representation of the message, equivalent to calling proto.Marshal(x).

It allows *ScheduleTimeoutDetails to implement encoding.BinaryMarshaler.

func (*ScheduleTimeoutDetails) ProtoMessage

func (*ScheduleTimeoutDetails) ProtoMessage()

func (*ScheduleTimeoutDetails) ProtoReflect

func (x *ScheduleTimeoutDetails) ProtoReflect() protoreflect.Message

func (*ScheduleTimeoutDetails) Reset

func (x *ScheduleTimeoutDetails) Reset()

func (*ScheduleTimeoutDetails) SetAt

func (*ScheduleTimeoutDetails) SetTimeout

func (x *ScheduleTimeoutDetails) SetTimeout(v *anypb.Any)

func (*ScheduleTimeoutDetails) String

func (x *ScheduleTimeoutDetails) String() string

func (*ScheduleTimeoutDetails) UnmarshalBinary added in v0.18.0

func (x *ScheduleTimeoutDetails) UnmarshalBinary(data []byte) error

UnmarshalBinary populates x from its binary representation, equivalent to calling proto.Unmarshal(data, x).

It allows *ScheduleTimeoutDetails to implement encoding.BinaryUnmarshaler.

type ScheduleTimeoutDetailsBuilder

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

func NewScheduleTimeoutDetailsBuilder

func NewScheduleTimeoutDetailsBuilder() *ScheduleTimeoutDetailsBuilder

NewScheduleTimeoutDetailsBuilder returns a builder that constructs ScheduleTimeoutDetails messages.

func (*ScheduleTimeoutDetailsBuilder) Build

Build returns a new ScheduleTimeoutDetails containing the values configured via the builder.

Each call returns a new message, such that future changes to the builder do not modify previously constructed messages.

func (*ScheduleTimeoutDetailsBuilder) From

From configures the builder to use x as the prototype for new messages, then returns b.

It performs a shallow copy of x, such that any changes made via the builder do not modify x. It does not make a copy of the field values themselves.

func (*ScheduleTimeoutDetailsBuilder) WithAt

WithAt configures the builder to set the At field to v, then returns b.

func (*ScheduleTimeoutDetailsBuilder) WithTimeout

WithTimeout configures the builder to set the Timeout field to v, then returns b.

type ScheduleTimeoutDetails_builder added in v0.23.0

type ScheduleTimeoutDetails_builder struct {
	Timeout *anypb.Any
	At      *timestamppb.Timestamp
	// contains filtered or unexported fields
}

func (ScheduleTimeoutDetails_builder) Build added in v0.23.0

type Scope

type Scope interface {
	Log(string, ...any)
}

Scope is the interface common to all Dogma scope interfaces.

Jump to

Keyboard shortcuts

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