Documentation ¶
Index ¶
- Constants
- Variables
- func CookieFromIncomingContext(ctx context.Context, name string) (*http.Cookie, error)
- func GetString(value *string) *wrapperspb.StringValue
- func SetCookie(ctx context.Context, cookie *http.Cookie) error
- func SetStatusCode(ctx context.Context, code int)
- func ToString(value *wrapperspb.StringValue) *string
- type ChainInterceptor
- type Gateway
- type GatewayOption
- type GatewayOptionFunc
- type Interceptor
Constants ¶
const (
// ContentType is a grpc content-type
ContentType = "application/grpc"
)
Variables ¶
var KeepaliveOption = grpc.KeepaliveParams(keepalive.ServerParameters{ MaxConnectionIdle: 5 * time.Minute, })
KeepaliveOption represents a keep alive option For more information have a look:
https://stackoverflow.com/questions/52993259/problem-with-grpc-setup-getting-an-intermittent-rpc-unavailable-error
var Match = cmux.HTTP2MatchHeaderFieldPrefixSendSettings("content-type", ContentType)
Match matches the request
Functions ¶
func CookieFromIncomingContext ¶
CookieFromIncomingContext returns the cookie
func GetString ¶
func GetString(value *string) *wrapperspb.StringValue
GetString converts to a string wrapper from a string pointer
func SetCookie ¶
SetCookie adds a Set-Cookie header to the provided server transport context. The provided cookie must have a valid Name. Invalid cookies may be silently dropped.
func SetStatusCode ¶
SetStatusCode sets the status code
func ToString ¶
func ToString(value *wrapperspb.StringValue) *string
ToString convert to a string pointer from wrapper
Types ¶
type ChainInterceptor ¶
type ChainInterceptor []Interceptor
ChainInterceptor creates a single interceptor out of a chain of many interceptors.
Execution is done in left-to-right order, including passing of context. For example ChainUnaryServer(one, two, three) will execute one before two before three, and three will see context changes of one and two.
func (ChainInterceptor) Stream ¶
func (ch ChainInterceptor) Stream(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error
Stream creates a single stream interceptor out of a chain of many interceptors.
func (ChainInterceptor) Unary ¶
func (ch ChainInterceptor) Unary(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)
Unary creates a single unary interceptor out of a chain of many interceptors.
type Gateway ¶
type Gateway struct { Server *grpc.Server Options []grpc.ServerOption }
Gateway represents a grpc server
func NewGateway ¶
func NewGateway(opts ...GatewayOption) *Gateway
NewGateway creates a new grpc server
type GatewayOption ¶
type GatewayOption interface {
Apply(*Gateway)
}
GatewayOption represents a gateway option
func WithChain ¶
func WithChain(chain ChainInterceptor) GatewayOption
WithChain sets the interceptor chain
type GatewayOptionFunc ¶
type GatewayOptionFunc func(*Gateway)
GatewayOptionFunc represnts a gateway option func
type Interceptor ¶
type Interceptor interface { Unary(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) Stream(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error }
Interceptor represents a grpc interface