transport

package
v0.14.5 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2019 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	//Error is the errs class of standard Transport Client errors
	Error = errs.Class("transport error")
)

Functions

func DialAddressInsecure

func DialAddressInsecure(ctx context.Context, address string, opts ...grpc.DialOption) (conn *grpc.ClientConn, err error)

DialAddressInsecure returns an insecure grpc connection without tls to a node.

Use this method for communication with localhost. For example, with the inspector or debugging services. Otherwise in most cases DialNode should be used for communicating with nodes since it is secure.

Types

type Client

type Client interface {
	DialNode(ctx context.Context, node *pb.Node, opts ...grpc.DialOption) (*grpc.ClientConn, error)
	DialAddress(ctx context.Context, address string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
	Identity() *identity.FullIdentity
	WithObservers(obs ...Observer) Client
}

Client defines the interface to an transport client.

func NewClient

func NewClient(tlsOpts *tlsopts.Options, obs ...Observer) Client

NewClient returns a transport client with a default timeout for requests

func NewClientWithTimeouts added in v0.12.0

func NewClientWithTimeouts(tlsOpts *tlsopts.Options, timeouts Timeouts, obs ...Observer) Client

NewClientWithTimeouts returns a transport client with a specified timeout for requests

type Observer

type Observer interface {
	ConnSuccess(ctx context.Context, node *pb.Node)
	ConnFailure(ctx context.Context, node *pb.Node, err error)
}

Observer implements the ConnSuccess and ConnFailure methods for Discovery and other services to use

type SimulatedNetwork

type SimulatedNetwork struct {
	DialLatency    time.Duration
	BytesPerSecond memory.Size
}

SimulatedNetwork allows creating connections that try to simulated realistic network conditions.

func (*SimulatedNetwork) DialOptions

func (network *SimulatedNetwork) DialOptions() []grpc.DialOption

DialOptions returns options such that it will use simulated network parameters

func (*SimulatedNetwork) GRPCDialContext

func (network *SimulatedNetwork) GRPCDialContext(ctx context.Context, address string) (_ net.Conn, err error)

GRPCDialContext implements DialContext that is suitable for `grpc.WithContextDialer`

func (*SimulatedNetwork) NewClient

func (network *SimulatedNetwork) NewClient(client Client) Client

NewClient wraps an exiting client with the simulated network params.

type Timeouts added in v0.12.0

type Timeouts struct {
	Request time.Duration
	Dial    time.Duration
}

Timeouts contains all of the timeouts configurable for a transport

type Transport

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

Transport interface structure

func (*Transport) DialAddress

func (transport *Transport) DialAddress(ctx context.Context, address string, opts ...grpc.DialOption) (conn *grpc.ClientConn, err error)

DialAddress returns a grpc connection with tls to an IP address.

Do not use this method unless having a good reason. In most cases DialNode should be used for communicating with nodes as it is more secure than DialAddress.

func (*Transport) DialNode

func (transport *Transport) DialNode(ctx context.Context, node *pb.Node, opts ...grpc.DialOption) (conn *grpc.ClientConn, err error)

DialNode returns a grpc connection with tls to a node.

Use this method for communicating with nodes as it is more secure than DialAddress. The connection will be established successfully only if the target node has the private key for the requested node ID.

func (*Transport) Identity

func (transport *Transport) Identity() *identity.FullIdentity

Identity is a getter for the transport's identity

func (*Transport) WithObservers

func (transport *Transport) WithObservers(obs ...Observer) Client

WithObservers returns a new transport including the listed observers.

Jump to

Keyboard shortcuts

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