Function tencent_scf::start_uncatched [−][src]
pub fn start_uncatched<Event, Response, Error, ConvertEventError, ConvertResponseError, Function>(
f: Function
) where
Function: ServerlessComputeFunction<Event = Event, Response = Response, Error = Error>,
Event: FromReader<Error = ConvertEventError>,
Response: IntoBytes<Error = ConvertResponseError>,
Error: Display,
ConvertEventError: Display,
ConvertResponseError: Display,
Start the runtime with the given serverless compute function without catching panics.
Typically this should be the last call in the main
function.
Panic
The runtime will panic if any of the following happens:
- Fail to initialize, for example, expected environment vairable not found.
- Fail to communicate to upstream cloud.
- Receive malformed response from upstream cloud.
- The serverless compute function panics during execution.
Example
Here is an example where the function must be started without panic catching:
use tencent_scf::{make_scf, start_uncatched, Context}; use ureq::AgentBuilder; // build an http agent // this object is not unwind-safe so any closure that captures it is not unwind-safe let agent = AgentBuilder::new().build(); // make the scf let scf = make_scf( move |event: serde_json::Value, _context: Context| -> Result<serde_json::Value, ureq::Error> { // do something using agent let _resp = agent.get("http://example.com/").call()?; Ok(event) }, ); // start the runtime in the main function start_uncatched(scf); // this doesn't compile // tencent_scf::start(scf);