Skip to content

Commit 394851a

Browse files
author
Mauricio Cassola
committed
Add example of use
1 parent ac1d005 commit 394851a

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/handlers/jobs.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,29 @@
44

55
// The metadata is a serde_json::Value
66
// Please refer to https://docs.rs/serde_json/latest/serde_json/value/fn.from_value.html
7-
// on how to interpret it as an instance of type T, implementing Deserialize.
7+
// on how to interpret it as an instance of type T, implementing Serialize/Deserialize.
8+
9+
// For example, if we want to sends a Zulip message every Friday at 11:30am ET into #t-release
10+
// with a @T-release meeting! content, we should create some Job like:
11+
//
12+
// #[derive(Serialize, Deserialize)]
13+
// struct ZulipMetadata {
14+
// pub message: String
15+
// }
16+
//
17+
// let metadata = serde_json::value::to_value(ZulipMetadata {
18+
// message: "@T-release meeting!".to_string()
19+
// }).unwrap();
20+
//
21+
// Job {
22+
// name: "send_zulip_message",
23+
// expected_time: "2022-09-30T11:30:00+10:00",
24+
// frequency: Some(7),
25+
// frequency_unit: Some(FrequencyUnit::Days),
26+
// metadata: metadata
27+
// }
28+
//
29+
// ... and add the corresponding "send_zulip_message" handler.
830

931
pub async fn handle_job(name: &String, metadata: &serde_json::Value) -> anyhow::Result<()> {
1032
match name {

0 commit comments

Comments
 (0)