flowcore

package
v19.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WorkflowStateUnknown   = autocore.WorkflowStateUnknown
	WorkflowStateRunning   = autocore.WorkflowStateRunning
	WorkflowStateCompleted = autocore.WorkflowStateCompleted
	WorkflowStateFailed    = autocore.WorkflowStateFailed
	WorkflowStateCanceled  = autocore.WorkflowStateCanceled
	WorkflowStateTimedOut  = autocore.WorkflowStateTimedOut
)

Variables

View Source
var ErrInvalidWorkflowKey = autocore.ErrInvalidWorkflowKey

ErrInvalidWorkflowKey is returned by GetWorkflow when the key is malformed.

View Source
var ErrWorkflowNotFound = autocore.ErrWorkflowNotFound

ErrWorkflowNotFound is returned by GetWorkflow when no workflow exists for the given key.

View Source
var File_internal_flowcore_engine_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type CallResult

type CallResult struct {
	Value *pkg_autoflow.Value
	Error string
}

type Engine

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

func NewEngine

func NewEngine(opts *Options) (*Engine, error)

func (*Engine) CancelWorkflow

func (e *Engine) CancelWorkflow(ctx context.Context, workflowKey string) error

CancelWorkflow requests cancellation of the workflow addressed by workflowKey. Cancellation is an asynchronous best-effort signal: the workflow transitions to a canceled state on a later replay round. Returns ErrInvalidWorkflowKey if the key is malformed, or ErrWorkflowNotFound if no such workflow exists.

func (*Engine) GetWorkflow

func (e *Engine) GetWorkflow(ctx context.Context, workflowKey string) (*Workflow, error)

GetWorkflow returns a snapshot of the workflow addressed by workflowKey, the key string returned by RunWorkflow. Returns autocore.ErrWorkflowNotFound if no such workflow exists, or an error if the key is malformed.

func (*Engine) RunWorkflow

func (e *Engine) RunWorkflow(ctx context.Context, namespaceID int64, identityKey string, input *RunWorkflowInput) (string, error)

RunWorkflow submits a RunWorkflow with the given input. Returns the autocore-assigned workflow key. If a workflow with the given (namespaceID, identityKey) already exists, returns its existing workflow key without re-creating.

type InvokeActionActivityInput

type InvokeActionActivityInput struct {
	ModuleName string                 `protobuf:"bytes,1,opt,name=module_name,json=moduleName" json:"module_name,omitempty"`
	ActionName string                 `protobuf:"bytes,2,opt,name=action_name,json=actionName" json:"action_name,omitempty"`
	Args       []*autoflow.Value      `protobuf:"bytes,3,rep,name=args" json:"args,omitempty"`
	Kwargs     []*autoflow.NamedValue `protobuf:"bytes,4,rep,name=kwargs" json:"kwargs,omitempty"`
	// contains filtered or unexported fields
}

func (*InvokeActionActivityInput) Descriptor deprecated

func (*InvokeActionActivityInput) Descriptor() ([]byte, []int)

Deprecated: Use InvokeActionActivityInput.ProtoReflect.Descriptor instead.

func (*InvokeActionActivityInput) GetActionName

func (x *InvokeActionActivityInput) GetActionName() string

func (*InvokeActionActivityInput) GetArgs

func (x *InvokeActionActivityInput) GetArgs() []*autoflow.Value

func (*InvokeActionActivityInput) GetKwargs

func (x *InvokeActionActivityInput) GetKwargs() []*autoflow.NamedValue

func (*InvokeActionActivityInput) GetModuleName

func (x *InvokeActionActivityInput) GetModuleName() string

func (*InvokeActionActivityInput) ProtoMessage

func (*InvokeActionActivityInput) ProtoMessage()

func (*InvokeActionActivityInput) ProtoReflect

func (*InvokeActionActivityInput) Reset

func (x *InvokeActionActivityInput) Reset()

func (*InvokeActionActivityInput) String

