class Application < Async::Service::Managed::Service
- Inherits from
Async::Service::Managed::Service
Runs the Laiya API application on Async::HTTP::Server.
Definitions
def start
Bind the service endpoint when the service starts.
Signature
-
returns
Nil The result of the superclass start hook.
Implementation
def start
super
@endpoint = @evaluator.endpoint
@bound_endpoint = Sync{@endpoint.bound}
end
def stop
Close the bound endpoint and API application when stopping.
Signature
-
returns
Nil The result of the superclass stop hook.
Implementation
def stop
@bound_endpoint&.close
@application&.close
super
end
def run(instance, evaluator)
Run one Async HTTP server instance.
Signature
-
parameter
instanceObject The managed service instance.
-
parameter
evaluatorObject The service environment evaluator.
-
returns
Object The running HTTP server task.
Implementation
def run(instance, evaluator)
@application = evaluator.application
server = Async::HTTP::Server.new(
@application,
@bound_endpoint,
protocol: @endpoint.protocol,
scheme: @endpoint.scheme,
)
return server.run
end