Documentation ¶
Index ¶
- Variables
- func DialAddressInsecure(ctx context.Context, address string, opts ...grpc.DialOption) (conn *grpc.ClientConn, err error)
- type Client
- type Observer
- type SimulatedNetwork
- type Timeouts
- type Transport
- func (transport *Transport) AlertFail(ctx context.Context, node *pb.Node, err error)
- func (transport *Transport) AlertSuccess(ctx context.Context, node *pb.Node)
- func (transport *Transport) DialAddress(ctx context.Context, address string, opts ...grpc.DialOption) (conn *grpc.ClientConn, err error)
- func (transport *Transport) DialNode(ctx context.Context, node *pb.Node, opts ...grpc.DialOption) (conn *grpc.ClientConn, err error)
- func (transport *Transport) FetchPeerIdentity(ctx context.Context, node *pb.Node, opts ...grpc.DialOption) (_ *identity.PeerIdentity, err error)
- func (transport *Transport) Identity() *identity.FullIdentity
- func (transport *Transport) Timeouts() Timeouts
- func (transport *Transport) WithObservers(obs ...Observer) Client
Constants ¶
This section is empty.
Variables ¶
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) FetchPeerIdentity(ctx context.Context, node *pb.Node, opts ...grpc.DialOption) (*identity.PeerIdentity, error) Identity() *identity.FullIdentity WithObservers(obs ...Observer) Client AlertSuccess(ctx context.Context, node *pb.Node) AlertFail(ctx context.Context, node *pb.Node, err error) }
Client defines the interface to an transport client.
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 ¶
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 Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport interface structure
func (*Transport) AlertFail ¶ added in v0.15.0
AlertFail alerts any subscribed observers of the failure 'err' for 'node'
func (*Transport) AlertSuccess ¶ added in v0.15.0
AlertSuccess alerts any subscribed observers of success for 'node'
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) FetchPeerIdentity ¶ added in v0.15.3
func (transport *Transport) FetchPeerIdentity(ctx context.Context, node *pb.Node, opts ...grpc.DialOption) (_ *identity.PeerIdentity, err error)
FetchPeerIdentity dials the node and fetches the identity
func (*Transport) Identity ¶
func (transport *Transport) Identity() *identity.FullIdentity
Identity is a getter for the transport's identity
func (*Transport) Timeouts ¶ added in v0.16.0
Timeouts returns the timeout values for dialing and requests.
func (*Transport) WithObservers ¶
WithObservers returns a new transport including the listed observers.