gateway

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2025 License: MIT Imports: 11 Imported by: 6

Documentation

Index

Constants

View Source
const (
	// HTTPTriggerStatusAccepted indicates the trigger request was accepted.
	HTTPTriggerStatusAccepted HTTPTriggerStatus = "ACCEPTED"
	// MethodWorkflowExecute is the method name for executing workflows.
	MethodWorkflowExecute string = "workflows.execute"
)
View Source
const (
	// Note: any addition to this list must be reflected in the handler's Methods() function.
	MethodPushWorkflowMetadata         = "push_workflow_metadata"
	MethodPullWorkflowMetadata         = "pull_workflow_metadata"
	KeyTypeECDSAEVM            KeyType = "ecdsa_evm"
)
View Source
const (
	// Note: any addition to this list must be reflected in the handler's Methods() function.
	MethodHTTPAction = "http_action"
)

Variables

View Source
var ErrNoGateways = errors.New("no gateways available")

Functions

func GetRequestID added in v0.8.0

func GetRequestID(methodName string, parts ...string) string

GetRequestID generates a unique request ID for a method call. The method name is prepended to the ID, followed by any identifiers such as workflow ID, execution ID, or request ID. The method name is used by the gateway to identify the message type (e.g. "http_action", "push_auth_metadata", "pull_auth_metadata").

func WithFixedStart

func WithFixedStart() func(*RoundRobinSelector)

WithFixedStart option will set the start point for the round robin selector.

Types

type AuthorizedKey added in v0.8.0

type AuthorizedKey struct {
	KeyType   KeyType `json:"keyType"`
	PublicKey string  `json:"publicKey"`
}

func (AuthorizedKey) MarshalJSON added in v0.9.0

func (r AuthorizedKey) MarshalJSON() ([]byte, error)

MarshalJSON implements custom JSON marshalling to ensure alphabetical order of keys for AuthorizedKey, and only includes non-empty fields.

type CacheSettings

type CacheSettings struct {
	ReadFromCache bool  `json:"readFromCache,omitempty"` // If true, attempt to read a cached response for the request
	MaxAgeMs      int32 `json:"maxAgeMs,omitempty"`      // Maximum age of a cached response in milliseconds.
}

CacheSettings defines cache control options for outbound HTTP requests.

type HTTPTriggerRequest

type HTTPTriggerRequest struct {
	Input    json.RawMessage  `json:"input"`    // Input parameters for the workflow.
	Key      AuthorizedKey    `json:"key"`      // Signing key for the request
	Workflow WorkflowSelector `json:"workflow"` // Selector for the workflow to execute.
}

HTTPTriggerRequest represents a request to trigger a workflow via HTTP.

func (HTTPTriggerRequest) MarshalJSON added in v0.9.0

func (r HTTPTriggerRequest) MarshalJSON() ([]byte, error)

MarshalJSON implements custom JSON marshalling to ensure deterministic output with sorted keys at all levels for map[string]any, including nested objects in the Input field.

type HTTPTriggerResponse

type HTTPTriggerResponse struct {
	WorkflowID          string            `json:"workflow_id,omitempty"`           // ID of the triggered workflow.
	WorkflowExecutionID string            `json:"workflow_execution_id,omitempty"` // ID of the workflow execution.
	Status              HTTPTriggerStatus `json:"status,omitempty"`                // Status of the trigger request.
}

HTTPTriggerResponse represents the response to an HTTP trigger request.

type HTTPTriggerStatus

type HTTPTriggerStatus string

HTTPTriggerStatus represents the status of an HTTP trigger request.

type KeyType added in v0.8.0

type KeyType string

type OutboundHTTPRequest

type OutboundHTTPRequest struct {
	URL           string            `json:"url"`                     // URL to query, only http and https protocols are supported.
	Method        string            `json:"method,omitempty"`        // HTTP verb, defaults to GET.
	Headers       map[string]string `json:"headers,omitempty"`       // HTTP headers, defaults to empty.
	Body          []byte            `json:"body,omitempty"`          // HTTP request body
	TimeoutMs     uint32            `json:"timeoutMs,omitempty"`     // Timeout in milliseconds
	CacheSettings CacheSettings     `json:"cacheSettings,omitempty"` // Best-effort cache control for the request

	// Maximum number of bytes to read from the response body.  If the gateway max response size is smaller than this value, the gateway max response size will be used.
	MaxResponseBytes uint32 `json:"maxBytes,omitempty"`
	WorkflowID       string `json:"workflowId"`
}

OutboundHTTPRequest represents an HTTP request to be sent from workflow node to the gateway.

func (OutboundHTTPRequest) Hash

func (req OutboundHTTPRequest) Hash() string

type OutboundHTTPResponse

type OutboundHTTPResponse struct {
	ErrorMessage string            `json:"errorMessage,omitempty"` // error message in case of execution errors. i.e. errors before or after attempting HTTP call to external client
	StatusCode   int               `json:"statusCode,omitempty"`   // HTTP status code
	Headers      map[string]string `json:"headers,omitempty"`      // HTTP headers
	Body         []byte            `json:"body,omitempty"`         // HTTP response body
}

OutboundHTTPResponse represents the response from gateway to workflow node.

type RoundRobinSelector

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

func NewRoundRobinSelector

func NewRoundRobinSelector(items []string, opts ...func(*RoundRobinSelector)) *RoundRobinSelector

NewRoundRobinSelector creates a selector that will select a string from a list using the round robin strategy. By default the index starts on a random start point in the list.

func (*RoundRobinSelector) NextGateway

func (r *RoundRobinSelector) NextGateway() (string, error)

type WorkflowMetadata added in v0.9.0

type WorkflowMetadata struct {
	WorkflowSelector WorkflowSelector
	AuthorizedKeys   []AuthorizedKey
}

WorkflowMetadata represents the workflow metadata for HTTP triggers including auth data. This type is used for communication between the gateway handler in the gateway node and the gateway connector handler in the workflow node.

func (*WorkflowMetadata) Digest added in v0.9.0

func (wm *WorkflowMetadata) Digest() (string, error)

type WorkflowSelector

type WorkflowSelector struct {
	WorkflowID    string `json:"workflowID,omitempty"`    // Unique ID of the workflow.
	WorkflowName  string `json:"workflowName,omitempty"`  // Name of the workflow.
	WorkflowOwner string `json:"workflowOwner,omitempty"` // Owner of the workflow.
	WorkflowTag   string `json:"workflowTag,omitempty"`   // Tag for the workflow.
}

WorkflowSelector specifies how to identify a workflow.

func (WorkflowSelector) MarshalJSON added in v0.9.0

func (ws WorkflowSelector) MarshalJSON() ([]byte, error)

MarshalJSON implements custom JSON marshalling to ensure alphabetical order of keys for WorkflowSelector, and only includes non-empty fields.

Jump to

Keyboard shortcuts

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