-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify Service Discovery by decoupling the service registry from in…
…tent brokering (#141) Service Discovery as its own service - Simple implementation
- Loading branch information
Showing
18 changed files
with
1,011 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT license. | ||
# SPDX-License-Identifier: MIT | ||
|
||
[package] | ||
name = "service_discovery" | ||
version = "0.1.0" | ||
edition = "2021" | ||
license = "MIT" | ||
|
||
[dependencies] | ||
parking_lot = { workspace = true } | ||
prost = { workspace = true } | ||
service_discovery_proto = { path = "../proto_build/"} | ||
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } | ||
tonic = { workspace = true } | ||
tracing = { version = "0.1" } | ||
tracing-subscriber = { version = "0.3", features = ["env-filter"] } | ||
|
||
[build-dependencies] | ||
tonic-build = { workspace = true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
// SPDX-License-Identifier: MIT | ||
|
||
//! Project Eclipse Chariott Service Discovery | ||
//! | ||
//! This is the Service Discovery system for Chariott. It includes a service registry, | ||
//! which is a database of services that are currently registered. Other applications | ||
//! can find the metadata for registered services. | ||
// Tells cargo to warn if a doc comment is missing and should be provided. | ||
#![warn(missing_docs)] | ||
|
||
use parking_lot::RwLock; | ||
use service_discovery_proto::service_registry::v1::service_registry_server::ServiceRegistryServer; | ||
use std::collections::HashMap; | ||
use std::net::SocketAddr; | ||
use std::sync::Arc; | ||
use tonic::transport::Server; | ||
use tracing::{debug, info}; | ||
use tracing_subscriber::util::SubscriberInitExt; | ||
use tracing_subscriber::EnvFilter; | ||
|
||
mod service_registry_impl; | ||
|
||
/// Endpoint for the service registry | ||
const SERVICE_REGISTRY_ADDR: &str = "0.0.0.0:50000"; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
// Set up tracing | ||
let collector = tracing_subscriber::fmt() | ||
.with_env_filter( | ||
EnvFilter::builder() | ||
.with_default_directive(tracing::Level::INFO.into()) | ||
.from_env_lossy(), | ||
) | ||
.finish(); | ||
|
||
collector.init(); | ||
|
||
// Start up registry service | ||
let addr: SocketAddr = SERVICE_REGISTRY_ADDR.parse()?; | ||
let registry_impl = | ||
service_registry_impl::ServiceRegistryImpl::new(Arc::new(RwLock::new(HashMap::new()))); | ||
info!("Service Registry listening on {addr}"); | ||
|
||
Server::builder().add_service(ServiceRegistryServer::new(registry_impl)).serve(addr).await?; | ||
|
||
debug!("The Service Registry has completed."); | ||
Ok(()) | ||
} |
Oops, something went wrong.