rpc

package
v1.1.16 Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetadataKeyTrackingID         string = "tracking-id"
	MetadataKeyURI                string = "uri"
	MetadataCustomWebhookEndpoint string = "custom-webhook-endpoint"
)

Keys used for retrieving value from gRPC metadata

Variables

This section is empty.

Functions

func GetCustomWebhookEndpointFromContext

func GetCustomWebhookEndpointFromContext(ctx context.Context) string

func GetTrackingIDFromContext

func GetTrackingIDFromContext(ctx context.Context) string

func GetURIFromContext

func GetURIFromContext(ctx context.Context) string

func NewProxy

func NewProxy(opts ...ProxyOption) *proxy

NewProxy creates a RESTful proxy server that routes RESTful request to gRPC server

Types

type API

type API interface {
	Bind(server *grpc.Server)
}

API provides APIs for specific gRPC server

type Middleware

type Middleware interface {
	ServeHTTP(w http.ResponseWriter, req *http.Request, next http.HandlerFunc)
}

type Proxy

type Proxy interface {
	Bind(mux *runtime.ServeMux) error
}

Proxy provides APIs for specific gRPC server

type ProxyOption

type ProxyOption func(*proxy)

func AllowCORS

func AllowCORS(origins []string) ProxyOption

AllowCORS represents the CORS origins to setup for RESTful API

func HTTPServer

func HTTPServer(s *http.Server) ProxyOption

HTTPServer represents customized HTTP server to the proxy

func HttpMetrics added in v1.0.1

func HttpMetrics(opts ...metrics.Option) ProxyOption

func Middlewares

func Middlewares(mws ...Middleware) ProxyOption

Middlewares represents the HTTP middlwares to be used in this proxy

func Proxies

func Proxies(proxies ...Proxy) ProxyOption

Proxies represents the proxy API to be registered to the http server

type Server

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

Server represents a gRPC server

func NewServer

func NewServer(opts ...ServerOption) *Server

NewServer creates a gRPC server with pre-configured services

func (*Server) Serve

func (s *Server) Serve(l net.Listener) error

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) Shutdown

func (s *Server) Shutdown()

type ServerOption

type ServerOption func(*Server)

func APIs

func APIs(apis ...API) ServerOption

APIs to be registered to the RPC server

func Credentials

func Credentials(credentials *tls.Config) ServerOption

Credentials for the RPC server

func Metrics

func Metrics(metrics metrics.ServerMetrics) ServerOption

func SeverOptions added in v1.1.6

func SeverOptions(opts ...grpc.ServerOption) ServerOption

SeverOptions passes additional gRPC server options

func StreamInterceptors

func StreamInterceptors(interceptors ...grpc.StreamServerInterceptor) ServerOption

func UnaryInterceptors

func UnaryInterceptors(interceptors ...grpc.UnaryServerInterceptor) ServerOption

Directories

Path Synopsis
Code generated by mockery v1.0.0
Code generated by mockery v1.0.0

Jump to

Keyboard shortcuts

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