Documentation ¶
Overview ¶
Package lile provides helper methods to quickly create RPC based services that have metrics, tracing and pub/sub support
Index ¶
- func AddGRPCGatewayHeader(header map[string]string)
- func AddGRPCGatewayOption(opt grpc.DialOption)
- func AddGRPCOption(opt grpc.ServerOption)
- func AddStreamInterceptor(sint grpc.StreamServerInterceptor)
- func AddUnaryInterceptor(unint grpc.UnaryServerInterceptor)
- func BaseCommand(serviceName, shortDescription string) *cobra.Command
- func ContextClientInterceptor() grpc.UnaryClientInterceptor
- func EnableCORS(opt ...handlers.CORSOption)
- func GrpcGatewayServer(r func(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...))
- func Name(n string)
- func NewTestServer(s *grpc.Server) (string, func())
- func Run() error
- func ServeGRPC() error
- func Server(r func(s *grpc.Server))
- func SetAddress(host string, port int)
- func SetTLS(serverCert, serverKey, clientKey, clientCert, caCert, serverName string)
- func Shutdown()
- func TestConn(addr string) *grpc.ClientConn
- func URLForService(name string) string
- type RegisterGrpcGatewayImpl
- type RegisterImplementation
- type Registry
- type ServerConfig
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddGRPCGatewayHeader ¶
add GRPCGatewayHeader
func AddStreamInterceptor ¶
func AddStreamInterceptor(sint grpc.StreamServerInterceptor)
AddStreamInterceptor adds a stream interceptor to the RPC server
func AddUnaryInterceptor ¶
func AddUnaryInterceptor(unint grpc.UnaryServerInterceptor)
AddUnaryInterceptor adds a unary interceptor to the RPC server
func BaseCommand ¶
BaseCommand provides the basic flags vars for running a service
func ContextClientInterceptor ¶
func ContextClientInterceptor() grpc.UnaryClientInterceptor
ContextClientInterceptor passes around headers for tracing and linkerd
func GrpcGatewayServer ¶
func GrpcGatewayServer(r func(ctx context.Context, mux *runtime.ServeMux, endpoint string, dopts []grpc.DialOption))
grpc gateway server
func NewTestServer ¶
NewTestServer is a helper function to create a gRPC server on a non-network socket and it returns the socket location and a func to call which starts the server
func Run ¶
func Run() error
Run is a blocking cmd to run the gRPC and metrics server. You should listen to os signals and call Shutdown() if you want a graceful shutdown or want to handle other goroutines
func SetTLS ¶
func SetTLS(serverCert, serverKey, clientKey, clientCert, caCert, serverName string)
Set TLS
func TestConn ¶
func TestConn(addr string) *grpc.ClientConn
TestConn is a connection that connects to a socket based connection
func URLForService ¶
URLForService returns a service URL via a registry or a simple DNS name if not available via the registry
Types ¶
type RegisterGrpcGatewayImpl ¶
type RegisterImplementation ¶
RegisterImplementation allows you to register your gRPC server
type Registry ¶
type Registry interface { // Register a service Register(s *Service) error // Deregister a service DeRegister(s *Service) error // Get a service by name Get(name string) (string, error) }
Registry is the interface to implement for external registry providers
type ServerConfig ¶
ServerConfig is a generic server configuration
func (*ServerConfig) Address ¶
func (c *ServerConfig) Address() string
Address Gets a logical addr for a ServerConfig
type Service ¶
type Service struct { ID string Name string //tls ServerCert string //server文件路径 ServerKey string //server路文件径 ClientKey string //文件路径 ClientCert string //文件路径 CACert string //文件路径 ServerName string //tls 对应name //cors Cors bool //是否跨域true 支持跨域,false: 不支持跨域 CORSOption []handlers.CORSOption // Interceptors UnaryInts []grpc.UnaryServerInterceptor StreamInts []grpc.StreamServerInterceptor // The RPC server implementation GRPCImplementation RegisterImplementation GRPCOptions []grpc.ServerOption //grpc-gateway implementation GRPCGatewayOption []grpc.DialOption GRPCGatewayImpl RegisterGrpcGatewayImpl GRPCGatewayHeader map[string]string // gRPC and Prometheus endpoints Config ServerConfig PrometheusConfig ServerConfig // Registry allows Lile to work with external registeries like // consul, zookeeper or similar Registry Registry // Private utils, exposed so they can be useful if needed ServiceListener net.Listener GRPCServer *grpc.Server PrometheusServer *http.Server }
Service is a gRPC based server with extra features
func NewService ¶
NewService creates a new service with a given name