func (x *InvokeActionActivityInput) String() string

type InvokeActionActivityOutput

type InvokeActionActivityOutput struct {

	// Types that are valid to be assigned to Response:
	//
	//	*InvokeActionActivityOutput_Result
	//	*InvokeActionActivityOutput_Error
	Response isInvokeActionActivityOutput_Response `protobuf_oneof:"response"`
	// contains filtered or unexported fields
}

func (*InvokeActionActivityOutput) Descriptor deprecated

func (*InvokeActionActivityOutput) Descriptor() ([]byte, []int)

Deprecated: Use InvokeActionActivityOutput.ProtoReflect.Descriptor instead.

func (*InvokeActionActivityOutput) GetError

func (x *InvokeActionActivityOutput) GetError() string

func (*InvokeActionActivityOutput) GetResponse

func (x *InvokeActionActivityOutput) GetResponse() isInvokeActionActivityOutput_Response

func (*InvokeActionActivityOutput) GetResult

func (x *InvokeActionActivityOutput) GetResult() *autoflow.Value

func (*InvokeActionActivityOutput) ProtoMessage

func (*InvokeActionActivityOutput) ProtoMessage()

func (*InvokeActionActivityOutput) ProtoReflect

func (*InvokeActionActivityOutput) Reset

func (x *InvokeActionActivityOutput) Reset()

func (*InvokeActionActivityOutput) String

func (x *InvokeActionActivityOutput) String() string

type InvokeActionActivityOutput_Error

type InvokeActionActivityOutput_Error struct {
	Error string `protobuf:"bytes,2,opt,name=error,oneof"`
}

type InvokeActionActivityOutput_Result

type InvokeActionActivityOutput_Result struct {
	Result *autoflow.Value `protobuf:"bytes,1,opt,name=result,oneof"`
}

type LoadModuleActivityInput

type LoadModuleActivityInput struct {
	Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
	// contains filtered or unexported fields
}

func (*LoadModuleActivityInput) Descriptor deprecated

func (*LoadModuleActivityInput) Descriptor() ([]byte, []int)

Deprecated: Use LoadModuleActivityInput.ProtoReflect.Descriptor instead.

func (*LoadModuleActivityInput) GetName

func (x *LoadModuleActivityInput) GetName() string

func (*LoadModuleActivityInput) ProtoMessage

func (*LoadModuleActivityInput) ProtoMessage()

func (*LoadModuleActivityInput) ProtoReflect

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

func (*LoadModuleActivityInput) Reset

func (x *LoadModuleActivityInput) Reset()

func (*LoadModuleActivityInput) String

func (x *LoadModuleActivityInput) String() string

type LoadModuleActivityOutput

type LoadModuleActivityOutput struct {
	ModuleDesc *autoflow.ModuleDescriptor `protobuf:"bytes,1,opt,name=module_desc,json=moduleDesc" json:"module_desc,omitempty"`
	// contains filtered or unexported fields
}

func (*LoadModuleActivityOutput) Descriptor deprecated

func (*LoadModuleActivityOutput) Descriptor() ([]byte, []int)

Deprecated: Use LoadModuleActivityOutput.ProtoReflect.Descriptor instead.

func (*LoadModuleActivityOutput) GetModuleDesc

func (*LoadModuleActivityOutput) ProtoMessage

func (*LoadModuleActivityOutput) ProtoMessage()

func (*LoadModuleActivityOutput) ProtoReflect

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

func (*LoadModuleActivityOutput) Reset

func (x *LoadModuleActivityOutput) Reset()

func (*LoadModuleActivityOutput) String

func (x *LoadModuleActivityOutput) String() string

type ModuleDescriptorResolver

type ModuleDescriptorResolver struct {
	ModuleName       string
	Desc             *pkg_autoflow.ModuleDescriptor
	PredeclaredFiles *protoregistry.Files
	InvokeAction     func(context.Context, *InvokeActionActivityInput) (*InvokeActionActivityOutput, error)
}

