standard

package
v0.0.0-...-f367847 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 35 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Verbosity = 3

Verbosity is configuration that can be used to globally reduce logging chattiness of various aspect of the dgrpc middleware.

Accepted value is a scale from 0 to 5 (inclusively). A verbosity of 0 means really not verbose, while 5 means really realy verbose. It can be mostly seen as: `Fatal` (0), `Error` (1), `Warn` (2), `Info` (3), `Debug` (4) and `Trace` (5).

For now, this controls server logging of gRCP code to zap level which reduce some of the case into `INFO` level and some more like `OK` on `DEBUG` level.

Functions

func SetupTracingInterceptors

func SetupTracingInterceptors(logger *zap.Logger, overrideTraceID bool) (grpc.UnaryServerInterceptor, grpc.StreamServerInterceptor)

Types

type Resolver

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

Resolver works by launching a ConnStateManager function when Build() is called.

func (*Resolver) Build

func (*Resolver) Close

func (r *Resolver) Close()

Close will close the context

func (*Resolver) ResolveNow

func (r *Resolver) ResolveNow(resolver.ResolveNowOptions)

ResolveNow is a noop for Resolver.

func (*Resolver) Scheme

func (r *Resolver) Scheme() string

type StandardServer

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

StandardServer is actually a thin wrapper struct around an `*http.StandardServer` and a `*grpc.StandardServer` to more easily managed how we deploy our gRPC service.

You first create a NewServer2(...) with the various option we provide for how stuff should be wired together. You then `Launch` it and the wrapper takes care of doing the hard code of correctly managing the lifecyle of everything.

Here how various options affects the behavior of the `Launch` method. - WithSecure(SecuredByX509KeyPair(..., ...)) => Starts a TLS HTTP2 endpoint to serve the gRPC over an encrypted connection - WithHealthCheck(check, HealthCheckOverHTTP) => Offers an HTTP endpoint `/healthz` to query the health check over HTTP

func NewServer

func NewServer(options *server.Options) *StandardServer

NewServer

The server is easily configurable by providing various `dgrpc.Option` options to change the behaviour of the server.

This new server is opinionated towards dfuse needs (for example supporting the health check over HTTP) but is generic and configurable enough to used by any organization.

Some elements are "hard-coded" but we are willing to open more the configuration if requested by the community.

**Important** We use `NewServer2` name temporarily while we test the concept, when

we are statisfied with the interface and feature set, the actual
`NewServer` will be replaced by this implementation.

func (*StandardServer) GrpcServer

func (s *StandardServer) GrpcServer() *grpc.Server

func (*StandardServer) Launch

func (s *StandardServer) Launch(serverListenerAddress string)

Launch starts all the necessary elements (gRPC StandardServer, HTTP StandardServer if required, etc.) and controls their lifecycle via the internal shutter.

This should be called in a Goroutine `go server.Launch("localhost:9000")` and `server.Shutdown()` should be called later on to stop gracefully the server.

func (*StandardServer) OnTerminated

func (s *StandardServer) OnTerminated(f func(err error))

func (*StandardServer) RegisterService

func (s *StandardServer) RegisterService(f func(gs grpc.ServiceRegistrar))

RegisterService can be used to register your own gRPC service handler.

server := dgrpc.NewServer2(...)
server.RegisterService(func (gs *grpc.StandardServer) {
  pbapi.RegisterStateService(gs, implementation)
})

**Note**

func (*StandardServer) ServiceRegistrar

func (s *StandardServer) ServiceRegistrar() grpc.ServiceRegistrar

func (*StandardServer) Shutdown

func (s *StandardServer) Shutdown(timeout time.Duration)

Jump to

Keyboard shortcuts

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