Commit graph

69 commits

Author SHA1 Message Date
Pmarquez
140b19e6e4
Generic Worker Pool (#55)
* generic async worker pool !!

* cfg tests
2022-08-02 14:32:58 +00:00
Pmarquez
549f5a1c4b
Max number of conns (#54)
* Max number of conns

* fixing builder , connect and example

* fix comments

* fix comments

* Update src/asynk/async_queue.rs

Co-authored-by: Ayrat Badykov <ayratin555@gmail.com>
2022-08-01 19:37:32 +00:00
Ayrat Badykov
36393676e7
limit the number of features for tokio (#53) 2022-08-01 19:57:17 +03:00
Pmarquez
785dc88b8f
configure workers (#52) 2022-08-01 16:55:36 +00:00
Pmarquez
7e66196373
Async Improvements AsyncRunnable param (#51)
* AsyncRunnable param in insert_task and insert_periodic_task

* fix example
2022-07-31 15:15:00 +00:00
Ayrat Badykov
133d142761
Async worker pool draft (#49)
* Async worker pool draft

* ignore all targets

* simple worker example

* add debug logs

* fix

* fix tests

* remove log

* remove debug logs

* fix clippy
2022-07-31 13:32:37 +00:00
Pmarquez
6222c15d99
Async scheduled tasks (#47)
* preparing queries for periodic tasks

* fixing clippy and some other things

* delete src/schema

* ignoring src/schema.rs

* fix compile error

* fix clippy

* Scheduler

* Scheduler done ??

* improve scheduler (#48)

* improve scheduler

* add number of restarts

* fix clippy

* add into attribute

* make number of restarts pub

* fixing bugs and start async scheduler tests

* fixing insert periodic task bug and scheduler tests bug

* fix clippy

* fix clippy tests

* fix clippy tests again

* fix task type :D

* Builder AsyncQueueTest and sleep in start

Co-authored-by: Ayrat Badykov <ayratin555@gmail.com>
2022-07-31 11:40:24 +00:00
Pmarquez
2d724c3776
Async worker test (#46)
* preparing code to tests

* changing queue tests and starting worker tests with new struct AsyncQueueTest

* fix clippy and delete Debug trait

* fix warnings

* Get task by id in worker tests and AsyncQueueTest #[cfg(test)]

* Defaults and AsyncWorker Builder

* Testing :D

* Execute task specific type

* deleting Options and comment

* insert task is back git !!

* Test remove tasks and changing insert task auxiliar func
2022-07-27 17:05:05 +00:00
Pmarquez
8d0a23e2f9
Async Worker (#44)
* stating with async worker

* async sleep solve and update state test

* uncomenting line

* retention mode and sleep params in lib.rs

* fixing code style

* trying to solve

* dont like changes

* Add AsyncQueueable trait (#45)

* add trait

* update runnable trait

* fix test

Co-authored-by: Ayrat Badykov <ayratin555@gmail.com>
2022-07-23 17:24:22 +03:00
Ayrat Badykov
d585bde870
split into async and blocking features (#36)
* split into async and blocking features

* update Cargo.toml file

* fix example
2022-07-20 16:08:02 +00:00
Pmarquez
d3805cd562
Returning fail task (#35)
* fail task returning

* fix clippy

* state check
2022-07-20 15:26:11 +00:00
Pmarquez
f56792a558
Returning Insert query (#34)
* insert query return task

* deleting schema
2022-07-20 14:27:01 +00:00
Ayrat Badykov
8f6f905fe9
Use transaction in all queries (#33)
* Use transaction in all queries

* fix clippy
2022-07-20 10:01:33 +00:00
Ayrat Badykov
3602097fb6
fetch_task static and AsyncQueue method (#32)
* fetch and touch a task inside of db transaction

* remove transaction from AsyncQueue

* fix `fetch_and_touch` test

* uncomment one more test
2022-07-19 20:05:09 +00:00
Pmarquez
abe324fc57
Fetch task (#26)
* fetch task async and renaming every Job/job to Task/task

* fixing cargo clippy

* Task instead Job in readme

* change one task because if not test will fail, redefined all tasks structs

* derive feature

* deleting schema

* changing query

* task builder

* fix bug enum fang task state

* fetch_test based on metadata, good improve testing fetch_task

* deleting toSql FromSql derives that are useless for Task

* builders and fail_task change
2022-07-19 13:49:43 +00:00
Pmarquez
9c478e66a4
Renaming task to job (#29) (#31) 2022-07-19 13:47:55 +00:00
Pmarquez
a60eb08fa6
fang_tasks queries done (#24)
* fang_tasks queries done

* queries with transaction rollback

* deleting unused imports

* some tests

* deleting schema , deleting feature section , updated_at corrected

* rollback and commit methods and execute modified

* transaction empty message

* fix cargo clippy
2022-07-18 10:44:05 +00:00
Pmarquez
e2481144dc
Merge pull request #25 from ayrat555/ayrat555/add-transaction
allow to use transaction to be able to rollback in tests
2022-07-17 19:41:41 +00:00
Ayrat Badykov
d186a5434c
allow to use transaction to be able to rollback in tests 2022-07-17 22:34:55 +03:00
Ayrat Badykov
c2c83d1031
async insert task query (#23)
* async insert task query

* return the number of rows
2022-07-17 19:22:00 +03:00
Pmarquez
5b61458b5f
sql queries (#22) 2022-07-17 15:06:23 +03:00
Ayrat Badykov
a707ce2f5c
start working on async queries 2022-07-17 10:13:45 +03:00
Ayrat Badykov
f999e55fa4
fix clippy 2022-07-17 09:16:54 +03:00
Ayrat Badykov
b1fbe8c5af
create sync mod 2022-07-17 09:10:32 +03:00
Ayrat Badykov
3bb45022d9
update typetag (#19)
* update `typetag`

typetage now requires rust 1.62

* stable rust

* disable extra-unused-lifetimes

the warning originates from diesel macro

* fix warning name
2022-07-01 09:03:27 +03:00
Ayrat Badykov
9545841152
fix clippy in nightly toolchain 2022-06-04 22:35:23 +03:00
Ayrat Badykov
ea5e740252
fix warning in the example project 2022-06-04 22:24:56 +03:00
Ayrat Badykov
216bac0f7e
update paypal link 2022-03-19 17:14:48 +02:00
dependabot[bot]
1de4254c52
ci(actions): bump actions/checkout from 2 to 3 (#16)
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-15 10:18:19 +02:00
Ayrat Badykov
a74d943896
fix shutdown test and add changelog entry 2021-12-05 08:43:17 +02:00
J
0473978460
Support graceful shutdown of worker (#14)
* Include shared state to allow graceful shutdown

Graceful shutdown of executors allows the current task to finish before
exiting. This prevents half completed tasks in the general case: when
workers are being scaled down.

To accomplish this a shared state (using an `Arc<RwLock<WorkerState>>`)
is created in a WorkerPool on instantiation. This shared state is then
passed to each thread (spawned with `WorkerThread::spawn_in_pool`), and
finally passed to the `Executor` instantiated by the `WorkerThread`.
This allows the infinit loop in the executor to receive signals from the
`WorkerPool`, and exit gracefully when requested.

* Add basic error handling

Add `FangError` enum derived from `thiserror::Error`. This should be the
default the error type for the Fang library, all errors returned by Fang
should be a value in this enum.

Use FangError for errors returned by start and shutdown, remove unwraps.

* Include instructions for running tests locally

* Track handles of panic'd worker threads

Allows the Drop trait impl of ThreadWorker to access the
`thread_join_handles` of WorkerPool so it can update the thread handle
when the previous thread unexpectedly exited and a new one is being
started. This is done in a way that prevents data leaks (by using a
Hashmap keyed off the name of the worker thread). It also ensures that
threads started from the Drop impl are properly joined on shutdown.

* Fix WorkerThread drop implementation

WorkerThread can not have `Clone` derived on it, as each cloned copy
will try to restart the thread when it's dropped, leading to an infinite
number of thread spawns till stack overflow. Oops

* Remove Option from SharedState type declaration

Instead of having an Option wrapping an enum, have the option codified
as a state in the enum.

* Bump version to 0.5.0

* Add integration test for shutdown

* Update simple_worker example to include signal monitoring and shutdown

* Update readme to mention using signal-hook to gracefully shutdown worker
2021-12-05 08:19:08 +02:00
Ayrat Badykov
b98cfedb33
bump version 2021-11-30 09:38:34 +02:00
Ayrat Badykov
5ee8b30448
bump deps (#13) 2021-11-30 09:31:11 +02:00
Ayrat Badykov
077e0a9b6d
try to trigger dependabot 2021-11-30 09:06:08 +02:00
Ayrat Badykov
f93faca772
Create FUNDING.yml 2021-08-26 12:42:15 +03:00
Ayrat Badykov
78f27eac3d
bump version to 0.4.1 2021-08-22 21:29:27 +03:00
Ayrat Badykov
4bf654c9b5
Do not use env logger, call log instead directly (#11)
* Do not use env logger, call log instead directly

* update example
2021-08-22 21:25:49 +03:00
Ayrat Badykov
d166313cab
add a note about El Monitorro 2021-08-18 22:09:49 +03:00
Ayrat Badykov
1aabb91206
bump version to 0.4.0 (#10)
* update readme

* remove note

* add CHANGELOG

* fix pr number
2021-07-31 10:40:11 +03:00
Ayrat Badykov
93e7e57d9a
Add simple example (#9)
* Add simple example

* fix env_logger
2021-07-31 09:47:53 +03:00
Ayrat Badykov
824e32f17b
pass PgConnection into run function (#8)
* pass PgConnection into run function

Changes:

- rename Postgres into Queue
- pass PgConnection into run function

* remove all tasks of specific type

* add pgconnection

* pass connection to every queue function

* add connection pool

* reuse connection in test

* update readme
2021-07-25 15:20:16 +03:00
Ayrat Badykov
cb02a03fea
bump version 2021-07-24 12:31:26 +03:00
Ayrat Badykov
7d92fd2d6a
Update Readme (#7)
* Update Readme

* change migration path in the readme
2021-07-24 12:13:59 +03:00
dependabot[bot]
1e0038a3e6
chore(cargo): update env_logger requirement from 0.8.4 to 0.9.0 (#6)
Updates the requirements on [env_logger](https://github.com/env-logger-rs/env_logger) to permit the latest version.
- [Release notes](https://github.com/env-logger-rs/env_logger/releases)
- [Changelog](https://github.com/env-logger-rs/env_logger/blob/main/CHANGELOG.md)
- [Commits](https://github.com/env-logger-rs/env_logger/compare/v0.8.4...v0.9.0)

---
updated-dependencies:
- dependency-name: env_logger
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-19 08:09:05 +03:00
Ayrat Badykov
45eb336b8a
Periodic tasks (#5)
* Periodic tasks

* schedule next execution

* add scheduler

* ignore test

* fix clippy

* make start public

* check if the period task already exists

* do not insert task if it's already in the queue

* fix tests
2021-07-18 22:09:30 +03:00
Ayrat Badykov
df1da87e13
bump version and add badges 2021-07-11 13:55:52 +03:00
Ayrat Badykov
b9e05213d9
fix workflow 2021-07-11 13:44:28 +03:00
Ayrat Badykov
12f6944e59
add github actions (#4)
* add github actions

* fix clippy

* skip check

* get rid of collect

* fix tests

* run ignored tests
2021-07-11 13:17:02 +03:00
Ayrat Badykov
4f50385c96
simplify usage by re-exporting serde traits (#3)
* simplify usage by re-exporting serde traits

* improve readme formatting

* use typetag

* try different approach

* reexport through macro

* fix re-exporting

* add CHANGELOG entry

* use typetag::serde in README
2021-07-11 10:26:20 +03:00
Ayrat Badykov
36e705a7ef
update README and bump version 2021-07-04 09:09:56 +03:00