Skip to content

Commit

Permalink
feat: working git events storage
Browse files Browse the repository at this point in the history
  • Loading branch information
kjuulh committed Mar 2, 2023
1 parent 3c6ac90 commit dbcb6e1
Show file tree
Hide file tree
Showing 4 changed files with 325 additions and 23 deletions.
200 changes: 180 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/gitevents_sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ edition = "2021"
async-trait = "0.1.64"
eyre = "0.6.8"
futures = "0.3.26"
git2 = { version = "0.16.1", features = ["vendored-libgit2", "vendored-openssl"] }
tokio = { version = "1.25.0", features = ["full"] }
tokio-cron-scheduler = { version = "0.9.4", features = ["signal"] }
tracing = { version = "0.1.37", features = ["log", "async-await"] }
Expand Down
44 changes: 44 additions & 0 deletions crates/gitevents_sdk/examples/generic_repo/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
use std::sync::Arc;
use std::time::Duration;

use async_trait::async_trait;
use gitevents_sdk::{
cron::SchedulerOpts,
events::{EventHandler, EventRequest, EventResponse},
};
use tracing::Level;

#[tokio::main]
async fn main() -> eyre::Result<()> {
tracing_subscriber::fmt()
.pretty()
.with_max_level(Level::TRACE)
.init();

gitevents_sdk::builder::Builder::new()
.set_generic_git_url("kjuulh/gitevents")
.set_scheduler_opts(&SchedulerOpts {
// Duration must not be lower than 1 second, otherwise async runtime won't proceed
duration: Duration::from_secs(1),
})
.action(|_req| async move { Ok(EventResponse {}) })
.action(other_action)
.add_handler(Arc::new(TestHandler {}))
.execute()
.await?;

Ok(())
}

async fn other_action(_req: EventRequest) -> eyre::Result<EventResponse> {
Ok(EventResponse {})
}

pub struct TestHandler;

#[async_trait]
impl EventHandler for TestHandler {
async fn handle(&self, _req: EventRequest) -> eyre::Result<EventResponse> {
Ok(EventResponse {})
}
}
Loading

0 comments on commit dbcb6e1

Please sign in to comment.