Commit graph

19 commits

Author SHA1 Message Date
18303be796
Make workers go brrrr... 2023-03-04 20:46:09 +01:00
0be173ef02
Support only async 2023-03-04 19:07:17 +01:00
Ayrat Badykov
a9c4faa338
Update crates (#111)
* update `diesel-derive-enum` from `2.0.0-rc.0` to `2.0.1`

* add CHANGELOG entry
2023-02-23 09:33:24 +02:00
Ayrat Badykov
19598d63cb
fix examples (#94) 2022-09-18 16:05:26 +03:00
Pmarquez
7fb4423bf5
update README and CHANGELOG, bump version (#79)
* README and CHANGELOG

* FUNDING

* bump version

Co-authored-by: Ayrat Badykov <ayratin555@gmail.com>
2022-09-03 11:27:03 +03:00
pxp9
ac45f36819
Examples fixed 2022-09-01 19:16:18 +02:00
Pmarquez
360140d064
Blocking refactor (#74)
* Adapting code to new Fang tables structure and refactoring to make it more generic (Not finished)

* Refactoring of the blocking module

* Finishing blocking module, starting to modify tests

* Worker tests done, Queue tests left

* Maybe all tests done ??

* Makefile clippy

* Examples fixed

* asynk feature

Co-authored-by: Ayrat Badykov <ayratin555@gmail.com>
2022-08-29 16:59:22 +00:00
Pmarquez
dffee33b9c
Asynk change schema (#75)
* add uniq method for AsyncRunnable trait (#70)

* add uniq method for asyncrunnable

* add hash enum

* remove string

* return bool values

* Task struct modified (#71)

* Task struct modified

* asynk module try to adapt new scheme

* delete period in millis

* delete period in millis completed

* Cron support :D

* Cron and single Schedule support :D

* Current timestamp value

* fix bug and new test that confirms that it was a bug

* fix a call

* Update Cargo.toml

Co-authored-by: Ayrat Badykov <ayratin555@gmail.com>

* comments suggestions

* fix clippy

* Better user api for schedule with cron

* Cron tested with example

* Comments adressed

* Comments adressed

Co-authored-by: Ayrat Badykov <ayratin555@gmail.com>

Co-authored-by: Ayrat Badykov <ayratin555@gmail.com>
2022-08-27 15:58:38 +00:00
Ayrat Badykov
ead367d33f
Recover from panics draft (#57)
* Recover from panics draft

* Handling worker pool panics and Scheduler panics , fix clippy also

* Update src/asynk/async_scheduler.rs

Co-authored-by: Ayrat Badykov <ayratin555@gmail.com>

* add new task

Co-authored-by: pxp9 <48651252+pxp9@users.noreply.github.com>
2022-08-04 15:22:53 +00:00
Pmarquez
cf2ce19c97
Handle imports and dependencies (#56)
* imports, exports and README

* serde_json not necessay

* deleting tokio_postgres

* authors

* blocking example

* Update fang_examples/simple_async_worker/src/lib.rs

Co-authored-by: Ayrat Badykov <ayratin555@gmail.com>
2022-08-03 08:37:53 +00:00
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
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
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
Ayrat Badykov
ea5e740252
fix warning in the example project 2022-06-04 22:24:56 +03: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
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
93e7e57d9a
Add simple example (#9)
* Add simple example

* fix env_logger
2021-07-31 09:47:53 +03:00