Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 (*Registry) Register ¶
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.