Skip to content

Instantly share code, notes, and snippets.

@ChillFish8
Created January 6, 2023 14:44
Show Gist options
  • Save ChillFish8/47e02de64c2df06aaa4cb18287564203 to your computer and use it in GitHub Desktop.
Save ChillFish8/47e02de64c2df06aaa4cb18287564203 to your computer and use it in GitHub Desktop.
use datacake_node::{ClusterExtension, DatacakeNode};
use async_trait::async_trait;
pub struct MyExtension;
#[async_trait]
impl ClusterExtension for MyExtension {
type Output = ();
type Error = MyError;
async fn init_extension(
self,
node: &DatacakeNode,
) -> Result<Self::Output, Self::Error> {
// In here we can setup our system using the live node.
// This gives us things like the cluster clock and RPC server:
println!("Creating my extension!");
let timestamp = node.clock().get_time().await;
println!("My timestamp: {timestamp}");
Ok(())
}
}
pub struct MyError;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment