From 60e0b8224725149cda2d9796cc95d4e2e55e9b2a Mon Sep 17 00:00:00 2001 From: "R. Tyler Croy" Date: Wed, 3 Mar 2021 10:38:33 -0800 Subject: [PATCH] Add a stub relational data service while I explore GraphQL See #63 --- Cargo.lock | 11 +++++++++++ Cargo.toml | 1 + docs/Developing_Services.adoc | 5 ++++- services/reldata/Cargo.toml | 12 ++++++++++++ services/reldata/README.adoc | 12 ++++++++++++ services/reldata/src/main.rs | 30 ++++++++++++++++++++++++++++++ 6 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 services/reldata/Cargo.toml create mode 100644 services/reldata/README.adoc create mode 100644 services/reldata/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index fea714c..574f1fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2010,6 +2010,17 @@ version = "0.6.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581" +[[package]] +name = "reldata" +version = "0.1.0" +dependencies = [ + "async-std", + "log", + "otto-models", + "pretty_env_logger 0.4.0", + "tide 0.15.1", +] + [[package]] name = "remove_dir_all" version = "0.5.3" diff --git a/Cargo.toml b/Cargo.toml index 4d4829f..b88efee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,7 @@ members = [ "services/local-orchestrator", "services/object-store", "services/parser", + "services/reldata", "stdlib/archive", "stdlib/dir", diff --git a/docs/Developing_Services.adoc b/docs/Developing_Services.adoc index 43ad9f7..6981de2 100644 --- a/docs/Developing_Services.adoc +++ b/docs/Developing_Services.adoc @@ -9,7 +9,6 @@ This document captures some details around developing these Otto services. |=== | Port | Service Name | Notes - | 7670 | Dashboard | Placeholder for the web dashboard @@ -27,5 +26,9 @@ This document captures some details around developing these Otto services. | Orchestrator | Service which can provision environments capable of executing agents. +| 7674 +| Relational Data +| Service which provides relational data services to clients. + |=== diff --git a/services/reldata/Cargo.toml b/services/reldata/Cargo.toml new file mode 100644 index 0000000..51a701c --- /dev/null +++ b/services/reldata/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "reldata" +version = "0.1.0" +authors = ["R. Tyler Croy "] +edition = "2018" + +[dependencies] +async-std = { version = "~1.7", features = ["attributes"]} +log = "~0.4.11" +otto-models = { path = "../../crates/models" } +pretty_env_logger = "~0.4.0" +tide = "~0.15.0" diff --git a/services/reldata/README.adoc b/services/reldata/README.adoc new file mode 100644 index 0000000..785a0c5 --- /dev/null +++ b/services/reldata/README.adoc @@ -0,0 +1,12 @@ += Relational Data + +The relational data service provides a centralized location for project, +pipeline, and more data to be stored. This is in contrast to the object store +which is expected to store large files/objects. + + +.Environnment Variables +|=== +| Name | Default | Description + +|=== diff --git a/services/reldata/src/main.rs b/services/reldata/src/main.rs new file mode 100644 index 0000000..cc4fdec --- /dev/null +++ b/services/reldata/src/main.rs @@ -0,0 +1,30 @@ +/* + * The relational data service largely is meant to expose information from an underlying database + */ +use tide::Request; + +async fn healthcheck(_req: Request<()>) -> tide::Result { + Ok(tide::Response::builder(200) + .body("{}") + .content_type("application/json") + .build()) +} + +#[async_std::main] +async fn main() -> std::io::Result<()> { + use std::{env, net::TcpListener, os::unix::io::FromRawFd}; + pretty_env_logger::init(); + + let mut app = tide::new(); + app.at("/health").get(healthcheck); + + if let Some(fd) = env::var("LISTEN_FD").ok().and_then(|fd| fd.parse().ok()) { + app.listen(unsafe { TcpListener::from_raw_fd(fd) }).await?; + } else { + app.listen("http://localhost:7674").await?; + } + Ok(()) +} + +#[cfg(test)] +mod tests {}