Documentation ¶
Index ¶
- Constants
- Variables
- func Current() *pb.VersionInfo
- func EncodeHeader(min, current uint32) string
- func FromContext(ctx context.Context) uint32
- func Negotiate(client, server *pb.VersionInfo_ProtocolVersion) (uint32, error)
- func ParseHeader(v string) (uint32, uint32, error)
- func StreamClientInterceptor(serverInfo *pb.VersionInfo) grpc.StreamClientInterceptor
- func UnaryClientInterceptor(serverInfo *pb.VersionInfo) grpc.UnaryClientInterceptor
- func WithContext(ctx context.Context, vsn uint32) context.Context
- type Type
Constants ¶
const ( HeaderClientApiProtocol = "client-api-protocol" HeaderClientEntrypointProtocol = "client-entrypoint-protocol" HeaderClientVersion = "client-version" )
Header keys.
Variables ¶
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 ¶
EncodeHeader creates a valid header value for the protocol version headers.
func FromContext ¶
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 ¶
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.