Documentation
¶
Overview ¶
Package transport is the sole extension point between the domainless Flow compiler and concrete transport adapters.
The contract ¶
A transport library provides:
A Resolver — converts DSL modifiers into action.Binding values at compile time.
A RuntimeProvider — opens a live connection for `nexssflow serve`.
A Library(...) function — returns the actions the transport adds to the pipeline (for example nats.publish, http.get).
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 ¶
- func Bind[T any](ctx context.Context, raw map[string]string, ...) (action.Library, error)
- func Decode[T any](ctx context.Context, raw map[string]string) (T, error)
- func HasProvider(prefix string) bool
- func KnownKinds() []string
- func KnownPrefixes() []string
- func KnownTriggerProtocols() []string
- func RegisterProvider(prefix string, fn ProviderFunc)
- func RegisterResolverMap(m map[string]ResolverFunc)
- func RegisterStateless[T any](ctx context.Context, name string, raw map[string]string) (action.Library, error)
- func RegisterTriggerResolver(r TriggerResolver)
- func Resolve(b *dslparse.TransportBinding) (action.Binding, bool, error)
- func ResolveEventTrigger(protocol, target string) (*dslparse.TransportBinding, error)
- func ServeOne(ctx context.Context, tr interface{ ... }, pipeline action.AnyAction, ...) error
- type ProviderFunc
- type ResolverFunc
- type Service
- type TriggerResolver
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 ¶
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 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 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 ¶
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.