Documentation
¶
Index ¶
- Constants
- Variables
- func GetRequestID(methodName string, parts ...string) string
- func WithFixedStart() func(*RoundRobinSelector)
- type AuthorizedKey
- type CacheSettings
- type HTTPTriggerRequest
- type HTTPTriggerResponse
- type HTTPTriggerStatus
- type KeyType
- type OutboundHTTPRequest
- type OutboundHTTPResponse
- type RoundRobinSelector
- type WorkflowMetadata
- type WorkflowSelector
Constants ¶
const ( // HTTPTriggerStatusAccepted indicates the trigger request was accepted. HTTPTriggerStatusAccepted HTTPTriggerStatus = "ACCEPTED" // MethodWorkflowExecute is the method name for executing workflows. MethodWorkflowExecute string = "workflows.execute" )
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" )
const (
// Note: any addition to this list must be reflected in the handler's Methods() function.
MethodHTTPAction = "http_action"
)
Variables ¶
var ErrNoGateways = errors.New("no gateways available")
Functions ¶
func GetRequestID ¶ added in v0.8.0
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 CacheSettings ¶
type CacheSettings struct {
MaxAgeMs int32 `json:"maxAgeMs,omitempty"` // Maximum age of a cached response in milliseconds.
Store bool `json:"store,omitempty"` // If true, cache the response.
// Deprecated: positive MaxAgeMs implies ReadFromCache is true
ReadFromCache bool `json:"readFromCache,omitempty"` // If true, attempt to read a cached response for the request
}
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 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"` // 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"`
WorkflowOwner string `json:"workflowOwner"`
}
OutboundHTTPRequest represents an HTTP request to be sent from workflow node to the gateway.
func (OutboundHTTPRequest) Hash ¶
func (req OutboundHTTPRequest) Hash() string
Hash generates a hash of the request for caching purposes. WorkflowID is not included in the hash because cached responses can be used across workflows
type OutboundHTTPResponse ¶
type OutboundHTTPResponse struct {
// ErrorMessage contains error details for gateway-level errors (validation, internal errors, or external endpoint failures like timeouts).
// This field is empty when the request successfully reaches the customer's endpoint and returns a response (regardless of HTTP status code).
ErrorMessage string `json:"errorMessage,omitempty"`
// IsExternalEndpointError indicates the request was sent to the customer's endpoint but failed while sending the request or receiving the response.
// (e.g., connection timeout, response too large, unreachable host). When true, ErrorMessage contains the failure details.
IsExternalEndpointError bool `json:"isExternalEndpointError,omitempty"`
// IsValidationError indicates the request was blocked by the gateway BEFORE being sent to the customer's endpoint
// due to policy violations (e.g., blocked HTTP headers, blocked IP addresses, invalid URL).
// This is distinct from StatusCode 4xx, which would indicate the customer's endpoint received and rejected the request.
IsValidationError bool `json:"isValidationError,omitempty"`
// StatusCode is the HTTP status code returned by the customer's endpoint (e.g., 2xx, 4xx, 5xx).
// This field is only populated when the request successfully reaches the customer's endpoint and the response is received.
StatusCode int `json:"statusCode,omitempty"`
Headers map[string]string `json:"headers,omitempty"` // HTTP headers returned by the customer's endpoint
Body []byte `json:"body,omitempty"` // HTTP response body returned by the customer's endpoint
ExternalEndpointLatency time.Duration `json:"externalEndpointLatency,omitempty"` // Time taken by the customer's endpoint to respond
}
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)
Digest returns a digest of the workflow metadata. This is used for aggregating metadata across multiple nodes. The digest is a SHA256 hash of the canonical JSON representation, ensuring deterministic output regardless of the order in which authorized keys are reported.
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.