journal

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	ID        int       `json:"id"`
	Type      EventType `json:"type"`
	Workflow  string    `json:"workflow"` // Workflow Definition Name
	StepName  string    `json:"step_name,omitempty"`
	Payload   []byte    `json:"payload,omitempty"` // Serialized input/output
	Error     string    `json:"error,omitempty"`   // Error message if failed
	Timestamp int64     `json:"timestamp"`
}

Event is a single immutable record in the journal.

type EventType

type EventType string

EventType represents the type of event in the journal.

const (
	EventWorkflowStarted   EventType = "WorkflowStarted"
	EventStepStarted       EventType = "StepStarted"
	EventStepCompleted     EventType = "StepCompleted"
	EventWorkflowCompleted EventType = "WorkflowCompleted"
	EventWorkflowFailed    EventType = "WorkflowFailed"
)

type Journal

type Journal interface {
	// Append adds a new event to the journal.
	Append(event Event) error

	// Read returns all events for a given workflow instance history.
	// In a real system, this might take an InstanceID.
	// For this MVP, we assume a single-threaded access or single instance per journal for simplicity,
	// or we can add InstanceID to the Event struct later.
	// For now, let's treat the Journal as a stream for *one* execution or filter by workflow.
	Read() ([]Event, error)

	// Close cleans up resources working with the journal.
	Close() error
}

Journal defines the storage interface for the execution engine.

type MemoryJournal

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

MemoryJournal is a simple thread-safe in-memory journal.

func NewMemoryJournal

func NewMemoryJournal() *MemoryJournal

NewMemoryJournal creates a new empty in-memory journal.

func (*MemoryJournal) Append

func (m *MemoryJournal) Append(event Event) error

Append adds an event to the history.

func (*MemoryJournal) Close

func (m *MemoryJournal) Close() error

func (*MemoryJournal) Read

func (m *MemoryJournal) Read() ([]Event, error)

Read returns a copy of the current history.

Jump to

Keyboard shortcuts

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