Documentation
¶
Index ¶
- Constants
- Variables
- func BoolValue(val string) (*wrapperspb.BoolValue, error)
- func BytesValue(val string) (*wrapperspb.BytesValue, error)
- func DoubleValue(val string) (*wrapperspb.DoubleValue, error)
- func Duration(val string) (*durationpb.Duration, error)
- func Enum(val string, enumValMap map[string]int32) (int32, error)
- func EnumP(val string, enumValMap map[string]int32) (*int32, error)
- func EnumSlice(val, sep string, enumValMap map[string]int32) ([]int32, error)
- func FloatValue(val string) (*wrapperspb.FloatValue, error)
- func HTTPPathPattern(ctx context.Context) (string, bool)
- func Int32Value(val string) (*wrapperspb.Int32Value, error)
- func Int64Value(val string) (*wrapperspb.Int64Value, error)
- func NewClient(addr string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
- func NewClientTLS(addr string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
- func NewServerMetadataContext(ctx context.Context, md ServerMetadata) context.Context
- func RPCMethod(ctx context.Context) (string, bool)
- func ReConnect(v interface{}, getEndPort func() string, opts []grpc.DialOption) func() error
- func Register(code ErrCode, msg string)
- func StringValue(val string) (*wrapperspb.StringValue, error)
- func Timestamp(val string) (*timestamppb.Timestamp, error)
- func UInt32Value(val string) (*wrapperspb.UInt32Value, error)
- func UInt64Value(val string) (*wrapperspb.UInt64Value, error)
- type AnnotateContextOption
- type ErrCode
- type ErrResp
- type GRPCStatus
- type ServerMetadata
- type ServerTransportStream
- func (s *ServerTransportStream) Method() string
- func (s *ServerTransportStream) SendHeader(md metadata.MD) error
- func (s *ServerTransportStream) ServerMetadata() ServerMetadata
- func (s *ServerTransportStream) SetHeader(md metadata.MD) error
- func (s *ServerTransportStream) SetTrailer(md metadata.MD) error
- type Unmarshaler
Constants ¶
const ( SysErr = ErrCode(-1) Success = ErrCode(codes.OK) Canceled = ErrCode(codes.Canceled) Unknown = ErrCode(codes.Unknown) InvalidArgument = ErrCode(codes.InvalidArgument) DeadlineExceeded = ErrCode(codes.DeadlineExceeded) NotFound = ErrCode(codes.NotFound) AlreadyExists = ErrCode(codes.AlreadyExists) PermissionDenied = ErrCode(codes.PermissionDenied) ResourceExhausted = ErrCode(codes.ResourceExhausted) FailedPrecondition = ErrCode(codes.FailedPrecondition) Aborted = ErrCode(codes.Aborted) OutOfRange = ErrCode(codes.OutOfRange) Unimplemented = ErrCode(codes.Unimplemented) Internal = ErrCode(codes.Internal) DataLoss = ErrCode(codes.DataLoss) Unauthenticated = ErrCode(codes.Unauthenticated) )
const MetadataHeaderPrefix = "Grpc-Metadata-"
MetadataHeaderPrefix is the http prefix that represents custom metadata parameters to or from a gRPC call.
const MetadataPrefix = "Grpc-Gateway-"
MetadataPrefix is prepended to permanent HTTP header keys (as specified by the IANA) when added to the gRPC context.
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 ¶
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.
var InternalMD = &metadata.MD{httpx.HeaderInternal: []string{"true"}}
var ReConnectMap = make(map[string]func() error)
这里的key值应该取什么
Functions ¶
func BoolValue ¶
func BoolValue(val string) (*wrapperspb.BoolValue, error)
BoolValue well-known type support as wrapper around bool type
func BytesValue ¶
func BytesValue(val string) (*wrapperspb.BytesValue, error)
BytesValue well-known type support as wrapper around bytes[] type
func DoubleValue ¶
func DoubleValue(val string) (*wrapperspb.DoubleValue, error)
DoubleValue well-known type support as wrapper around float64 type
func Duration ¶
func Duration(val string) (*durationpb.Duration, error)
Duration converts the given string into a timestamp.Duration.
func Enum ¶
Enum converts the given string into an int32 that should be type casted into the correct enum proto type.
func EnumP ¶ added in v1.6.2
EnumP converts the given string into an int32 pointer that should be type casted into the correct enum proto type.
func EnumSlice ¶
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 FloatValue ¶
func FloatValue(val string) (*wrapperspb.FloatValue, error)
FloatValue well-known type support as wrapper around float32 type
func HTTPPathPattern ¶
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 Int32Value ¶
func Int32Value(val string) (*wrapperspb.Int32Value, error)
Int32Value well-known type support as wrapper around int32 type
func Int64Value ¶
func Int64Value(val string) (*wrapperspb.Int64Value, error)
Int64Value well-known type support as wrapper around int64 type
func NewClient ¶
func NewClient(addr string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
func NewClientTLS ¶ added in v1.3.20
func NewClientTLS(addr string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
func NewServerMetadataContext ¶
func NewServerMetadataContext(ctx context.Context, md ServerMetadata) context.Context
NewServerMetadataContext creates a new context with ServerMetadata
func RPCMethod ¶
RPCMethod returns the method string for the server context. The returned string is in the format of "/package.service/method".
func ReConnect ¶
func ReConnect(v interface{}, getEndPort func() string, opts []grpc.DialOption) func() error
func StringValue ¶
func StringValue(val string) (*wrapperspb.StringValue, error)
StringValue well-known type support as wrapper around string type
func Timestamp ¶
func Timestamp(val string) (*timestamppb.Timestamp, error)
Timestamp converts the given RFC3339 formatted string into a timestamp.Timestamp.
func UInt32Value ¶
func UInt32Value(val string) (*wrapperspb.UInt32Value, error)
UInt32Value well-known type support as wrapper around uint32 type
func UInt64Value ¶
func UInt64Value(val string) (*wrapperspb.UInt64Value, error)
UInt64Value well-known type support as wrapper around uint64 type
Types ¶
type AnnotateContextOption ¶
func WithHTTPPathPattern ¶
func WithHTTPPathPattern(pattern string) AnnotateContextOption
type ErrCode ¶
func (ErrCode) GRPCStatus ¶
type ErrResp ¶ added in v1.3.9
func ErrRespFrom ¶ added in v1.6.6
func NewErrResp ¶ added in v1.6.6
func (*ErrResp) GRPCStatus ¶ added in v1.3.9
func (*ErrResp) MarshalJSON ¶ added in v1.3.9
type GRPCStatus ¶
type ServerMetadata ¶
ServerMetadata consists of metadata sent from gRPC server.
func ServerMetadataFromContext ¶
func ServerMetadataFromContext(ctx context.Context) (md ServerMetadata, ok bool)
ServerMetadataFromContext returns the ServerMetadata in ctx
type ServerTransportStream ¶
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) Method ¶
func (s *ServerTransportStream) Method() string
Method returns the method for the stream.
func (*ServerTransportStream) SendHeader ¶
func (s *ServerTransportStream) SendHeader(md metadata.MD) error
SendHeader sets the header metadata.
func (*ServerTransportStream) ServerMetadata ¶ added in v1.5.1
func (s *ServerTransportStream) ServerMetadata() ServerMetadata
Header returns the server metadata of the stream.
func (*ServerTransportStream) SetHeader ¶
func (s *ServerTransportStream) SetHeader(md metadata.MD) error
SetHeader sets the header metadata.
func (*ServerTransportStream) SetTrailer ¶
func (s *ServerTransportStream) SetTrailer(md metadata.MD) error
SetTrailer sets the trailer metadata.
type Unmarshaler ¶ added in v1.6.6
var (
DefaultUnmarshaler Unmarshaler = &protojson.UnmarshalOptions{}
)