In order to keep services running across different queries, the ServiceSyncRuntime type must outlive the queries it handles. The runtime must run in a single thread and does not implement Send (because the User{Contract,Service}Instance types used for the loaded_applications does not implement Send). Therefore, the current approach of spawn_blocking the runtime thread only before handling a query does not work.
Proposal
Make the service runtime run as an actor, executing on its own spawn_blocking thread and waiting for ServiceRuntimeRequests to handle. The thread is started by the ChainWorkerActor, in preparation for the next PR which will use the incoming chain worker requests to determine if the runtime should be restarted or not.
Test Plan
Existing CI tests should catch any regressions, as this is an internal refactor.
Release Plan
Nothing needed, because this is an internal refactor.
Motivation
In order to keep services running across different queries, the
ServiceSyncRuntime
type must outlive the queries it handles. The runtime must run in a single thread and does not implementSend
(because theUser{Contract,Service}Instance
types used for theloaded_applications
does not implementSend
). Therefore, the current approach ofspawn_blocking
the runtime thread only before handling a query does not work.Proposal
Make the service runtime run as an actor, executing on its own
spawn_blocking
thread and waiting forServiceRuntimeRequest
s to handle. The thread is started by theChainWorkerActor
, in preparation for the next PR which will use the incoming chain worker requests to determine if the runtime should be restarted or not.Test Plan
Existing CI tests should catch any regressions, as this is an internal refactor.
Release Plan
Nothing needed, because this is an internal refactor.
Links