models

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package models provides the data structures and constants used to define workflows in the orcaloop-sdk. This includes the definition of workflows, steps, parameters, and various control flow constructs such as parallel execution, loops, conditionals, and switches.

Index

Constants

View Source
const (
	EndpointTypeLocal     = "local"
	EndpointTypeRest      = "rest"
	EndpointTypeMessaging = "messaging"
)
View Source
const (
	// StatusUnknown represents an unknown status of the workflow
	StatusUnknown Status = iota
	// StatusPending represents a pending status of the workflow
	StatusPending
	// StatusRunning represents a running status of the workflow
	StatusRunning
	// StatusCompleted represents a completed status of the workflow
	StatusCompleted
	// StatusFailed represents a failed status of the workflow
	StatusFailed
	// StatusSkipped represents a skipped status of the workflow
	StatusSkipped

	// StatusPendingStr is the string representation of the StatusPending constant
	StatusPendingStr = "Pending"
	// StatusRunningStr is the string representation of the StatusRunning constant
	StatusRunningStr = "Running"
	// StatusCompletedStr is the string representation of the StatusCompleted constant
	StatusCompletedStr = "Completed"
	// StatusFailedStr is the string representation of the StatusFailed constant
	StatusFailedStr = "Failed"
	// StatusSkippedStr is the string representation of the StatusSkipped constant
	StatusSkippedStr = "Skipped"
	// StatusUnkonwnStr is the string representation of the StatusUnknown constant
	StatusUnkonwnStr = "Unknown"
)
View Source
const (
	// FieldTypeByte is the byte type
	FieldTypeByte FieldType = "byte"
	// FieldTypeString is the string type
	FieldTypeString = "string"
	// FieldTypeDateStr is the int type
	FieldTypeDateStr = "date"
	// FieldTypeInt is the int type
	FieldTypeInt = "int"
	//FeildTypeInt64 is the float type
	FieldTypeInt64 = "long"
	// FieldTypeFloat is the float type
	FieldTypeFloat32 = "float"
	// FieldTypeDouble is the double type
	FieldTypeFloat64 = "double"
	// FieldTypeBool is the bool type
	FieldTypeBool = "bool"
	// FieldTypeObject is the object type
	FieldTypeObject = "object"
	// FieldTypeArray is the array type
	FieldTypeArray = "array"
)
View Source
const (
	// StepTypeAction represents an action step in the workflow.
	StepTypeAction = "Action"
	// StepTypeParallel represents a parallel execution step in the workflow.
	StepTypeParallel = "Parallel"
	// StepTypeIf represents a conditional step in the workflow.
	StepTypeIf = "If"
	// StepTypeSwitch represents a switch-case step in the workflow.
	StepTypeSwitch = "Switch"
	// StepTypeForLoop represents a loop step in the workflow.
	StepTypeForLoop = "ForLoop"
	// ModeSync represents synchronous execution mode.
	ModeSync = "sync"
	// ModeAsync represents asynchronous execution mode.
	ModeAsync = "async"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionSpec

type ActionSpec struct {
	// Id is the id of the action
	Id string `json:"id" yaml:"id"`
	// Name is the name of the action
	Name string `json:"name" yaml:"name"`
	// Description is the description of the action
	Description string `json:"description" yaml:"description"`
	//Parameters is the parameters of the action
	Parameters []*Schema `json:"parameters" yaml:"parameters"`
	// Returns is the returns of the action
	Returns []*Schema `json:"returns" yaml:"returns"`
	// Async  is the async flag of the action
	Async bool `json:"async" yaml:"async"`
	// Endpoint is the endpoint of the action
	Endpoint *Endpoint `json:"endpoint" yaml:"endpoint"`
}

ActionSpec represents the specification of an action. It contains metadata and configuration for the action.

Fields:

  • Id: The unique identifier of the action.
  • Name: The name of the action.
  • Description: A brief description of the action.
  • Parameters: A list of schemas representing the parameters of the action.
  • Returns: A list of schemas representing the return values of the action.
  • Async: A flag indicating whether the action is asynchronous.
  • Endpoint: The endpoint configuration for the action.

type Builtin

type Builtin struct {
}

type Case

type Case struct {
	Value   any     `yaml:"value" json:"value"`
	Default bool    `yaml:"default" json:"default"`
	Steps   []*Step `yaml:"steps" json:"steps"`
}

Case represents a conditional branch in a workflow. Fields: - Value: Value to match against. - Default: Flag indicating if this is the default case. - Steps: List of steps to execute if the case matches.

type Else

type Else struct {
	Steps []*Step `yaml:"steps" json:"steps"`
}

Else represents an else branch in a conditional step. Fields: - Steps: List of steps to be executed if none of the conditions are true.

type ElseIf

type ElseIf struct {
	Condition string  `yaml:"condition" json:"condition"`
	Steps     []*Step `yaml:"steps" json:"steps"`
}

ElseIf represents an else-if branch in a conditional step. Fields: - Condition: Condition to evaluate. - Steps: List of steps to be executed if the condition is true.

type Endpoint

type Endpoint struct {

	// type is the type of the Endpoint
	Type string `json:"type" yaml:"type"`
	//Local is the local endpoint
	Builtin *Builtin `json:"builtin" yaml:"builtin"`
	//Rest is the rest endpoint
	Rest *RestEndpoint `json:"rest" yaml:"rest"`
	//Messaging is the messaging endpoint
	Messaging *MessagingEndpoint `json:"messaging" yaml:"messaging"`
	//Qos is the quality of service
	Qos *Qos `json:"qos" yaml:"qos"`
}

Endpoint represents a network endpoint configuration.

Fields:

  • Type: Specifies the type of the Endpoint.
  • Local: Represents the local endpoint configuration.
  • Rest: Represents the REST endpoint configuration.
  • Messaging: Represents the messaging endpoint configuration.
  • Grpc: Represents the gRPC endpoint configuration.
  • Qos: Represents the quality of service configuration.

type Error

type Error struct {
	//Code is the error code
	Code string `json:"code" yaml:"code"`
	//Message is the error message
	Message string `json:"message" yaml:"message"`
	//Details is the error details
	// This is an optional field
	Details string `json:"details,omitempty" yaml:"details,omitempty"`
}

Error is a struct that represents an error

type FieldType

type FieldType string

FieldType is the type of the field

type For

type For struct {
	Loopvar  string  `yaml:"loop_var" json:"loop_var"`
	IndexVar string  `yaml:"index_var" json:"index_var"`
	ItemsVar string  `yaml:"items_var" json:"items_var"`
	ItemsArr []any   `yaml:"items" json:"items"`
	Steps    []*Step `yaml:"steps" json:"steps"`
}

For represents a loop step in the workflow. Fields: - Loopvar: Loop variable name. - IndexVar: Index variable name. - ItemsVar: Items variable name. - ItemsArr: Array of items to loop over. - Steps: List of steps to be executed in the loop.

type If

type If struct {
	Condition string    `yaml:"condition" json:"condition"`
	Steps     []*Step   `yaml:"steps" json:"steps"`
	ElseIfs   []*ElseIf `yaml:"else_ifs" json:"else_ifs"`
	Else      *Else     `yaml:"else" json:"else"`
}

If represents a conditional step in the workflow. Fields: - Condition: Condition to evaluate. - Steps: List of steps to be executed if the condition is true. - ElseIfs: List of else-if branches. - Else: Else branch.

type MessagingEndpoint

type MessagingEndpoint struct {
	// Url is the URL of the messaging provider.
	// The format is <provider_scheme>://destination.
	// The provider_scheme is the scheme of the messaging provider.
	// The destination is the destination of the messaging provider.
	Url string `json:"url" yaml:"url"`
}

MessagingEndpoint represents the configuration for a messaging endpoint. It contains the URL, request headers, body, and body MIME type for the messaging provider. See https://pkg.go.dev/oss.nandlabs.io/golly/messaging#Provider for more information for the messaging provider.

type Parallel

type Parallel struct {
	Steps []*Step `yaml:"steps" json:"steps"`
}

Parallel represents a parallel execution step in the workflow. Fields: - Steps: List of steps to be executed in parallel.

type Parameter

type Parameter struct {
	Name  string `yaml:"name" json:"name"`
	Value any    `yaml:"value" json:"value"`
	Var   string `yaml:"var" json:"var"`
}

Parameter represents a parameter in the workflow. Fields: - Name: Name of the parameter. - Value: Value of the parameter. - Var: Variable name of the parameter.

type Qos

type Qos struct {
	// Retries is the number of retries
	Retries int
	// Timeout is the timeout
	Timeout int
	// CircuitBreakerInfo is the circuit breaker info
	BreakerInfo *clients.BreakerInfo
}

Qos represents the Quality of Service settings for a particular action. It includes the number of retries, timeout duration, and circuit breaker information.

type RestEndpoint

type RestEndpoint struct {
	// Url is the url of the rest endpoint
	// The format is http[s]://host:[port]/[pathname|$pathParam]*/?[name=value&]*
	// The $pathParam is the path param name from the pipeline
	Url string `json:"url" yaml:"url"`
	// AuthProvider
	AuthProvider string `json:"authProvider" yaml:"authProvider"`
}

type Result added in v0.0.5

type Result struct {
	OutputVar   string `yaml:"output_var" json:"output_var"`
	PipelineVar string `yaml:"pipeline_var" json:"pipeline_var"`
}

Result represents the result of an action execution. Fields: - OutputVar: variable name of the tool output. - PipelineVar: Variable Name in pipeline to store the result.

type Schema

type Schema struct {
	// Name is the name of the input/output
	Name string `json:"name" yaml:"name"`
	// Description is the description of the input/output
	Description string `json:"description" yaml:"description"`
	// Type is the type of the field
	Type FieldType `json:"type" yaml:"type"`
	// Items used when the type is an array
	Items *Schema `json:"items" yaml:"items"`
	// Properties used when the type is an object
	Properties []*Schema `json:"properties" yaml:"properties"`
	// Enum is the enum of the field used
	Enum any `json:"enum" yaml:"enum"`
	// Default is the default value of the field
	Default any `json:"default" yaml:"default"`
	// Required is the required flag of the field
	Required bool `json:"required" yaml:"required"`
}

Schema represents the structure of an input/output schema with various attributes.

Fields:

  • Name: The name of the input/output.
  • Description: The description of the input/output.
  • Type: The type of the field.
  • Items: Used when the type is an array, represents the schema of the array items.
  • Properties: Used when the type is an object, represents the schema of the object properties.
  • Enum: The enum of the field used.
  • Default: The default value of the field.
  • Required: The required flag of the field.

type Status

type Status int

Status represents the execution status of the workflow

func (Status) String

func (s Status) String() string

String returns the string representation of the Status. It maps each Status value to its corresponding string constant. If the Status value is not recognized, it returns StatusUnkonwnStr. Implements Stringer interface.

type Step

type Step struct {
	Id       string      `yaml:"id" json:"id"`
	Skip     bool        `yaml:"skip" json:"skip"`
	Type     string      `yaml:"type" json:"type"`
	Parallel *Parallel   `yaml:"parallel,omitempty" json:"parallel,omitempty"`
	For      *For        `yaml:"for,omitempty" json:"for,omitempty"`
	If       *If         `yaml:"if,omitempty" json:"if,omitempty"`
	Switch   *Switch     `yaml:"switch,omitempty" json:"switch,omitempty"`
	Action   *StepAction `yaml:"action,omitempty" json:"action,omitempty"`
}

Step represents a step in the workflow. Fields: - Id: Unique identifier for the step. - Skip: Flag indicating if the step should be skipped. - Type: Type of the step (e.g., Action, Parallel, If, Switch, ForLoop). - Parallel: Parallel execution step. - For: Loop step. - If: Conditional step. - Switch: Switch-case step. - Action: Action step.

type StepAction

type StepAction struct {
	Id         string       `yaml:"id" json:"id"`
	Name       string       `yaml:"name" json:"name"`
	Parameters []*Parameter `yaml:"parameters" json:"parameters"`
	Results    []*Result    `yaml:"results" json:"results"`
}

StepAction represents a substep in the workflow. Fields: - Id: Unique identifier for the action. - Name: Name of the action. - Parameters: List of parameters for the action. - Output: List of output names for the action.

type Switch

type Switch struct {
	Variable string  `yaml:"variable" json:"variable"`
	Cases    []*Case `yaml:"cases" json:"cases"`
}

Switch represents a switch-case step in the workflow. Fields: - Variable: Variable to switch on. - Cases: List of cases to match against.

type Workflow

type Workflow struct {
	Id          string  `yaml:"id" json:"id"`
	Name        string  `yaml:"name" json:"name"`
	Version     int     `yaml:"version" json:"version"`
	Description string  `yaml:"description" json:"description"`
	Steps       []*Step `yaml:"steps" json:"steps"`
}

Workflow represents a workflow definition. Fields: - Id: Unique identifier for the workflow. - Name: Name of the workflow. - Version: Version number of the workflow. - Description: Description of the workflow. - Steps: List of steps in the workflow.

Jump to

Keyboard shortcuts

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