class
GRPC::Server
- GRPC::Server
- Reference
- Object
Overview
Server hosts registered gRPC services and dispatches incoming RPCs.
Plain TCP example: server = GRPC::Server.new server.handle GreeterImpl.new server.listen "0.0.0.0", 50051
TLS example: server = GRPC::Server.new server.use_tls(cert: "server.crt", key: "server.key") server.handle GreeterImpl.new server.listen "0.0.0.0", 50051
Defined in:
grpc/server.crConstant Summary
-
LOGGER =
::Log.for(self)
Constructors
Instance Method Summary
-
#bind(address : String) : self
bind sets up the TCP listener without starting the serve loop.
-
#enable_health_checking(default_status : Grpc::Health::V1::HealthCheckResponse::ServingStatus = ::Grpc::Health::V1::HealthCheckResponse::ServingStatus::SERVING) : Health::Reporter
enable_health_checking registers the built-in health service and returns its reporter.
-
#enable_reflection : Reflection::Service
enable_reflection registers the built-in reflection service and returns it.
-
#handle(service : Service) : self
handle registers a service implementation with the server.
-
#intercept(interceptor : ServerInterceptor) : self
intercept registers a server-side interceptor.
-
#listen(host : String, port : Int32) : Nil
listen binds to the given host and port and starts serving.
-
#listen(host : String, port : String) : Nil
listen with port as a string.
-
#listen(address : String) : Nil
listen with a combined "host:port" address string.
-
#reflection_service? : Reflection::Service | Nil
Returns the registered reflection service if enabled.
-
#serve : Nil
serve starts the accept loop.
-
#start : Nil
start runs the server in a background fiber, returning immediately.
- #stop : Nil
-
#use_tls(cert : String, key : String) : self
use_tls configures the server to accept TLS connections.
-
#use_tls(context : OpenSSL::SSL::Context::Server) : self
use_tls with a pre-built OpenSSL context for full control over TLS settings.
Constructor Detail
Instance Method Detail
bind sets up the TCP listener without starting the serve loop. Call serve (or start for non-blocking) afterward.
enable_health_checking registers the built-in health service and returns its reporter. Calling this multiple times returns the same instance.
enable_reflection registers the built-in reflection service and returns it. Register FileDescriptorProto bytes on the returned service via add_file_descriptor.
handle registers a service implementation with the server.
intercept registers a server-side interceptor. Interceptors run outermost-first (first registered wraps all others). Must be called before listen/bind.
listen binds to the given host and port and starts serving. Blocks until stopped.
Returns the registered reflection service if enabled.
start runs the server in a background fiber, returning immediately. Useful for tests and embedded servers.
use_tls configures the server to accept TLS connections. cert is the path to the PEM-encoded certificate chain file. key is the path to the PEM-encoded private key file. Must be called before listen/bind.
use_tls with a pre-built OpenSSL context for full control over TLS settings.