rkgrpcinter

package
v1.2.25 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package rkgrpcinter provides common utility functions for middleware of grpc framework

Index

Constants

This section is empty.

Variables

View Source
var (
	LocalIp = zap.String("localIp", rkcommon.GetLocalIP())
	// LocalHostname read hostname from localhost
	LocalHostname = zap.String("localHostname", rkcommon.GetLocalHostname())
)
View Source
var RpcPayloadAppended = rpcPayloadAppended{}

RpcPayloadAppended a flag used in inner middleware

Functions

func AddToServerContextPayload

func AddToServerContextPayload(ctx context.Context, key interface{}, value interface{})

AddToServerContextPayload add k/v into payload injected into server side context

func ContainsServerPayload

func ContainsServerPayload(ctx context.Context) bool

ContainsServerPayload is payload injected into server side context?

func GetGrpcInfo

func GetGrpcInfo(fullMethod string) (grpcService, grpcMethod string)

GetGrpcInfo Extract grpc related information from fullMethod.

func GetGwInfo

func GetGwInfo(md metadata.MD) (gwMethod, gwPath, gwScheme, gwUserAgent string)

GetGwInfo Extract gateway related information from metadata.

func GetRemoteAddressSet

func GetRemoteAddressSet(ctx context.Context) (ip, port, netType string)

GetRemoteAddressSet Read remote Ip and port from metadata first.

func GetRemoteAddressSetFromMeta

func GetRemoteAddressSetFromMeta(md metadata.MD) (ip, port string)

GetRemoteAddressSetFromMeta Read remote Ip and port from metadata. If user enabled RK style gateway server mux option, then there would be bellow headers forwarded to grpc metadata 1: x-forwarded-method 2: x-forwarded-path 3: x-forwarded-scheme 4: x-forwarded-user-agent 5: x-forwarded-remote-addr

func GetServerContextPayload

func GetServerContextPayload(ctx context.Context) map[interface{}]interface{}

GetServerContextPayload get context payload injected into server side context

func GetServerPayloadKey added in v1.2.2

func GetServerPayloadKey() interface{}

GetServerPayloadKey get server payload key used in context.Context

func MergeAndDeduplicateSlice

func MergeAndDeduplicateSlice(src []string, target []string) []string

MergeAndDeduplicateSlice Merge src and targets and deduplicate

func MergeToOutgoingMD

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

MergeToOutgoingMD Merge md to context outgoing metadata.

func ToOptionsKey

func ToOptionsKey(entryName, rpcType string) string

ToOptionsKey Convert to optionsMap key with entry name and rpcType.

func WrapContextForServer

func WrapContextForServer(ctx context.Context) context.Context

WrapContextForServer Wrap server context.

Types

This section is empty.

Directories

Path Synopsis
Package rkgrpcauth is auth interceptor for grpc framework
Package rkgrpcauth is auth interceptor for grpc framework
Package rkgrpcctx provides utility functions deal with metadata in RPC context
Package rkgrpcctx provides utility functions deal with metadata in RPC context
Package rkgrpccsrf is a CSRF interceptor for grpc framework
Package rkgrpccsrf is a CSRF interceptor for grpc framework
log
zap
metrics
tracing

Jump to

Keyboard shortcuts

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