Bootstrap the runtime Execute initialization code Execute handler code Small packages Use Lambda Execution Context Code Avoid Fat Lambda Cache assets in the /tmp dir Graviton2 Use parallelism when possible @dfrasca80
Rust program manages memory. Garbage Collector I declare my variable and the language runtime takes care I don't need to worry about what goes on the stack and heap Move the data itself and give up ownership in the process Create a copy of the data and pass that along Pass a reference to the data and retain ownership, letting the recipient borrow it for a while @dfrasca80
data type that lets you package together and name multiple related values that make up a meaningful group. A trait abstractly defines shared behaviour. For example, we can use trait bounds to specify that a generic type can be any type that has particular behaviour. pub struct Tweet { pub username: String, pub content: String, } pub trait Summary { fn summarise(&self) -> String; } @dfrasca80
Option is either Some and contains a value or None. Type Result can represent either success/Ok or failure/Err. enum Coin { Ten, Twenty, } async fn do() -> Result<MyDto, Error> {} fn value_in_cents(coin: &Coin) -> Option<u8> { match coin { Coin::Ten => Some<10>, Coin::Twenty => Some<20>, _ => None, } @dfrasca80
is an open-source framework that you can use to build a serverless application. ServerlessLand patterns to quickly build integrations using AWS SAM, CDK, Terraform and Serverless Framework. @dfrasca80
Result<impl IntoResponse, Error> { let path_parameters = request.path_parameters(); let id = match path_parameters.first("id") { Some(id) => id, None => return Ok(Response::builder().status(400).body("id is required")?), }; let body = match request.body() { Body::Empty => "".to_string(), Body::Text(body) => body.clone(), Body::Binary(body) => String::from_utf8_lossy(body).to_string(), }; // Put the item in the DynamoDB table let res = client .put_item() .table_name(table_name) .item("id", AttributeValue::S(id.to_string())) .item("payload", AttributeValue::S(body)) .send() .await; match res { Ok(_) => Ok(Response::builder().status(200).body("item saved")?), Err(_) => Ok(Response::builder().status(500).body("internal error")?), } } @dfrasca80
Result<impl IntoResponse, Error> { let path_parameters = request.path_parameters(); let id = match path_parameters.first("id") { Some(id) => id, None => return Ok(Response::builder().status(400).body("id is required")?), }; let body = match request.body() { Body::Empty => "".to_string(), Body::Text(body) => body.clone(), Body::Binary(body) => String::from_utf8_lossy(body).to_string(), }; let res = client .put_item() .table_name(table_name) .item("id", AttributeValue::S(id.to_string())) .item("payload", AttributeValue::S(body)) .send() .await; // Return a response to the end-user match res { Ok(_) => Ok(Response::builder().status(200).body("item saved")?), Err(_) => Ok(Response::builder().status(500).body("internal error")?), } } @dfrasca80
name will be the same with "Mock" prepended. 2 Instantiate the mock struct with its new or default method. 3 Set expectations on the mock struct. @dfrasca80