event

package
v0.0.0-...-9bdbb14 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package event describes the event set and an interface for recording events. Events are generated as workflows execute.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionFailed

type ActionFailed struct {
	ActionID   string
	WorkflowID string
	Reason     string
	Message    string
}

ActionFailed occurs when an action fails to complete.

func (ActionFailed) GetName

func (ActionFailed) GetName() Name

func (ActionFailed) String

func (e ActionFailed) String() string

type ActionStarted

type ActionStarted struct {
	ActionID   string
	WorkflowID string
}

ActionStarted occurs when an action begins running.

func (ActionStarted) GetName

func (ActionStarted) GetName() Name

func (ActionStarted) String

func (e ActionStarted) String() string

type ActionSucceeded

type ActionSucceeded struct {
	ActionID   string
	WorkflowID string
}

ActionSucceeded occurs when an action successfully completes.

func (ActionSucceeded) GetName

func (ActionSucceeded) GetName() Name

func (ActionSucceeded) String

func (e ActionSucceeded) String() string

type Event

type Event interface {
	// GetName retrieves the event name.
	GetName() Name
	// contains filtered or unexported methods
}

Event is an event generated during execution of a Workflow. Each event in the event package implements this interface. Consumers may type switch the Event to the appropriate type for event handling.

E.g.

switch ev.(type) {
case event.ActionStarted:
	// Handle ActionStarted event.
default:
	// Unsupported event.
}

type IncompatibleError

type IncompatibleError struct {
	Event Event
}

IncompatibleError indicates an event was received that.

func (IncompatibleError) Error

func (e IncompatibleError) Error() string

type Name

type Name string

Name is a unique name identifying an event.

const (
	ActionStartedName   Name = "ActionStarted"
	ActionSucceededName Name = "ActionSucceeded"
	ActionFailedName    Name = "ActionFailed"
)
const WorkflowRejectedName Name = "WorkflowRejected"

type Recorder

type Recorder interface {
	RecordEvent(context.Context, Event) error
}

Recorder provides event recording methods.

type RecorderMock

type RecorderMock struct {
	// RecordEventFunc mocks the RecordEvent method.
	RecordEventFunc func(contextMoqParam context.Context, event Event) error
	// contains filtered or unexported fields
}

RecorderMock is a mock implementation of Recorder.

func TestSomethingThatUsesRecorder(t *testing.T) {

	// make and configure a mocked Recorder
	mockedRecorder := &RecorderMock{
		RecordEventFunc: func(contextMoqParam context.Context, event Event) error {
			panic("mock out the RecordEvent method")
		},
	}

	// use mockedRecorder in code that requires Recorder
	// and then make assertions.

}

func NoopRecorder

func NoopRecorder() *RecorderMock

NoopRecorder retrieves a nooping fake recorder.

func (*RecorderMock) RecordEvent

func (mock *RecorderMock) RecordEvent(contextMoqParam context.Context, event Event) error

RecordEvent calls RecordEventFunc.

func (*RecorderMock) RecordEventCalls

func (mock *RecorderMock) RecordEventCalls() []struct {
	ContextMoqParam context.Context
	Event           Event
}

RecordEventCalls gets all the calls that were made to RecordEvent. Check the length with:

len(mockedRecorder.RecordEventCalls())

type WorkflowRejected

type WorkflowRejected struct {
	ID      string
	Message string
}

WorkflowRejected is generated when a workflow is being rejected by the agent.

func (WorkflowRejected) GetName

func (WorkflowRejected) GetName() Name

func (WorkflowRejected) String

func (e WorkflowRejected) String() string

Jump to

Keyboard shortcuts

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