grpc

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const MetadataHeaderPrefix = "Grpc-Metadata-"

MetadataHeaderPrefix is the http prefix that represents custom metadata parameters to or from a gRPC call.

View Source
const MetadataPrefix = "grpcgateway-"

MetadataPrefix is prepended to permanent HTTP header keys (as specified by the IANA) when added to the gRPC context.

View Source
const MetadataTrailerPrefix = "Grpc-Trailer-"

MetadataTrailerPrefix is prepended to gRPC metadata as it is converted to HTTP headers in a response handled by grpc-gateway

Variables

View Source
var ClientConns = make(clientConns)
View Source
var DefaultContextTimeout = 0 * time.Second

DefaultContextTimeout is used for gRPC call context.WithTimeout whenever a Grpc-Timeout inbound header isn't present. If the value is 0 the sent `context` will not have a timeout.

View Source
var Internal = &metadata.MD{httpi.HeaderInternal: []string{"true"}}

Functions

func Bool added in v1.5.11

func Bool(val string) (bool, error)

Bool converts the given string representation of a boolean value into bool.

func BoolSlice added in v1.5.11

func BoolSlice(val, sep string) ([]bool, error)

BoolSlice converts 'val' where individual booleans are separated by 'sep' into a bool slice.

func BoolValue added in v1.5.11

func BoolValue(val string) (*wrapperspb.BoolValue, error)

BoolValue well-known type support as wrapper around bool type

func Bytes added in v1.5.11

func Bytes(val string) ([]byte, error)

Bytes converts the given string representation of a byte sequence into a slice of bytes A bytes sequence is encoded in URL-safe base64 without padding

func BytesSlice added in v1.5.11

func BytesSlice(val, sep string) ([][]byte, error)

BytesSlice converts 'val' where individual bytes sequences, encoded in URL-safe base64 without padding, are separated by 'sep' into a slice of bytes slices slice.

func BytesValue added in v1.5.11

func BytesValue(val string) (*wrapperspb.BytesValue, error)

BytesValue well-known type support as wrapper around bytes[] type

func ClientConnsClose

func ClientConnsClose() error

func DoubleValue added in v1.5.11

func DoubleValue(val string) (*wrapperspb.DoubleValue, error)

DoubleValue well-known type support as wrapper around float64 type

func Duration added in v1.5.11

func Duration(val string) (*durationpb.Duration, error)

Duration converts the given string into a timestamp.Duration.

func Enum added in v1.5.11

func Enum(val string, enumValMap map[string]int32) (int32, error)

Enum converts the given string into an int32 that should be type casted into the correct enum proto type.

func EnumSlice added in v1.5.11

func EnumSlice(val, sep string, enumValMap map[string]int32) ([]int32, error)

EnumSlice converts 'val' where individual enums are separated by 'sep' into a int32 slice. Each individual int32 should be type casted into the correct enum proto type.

func Float32 added in v1.5.11

func Float32(val string) (float32, error)

Float32 converts the given string representation of a floating point number into float32.

func Float32Slice added in v1.5.11

func Float32Slice(val, sep string) ([]float32, error)

Float32Slice converts 'val' where individual floating point numbers are separated by 'sep' into a float32 slice.

func Float64 added in v1.5.11

func Float64(val string) (float64, error)

Float64 converts the given string representation into representation of a floating point number into float64.

func Float64Slice added in v1.5.11

func Float64Slice(val, sep string) ([]float64, error)

Float64Slice converts 'val' where individual floating point numbers are separated by 'sep' into a float64 slice.

func FloatValue added in v1.5.11

func FloatValue(val string) (*wrapperspb.FloatValue, error)

FloatValue well-known type support as wrapper around float32 type

func HTTPPathPattern added in v1.5.11

func HTTPPathPattern(ctx context.Context) (string, bool)

HTTPPathPattern returns the HTTP path pattern string relating to the HTTP handler, if one exists. The format of the returned string is defined by the google.api.http path template type.

func Int32 added in v1.5.11

func Int32(val string) (int32, error)

Int32 converts the given string representation of an integer into int32.

func Int32Slice added in v1.5.11

func Int32Slice(val, sep string) ([]int32, error)

Int32Slice converts 'val' where individual integers are separated by 'sep' into a int32 slice.

func Int32Value added in v1.5.11

func Int32Value(val string) (*wrapperspb.Int32Value, error)

Int32Value well-known type support as wrapper around int32 type

func Int64 added in v1.5.11

func Int64(val string) (int64, error)

Int64 converts the given string representation of an integer into int64.

func Int64Slice added in v1.5.11

func Int64Slice(val, sep string) ([]int64, error)

