File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ use std::sync::{Arc, Mutex};
5
5
use tokio:: sync:: { OwnedSemaphorePermit , Semaphore } ;
6
6
use tokio_postgres:: Client as DbClient ;
7
7
8
+ pub mod events;
8
9
pub mod issue_data;
9
10
pub mod notifications;
10
11
pub mod rustc_commits;
@@ -215,5 +216,15 @@ CREATE TABLE issue_data (
215
216
data JSONB,
216
217
PRIMARY KEY (repo, issue_number, key)
217
218
);
219
+ " ,
220
+ "
221
+ CREATE TABLE events (
222
+ event_id UUID PRIMARY KEY,
223
+ event_name TEXT NOT NULL,
224
+ expected_event_time TIMESTAMP WITH TIME ZONE NOT NULL,
225
+ event_metadata JSONB,
226
+ executed_at TIMESTAMP WITH TIME ZONE NOT NULL,
227
+ failed TEXT
228
+ );
218
229
" ,
219
230
] ;
Original file line number Diff line number Diff line change
1
+ //! The `events` table provides a way to have scheduled events
2
+
3
+ use anyhow:: { Result } ;
4
+ use chrono:: { DateTime , FixedOffset } ;
5
+ use tokio_postgres:: { Client as DbClient } ;
6
+ use uuid:: Uuid ;
7
+
8
+ #[ derive( Debug ) ]
9
+ pub struct Event {
10
+ pub event_id : Uuid ,
11
+ pub event_name : String ,
12
+ pub expected_event_time : DateTime < FixedOffset > ,
13
+ pub event_metadata : String ,
14
+ pub executed_at : DateTime < FixedOffset > ,
15
+ pub failed : Option < String > ,
16
+ }
17
+
18
+ pub async fn insert_failed ( db : & DbClient ) -> Result < ( ) > {
19
+ unimplemented ! ( ) ;
20
+ }
21
+
22
+ pub async fn delete_event ( db : & DbClient ) -> Result < ( ) > {
23
+ unimplemented ! ( ) ;
24
+ }
25
+
26
+ pub async fn get_events_to_execute ( db : & DbClient ) -> Result < Vec < Event > > {
27
+ let events = db
28
+ . query (
29
+ "
30
+ SELECT * FROM events" ,
31
+ & [ ] ,
32
+ )
33
+ . await
34
+ . unwrap ( ) ;
35
+
36
+ Ok ( vec ! [ ] )
37
+ }
You can’t perform that action at this time.
0 commit comments