protocolversion

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2022 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderClientApiProtocol        = "client-api-protocol"
	HeaderClientEntrypointProtocol = "client-entrypoint-protocol"
	HeaderClientVersion            = "client-version"
)

Header keys.

Variables

View Source
var (
	ErrClientOutdated = errors.New(strings.TrimSpace(`
The client's supported protocol version is not understood by the server.

This means that the client is too outdated for the server. To solve this,
the client must be upgraded to a newer version.
`))

	ErrServerOutdated = errors.New(strings.TrimSpace(`
The server's minimum advertised protocol version is too outdated for the client.

This means that the client being run is newer than the server and the
API has changed significantly enough that this client can no longer communicate
to this server.

To solve this, either downgrade the client or upgrade the server. Please read
any upgrade guides prior to doing this to ensure a safe transition.
`))
)

Functions

func Current

func Current() *pb.VersionInfo

Current returns the current protocol version information.

func EncodeHeader

func EncodeHeader(min, current uint32) string

EncodeHeader creates a valid header value for the protocol version headers.

func FromContext

func FromContext(ctx context.Context) uint32

FromContext retrieves the protocol version from the context, or returns zero if no version was present.

func Negotiate

func Negotiate(client, server *pb.VersionInfo_ProtocolVersion) (uint32, error)

Negotiate takes two protocol versions and determines the value to use. If negotiation is impossible, an error is returned. The error value is one of the exported variables in this file.

func ParseHeader

func ParseHeader(v string) (uint32, uint32, error)

ParseHeader parses header values containing minimum and current protocol version numbers. This returns an error if parsing fails for reason, including blank values.

func StreamClientInterceptor

func StreamClientInterceptor(serverInfo *pb.VersionInfo) grpc.StreamClientInterceptor

StreamClientInterceptor returns an interceptor for the client to set the proper headers for stream APIs.

func UnaryClientInterceptor

func UnaryClientInterceptor(serverInfo *pb.VersionInfo) grpc.UnaryClientInterceptor

UnaryClientInterceptor returns an interceptor for the client to set the proper headers based on the attached VersionInfo. The VersionInfo is misnamed in this case and represents the client info.

func WithContext

func WithContext(ctx context.Context, vsn uint32) context.Context

WithContext stores the protocol version in the context.

Types

type Type

type Type uint8

Type is the enum of protocol version types.

const (
	Invalid    Type = iota // invalid
	Api                    // api
	Entrypoint             // entrypoint
)

func (Type) String

func (i Type) String() string

Jump to

Keyboard shortcuts

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