flows
This commit is contained in:
parent
21fe567ba6
commit
e7fe303941
6 changed files with 54 additions and 21 deletions
|
@ -1,30 +1,30 @@
|
||||||
{
|
{
|
||||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||||
"title": "Process",
|
"title": "Flow",
|
||||||
"description": "Process Description",
|
"description": "Workflow Description",
|
||||||
"properties": {
|
"properties": {
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"title": "Process Name",
|
"title": "Flow Name",
|
||||||
"description": "The name of the Process"
|
"description": "The name of the Flow"
|
||||||
},
|
},
|
||||||
"depends": {
|
"depends": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"title": "Process Dependencies",
|
"title": "Flow Dependencies",
|
||||||
"description": "List of Items a Process depends on",
|
"description": "List of Items a Flow depends on",
|
||||||
"items": {
|
"items": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"next": {
|
"next": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"title": "Next Process",
|
"title": "Next Flow",
|
||||||
"description": "The Process that succeeds this one."
|
"description": "The Flow that succeeds this one."
|
||||||
},
|
},
|
||||||
"produces": {
|
"produces": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"title": "Produced Items",
|
"title": "Produced Items",
|
||||||
"description": "Items this Process will produce",
|
"description": "Items this Flow can produce",
|
||||||
"items": {
|
"items": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
43
src/flow.rs
Normal file
43
src/flow.rs
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use mongod::{assert_reference_of, Reference, Validate};
|
||||||
|
|
||||||
|
pub struct FlowInfo {
|
||||||
|
pub name: String,
|
||||||
|
pub depends: HashMap<String, i64>,
|
||||||
|
pub next: Option<String>,
|
||||||
|
pub produces: Option<Vec<String>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
use mongod::{
|
||||||
|
derive::{Model, Referencable},
|
||||||
|
Model, Referencable, ToAPI,
|
||||||
|
};
|
||||||
|
use mongodb::bson::doc;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use serde_json::json;
|
||||||
|
|
||||||
|
/// A production flow
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize, Model, Referencable)]
|
||||||
|
pub struct Flow {
|
||||||
|
/// ID
|
||||||
|
pub _id: String,
|
||||||
|
/// Tiemstamp when the flow was started
|
||||||
|
pub started: i64,
|
||||||
|
/// Timestamp when the flow was ended
|
||||||
|
pub ended: i64,
|
||||||
|
/// Kind of flow; ID of the describing JSON
|
||||||
|
pub kind: String,
|
||||||
|
/// The flow succedding this one
|
||||||
|
pub next: Option<Reference>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Validate for Flow {
|
||||||
|
async fn validate(&self) -> Result<(), String> {
|
||||||
|
if let Some(next) = &self.next {
|
||||||
|
assert_reference_of!(next, Flow);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,8 +11,6 @@ use serde_json::json;
|
||||||
use crate::transaction::Transaction;
|
use crate::transaction::Transaction;
|
||||||
use crate::variant::Variant;
|
use crate::variant::Variant;
|
||||||
|
|
||||||
// todo : api key auth
|
|
||||||
|
|
||||||
// ITEM
|
// ITEM
|
||||||
// VARIANTS
|
// VARIANTS
|
||||||
// QUANTIZATION
|
// QUANTIZATION
|
||||||
|
|
|
@ -8,10 +8,10 @@ use rocket::{http::Method, launch};
|
||||||
|
|
||||||
mod config;
|
mod config;
|
||||||
mod db;
|
mod db;
|
||||||
|
mod flow;
|
||||||
mod item;
|
mod item;
|
||||||
mod json_store;
|
mod json_store;
|
||||||
mod location;
|
mod location;
|
||||||
mod process;
|
|
||||||
mod routes;
|
mod routes;
|
||||||
mod transaction;
|
mod transaction;
|
||||||
mod variant;
|
mod variant;
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
pub struct ProcessInfo {
|
|
||||||
pub name: String,
|
|
||||||
pub depends: HashMap<String, i64>,
|
|
||||||
pub next: Option<String>,
|
|
||||||
pub produces: Option<Vec<String>>,
|
|
||||||
}
|
|
|
@ -30,7 +30,7 @@ impl<'r> FromRequest<'r> for Token {
|
||||||
type Error = ();
|
type Error = ();
|
||||||
|
|
||||||
async fn from_request(request: &'r Request<'_>) -> rocket::request::Outcome<Self, Self::Error> {
|
async fn from_request(request: &'r Request<'_>) -> rocket::request::Outcome<Self, Self::Error> {
|
||||||
match request.headers().get_one("token") {
|
match request.headers().get_one("Token") {
|
||||||
Some(key) => Outcome::Success(Token(key.to_string())),
|
Some(key) => Outcome::Success(Token(key.to_string())),
|
||||||
None => Outcome::Error((Status::Unauthorized, ())),
|
None => Outcome::Error((Status::Unauthorized, ())),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue