Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fang 0.9 integration #247

Merged
merged 13 commits into from
Sep 4, 2022
110 changes: 80 additions & 30 deletions Cargo.lock

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

8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ rust-version = "1.62"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
thiserror = "1.0"
once_cell = "1.13"
aho-corasick = "0.7"
atom_syndication = "0.11"
chrono = "0.4"
diesel = { version = "1", features = ["postgres", "chrono", "r2d2"] }
diesel = { version = "2", features = ["postgres","r2d2"] }
dotenv = "0.15"
env_logger = "0.9"
fang = { version = "0.8", features = ["blocking"], default-features = false }
fang = { version = "0.9", features = ["blocking"], default-features = false }
feed-rs = "1"
frankenstein = { version = "0.20", default-features = false, features = ["telegram-trait"] }
handlebars = "4"
Expand All @@ -32,4 +34,4 @@ typed-builder = "0.10"
url = "2"

[dev-dependencies]
mockito = "0.31"
mockito = "0.31"
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
db:
docker run --rm -d --name postgres -p 5432:5432 \
-e POSTGRES_DB=el_monitorro \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
postgres:latest
clippy:
cargo clippy --all-features
diesel:
DATABASE_URL=postgres://postgres:postgres@localhost/el_monitorro diesel migration run
stop:
docker kill postgres
tests:
DATABASE_URL=postgres://postgres:postgres@localhost/el_monitorro cargo test --all-features -- --color always --nocapture

ignored:
DATABASE_URL=postgres://postgres:postgres@localhost/el_monitorro cargo test --all-features -- --color always --nocapture --ignored

doc:
cargo doc --open
5 changes: 0 additions & 5 deletions diesel.toml

This file was deleted.

29 changes: 29 additions & 0 deletions migrations/2022-09-02-144340_change_fang_tables/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
DROP TABLE fang_periodic_tasks;
DROP TABLE fang_tasks;

CREATE TABLE fang_tasks (
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
metadata jsonb NOT NULL,
error_message TEXT,
state fang_task_state default 'new' NOT NULL,
task_type VARCHAR default 'common' NOT NULL,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);

CREATE INDEX fang_tasks_state_index ON fang_tasks(state);
CREATE INDEX fang_tasks_type_index ON fang_tasks(task_type);
CREATE INDEX fang_tasks_created_at_index ON fang_tasks(created_at);
CREATE INDEX fang_tasks_metadata_index ON fang_tasks(metadata);

CREATE TABLE fang_periodic_tasks (
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
metadata jsonb NOT NULL,
period_in_millis BIGINT NOT NULL,
scheduled_at TIMESTAMP WITH TIME ZONE,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);

CREATE INDEX fang_periodic_tasks_scheduled_at_index ON fang_periodic_tasks(scheduled_at);
CREATE INDEX fang_periodic_tasks_metadata_index ON fang_periodic_tasks(metadata);
19 changes: 19 additions & 0 deletions migrations/2022-09-02-144340_change_fang_tables/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
DROP TABLE fang_periodic_tasks;
DROP TABLE fang_tasks;

CREATE TABLE fang_tasks (
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
metadata jsonb NOT NULL,
error_message TEXT,
state fang_task_state DEFAULT 'new' NOT NULL,
task_type VARCHAR DEFAULT 'common' NOT NULL,
uniq_hash CHAR(64),
scheduled_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);

CREATE INDEX fang_tasks_state_index ON fang_tasks(state);
CREATE INDEX fang_tasks_type_index ON fang_tasks(task_type);
CREATE INDEX fang_tasks_scheduled_at_index ON fang_tasks(scheduled_at);
CREATE INDEX fang_tasks_uniq_hash ON fang_tasks(uniq_hash);
4 changes: 3 additions & 1 deletion src/bin/cleaner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ fn main() {
dotenv().ok();
env_logger::init();

let queue = Queue::new();
let queue = Queue::builder()
.connection_pool(el_monitorro::db::pool().clone())
.build();

el_monitorro::start_clean_workers(&queue);

Expand Down
4 changes: 3 additions & 1 deletion src/bin/deliver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ fn main() {
dotenv().ok();
env_logger::init();

let queue = Queue::new();
let queue = Queue::builder()
.connection_pool(el_monitorro::db::pool().clone())
.build();

el_monitorro::start_delivery_workers(&queue);

Expand Down
4 changes: 3 additions & 1 deletion src/bin/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ fn main() {
dotenv().ok();
env_logger::init();

let queue = Queue::new();
let queue = Queue::builder()
.connection_pool(el_monitorro::db::pool().clone())
.build();

el_monitorro::start_sync_workers(&queue);

Expand Down
Loading