Int64Slice converts 'val' where individual integers are separated by 'sep' into a int64 slice.

func Int64Value added in v1.5.11

func Int64Value(val string) (*wrapperspb.Int64Value, error)

Int64Value well-known type support as wrapper around int64 type

func NewClient added in v1.5.11

func NewClient(addr string, opts ...grpc.DialOption) (*grpc.ClientConn, error)

func NewServerMetadataContext added in v1.5.11

func NewServerMetadataContext(ctx context.Context, md ServerMetadata) context.Context

NewServerMetadataContext creates a new context with ServerMetadata

func NewTLSClient added in v1.5.11

func NewTLSClient(addr string, opts ...grpc.DialOption) (*grpc.ClientConn, error)

func RPCMethod added in v1.5.11

func RPCMethod(ctx context.Context) (string, bool)

RPCMethod returns the method string for the server context. The returned string is in the format of "/package.service/method".

func String added in v1.5.11

func String(val string) (string, error)

String just returns the given string. It is just for compatibility to other types.

func StringSlice added in v1.5.11

func StringSlice(val, sep string) ([]string, error)

StringSlice converts 'val' where individual strings are separated by 'sep' into a string slice.

func StringValue added in v1.5.11

func StringValue(val string) (*wrapperspb.StringValue, error)

StringValue well-known type support as wrapper around string type

func Timestamp added in v1.5.11

func Timestamp(val string) (*timestamppb.Timestamp, error)

Timestamp converts the given RFC3339 formatted string into a timestamp.Timestamp.

func UInt32Value added in v1.5.11

func UInt32Value(val string) (*wrapperspb.UInt32Value, error)

UInt32Value well-known type support as wrapper around uint32 type

func UInt64Value added in v1.5.11

func UInt64Value(val string) (*wrapperspb.UInt64Value, error)

UInt64Value well-known type support as wrapper around uint64 type

func Uint32 added in v1.5.11

func Uint32(val string) (uint32, error)

Uint32 converts the given string representation of an integer into uint32.

func Uint32Slice added in v1.5.11

func Uint32Slice(val, sep string) ([]uint32, error)

Uint32Slice converts 'val' where individual integers are separated by 'sep' into a uint32 slice.

func Uint64 added in v1.5.11

func Uint64(val string) (uint64, error)

Uint64 converts the given string representation of an integer into uint64.

func Uint64Slice added in v1.5.11

func Uint64Slice(val, sep string) ([]uint64, error)

Uint64Slice converts 'val' where individual integers are separated by 'sep' into a uint64 slice.

Types

type AnnotateContextOption added in v1.5.11

type AnnotateContextOption func(ctx context.Context) context.Context

func WithHTTPPathPattern added in v1.5.11

func WithHTTPPathPattern(pattern string) AnnotateContextOption

type ServerMetadata added in v1.5.11

type ServerMetadata struct {
	HeaderMD  metadata.MD
	TrailerMD metadata.MD
}

ServerMetadata consists of metadata sent from gRPC server.

func ServerMetadataFromContext added in v1.5.11

func ServerMetadataFromContext(ctx context.Context) (md ServerMetadata, ok bool)

ServerMetadataFromContext returns the ServerMetadata in ctx

type ServerTransportStream added in v1.5.11

type ServerTransportStream struct {
	// contains filtered or unexported fields
}

ServerTransportStream implements grpc.ServerTransportStream. It should only be used by the generated files to support grpc.SendHeader outside of gRPC server use.

func (*ServerTransportStream) Header added in v1.5.11

func (s *ServerTransportStream) Header() metadata.MD

Header returns the header metadata of the stream.

func (*ServerTransportStream) Method added in v1.5.11

func (s *ServerTransportStream) Method() string

Method returns the method for the stream.

func (*ServerTransportStream) SendHeader added in v1.5.11

func (s *ServerTransportStream) SendHeader(md metadata.MD) error

SendHeader sets the header metadata.

func (*ServerTransportStream) SetHeader added in v1.5.11

func (s *ServerTransportStream) SetHeader(md metadata.MD) error

SetHeader sets the header metadata.

func (*ServerTransportStream) SetTrailer added in v1.5.11

func (s *ServerTransportStream) SetTrailer(md metadata.MD) error

SetTrailer sets the trailer metadata.

func (*ServerTransportStream) Trailer added in v1.5.11

func (s *ServerTransportStream) Trailer() metadata.MD

Trailer returns the cached trailer metadata.

Directories

Path Synopsis
gin
web
`grpcweb` implements the gRPC-Web spec as a wrapper around a gRPC-Go Server.
`grpcweb` implements the gRPC-Web spec as a wrapper around a gRPC-Go Server.

Jump to

Keyboard shortcuts

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