transport

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package transport is the sole extension point between the domainless Flow compiler and concrete transport adapters.

The contract

A transport library provides:

  1. A Resolver — converts DSL modifiers into action.Binding values at compile time.

  2. A RuntimeProvider — opens a live connection for `nexssflow serve`.

  3. A Library(...) function — returns the actions the transport adds to the pipeline (for example nats.publish, http.get).

  4. An init() function — calls RegisterResolver and RegisterRuntimeProvider so the compiler sees the transport.

What belongs here

Only the interfaces and the registry. No concrete transport.

What does NOT belong here

Anything that imports net/http, nats.go, os/exec, or a transport package. This package must remain dependency-free apart from kernel/action and flow/dslparse.

Example transport

See github.com/nexssp/transportnats/nexssflow for a complete example.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bind

func Bind[T any](ctx context.Context, raw map[string]string, factory func(T) (action.Library, error)) (action.Library, error)

Bind populates T from raw options, resolving env tags and defaults, validates, and invokes factory.

func Decode

func Decode[T any](ctx context.Context, raw map[string]string) (T, error)

Decode maps a raw string map into a typed options struct.

flow:"key"        key name in the @require block
default:"..."     value used when the key is absent
validate:"..."    ecosystem validator tag (required, url, min, …)

Unknown keys are rejected. Values that fail `validate` are returned as xerr.Validation with structured details.

func HasProvider

func HasProvider(prefix string) bool

func KnownKinds

func KnownKinds() []string

func KnownPrefixes

func KnownPrefixes() []string

func KnownTriggerProtocols

func KnownTriggerProtocols() []string

func RegisterProvider

func RegisterProvider(prefix string, fn ProviderFunc)

RegisterProvider registers a runtime provider under a prefix.

func RegisterResolverMap

func RegisterResolverMap(m map[string]ResolverFunc)

RegisterResolverMap binds every kind in the map. Panics on a duplicate kind: a misconfigured ecosystem must fail at process start, not at run time.

func RegisterStateless

func RegisterStateless[T any](ctx context.Context, name string, raw map[string]string) (action.Library, error)

RegisterStateless validates options against T and returns an empty library. Transports without actions of their own (HTTP, CLI, cron, worker, topic) call this from their Register.

func RegisterTriggerResolver

func RegisterTriggerResolver(r TriggerResolver)

func Resolve

Resolve translates a DSL binding into a runtime Binding.

func ResolveEventTrigger

func ResolveEventTrigger(protocol, target string) (*dslparse.TransportBinding, error)

func ServeOne

func ServeOne(
	ctx context.Context,
	tr interface {
		Mount([]action.AnyAction)
		Do(context.Context, any) (any, error)
	},
	pipeline action.AnyAction,
	binding *dslparse.TransportBinding,
) error

ServeOne mounts a single pipeline on the given binding and blocks. Providers call this from their Serve method.

Types

type ProviderFunc

type ProviderFunc func(ctx context.Context, cfg map[string]string) (Service, error)

ProviderFunc opens a runtime transport for `nexssflow serve`.

func ProviderByPrefix

func ProviderByPrefix(prefix string) (ProviderFunc, bool)

type ResolverFunc

type ResolverFunc func(*dslparse.TransportBinding) (action.Binding, error)

ResolverFunc translates one DSL binding kind into an action.Binding.

type Service

type Service interface {
	Serve(ctx context.Context, pipeline action.AnyAction, binding *dslparse.TransportBinding) error
	Close() error
}

Service is a live transport instance.

type TriggerResolver

type TriggerResolver interface {
	Handles(protocol string) bool
	Resolve(protocol, target string) (*dslparse.TransportBinding, error)
}

TriggerResolver converts an @on event declaration into the TransportBinding that the transport's own Resolver will later convert into an action.Binding.

Each transport library registers exactly one, and owns the grammar of its own protocol strings.

Jump to

Keyboard shortcuts

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