transport

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package transport defines the cross-cutting Endpoint + Error abstractions every concrete transport (grpc, rest, amqp, nats, tcp, udp, websocket) implements.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSONDecoder added in v0.4.0

func JSONDecoder[T any](_ context.Context, payload []byte) (T, error)

JSONDecoder is a ready-made Decoder for JSON payloads. Mirror of JSONEncoder for the consumer side.

func JSONEncoder added in v0.4.0

func JSONEncoder[T any](_ context.Context, v T) ([]byte, error)

JSONEncoder is a ready-made Encoder for JSON payloads. Most services can use this directly instead of writing a per-type encoder.

Types

type AnyEndpoint

type AnyEndpoint func(ctx context.Context, request interface{}) (interface{}, error)

type Decoder added in v0.4.0

type Decoder[T any] func(ctx context.Context, payload []byte) (T, error)

Decoder is the inverse of Encoder: given a payload (and any broker metadata the transport extracted into ctx) it returns the decoded value or an error.

type EmptyResEndpoint

type EmptyResEndpoint[I any] func(ctx context.Context, request I) error

type Encoder added in v0.4.0

type Encoder[T any] func(ctx context.Context, v T) ([]byte, error)

Encoder turns an application value into the byte payload that goes on the wire. Returns an error if the value cannot be marshalled.

type Endpoint

type Endpoint[I, O any] func(ctx context.Context, request I) (O, error)

type ErrorHandler

type ErrorHandler interface {
	Handle(ctx context.Context, err error)
}

type Handler added in v0.4.0

type Handler[T any] interface {
	Handle(ctx context.Context, event T) error
}

Handler is implemented by application code that consumes events. Returning a non-nil error signals the transport to nack / retry the message according to its semantics.

type HandlerFunc added in v0.4.0

type HandlerFunc[T any] func(ctx context.Context, event T) error

HandlerFunc adapts a plain function to the Handler interface.

func (HandlerFunc[T]) Handle added in v0.4.0

func (f HandlerFunc[T]) Handle(ctx context.Context, event T) error

Handle satisfies the Handler interface.

Directories

Path Synopsis
Package amqp provides a comprehensive RabbitMQ/AMQP consumer and producer framework.
Package amqp provides a comprehensive RabbitMQ/AMQP consumer and producer framework.
amqptest
Package amqptest provides mocks and helpers for testing AMQP connections
Package amqptest provides mocks and helpers for testing AMQP connections
Package grpc provides a comprehensive gRPC server and client framework.
Package grpc provides a comprehensive gRPC server and client framework.
middleware
Package middleware provides common gRPC server middlewares
Package middleware provides common gRPC server middlewares
Package nats provides NATS / JetStream consumer + publisher helpers built on the broker-agnostic kit/transport interface.
Package nats provides NATS / JetStream consumer + publisher helpers built on the broker-agnostic kit/transport interface.
Package rest provides the kit's HTTP/REST server, client, and route-registration primitives.
Package rest provides the kit's HTTP/REST server, client, and route-registration primitives.
Package tcp provides a comprehensive TCP server and client framework.
Package tcp provides a comprehensive TCP server and client framework.
Package udp provides a UDP transport implementation with optional reliability.
Package udp provides a UDP transport implementation with optional reliability.
Package websocket provides a comprehensive WebSocket client framework.
Package websocket provides a comprehensive WebSocket client framework.

Jump to

Keyboard shortcuts

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