modtool

package
v19.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package modtool holds conversions between AutoFlow values and the pieces of an HTTP request and response, shared by the built-in modules that call an API.

Index

Constants

View Source
const (
	MetricOutboundRequestsTotal = "autoflow_outbound_requests_total"
)

Variables

View Source
var ErrDisabledModule = errors.New("module disabled")

Functions

func DisabledModule added in v19.4.0

func DisabledModule(name string, err error) pkg_autoflow.Module

DisabledModule stands in for a built-in module that a deployment cannot provide the dependency for. It fails the flow's load() with err rather than its first action, so a flow that cannot do its job does not get part way through it first.

It stands in rather than being left out, because the name is reserved only for as long as a built-in holds it: an absent built-in is looked up among the agent-registered modules instead, which would answer a flow with "not registered" and would let an agent's module of the same name take the calls.

func HeaderValue

func HeaderValue(h http.Header) *pkg_autoflow.Value

HeaderValue renders response headers as a dict of header name to list of values.

func NewOutboundRequestsCounter added in v19.4.0

func NewOutboundRequestsCounter(meter metric.Meter) (metric.Int64Counter, error)

NewOutboundRequestsCounter creates the counter of requests built-in modules send on a flow's behalf, recorded through OutboundRequests.

func RequestHeader

func RequestHeader(v *pkg_autoflow.Value) (http.Header, error)

RequestHeader converts a dict value, whose values are each a single element or a list of elements, into request headers. Header names are canonicalized, so several dict keys can map to the same name; their values are merged in the order the keys appear in the dict.

A nil value yields nil headers: that is what an absent or None argument binds to, so a caller does not have to check for one.

func RequestQuery

func RequestQuery(v *pkg_autoflow.Value) (url.Values, error)

RequestQuery converts a dict value, whose values are each a single element or a list of elements, into URL query parameters.

A nil value yields nil query parameters: that is what an absent or None argument binds to, so a caller does not have to check for one.

func ScalarText

func ScalarText[T ~string | ~[]byte](v *pkg_autoflow.Value) (T, error)

ScalarText extracts the text of a value, which must be a (sensitive) string or (sensitive) bytes.

func StringValue

func StringValue(v *pkg_autoflow.Value) (string, bool)

StringValue extracts the text of a string value.

Types

type OutboundRequests added in v19.4.0

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

OutboundRequests counts the requests a module sends to one target, by the status class of the response.

func NewOutboundRequests added in v19.4.0

func NewOutboundRequests(counter metric.Int64Counter, target string) *OutboundRequests

NewOutboundRequests returns the recorder of requests to target on counter.

func (*OutboundRequests) Record added in v19.4.0

func (r *OutboundRequests) Record(ctx context.Context, resp *http.Response, err error)

Record counts one request that got resp, or no response when err is set.

Jump to

Keyboard shortcuts

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