15 releases

0.3.2 Mar 7, 2024
0.3.1 Apr 3, 2023
0.2.1 Mar 3, 2023
0.2.0 Feb 20, 2023
0.1.9 Jan 30, 2023

#1 in #send-response

Download history 137/week @ 2025-01-31 233/week @ 2025-02-07 144/week @ 2025-02-14 178/week @ 2025-02-21 158/week @ 2025-02-28 156/week @ 2025-03-07 320/week @ 2025-03-14 175/week @ 2025-03-21 140/week @ 2025-03-28 95/week @ 2025-04-04 178/week @ 2025-04-11 131/week @ 2025-04-18 284/week @ 2025-04-25 187/week @ 2025-05-02 72/week @ 2025-05-09 45/week @ 2025-05-16

634 downloads per month

MIT/Apache

10KB
141 lines

This is a library for storing key/value in your flow function in flows.network.

Usage example

use serde_json::json;
use lambda_flows::{request_received, send_response};
use store_flows::{get, set, Expire, ExpireKind};

#[no_mangle]
pub fn run() {
    if let Some((_qry, _body)) = request_received() {
      let mut c = match get("count") {
          Some(v) => v.as_u64().unwrap_or_default(),
          None => 0,
      };

      c = c + 1;

      set(
          "count",
          json!(c),
          Some(Expire {
              kind: ExpireKind::Ex,
              value: 20,
          }),
      );

      send_response(
          200,
          vec![(String::from("content-type"), String::from("text/html"))],
          c.to_string().as_bytes().to_vec(),
      );
    }
}

This is a Lambda flow function. It can show the times it has been called. When a request is received, we get the previous count number from store, imcrement it by one, then set it back to store.

The whole document is here.

Dependencies

~0.9–1.8MB
~40K SLoC