Trait plumber_rs::servlet::SyncServlet [−][src]
pub trait SyncServlet { type ProtocolType: ProtocolModel; type DataModelType: DataModel<Self::ProtocolType>; fn init(
&mut self,
args: &[&str],
proto_model: &mut Self::ProtocolType
) -> ServletFuncResult; fn exec(&mut self, data_model: Self::DataModelType) -> ServletFuncResult; fn cleanup(&mut self) -> ServletFuncResult; }
The trait for a synchronous servlet.
A sync servlet is a servlet occupies the worker thread during execution. This is the most common form of servlet. However, when there are some blocking operations needs to be done by the servlet, this model is really ineffecient because it blocks the worker thread completely and reduces the system throughput.
Associated Types
type ProtocolType: ProtocolModel
The type used to represent the protocol.
This protocol type is ususally build by the macro protodef!
.
type DataModelType: DataModel<Self::ProtocolType>
Required Methods
fn init(
&mut self,
args: &[&str],
proto_model: &mut Self::ProtocolType
) -> ServletFuncResult
&mut self,
args: &[&str],
proto_model: &mut Self::ProtocolType
) -> ServletFuncResult
The initialization function.
This should be called by the Plumber framework before the application gets started. All the pipe declaration should be done in this function.
args
: The servlet init argument listproto_model
: The protocol model object for this servlet
Return the result of the servlet
fn exec(&mut self, data_model: Self::DataModelType) -> ServletFuncResult
The sync execute function.
This should be called by Plumber framework when the framework decide to activate the servlet due to some input event. This function will be called from any worker thread.
data_model
: The data model object which can be used to access the typed data
Return The servlet function result.
fn cleanup(&mut self) -> ServletFuncResult
The cleanup function
This should be called by Plumber framework when the Plumber application gets either killed or upgraded (and new version of the binary is loaded).
Return the servlet function result.
Implementors
impl SyncServlet for Unimplemented type ProtocolType = Untyped; type DataModelType = Untyped;