pub struct ModuleHost {
pub info: Arc<ModuleInfo>,
/* private fields */
}Fields§
§info: Arc<ModuleInfo>Implementations§
Source§impl ModuleHost
impl ModuleHost
pub fn info(&self) -> &ModuleInfo
pub fn subscriptions(&self) -> &ModuleSubscriptions
Sourcepub async fn on_module_thread<F, R>(
&self,
label: &str,
f: F,
) -> Result<R, Error>
pub async fn on_module_thread<F, R>( &self, label: &str, f: F, ) -> Result<R, Error>
Run a function on the JobThread for this module.
This would deadlock if it is called within another call to on_module_thread.
Since this is async, and f is sync, deadlocking shouldn’t be a problem.
pub async fn disconnect_client(&self, client_id: ClientActorId)
Sourcepub async fn call_identity_connected(
&self,
caller_identity: Identity,
caller_connection_id: ConnectionId,
) -> Result<(), ClientConnectedError>
pub async fn call_identity_connected( &self, caller_identity: Identity, caller_connection_id: ConnectionId, ) -> Result<(), ClientConnectedError>
Invoke the module’s client_connected reducer, if it has one,
and insert a new row into st_client for (caller_identity, caller_connection_id).
The host inspects st_client when restarting in order to run client_disconnected reducers
for clients that were connected at the time when the host went down.
This ensures that every client connection eventually has client_disconnected invoked.
If this method returns Ok, then the client connection has been approved,
and the new row has been inserted into st_client.
If this method returns Err, then the client connection has either failed or been rejected,
and st_client has not been modified.
In this case, the caller should terminate the connection.
pub fn call_identity_disconnected_inner( &self, caller_identity: Identity, caller_connection_id: ConnectionId, inst: &mut dyn ModuleInstance, ) -> Result<(), ReducerCallError>
Sourcepub async fn call_identity_disconnected(
&self,
caller_identity: Identity,
caller_connection_id: ConnectionId,
) -> Result<(), ReducerCallError>
pub async fn call_identity_disconnected( &self, caller_identity: Identity, caller_connection_id: ConnectionId, ) -> Result<(), ReducerCallError>
Invoke the module’s client_disconnected reducer, if it has one,
and delete the client’s row from st_client, if any.
The host inspects st_client when restarting in order to run client_disconnected reducers
for clients that were connected at the time when the host went down.
This ensures that every client connection eventually has client_disconnected invoked.
Unlike Self::call_identity_connected,
this method swallows errors returned by the client_disconnected reducer.
The database can’t reject a disconnection - the client’s gone, whether the database likes it or not.
If this method returns an error, the database is likely to wind up in a bad state,
as that means we’ve somehow failed to delete from st_client.
We cannot meaningfully handle this.
Sometimes it just means that the database no longer exists, though, which is fine.
pub async fn call_reducer( &self, caller_identity: Identity, caller_connection_id: Option<ConnectionId>, client: Option<Arc<ClientConnectionSender>>, request_id: Option<RequestId>, timer: Option<Instant>, reducer_name: &str, args: ReducerArgs, ) -> Result<ReducerCallResult, ReducerCallError>
pub async fn call_scheduled_reducer( &self, call_reducer_params: impl FnOnce(&MutTxId) -> Result<Option<CallReducerParams>> + Send + 'static, ) -> Result<ReducerCallResult, ReducerCallError>
pub fn subscribe_to_logs(&self) -> Result<Receiver<Bytes>>
pub async fn init_database( &self, program: Program, ) -> Result<Option<ReducerCallResult>, InitDatabaseError>
pub async fn update_database( &self, program: Program, old_module_info: Arc<ModuleInfo>, ) -> Result<UpdateDatabaseResult, Error>
pub async fn exit(&self)
pub async fn exited(&self)
pub fn inject_logs(&self, log_level: LogLevel, message: &str)
Sourcepub async fn one_off_query<F: WebsocketFormat>(
&self,
caller_identity: Identity,
query: String,
client: Arc<ClientConnectionSender>,
message_id: Vec<u8>,
timer: Instant,
into_message: impl FnOnce(OneOffQueryResponseMessage<F>) -> SerializableMessage + Send + 'static,
) -> Result<(), Error>
pub async fn one_off_query<F: WebsocketFormat>( &self, caller_identity: Identity, query: String, client: Arc<ClientConnectionSender>, message_id: Vec<u8>, timer: Instant, into_message: impl FnOnce(OneOffQueryResponseMessage<F>) -> SerializableMessage + Send + 'static, ) -> Result<(), Error>
Execute a one-off query and send the results to the given client. This only returns an error if there is a db-level problem. An error with the query itself will be sent to the client.
Sourcepub fn clear_table(&self, table_name: &str) -> Result<(), Error>
pub fn clear_table(&self, table_name: &str) -> Result<(), Error>
FIXME(jgilles): this is a temporary workaround for deleting not currently being supported for tables without primary keys. It is only used in the benchmarks. Note: this doesn’t drop the table, it just clears it!
pub fn downgrade(&self) -> WeakModuleHost
pub fn database_info(&self) -> &Database
Trait Implementations§
Source§impl Clone for ModuleHost
impl Clone for ModuleHost
Source§fn clone(&self) -> ModuleHost
fn clone(&self) -> ModuleHost
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ModuleHost
impl !RefUnwindSafe for ModuleHost
impl Send for ModuleHost
impl Sync for ModuleHost
impl Unpin for ModuleHost
impl !UnwindSafe for ModuleHost
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more