Skip to content

Commit

Permalink
Update to include persistance
Browse files Browse the repository at this point in the history
Signed-off-by: Heinz N. Gies <[email protected]>
  • Loading branch information
Licenser committed Oct 1, 2021
1 parent c6b34e0 commit 291c728
Show file tree
Hide file tree
Showing 13 changed files with 630 additions and 315 deletions.
85 changes: 85 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ base16 = "*"
chrono = "0.4.19"
clap = "3.0.0-beta.2"
color-eyre = "0.5.10"
diesel = { version = "1.4.4", features = ["postgres", "sqlite"] }
dotenv = "0.15.0"
futures-util = "0.3"
hmac = "0.11"
hyper = { version = "0.14", features = ["full"] }
hyper-staticfile = "*"
octocrab = "0.12"
pretty_env_logger = "0.4"
serde = { version = "1.0.125", features = ["derive"] }
Expand Down
5 changes: 5 additions & 0 deletions diesel.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# For documentation on how to configure this file,
# see diesel.rs/guides/configuring-diesel-cli

[print_schema]
file = "src/schema.rs"
Empty file added migrations/.gitkeep
Empty file.
2 changes: 2 additions & 0 deletions migrations/2021-10-01-103631_create_benchmarks/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- This file should undo anything in `up.sql`
DROP TABLE benchmarks;
10 changes: 10 additions & 0 deletions migrations/2021-10-01-103631_create_benchmarks/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- Your SQL goes here
CREATE TABLE benchmarks (
id VARCHAR NOT NULL PRIMARY KEY,
created_at DATE NOT NULL,
commit_hash CHAR(40) NOT NULL,
bench_name VARCHAR NOT NULL,
mpbs FLOAT8 NOT NULL,
eps FLOAT8 NOT NULL,
hist TEXT NOT NULL
);
68 changes: 68 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
use std::fmt::Display;

// Copyright 2020-2021, The Tremor Team
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use hmac::crypto_mac::InvalidKeyLength;

impl From<hyper::Error> for Error {
fn from(e: hyper::Error) -> Self {
Self::Hyper(e)
}
}
impl From<&str> for Error {
fn from(e: &str) -> Self {
Self::Text(e.to_string())
}
}
impl From<InvalidKeyLength> for Error {
fn from(_: InvalidKeyLength) -> Self {
Self::Other
}
}

impl From<serde_json::Error> for Error {
fn from(e: serde_json::Error) -> Self {
Self::BadRequest(format!("Invalid JSON: {}", e))
}
}
impl From<std::io::Error> for Error {
fn from(_: std::io::Error) -> Self {
Self::Other
}
}
impl<T> From<async_std::channel::SendError<T>> for Error {
fn from(_: async_std::channel::SendError<T>) -> Self {
Self::Other
}
}
impl From<diesel::result::Error> for Error {
fn from(_: diesel::result::Error) -> Self {
Self::Other
}
}

#[derive(Debug)]
pub enum Error {
Other,
Text(String),
Hyper(hyper::Error),
BadRequest(String),
}
impl Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}

impl std::error::Error for Error {}
Loading

0 comments on commit 291c728

Please sign in to comment.