go-micro: github.com/micro/go-micro/transport Index | Files | Directories

package transport

import "github.com/micro/go-micro/transport"

Package transport is an interface for synchronous communication

Index

Package Files

http_transport.go options.go transport.go

type Client Uses

type Client interface {
    Socket
}

type DialOption Uses

type DialOption func(*DialOptions)

func WithStream Uses

func WithStream() DialOption

Indicates whether this is a streaming connection

func WithTimeout Uses

func WithTimeout(d time.Duration) DialOption

Timeout used when dialling the remote side

type DialOptions Uses

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 Uses

type ListenOption func(*ListenOptions)

type ListenOptions Uses

type ListenOptions struct {

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

type Listener Uses

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

type Message Uses

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

type Option Uses

type Option func(*Options)

func Addrs Uses

func Addrs(addrs ...string) Option

Addrs to use for transport

func Codec Uses

func Codec(c codec.Codec) Option

Codec sets the codec used for encoding where the transport does not support message headers

func Secure Uses

func Secure(b bool) Option

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

func TLSConfig Uses

func TLSConfig(t *tls.Config) Option

TLSConfig to be used for the transport.

func Timeout Uses

func Timeout(t time.Duration) Option

Timeout sets the timeout for Send/Recv execution

type Options Uses

type Options struct {
    Addrs     []string
    Codec     codec.Codec
    Secure    bool
    TLSConfig *tls.Config
    // Timeout sets the timeout for Send/Recv
    Timeout time.Duration
    // Other options for implementations of the interface
    // can be stored in a context
    Context context.Context
}

type Socket Uses

type Socket interface {
    Recv(*Message) error
    Send(*Message) error
    Close() error
    Local() string
    Remote() string
}

type Transport Uses

type Transport interface {
    Init(...Option) error
    Options() Options
    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 Uses

func NewTransport(opts ...Option) Transport

Directories

PathSynopsis
codec
codec/json
codec/noop
httpPackage http returns a http2 transport using net/http
mock

Package transport imports 18 packages (graph) and is imported by 97 packages. Updated 2018-11-22. Refresh now. Tools for package owners.