grpcutil

package
v1.58.0-dev Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package grpcutil provides utility functions used across the gRPC codebase.

Index

Constants

This section is empty.

Variables

View Source
var RegisteredCompressorNames []string

RegisteredCompressorNames holds names of the registered compressors.

Functions

func ContentSubtype added in v1.31.0

func ContentSubtype(contentType string) (string, bool)

ContentSubtype returns the content-subtype for the given content-type. The given content-type must be a valid content-type that starts with "application/grpc". A content-subtype will follow "application/grpc" after a "+" or ";". See https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests for more details.

If contentType is not a valid content-type for gRPC, the boolean will be false, otherwise true. If content-type == "application/grpc", "application/grpc+", or "application/grpc;", the boolean will be true, but no content-subtype will be returned.

contentType is assumed to be lowercase already.

func ContentType added in v1.31.0

func ContentType(contentSubtype string) string

ContentType builds full content type with the given sub-type.

contentSubtype is assumed to be lowercase

func EncodeDuration added in v1.31.0

func EncodeDuration(t time.Duration) string

EncodeDuration encodes the duration to the format grpc-timeout header accepts.

https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests

func ExtraMetadata added in v1.31.0

func ExtraMetadata(ctx context.Context) (md metadata.MD, ok bool)

ExtraMetadata returns the incoming metadata in ctx if it exists. The returned MD should not be modified. Writing to it may cause races. Modification should be made to copies of the returned MD.

func FullMatchWithRegex added in v1.42.0

func FullMatchWithRegex(re *regexp.Regexp, text string) bool

FullMatchWithRegex returns whether the full text matches the regex provided.

func IsCompressorNameRegistered added in v1.51.0

func IsCompressorNameRegistered(name string) bool

IsCompressorNameRegistered returns true when name is available in registry.

func ParseMethod added in v1.30.0

func ParseMethod(methodName string) (service, method string, _ error)

ParseMethod splits service and method from the input. It expects format "/service/method".

func RegisteredCompressors added in v1.51.0

func RegisteredCompressors() string

RegisteredCompressors returns a string of registered compressor names separated by comma.

func WithExtraMetadata added in v1.31.0

func WithExtraMetadata(ctx context.Context, md metadata.MD) context.Context

WithExtraMetadata creates a new context with incoming md attached.

Types

This section is empty.

Jump to

Keyboard shortcuts

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