diff options
| author | n1c00o <git.n1c00o@gmail.com> | 2021-07-30 23:00:03 +0200 |
|---|---|---|
| committer | n1c00o <git.n1c00o@gmail.com> | 2021-07-30 23:00:03 +0200 |
| commit | efbb1216f5f4d8dd7d99d044fa736ba5095565a9 (patch) | |
| tree | 4516c93363061b20579d56448d4f0baf76e1e20e | |
| parent | 8cf0db34859e6e2119e410b89a22f96e412f20b8 (diff) | |
add todos
| -rw-r--r-- | src/client.rs | 2 | ||||
| -rw-r--r-- | src/server.rs | 8 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/client.rs b/src/client.rs index 750fe1a..f0b871b 100644 --- a/src/client.rs +++ b/src/client.rs @@ -1,3 +1,5 @@ +// !Sample implementation of a gRPC Client for Clawflake, not meant to production! + use clawflake::clawflake_client::ClawflakeClient; use clawflake::IdRequest; diff --git a/src/server.rs b/src/server.rs index edb69ef..2d18d97 100644 --- a/src/server.rs +++ b/src/server.rs @@ -15,6 +15,10 @@ pub mod clawflake { mod id_worker; use id_worker::IdWorker; +const EPOCH: i64 = 1_564_790_400_000; // todo(n1c00o): find a good custom epoch for production cuz its fun +const WORKER_ID: i64 = 0; // todo(n1c00o): need a way to detect the worker id from Kubernetes +const DATACENTER_ID: i64 = 0; // todo(n1c00o): need a way to detect the data center id from idk + #[derive(Debug, Default)] pub struct MyClawflakeService { } @@ -27,7 +31,7 @@ impl Clawflake for MyClawflakeService { ) -> Result<Response<IdReply>, Status> { info!("request on GetID"); - let mut worker: IdWorker = IdWorker::new(1_564_790_400_000, 0, 0); + let mut worker: IdWorker = IdWorker::new(EPOCH, WORKER_ID, DATACENTER_ID); let reply: IdReply = clawflake::IdReply { id: format!("{}", worker.next_id()).into(), @@ -49,7 +53,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { } // init tonic and IdWorker - let addr: SocketAddr = "[::1]:50051".parse()?; + let addr: SocketAddr = "[::1]:50051".parse()?; //todo(n1c00o): make sure we can manage addr, then make the Dockerfile let srv: MyClawflakeService = MyClawflakeService::default(); println!("Service listening on {}", addr); |
