Class AbstractGrpcServerFactory<T extends ServerBuilder<T>>
java.lang.Object
net.devh.boot.grpc.server.serverfactory.AbstractGrpcServerFactory<T>
- Type Parameters:
T
- The type of builder used by this factory.
- All Implemented Interfaces:
GrpcServerFactory
- Direct Known Subclasses:
InProcessGrpcServerFactory
,NettyGrpcServerFactory
,ShadedNettyGrpcServerFactory
public abstract class AbstractGrpcServerFactory<T extends ServerBuilder<T>>
extends Object
implements GrpcServerFactory
Abstract factory for grpc servers.
- Since:
- 5/17/16
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final GrpcServerProperties
protected final List<GrpcServerConfigurer>
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractGrpcServerFactory
(GrpcServerProperties properties, List<GrpcServerConfigurer> serverConfigurers) Creates a new server factory with the given properties. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addService
(GrpcServiceDefinition service) Adds the given grpc service definition to this factory.protected void
Configures the given server builder.protected void
configureConnectionLimits
(T builder) Configures the keep alive options that should be used by the server.protected void
configureKeepAlive
(T builder) Configures the keep alive options that should be used by the server.protected void
configureLimits
(T builder) Configures limits such as max message sizes that should be used by the server.protected void
configureSecurity
(T builder) Configures the security options that should be used by the server.protected void
configureServices
(T builder) Configures the services that should be served by the server.Creates a new grpc server with the stored options.Gets the IP address the created server will be bound to.int
getPort()
Gets the local port the created server will use to listen to requests.protected abstract T
Creates a new server builder.
-
Field Details
-
properties
-
serverConfigurers
-
-
Constructor Details
-
AbstractGrpcServerFactory
protected AbstractGrpcServerFactory(GrpcServerProperties properties, List<GrpcServerConfigurer> serverConfigurers) Creates a new server factory with the given properties.- Parameters:
properties
- The properties used to configure the server.serverConfigurers
- The server configurers to use. Can be empty.
-
-
Method Details
-
createServer
Description copied from interface:GrpcServerFactory
Creates a new grpc server with the stored options. The entire lifecycle management of the server should be managed by the calling class. This includes starting and stopping the server.- Specified by:
createServer
in interfaceGrpcServerFactory
- Returns:
- The newly created grpc server.
-
newServerBuilder
Creates a new server builder.- Returns:
- The newly created server builder.
-
configure
Configures the given server builder. This method can be overwritten to add features that are not yet supported by this library or use aGrpcServerConfigurer
instead.- Parameters:
builder
- The server builder to configure.
-
configureServices
Configures the services that should be served by the server.- Parameters:
builder
- The server builder to configure.
-
configureKeepAlive
Configures the keep alive options that should be used by the server.- Parameters:
builder
- The server builder to configure.
-
configureConnectionLimits
Configures the keep alive options that should be used by the server.- Parameters:
builder
- The server builder to configure.
-
configureSecurity
Configures the security options that should be used by the server.- Parameters:
builder
- The server builder to configure.
-
configureLimits
Configures limits such as max message sizes that should be used by the server.- Parameters:
builder
- The server builder to configure.
-
getAddress
Description copied from interface:GrpcServerFactory
Gets the IP address the created server will be bound to.- Specified by:
getAddress
in interfaceGrpcServerFactory
- Returns:
- The IP address the server will be bound to.
-
getPort
public int getPort()Description copied from interface:GrpcServerFactory
Gets the local port the created server will use to listen to requests.- Specified by:
getPort
in interfaceGrpcServerFactory
- Returns:
- Gets the local port the server will use.
-
addService
Description copied from interface:GrpcServerFactory
Adds the given grpc service definition to this factory. The created server will serve the services described by these definitions.Note: Adding a service does not effect servers that have already been created.
- Specified by:
addService
in interfaceGrpcServerFactory
- Parameters:
service
- The service to add to the grpc server.
-