func NewContext(ctx context.Context, p *Peer) context.Context
NewContext creates a new context with peer information attached.
Peer contains the information of the peer for an RPC, such as the address and authentication information.
type Peer struct { // Addr is the peer address. Addr net.Addr // LocalAddr is the local address. LocalAddr net.Addr // AuthInfo is the authentication information of the transport. // It is nil if there is no transport security being used. AuthInfo credentials.AuthInfo }
func FromContext(ctx context.Context) (p *Peer, ok bool)
FromContext returns the peer information in ctx if it exists.
func (p *Peer) String() string
String ensures the Peer types implements the Stringer interface in order to allow to print a context with a peerKey value effectively.