Class: Restate::Server::Handler
- Inherits:
-
Object
- Object
- Restate::Server::Handler
- Defined in:
- lib/restate/server/handler.rb
Overview
Rack-compatible application that handles Restate protocol requests. Designed to work with Falcon for HTTP/2 bidirectional streaming.
Routes:
GET /discover → service manifest
GET /health → health check
POST /invoke/:service/:handler → handler invocation
Defined Under Namespace
Classes: StreamingBody
Constant Summary collapse
- SDK_VERSION =
Internal::SDK_VERSION
- X_RESTATE_SERVER =
"restate-sdk-ruby/#{SDK_VERSION}".freeze
- LOGGER =
Logger.new($stdout, progname: 'Restate::Server::Handler')
Instance Method Summary collapse
-
#call(env) ⇒ Object
Rack interface.
-
#initialize(endpoint) ⇒ Handler
constructor
A new instance of Handler.
Constructor Details
#initialize(endpoint) ⇒ Handler
Returns a new instance of Handler.
24 25 26 27 |
# File 'lib/restate/server/handler.rb', line 24 def initialize(endpoint) @endpoint = endpoint @identity_verifier = Internal::IdentityVerifier.new(endpoint.identity_keys) end |
Instance Method Details
#call(env) ⇒ Object
Rack interface
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/restate/server/handler.rb', line 30 def call(env) path = env['PATH_INFO'] || '/' parsed = parse_path(path) case parsed[:type] when :health health_response when :discover handle_discover(env) when :invocation handle_invocation(env, parsed[:service], parsed[:handler]) else not_found_response end rescue StandardError => e LOGGER.error("Exception in Restate server: #{e.inspect}") LOGGER.error(e.backtrace&.join("\n")) if e.backtrace error_response(500, 'Internal server error') end |