Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrServerAlreadyRunning = errors.New("server is already running") ErrListenerNotSet = errors.New("listener is not set") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
func WithAddress ¶
WithAddress sets the address of the server and is used if no listener is set.
func WithGrpcServer ¶
func WithGrpcServer(s grpcServer) Option
WithGrpcServer sets the grpc server. For testing purposes.
func WithListener ¶
WithListener sets the listener for the server.
func WithReflection ¶
func WithReflection() Option
func WithServiceRegistrar ¶
func WithServiceRegistrar(r func(grpc.ServiceRegistrar)) Option
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func New ¶
New creates a new grpc server.
- If no listener is set, the server will create a new listener on the address.
- If no grpc server is set, the server will create a new grpc server.
- If reflection is enabled, the server will register the reflection service.
- If server registers are set, the server will register the services.
Example:
grpcserver.New( grpcserver.WithGrpcServer(grpc.NewServer(grpc.Creds(creds))), grpcserver.WithAddress(fmt.Sprintf(":%d", grpcPort)), grpcserver.WithServiceRegistrars(serviceRegistrars), )
Example with listener:
grpcserver.New( grpcserver.WithGrpcServer(grpc.NewServer(grpc.Creds(creds))), grpcserver.WithLIstener(lis), grpcserver.WithServiceRegistrars(serviceRegistrars), )
Click to show internal directories.
Click to hide internal directories.