Documentation ¶
Overview ¶
Package grpcsrv provides a default set of configuration for hosting a grpc server in a service.
Example ¶
package main import ( "context" "io/ioutil" "net/http" "time" "github.com/LUSHDigital/core/middleware/paginationmw" "github.com/LUSHDigital/core/workers/grpcsrv" "google.golang.org/grpc" ) var ctx context.Context func main() { srv := grpcsrv.New(&grpcsrv.Config{ Addr: ":8080", }, grpc.StreamInterceptor(paginationmw.StreamServerInterceptor), grpc.UnaryInterceptor(paginationmw.UnaryServerInterceptor), ) srv.Run(ctx, ioutil.Discard) }
Output:
Index ¶
Examples ¶
Constants ¶
View Source
const (
// Port is the default gRPC port used in examples.
Port = 50051
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Addr string
}
Config represents configuration for the GRPC server.
type Server ¶
type Server struct { Connection *grpc.Server Now func() time.Time // contains filtered or unexported fields }
Server represents a collection of functions for starting and running an RPC server.
func New ¶
func New(config *Config, options ...grpc.ServerOption) *Server
New sets up a new grpc server.
Click to show internal directories.
Click to hide internal directories.