func (*ModuleDescriptorResolver) LoadSymbols

func (r *ModuleDescriptorResolver) LoadSymbols() (starlark.StringDict, error)

type ModuleManager

type ModuleManager interface {
	// LoadModuleDescriptor loads a module descriptor.
	// Returns (nil, nil) if not found.
	LoadModuleDescriptor(ctx context.Context, moduleName string) (*pkg_autoflow.ModuleDescriptor, error)
	InvokeAction(ctx context.Context, moduleName, actionName, idempotencyKey string, args []*pkg_autoflow.Value, kwargs []*pkg_autoflow.NamedValue) (CallResult, error)
}

type Options

type Options struct {
	Log            *slog.Logger
	Client         autocore.Client
	Registry       *autocore.Registry
	RateLimiter    RateLimiter
	ModuleManager  ModuleManager
	TracerProvider oteltrace.TracerProvider
	// PredeclaredProtoFiles is the set of proto file descriptors that
	// AutoFlow modules' descriptor sets may import. Used to resolve
	// imports when reconstructing module proto descriptors; we deliberately
	// do not fall back to protoregistry.GlobalFiles so a module cannot pull
	// in arbitrary types linked into the binary.
	// Order is important here - files that come later can import files that come earlier,
	// but not the other way around.
	PredeclaredProtoFiles []protoreflect.FileDescriptor
}

type RateLimiter

type RateLimiter interface {
	Allow(ctx context.Context, projectID int64, eventType string) bool
}

type RunActivityInput

type RunActivityInput struct {
	Uri           string   `protobuf:"bytes,1,opt,name=uri" json:"uri,omitempty"`
	WorkflowId    string   `protobuf:"bytes,2,opt,name=workflow_id,json=workflowId" json:"workflow_id,omitempty"`
	Args          []string `protobuf:"bytes,3,rep,name=args" json:"args,omitempty"`
	DuoCallNumber int32    `protobuf:"varint,4,opt,name=duo_call_number,json=duoCallNumber" json:"duo_call_number,omitempty"`
	// contains filtered or unexported fields
}

func (*RunActivityInput) Descriptor deprecated

func (*RunActivityInput) Descriptor() ([]byte, []int)

Deprecated: Use RunActivityInput.ProtoReflect.Descriptor instead.

func (*RunActivityInput) GetArgs

func (x *RunActivityInput) GetArgs() []string

func (*RunActivityInput) GetDuoCallNumber

func (x *RunActivityInput) GetDuoCallNumber() int32

func (*RunActivityInput) GetUri

func (x *RunActivityInput) GetUri() string

func (*RunActivityInput) GetWorkflowId

func (x *RunActivityInput) GetWorkflowId() string

func (*RunActivityInput) ProtoMessage

func (*RunActivityInput) ProtoMessage()

func (*RunActivityInput) ProtoReflect

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

func (*RunActivityInput) Reset

func (x *RunActivityInput) Reset()

func (*RunActivityInput) String

func (x *RunActivityInput) String() string

type RunActivityOutput

type RunActivityOutput struct {
	Payload string `protobuf:"bytes,1,opt,name=payload" json:"payload,omitempty"`
	// contains filtered or unexported fields
}

func (*RunActivityOutput) Descriptor deprecated

func (*RunActivityOutput) Descriptor() ([]byte, []int)

Deprecated: Use RunActivityOutput.ProtoReflect.Descriptor instead.

func (*RunActivityOutput) GetPayload

func (x *RunActivityOutput) GetPayload() string

func (*RunActivityOutput) ProtoMessage

func (*RunActivityOutput) ProtoMessage()

func (*RunActivityOutput) ProtoReflect

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

func (*RunActivityOutput) Reset

func (x *RunActivityOutput) Reset()

func (*RunActivityOutput) String

func (x *RunActivityOutput) String() string

type RunWorkflowInput

