Refactor the parser code into its own crate for future development

This will inform #46
This commit is contained in:
R Tyler Croy 2020-11-28 21:40:35 -08:00
parent 9a39ea00d6
commit 127d3b7aa4
18 changed files with 38 additions and 12 deletions

13
Cargo.lock generated
View File

@ -1652,11 +1652,22 @@ dependencies = [
name = "otto-parser"
version = "0.1.0"
dependencies = [
"async-std",
"log",
"otto-models",
"pest",
"pest_derive",
"serde_json",
"uuid",
]
[[package]]
name = "otto-parser-service"
version = "0.1.0"
dependencies = [
"async-std",
"log",
"otto-models",
"otto-parser",
"pretty_env_logger 0.4.0",
"serde_json",
"tide 0.15.0",

View File

@ -6,6 +6,7 @@ members = [
"crates/agent",
"crates/models",
"crates/parser",
"services/auctioneer",
"services/eventbus",

13
crates/parser/Cargo.toml Normal file
View File

@ -0,0 +1,13 @@
[package]
name = "otto-parser"
version = "0.1.0"
authors = ["R. Tyler Croy <rtyler@brokenco.de>"]
edition = "2018"
[dependencies]
log = "~0.4.11"
otto-models = { path = "../models" }
pest = "~2.1.3"
pest_derive = "~2.1.0"
serde_json = "~1.0.59"
uuid = { version = "~0.8.1", features = ["v4", "serde"]}

View File

@ -0,0 +1,6 @@
= Otto Parser
The Otto Parser service is basically a parser engine that speaks HTTP. In the
`src/` directory you will find the `.pest` grammar definition which outlines
the Otto Pipeline syntax.

View File

@ -9,6 +9,9 @@ use pest::iterators::{Pair, Pairs};
use pest::Parser;
use uuid::Uuid;
pub use pest::error::ErrorVariant;
pub use pest::error::LineColLocation;
#[derive(Parser)]
#[grammar = "pipeline.pest"]
struct PipelineParser;

View File

@ -1,13 +1,9 @@
[package]
name = "otto-parser"
name = "otto-parser-service"
version = "0.1.0"
authors = ["R. Tyler Croy <rtyler@brokenco.de>"]
edition = "2018"
[lib]
name = "otto_parser"
path = "src/lib.rs"
[[bin]]
name = "otto-parser"
path = "src/main.rs"
@ -16,8 +12,7 @@ path = "src/main.rs"
async-std = { version = "1.6.5", features = ["attributes"]}
log = "~0.4.11"
otto-models = { path = "../../crates/models" }
pest = "~2.1.3"
pest_derive = "~2.1.0"
otto-parser = { path = "../../crates/parser" }
pretty_env_logger = "~0.4.0"
serde_json = "~1.0.59"
tide = "~0.15.0"

View File

@ -1,8 +1,6 @@
= Parser service
The Otto Parser service is basically a parser engine that speaks HTTP. In the
`src/` directory you will find the `.pest` grammar definition which outlines
the Otto Pipeline syntax.
The Otto Parser Service presents the parser crate as an HTTP service.
The `apispec.yml` is an link:https://en.wikipedia.org/wiki/Open_API[OpenAPI]
specification that describes the public HTTP endpoints that the parser service

View File

@ -16,7 +16,6 @@ async fn parse(mut req: Request<()>) -> tide::Result {
match parsed {
Err(e) => {
use pest::error::*;
error!("Failed to parse: {:?}", e);
let variant = match e.variant {