Documentation
¶
Index ¶
- Constants
- func ExtractVariableReferences(value string) []string
- func HasVariableReferences(value string) bool
- func MergeFields(dest, source map[string]interface{})
- func WalkJSON(data interface{}, fn func(string) (string, error)) (interface{}, error)
- type ActionError
- type ActionQuery
- type ActionResult
- type ActionResultResolver
- type ActionTarget
- type ChainVariableResolver
- type ControlMetadata
- type Event
- func NewActionFailureEvent(action *RuntimeAction, durationMs int64) *Event
- func NewActionSuccessEvent(action *RuntimeAction, durationMs int64) *Event
- func NewEvent(eventType, name, description string) *Event
- func NewRequestSentEvent(action *RuntimeAction, serviceURL string, requestSize int) *Event
- func NewResponseReceivedEvent(action *RuntimeAction, serviceURL string, httpStatus, responseSize int, ...) *Event
- func NewWorkflowCompletedEvent(workflowID string, durationMs int64, ...) *Event
- func NewWorkflowStartedEvent(workflowID, templateID, templateVersion string, actionCount int, ...) *Event
- type EventStore
- func (s *EventStore) CreateTables(ctx context.Context) error
- func (s *EventStore) DeleteEventsByWorkflow(ctx context.Context, workflowID string) error
- func (s *EventStore) GetEventStats(ctx context.Context, workflowID string, from, to time.Time) (map[string]int, error)
- func (s *EventStore) GetEventsByAction(ctx context.Context, workflowID, actionID string, limit, offset int) ([]*Event, error)
- func (s *EventStore) GetEventsByType(ctx context.Context, eventType string, limit, offset int) ([]*Event, error)
- func (s *EventStore) GetEventsByWorkflow(ctx context.Context, workflowID string, limit, offset int) ([]*Event, error)
- func (s *EventStore) SaveEvent(ctx context.Context, event *Event) error
- type MapVariableResolver
- type RuntimeAction
- type RuntimeRepository
- func (r *RuntimeRepository) Close() error
- func (r *RuntimeRepository) DeleteAction(ctx context.Context, workflowID, actionID string) error
- func (r *RuntimeRepository) DeleteWorkflow(ctx context.Context, workflowID string) error
- func (r *RuntimeRepository) GetAction(ctx context.Context, workflowID, actionID string) (*RuntimeAction, error)
- func (r *RuntimeRepository) GetWorkflow(ctx context.Context, workflowID string) (*RuntimeAction, error)
- func (r *RuntimeRepository) ListActionsByWorkflow(ctx context.Context, workflowID string) ([]*RuntimeAction, error)
- func (r *RuntimeRepository) ListWorkflows(ctx context.Context, limit int) ([]*RuntimeAction, error)
- func (r *RuntimeRepository) SaveAction(ctx context.Context, action *RuntimeAction) error
- func (r *RuntimeRepository) SaveWorkflow(ctx context.Context, workflow *RuntimeAction) error
- type VariableResolver
Constants ¶
const ( EventTypeRequestSent = "request_sent" EventTypeResponseReceived = "response_received" EventTypeActionSuccess = "action_success" EventTypeActionFailure = "action_failure" EventTypeWorkflowStarted = "workflow_started" EventTypeWorkflowCompleted = "workflow_completed" )
EventType constants for common event types
Variables ¶
This section is empty.
Functions ¶
func ExtractVariableReferences ¶
ExtractVariableReferences extracts all variable references from a string Returns the references without ${} wrappers
func HasVariableReferences ¶
HasVariableReferences checks if a string contains any ${...} references
func MergeFields ¶
func MergeFields(dest, source map[string]interface{})
MergeFields merges source fields into destination Source values take precedence over destination values
Types ¶
type ActionError ¶
type ActionError struct {
Type string `json:"@type,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
AdditionalProperty map[string]interface{} `json:"additionalProperty,omitempty"`
}
ActionError represents error information for failed actions
type ActionQuery ¶
type ActionQuery struct {
Type string `json:"@type,omitempty"`
QueryInput string `json:"queryInput,omitempty"`
}
ActionQuery represents the query specification of an action
type ActionResult ¶
type ActionResult struct {
Type string `json:"@type,omitempty"`
Identifier string `json:"identifier,omitempty"`
ContentURL string `json:"contentUrl,omitempty"`
EncodingFormat string `json:"encodingFormat,omitempty"`
Text string `json:"text,omitempty"`
ContentSize string `json:"contentSize,omitempty"`
SHA256 string `json:"sha256,omitempty"`
DateCreated string `json:"dateCreated,omitempty"`
Description string `json:"description,omitempty"`
AdditionalProperty map[string]interface{} `json:"additionalProperty,omitempty"`
}
ActionResult represents the result specification or output of an action
type ActionResultResolver ¶
type ActionResultResolver struct {
// GetAction retrieves an action by ID
GetAction func(actionID string) (*RuntimeAction, error)
}
ActionResultResolver resolves references to action results Example: "action-id.result.contentUrl"
type ActionTarget ¶
type ActionTarget struct {
Type string `json:"@type,omitempty"`
URL string `json:"url,omitempty"`
URLTemplate string `json:"urlTemplate,omitempty"`
HTTPMethod string `json:"httpMethod,omitempty"`
ContentType string `json:"contentType,omitempty"`
AdditionalProperty map[string]interface{} `json:"additionalProperty,omitempty"`
}
ActionTarget represents the target/endpoint of an action
type ChainVariableResolver ¶
type ChainVariableResolver struct {
Resolvers []VariableResolver
}
ChainVariableResolver chains multiple resolvers Tries each resolver in order until one succeeds
type ControlMetadata ¶
type ControlMetadata struct {
URL string `json:"url,omitempty"`
HTTPMethod string `json:"httpMethod,omitempty"`
Enabled bool `json:"enabled,omitempty"`
RetryCount int `json:"retryCount,omitempty"`
RetryBackoff string `json:"retryBackoff,omitempty"`
Singleton bool `json:"singleton,omitempty"`
}
ControlMetadata contains execution control and routing information
type Event ¶
type Event struct {
Context string `json:"@context"`
Type string `json:"@type"`
Identifier string `json:"identifier"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
StartDate time.Time `json:"startDate"`
// What this event is about (the action/workflow)
About map[string]interface{} `json:"about,omitempty"`
// Who/what triggered or organized this event
Organizer map[string]interface{} `json:"organizer,omitempty"`
// Where the event occurred (service URL, etc.)
Location map[string]interface{} `json:"location,omitempty"`
// Result of the event
Result map[string]interface{} `json:"result,omitempty"`
// Additional properties for event-specific metadata
AdditionalProperty map[string]interface{} `json:"additionalProperty,omitempty"`
}
Event represents a Schema.org Event for logging significant occurrences Used for audit trails and operational logging
func NewActionFailureEvent ¶
func NewActionFailureEvent(action *RuntimeAction, durationMs int64) *Event
NewActionFailureEvent creates an event for failed action
func NewActionSuccessEvent ¶
func NewActionSuccessEvent(action *RuntimeAction, durationMs int64) *Event
NewActionSuccessEvent creates an event for successful action completion
func NewRequestSentEvent ¶
func NewRequestSentEvent(action *RuntimeAction, serviceURL string, requestSize int) *Event
NewRequestSentEvent creates an event for when a request is sent to a service
func NewResponseReceivedEvent ¶
func NewResponseReceivedEvent(action *RuntimeAction, serviceURL string, httpStatus, responseSize int, durationMs int64) *Event
NewResponseReceivedEvent creates an event for when a response is received from a service
func NewWorkflowCompletedEvent ¶
func NewWorkflowCompletedEvent(workflowID string, durationMs int64, actionsCompleted, actionsFailed, actionsCancelled int) *Event
NewWorkflowCompletedEvent creates an event for workflow completion
func NewWorkflowStartedEvent ¶
func NewWorkflowStartedEvent(workflowID, templateID, templateVersion string, actionCount int, parameters map[string]string) *Event
NewWorkflowStartedEvent creates an event for workflow start
func (*Event) AddPayloadReference ¶
AddPayloadReference adds a reference to a stored payload file
func (*Event) SetOrganizer ¶
SetOrganizer sets the organizer (who/what triggered the event)
type EventStore ¶
type EventStore struct {
// contains filtered or unexported fields
}
EventStore manages Event storage in PostgreSQL for audit trails
func NewEventStore ¶
func NewEventStore(pg *db.PostgresDB) *EventStore
NewEventStore creates a new event store
func (*EventStore) CreateTables ¶
func (s *EventStore) CreateTables(ctx context.Context) error
CreateTables creates the necessary database tables if they don't exist
func (*EventStore) DeleteEventsByWorkflow ¶
func (s *EventStore) DeleteEventsByWorkflow(ctx context.Context, workflowID string) error
DeleteEventsByWorkflow deletes all events for a workflow
func (*EventStore) GetEventStats ¶
func (s *EventStore) GetEventStats(ctx context.Context, workflowID string, from, to time.Time) (map[string]int, error)
GetEventStats retrieves statistics about events for a workflow
func (*EventStore) GetEventsByAction ¶
func (s *EventStore) GetEventsByAction(ctx context.Context, workflowID, actionID string, limit, offset int) ([]*Event, error)
GetEventsByAction retrieves all events for a specific action
func (*EventStore) GetEventsByType ¶
func (s *EventStore) GetEventsByType(ctx context.Context, eventType string, limit, offset int) ([]*Event, error)
GetEventsByType retrieves events by type
func (*EventStore) GetEventsByWorkflow ¶
func (s *EventStore) GetEventsByWorkflow(ctx context.Context, workflowID string, limit, offset int) ([]*Event, error)
GetEventsByWorkflow retrieves all events for a workflow
type MapVariableResolver ¶
MapVariableResolver implements VariableResolver using a simple map Useful for testing and simple parameter substitution
type RuntimeAction ¶
type RuntimeAction struct {
// Core Schema.org fields (typed for fast access)
Context interface{} `json:"@context,omitempty"`
Type string `json:"@type"`
Identifier string `json:"identifier"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
// Execution state
ActionStatus string `json:"actionStatus,omitempty"`
StartTime *time.Time `json:"startTime,omitempty"`
EndTime *time.Time `json:"endTime,omitempty"`
// Dependencies
Requires []string `json:"requires,omitempty"`
// Semantic relationships
IsPartOf string `json:"isPartOf,omitempty"`
ExampleOfWork string `json:"exampleOfWork,omitempty"`
// Query specification
Query *ActionQuery `json:"query,omitempty"`
// Target specification
Target *ActionTarget `json:"target,omitempty"`
// Result specification/output
Result *ActionResult `json:"result,omitempty"`
// Error information
Error *ActionError `json:"error,omitempty"`
// Object being acted upon
Object map[string]interface{} `json:"object,omitempty"`
// Control metadata (routing and execution control)
ControlMetadata *ControlMetadata `json:"controlMetadata,omitempty"`
// Timestamps
DateCreated time.Time `json:"dateCreated,omitempty"`
DateModified time.Time `json:"dateModified,omitempty"`
// Additional type for control actions, etc.
AdditionalType string `json:"additionalType,omitempty"`
// Agent who triggered/executed the action
Agent map[string]interface{} `json:"agent,omitempty"`
// THE KEY: Preserve ALL other fields not explicitly typed above
// This map contains the complete JSON-LD document
AllFields map[string]interface{} `json:"-"`
}
RuntimeAction represents a Schema.org Action at runtime with complete JSON-LD preservation. It uses custom marshaling to preserve ALL fields from the original JSON-LD while providing typed access to commonly used fields for performance.
Key principle: No data loss. Everything from the definition is preserved in AllFields.
func SubstituteVariables ¶
func SubstituteVariables(action *RuntimeAction, resolver VariableResolver) (*RuntimeAction, error)
SubstituteVariables walks through an action's AllFields and substitutes all ${...} references Returns a new action with substituted values (does not modify original)
func (*RuntimeAction) DeepCopy ¶
func (a *RuntimeAction) DeepCopy() *RuntimeAction
DeepCopy creates a deep copy of the RuntimeAction
func (*RuntimeAction) GetField ¶
func (a *RuntimeAction) GetField(path string) (interface{}, error)
GetField retrieves a nested field from AllFields using dot notation Example: action.GetField("result.contentUrl")
func (*RuntimeAction) MarshalJSON ¶
func (a *RuntimeAction) MarshalJSON() ([]byte, error)
MarshalJSON implements custom marshaling to output complete JSON-LD AllFields is the source of truth - typed fields are only used if not in AllFields
func (*RuntimeAction) SetField ¶
func (a *RuntimeAction) SetField(path string, value interface{}) error
SetField sets a nested field in AllFields using dot notation
func (*RuntimeAction) UnmarshalJSON ¶
func (a *RuntimeAction) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom unmarshaling to preserve all fields
type RuntimeRepository ¶
type RuntimeRepository struct {
// contains filtered or unexported fields
}
RuntimeRepository manages RuntimeAction storage in CouchDB. This repository uses a single database with path-based document IDs:
- Workflows: {workflow-uuid}
- Actions: {workflow-uuid}/{action-id}
This pattern enables efficient range queries for all actions in a workflow.
func NewRuntimeRepository ¶
func NewRuntimeRepository(url, database, user, password string) (*RuntimeRepository, error)
NewRuntimeRepository creates a new runtime action repository
func (*RuntimeRepository) Close ¶
func (r *RuntimeRepository) Close() error
Close closes the CouchDB connection
func (*RuntimeRepository) DeleteAction ¶
func (r *RuntimeRepository) DeleteAction(ctx context.Context, workflowID, actionID string) error
DeleteAction deletes an action
func (*RuntimeRepository) DeleteWorkflow ¶
func (r *RuntimeRepository) DeleteWorkflow(ctx context.Context, workflowID string) error
DeleteWorkflow deletes a workflow and all its actions
func (*RuntimeRepository) GetAction ¶
func (r *RuntimeRepository) GetAction(ctx context.Context, workflowID, actionID string) (*RuntimeAction, error)
GetAction retrieves an action by workflow ID and action ID
func (*RuntimeRepository) GetWorkflow ¶
func (r *RuntimeRepository) GetWorkflow(ctx context.Context, workflowID string) (*RuntimeAction, error)
GetWorkflow retrieves a workflow by ID
func (*RuntimeRepository) ListActionsByWorkflow ¶
func (r *RuntimeRepository) ListActionsByWorkflow(ctx context.Context, workflowID string) ([]*RuntimeAction, error)
ListActionsByWorkflow retrieves all actions for a workflow
func (*RuntimeRepository) ListWorkflows ¶
func (r *RuntimeRepository) ListWorkflows(ctx context.Context, limit int) ([]*RuntimeAction, error)
ListWorkflows retrieves all workflow instances
func (*RuntimeRepository) SaveAction ¶
func (r *RuntimeRepository) SaveAction(ctx context.Context, action *RuntimeAction) error
SaveAction saves an action
func (*RuntimeRepository) SaveWorkflow ¶
func (r *RuntimeRepository) SaveWorkflow(ctx context.Context, workflow *RuntimeAction) error
SaveWorkflow saves a workflow instance
type VariableResolver ¶
type VariableResolver interface {
// Resolve resolves a variable reference to its value
// Example: "action-id.result.contentUrl" or "PARAMETER_NAME"
Resolve(reference string) (string, error)
}
VariableResolver is an interface for resolving variable references