type RunWorkflowInput struct {
	WorkflowDefinition []byte    `protobuf:"bytes,1,opt,name=workflow_definition,json=workflowDefinition" json:"workflow_definition,omitempty"`
	Secrets            []*Secret `protobuf:"bytes,2,rep,name=secrets" json:"secrets,omitempty"`
	// contains filtered or unexported fields
}

func (*RunWorkflowInput) Descriptor deprecated

func (*RunWorkflowInput) Descriptor() ([]byte, []int)

Deprecated: Use RunWorkflowInput.ProtoReflect.Descriptor instead.

func (*RunWorkflowInput) GetSecrets

func (x *RunWorkflowInput) GetSecrets() []*Secret

func (*RunWorkflowInput) GetWorkflowDefinition

func (x *RunWorkflowInput) GetWorkflowDefinition() []byte

func (*RunWorkflowInput) ProtoMessage

func (*RunWorkflowInput) ProtoMessage()

func (*RunWorkflowInput) ProtoReflect

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

func (*RunWorkflowInput) Reset

func (x *RunWorkflowInput) Reset()

func (*RunWorkflowInput) String

func (x *RunWorkflowInput) String() string

type RunWorkflowOutput

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

func (*RunWorkflowOutput) Descriptor deprecated

func (*RunWorkflowOutput) Descriptor() ([]byte, []int)

Deprecated: Use RunWorkflowOutput.ProtoReflect.Descriptor instead.

func (*RunWorkflowOutput) ProtoMessage

func (*RunWorkflowOutput) ProtoMessage()

func (*RunWorkflowOutput) ProtoReflect

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

func (*RunWorkflowOutput) Reset

func (x *RunWorkflowOutput) Reset()

func (*RunWorkflowOutput) String

func (x *RunWorkflowOutput) String() string

type Secret

type Secret struct {
	Key   string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"`
	Value string `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"`
	// contains filtered or unexported fields
}

func (*Secret) Descriptor deprecated

func (*Secret) Descriptor() ([]byte, []int)

Deprecated: Use Secret.ProtoReflect.Descriptor instead.

func (*Secret) GetKey

func (x *Secret) GetKey() string

func (*Secret) GetValue

func (x *Secret) GetValue() string

func (*Secret) ProtoMessage

func (*Secret) ProtoMessage()

func (*Secret) ProtoReflect

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

func (*Secret) Reset

func (x *Secret) Reset()

func (*Secret) String

func (x *Secret) String() string

type ValueConverter

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

ValueConverter converts between AutoFlow proto Values and Starlark values.

Proto message Values (google.protobuf.Any) are resolved against the supplied descriptor set, falling back to the predeclared files. protoregistry.GlobalFiles is intentionally NOT consulted. Safe to use concurrently.

func NewValueConverter

func NewValueConverter(predeclaredFiles *protoregistry.Files, descriptorSet *descriptorpb.FileDescriptorSet) *ValueConverter

NewValueConverter constructs a new ValueConverter. descriptorSet is optional, can be nil

func (*ValueConverter) FromStarlark

func (c *ValueConverter) FromStarlark(v starlark.Value) (*pkg_autoflow.Value, error)

FromStarlark converts a Starlark value into a proto Value.

func (*ValueConverter) ToStarlark

func (c *ValueConverter) ToStarlark(v *pkg_autoflow.Value) (starlark.Value, error)

ToStarlark converts a proto Value into a Starlark value.

type Workflow

type Workflow struct {
	Key         string
	Name        string
	IdentityKey string
	State       WorkflowState
	CreatedAt   time.Time
	UpdatedAt   time.Time
	Output      *RunWorkflowOutput
	Error       string
}

Workflow is a read-only snapshot of a workflow returned by GetWorkflow. Output holds the workflow's decoded output and is set only when the workflow completed; Error holds the failure message and is set only when it failed.

type WorkflowState

type WorkflowState = autocore.WorkflowState

WorkflowState is the lifecycle state of an AutoFlow workflow.

Jump to

Keyboard shortcuts

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