start on executor
This commit is contained in:
parent
102f6654a9
commit
006a39ba8f
|
@ -654,6 +654,10 @@ dependencies = [
|
|||
"version_check 0.9.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "executor"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "eyre"
|
||||
version = "0.6.1"
|
||||
|
|
|
@ -46,5 +46,6 @@ features = [ "blocking" ]
|
|||
|
||||
[workspace]
|
||||
members = [
|
||||
"./executor",
|
||||
"./lib/rocket_upload"
|
||||
]
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
[package]
|
||||
name = "executor"
|
||||
version = "0.1.0"
|
||||
authors = ["Christine Dodrill <me@christine.website>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
-- This file should undo anything in `up.sql`
|
|
@ -0,0 +1,18 @@
|
|||
CREATE TABLE IF NOT EXISTS executions
|
||||
( id UUID DEFAULT uuid_generate_v4() NOT NULL
|
||||
, handler_id UUID NOT NULL
|
||||
, finished BOOLEAN NOT NULL DEFAULT false
|
||||
, stderr VARCHAR
|
||||
, created_at TIMESTAMP NOT NULL DEFAULT NOW()
|
||||
, updated_at TIMESTAMP NOT NULL DEFAULT NOW()
|
||||
, execution_time INTEGER -- XXX(Cadey): change this when you need handlers to run longer than 22 days
|
||||
, PRIMARY KEY (id)
|
||||
, CONSTRAINT fk_handler_id
|
||||
FOREIGN KEY (handler_id)
|
||||
REFERENCES handlers(id)
|
||||
);
|
||||
|
||||
CREATE TRIGGER set_timestamp_executions
|
||||
BEFORE UPDATE ON executions
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE trigger_set_timestamp();
|
|
@ -3,6 +3,7 @@
|
|||
set -e
|
||||
set -x
|
||||
|
||||
docker rm -f wasmcloud-postgres ||:
|
||||
docker \
|
||||
run \
|
||||
--name wasmcloud-postgres \
|
||||
|
@ -11,3 +12,5 @@ docker \
|
|||
-p 5432:5432 \
|
||||
-d \
|
||||
postgres:alpine
|
||||
sleep 2
|
||||
diesel migration run
|
||||
|
|
|
@ -3,7 +3,8 @@ let
|
|||
rust = import ./nix/rust.nix { inherit sources; };
|
||||
pkgs = import sources.nixpkgs { };
|
||||
in pkgs.mkShell rec {
|
||||
buildInputs = with pkgs; [
|
||||
buildInputs = with pkgs; with elmPackages; [
|
||||
# rust
|
||||
rust
|
||||
diesel-cli
|
||||
postgresql
|
||||
|
@ -11,6 +12,11 @@ in pkgs.mkShell rec {
|
|||
cargo-watch
|
||||
pkg-config
|
||||
openssl
|
||||
|
||||
# elm
|
||||
elm2nix
|
||||
elm
|
||||
elm-language-server
|
||||
];
|
||||
|
||||
B2_CREDFILE = "./var/secret/b2-creds.txt";
|
||||
|
|
|
@ -102,3 +102,24 @@ pub struct HandlerConfig {
|
|||
pub created_at: NaiveDateTime,
|
||||
pub updated_at: NaiveDateTime,
|
||||
}
|
||||
|
||||
#[derive(Insertable)]
|
||||
#[table_name = "executions"]
|
||||
pub struct NewExecution {
|
||||
pub handler_id: Uuid,
|
||||
pub finished: bool,
|
||||
pub stderr: Option<String>,
|
||||
pub execution_time: i32,
|
||||
}
|
||||
|
||||
#[derive(Queryable, Debug, Clone, Serialize)]
|
||||
pub struct Execution {
|
||||
pub id: Uuid,
|
||||
pub handler_id: Uuid,
|
||||
pub finished: bool,
|
||||
pub stderr: Option<String>,
|
||||
pub execution_time: i32,
|
||||
|
||||
pub created_at: NaiveDateTime,
|
||||
pub updated_at: NaiveDateTime,
|
||||
}
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
table! {
|
||||
executions (id) {
|
||||
id -> Uuid,
|
||||
handler_id -> Uuid,
|
||||
finished -> Bool,
|
||||
stderr -> Nullable<Varchar>,
|
||||
created_at -> Timestamp,
|
||||
updated_at -> Timestamp,
|
||||
execution_time -> Nullable<Int4>,
|
||||
}
|
||||
}
|
||||
|
||||
table! {
|
||||
gitea_tokens (id) {
|
||||
id -> Uuid,
|
||||
|
@ -55,9 +67,8 @@ table! {
|
|||
}
|
||||
}
|
||||
|
||||
joinable!(handler_config -> handlers (handler_id));
|
||||
|
||||
allow_tables_to_appear_in_same_query!(
|
||||
executions,
|
||||
gitea_tokens,
|
||||
handler_config,
|
||||
handlers,
|
||||
|
|
Loading…
Reference in New Issue