sidechannel

package
v14.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenSidechannel

func OpenSidechannel(ctx context.Context) (_ net.Conn, err error)

OpenSidechannel opens a sidechannel connection from the stream opener extracted from the current peer connection.

Types

type Registry

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

Registry manages sidechannel connections. It allows the RPC handlers to wait for the secondary incoming connection made by the client.

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns a new Registry instance

func (*Registry) Register

func (s *Registry) Register(callback func(net.Conn) error) *Waiter

Register registers the caller into the waiting list. The caller must provide a callback function. The caller receives a waiter instance. After the connection arrives, the callback function is executed with arrived connection in a new goroutine. The caller receives execution result via waiter.Wait().

type ServerHandshaker

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

ServerHandshaker implements the server-side sidechannel handshake.

func NewServerHandshaker

func NewServerHandshaker(registry *Registry) *ServerHandshaker

NewServerHandshaker creates a new handshaker for sidechannel to embed into listenmux.

func (*ServerHandshaker) Handshake

func (s *ServerHandshaker) Handshake(conn net.Conn, authInfo credentials.AuthInfo) (net.Conn, credentials.AuthInfo, error)

Handshake implements the handshaking logic for sidechannel so that this handshaker reads the sidechannel ID from the wire, and then delegates the connection to the sidechannel registry

func (*ServerHandshaker) Magic

func (s *ServerHandshaker) Magic() string

Magic returns the magic bytes for sidechannel

type Waiter

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

Waiter lets the caller waits until a connection with matched id is pushed into the registry, then execute the callback

func RegisterSidechannel

func RegisterSidechannel(ctx context.Context, registry *Registry, callback func(net.Conn) error) (context.Context, *Waiter)

RegisterSidechannel registers the caller into the waiting list of the sidechannel registry and injects the sidechannel ID into outgoing metadata. The caller is expected to establish the request with the returned context. The callback is executed automatically when the sidechannel connection arrives. The result is pushed to the error channel of the returned waiter.

func (*Waiter) Close

func (w *Waiter) Close() error

Close cleans the waiter, removes it from the registry. If the callback is executing, this method is blocked until the callback is done.

func (*Waiter) Wait

func (w *Waiter) Wait() error

Wait waits until either the callback is executed, or the waiter is closed

Jump to

Keyboard shortcuts

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