rpc

package
v0.0.0-...-7851fa2 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderRPCContext = "x-rpc-context"
)
View Source
const (
	// uint32
	LengthSize = 4
)

Variables

This section is empty.

Functions

func BoundedReceive

func BoundedReceive(stream io.Reader, rr VTMarshaler, max uint32) error

func DeserializeContextHeader

func DeserializeContextHeader(ctx context.Context, r http.Header) (context.Context, bool)

Deserialize RPC context from http headers. The RPC context can be retrieved with GetContext()

func DisablePooling

func DisablePooling(baseCtx context.Context) context.Context

Disable HTTP client pool for this client

func DynamicTunnelClient

func DynamicTunnelClient(baseContext context.Context, tunnelTransport transport.Transport) protocol.TunnelService

DynamicTunnelClient returns a rpc client suitable for TunnelService, with the destination set per call dynamically according to the destination in context. Use WithNode(ctx, node) at call site to dynamically dispatch. Optionally, use WithClientToken(ctx, token) to include client token.

func ExtractContext

func ExtractContext(base http.Handler) http.Handler

Middleware to attach the deserialized RPC context to the current request

func GetContext

func GetContext(ctx context.Context) *protocol.Context

Retrieve the RPC context of this request

func GetDelegation

func GetDelegation(ctx context.Context) *transport.StreamDelegate

Retrieve the delegation of this request

func GetErrorMeta

func GetErrorMeta(err twirp.Error) (cause, kv string)

func GetNode

func GetNode(ctx context.Context) *protocol.Node

Retrieve the node of this request

func Receive

func Receive(stream io.Reader, rr VTMarshaler) error

func Send

func Send(stream io.Writer, rr VTMarshaler) error

func SerializeContextHeader

func SerializeContextHeader(ctx context.Context, r http.Header)

Serialize RPC context as http headers

func WithContext

func WithContext(ctx context.Context, rpcCtx *protocol.Context) context.Context

Send RPC context for this request

func WithDelegation

func WithDelegation(ctx context.Context, delegate *transport.StreamDelegate) context.Context

Attach the delegation triggering the request

func WithNode

func WithNode(ctx context.Context, node *protocol.Node) context.Context

Connect to the provided node in this request

func WrapError

func WrapError(err error) error

func WrapErrorKV

func WrapErrorKV(key string, err error) error

Types

type ChordClient

type ChordClient interface {
	protocol.VNodeService
	protocol.KVService
	RatePer(interval time.Duration) float64
}

func DynamicChordClient

func DynamicChordClient(baseContext context.Context, chordTransport transport.Transport) ChordClient

DynamicChordClient returns a rpc client suitable for both VNodeService and KVService, with the destination set per call dynamically according to the destination in context. Use WithNode(ctx, node) at call site to dynamically dispatch.

type VTMarshaler

type VTMarshaler interface {
	MarshalToSizedBufferVT(dAtA []byte) (n int, err error)
	MarshalVT() (dAtA []byte, err error)
	UnmarshalVT(dAtA []byte) error
	SizeVT() int
}

Jump to

Keyboard shortcuts

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