Documentation
¶
Overview ¶
Package transport is an interface for synchronous connection based communication
Index ¶
- func NewContext(ctx context.Context, c Transport) context.Context
- type Client
- type DialOption
- type DialOptions
- type ListenOption
- type ListenOptions
- type Listener
- type Message
- type Option
- func Addrs(addrs ...string) Option
- func Codec(c codec.Codec) Option
- func Context(ctx context.Context) Option
- func Logger(l logger.Logger) Option
- func Meter(m meter.Meter) Option
- func Name(n string) Option
- func SetOption(k, v interface{}) Option
- func TLSConfig(t *tls.Config) Option
- func Timeout(t time.Duration) Option
- func Tracer(t tracer.Tracer) Option
- type Options
- type Socket
- type Transport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DialOption ¶
type DialOption func(*DialOptions)
DialOption is the option signature
func WithStream ¶
func WithStream() DialOption
WithStream indicates whether this is a streaming connection
func WithTimeout ¶
func WithTimeout(d time.Duration) DialOption
WithTimeout used when dialling the remote side
type DialOptions ¶
type DialOptions struct {
// Tells the transport this is a streaming connection with
// multiple calls to send/recv and that send may not even be called
Stream bool
// Timeout for dialing
Timeout time.Duration
// Other options for implementations of the interface
// can be stored in a context
Context context.Context
}
DialOptions struct
func NewDialOptions ¶
func NewDialOptions(opts ...DialOption) DialOptions
NewDialOptions returns new DialOptions
type ListenOptions ¶
type ListenOptions struct {
// Other options for implementations of the interface
// can be stored in a context
Context context.Context
}
ListenOptions struct
func NewListenOptions ¶
func NewListenOptions(opts ...ListenOption) ListenOptions
NewListenOptions returns new ListenOptions
type Option ¶
type Option func(*Options)
Option is the option signature
func Codec ¶
Codec sets the codec used for encoding where the transport does not support message headers
func SetOption ¶ added in v3.1.0
func SetOption(k, v interface{}) Option
SetOption returns a function to setup a context with given value
type Options ¶
type Options struct {
Name string
// Addrs is the list of intermediary addresses to connect to
Addrs []string
// Codec is the codec interface to use where headers are not supported
// by the transport and the entire payload must be encoded
Codec codec.Codec
// Secure tells the transport to secure the connection.
// In the case TLSConfig is not specified best effort self-signed
// certs should be used
Secure bool
// TLSConfig to secure the connection. The assumption is that this
// is mTLS keypair
TLSConfig *tls.Config
// Timeout sets the timeout for Send/Recv
Timeout time.Duration
// Logger sets the logger
Logger logger.Logger
// Meter sets the meter
Meter meter.Meter
// Tracer
Tracer tracer.Tracer
// Other options for implementations of the interface
// can be stored in a context
Context context.Context
}
type Socket ¶
type Socket interface {
Recv(*Message) error
Send(*Message) error
Close() error
Local() string
Remote() string
}
Socket bastraction interface
type Transport ¶
type Transport interface {
Init(...Option) error
Options() Options
Dial(ctx context.Context, addr string, opts ...DialOption) (Client, error)
Listen(ctx context.Context, addr string, opts ...ListenOption) (Listener, error)
String() string
}
Transport is an interface which is used for communication between services. It uses connection based socket send/recv semantics and has various implementations; http, grpc, quic.
var ( // DefaultTransport is the global default transport DefaultTransport Transport = NewTransport() // Default dial timeout DefaultDialTimeout = time.Second * 5 )
func FromContext ¶ added in v3.1.0
FromContext get transport from context
func NewTransport ¶
NewTransport creates new noop transport