transport

package
v0.0.0-...-257333a Latest Latest
Warning

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

Go to latest
Published: May 26, 2016 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package is an interface for synchronous communication.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func String

func String() string

Types

type Client

type Client interface {
	Recv(*Message) error
	Send(*Message) error
	Close() error
}

func Dial

func Dial(addr string, opts ...DialOption) (Client, error)

type DialOption

type DialOption func(*DialOptions)

func WithStream

func WithStream() DialOption

Indicates whether this is a streaming connection

func WithTimeout

func WithTimeout(d time.Duration) DialOption

Timeout used when dialling the remote side

type DialOptions

type DialOptions struct {
	Stream  bool
	Timeout time.Duration

	// Other options for implementations of the interface
	// can be stored in a context
	Context context.Context
}

type ListenOption

type ListenOption func(*ListenOptions)

type ListenOptions

type ListenOptions struct {

	// Other options for implementations of the interface
	// can be stored in a context
	Context context.Context
}

type Listener

type Listener interface {
	Addr() string
	Close() error
	Accept(func(Socket)) error
}

func Listen

func Listen(addr string, opts ...ListenOption) (Listener, error)

type Message

type Message struct {
	Header map[string]string
	Body   []byte
}

type Option

type Option func(*Options)

func Addrs

func Addrs(addrs ...string) Option

Addrs to use for transport

func Secure

func Secure(b bool) Option

Use secure communication. If TLSConfig is not specified we use InsecureSkipVerify and generate a self signed cert

func TLSConfig

func TLSConfig(t *tls.Config) Option

TLSConfig to be used for the transport.

type Options

type Options struct {
	Addrs     []string
	Secure    bool
	TLSConfig *tls.Config

	// 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
}

type Transport

type Transport interface {
	Dial(addr string, opts ...DialOption) (Client, error)
	Listen(addr string, opts ...ListenOption) (Listener, error)
	String() string
}

Transport is an interface which is used for communication between services. It uses socket send/recv semantics and had various implementations {HTTP, RabbitMQ, NATS, ...}

var (
	DefaultTransport Transport = newHTTPTransport()

	DefaultDialTimeout = time.Second * 5
)

func NewTransport

func NewTransport(opts ...Option) Transport

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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