transport

package
v0.3.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the client implementation for the internal TCP server. It maintains a connection pool and manages request-response cycle.

func NewClient

func NewClient(cc *ClientConfig) *Client

NewClient returns a new Client.

func (*Client) Close

func (c *Client) Close()

Close all the connections in the connection pool.

func (*Client) ClosePool

func (c *Client) ClosePool(addr string)

ClosePool closes the underlying connections in a pool, deletes from Olric's pools map and frees resources.

func (*Client) CloseWithAddr

func (c *Client) CloseWithAddr(addr string)

CloseWithAddr closes the connection for given addr, if any exists.

func (*Client) CreateStream added in v0.3.0

func (c *Client) CreateStream(ctx context.Context, addr string, read chan<- protocol.EncodeDecoder, write <-chan protocol.EncodeDecoder) error

CreateStream creates a new Stream connection which provides a bidirectional communication channel between Olric nodes and clients.

func (*Client) Request

Request initiates a request-response cycle to randomly selected host.

func (*Client) RequestTo

func (c *Client) RequestTo(addr string, req protocol.EncodeDecoder) (protocol.EncodeDecoder, error)

RequestTo initiates a request-response cycle to given host.

type ClientConfig

type ClientConfig struct {
	Addrs       []string
	DialTimeout time.Duration
	KeepAlive   time.Duration
	MinConn     int
	MaxConn     int
}

ClientConfig configuration parameters of the client.

type RoundRobin

type RoundRobin struct {
	sync.Mutex
	// contains filtered or unexported fields
}

RoundRobin implements quite simple round-robin algorithm to distribute load fairly between servers.

func NewRoundRobin

func NewRoundRobin(addrs []string) *RoundRobin

NewRoundRobin returns a new RoundRobin.

func (*RoundRobin) Get

func (r *RoundRobin) Get() string

Get returns a host address.

type Server

type Server struct {
	StartCh chan struct{}
	// contains filtered or unexported fields
}

Server implements a concurrent TCP server.

func NewServer

func NewServer(bindAddr string, bindPort int, keepalivePeriod time.Duration, logger *flog.Logger) *Server

NewServer creates and returns a new Server.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe listens on the TCP network address addr.

func (*Server) SetDispatcher

func (s *Server) SetDispatcher(f func(w, r protocol.EncodeDecoder))

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the server without interrupting any active connections. Shutdown works by first closing all open listeners, then closing all idle connections, and then waiting indefinitely for connections to return to idle and then shut down. If the provided context expires before the shutdown is complete, Shutdown returns the context's error, otherwise it returns any error returned from closing the Server's underlying Listener(s).

Jump to

Keyboard shortcuts

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