Documentation ¶
Index ¶
- Variables
- func LoadTLSCredentials(CaCertFile string, ServerKeyFile string, ServerCertFile string) (credentials.TransportCredentials, error)
- func MarshalMessageBody(body interface{}) ([]byte, error)
- func Obfuscate(input string, edgesLength int) string
- func SplitMethodAndPackage(fullMethodName string) (packageAndService string, methodName string)
- type ErrorMapper
- type MDTraceCarrier
- type ProtobufHTTPClient
Constants ¶
This section is empty.
Variables ¶
var DefaultProtobufHTTPClient = CreateProtobufHTTPClient(nil, nil, nil)
DefaultProtobufHTTPClient uses default http Client, error mapper and marshaller
Functions ¶
func LoadTLSCredentials ¶
func LoadTLSCredentials(CaCertFile string, ServerKeyFile string, ServerCertFile string) (credentials.TransportCredentials, error)
func MarshalMessageBody ¶
MarshalMessageBody convenience method to marshal different interfaces into JSON
func Obfuscate ¶
Obfuscate is a helper function to obfuscate a string, used mostly to hide passwords, etc
func SplitMethodAndPackage ¶
SplitMethodAndPackage is a helper method to split gRPC `package.service/method`
Types ¶
type ErrorMapper ¶
ErrorMapper is a map function that maps HTTP Status Code into its gRPC counter part.
type MDTraceCarrier ¶
MDTraceCarrier is an implementation for Tracing carrier, it will hold traceID, etc
func (MDTraceCarrier) ForeachKey ¶
func (md MDTraceCarrier) ForeachKey(handler func(key, value string) error) error
ForeachKey part of the Carrier interface
func (MDTraceCarrier) Set ¶
func (md MDTraceCarrier) Set(key, value string)
Set part of the Carrier interface
type ProtobufHTTPClient ¶
type ProtobufHTTPClient interface { // Example: // var response *pbpkg.ResponseMessage // var request = &pbpkg.RequestMessage{Name: "test"} // err := Do(ctx, http.MethodPost, "http://host/path", request, &response) // // Error returned will be of type `(*status.Status).Err()` meaning it will be a gRPC type error. // // Note: // you can pass `nil` as the last parameter if you don't want to unmarshal HTTP response body. // or you know it's going to be empty == EOF // err := Do(ctx, http.MethodPost, "http://host/path", request, nil) Do(ctx context.Context, method, url string, in proto.Message, out interface{}) error }
ProtobufHTTPClient is a helper util in situations where you want to call a REST API, but you have all the definitions as Protobuf.
func CreateProtobufHTTPClient ¶
func CreateProtobufHTTPClient(client *http.Client, errorMapper ErrorMapper, marshaller runtime.Marshaler) ProtobufHTTPClient
CreateProtobufHTTPClient Creates a custom Protobuf aware HTTP client