Add the local orchestrator apispecs and a simple healthcheck

Still not sure what this API should look like, but will start playing around
with it.
This commit is contained in:
R Tyler Croy 2020-11-21 15:42:10 -08:00
parent e6432839d8
commit 391894ded7
2 changed files with 44 additions and 1 deletions

View File

@ -0,0 +1,34 @@
---
openapi: 3.0.3
info:
title: Otto Orchestrator Service
description: |
This specification describes the Local Orchestrator which doesn't really do
much other than run an `otto-agent` locally.
version: '1.0.0'
contact:
name: R Tyler Croy
email: 'rtyler@brokenco.de'
x-twitter: agentdero
license:
name: 'GNU AGPL 3.0'
url: 'https://www.gnu.org/licenses/agpl-3.0.en.html'
externalDocs:
description: 'Find out more about Otto'
url: 'https://github.com/rtyler/otto'
servers:
- url: 'http://localhost:7673'
description: 'Local dev server'
paths:
'/health':
get:
operationId: GetHealth
description: |
The health endpoint helps indicate whether the service is healthy or not.
Any non-200 response is unhealthy.
responses:
'200':
description: 'A successful healthcheck'
content:
application/json: {}

View File

@ -1,13 +1,22 @@
/*
* The local orchestrator doesn't do much
*/
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};
tide::log::start();
let app = tide::new();
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?;