Commit graph

22 commits

Author SHA1 Message Date
Ayrat Badykov
a707ce2f5c
start working on async queries 2022-07-17 10:13:45 +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
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
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
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
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
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
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
df1da87e13
bump version and add badges 2021-07-11 13:55:52 +03:00
Ayrat Badykov
36e705a7ef
update README and bump version 2021-07-04 09:09:56 +03:00
Ayrat Badykov
c601984d37
prepare to publish on crates.io 2021-06-24 13:17:11 +03:00
Ayrat Badykov
3bc32c9c93
add job pool 2021-06-23 08:32:35 +03:00
Ayrat Badykov
e52c81ddde
execute a task 2021-06-20 11:10:02 +03:00
Ayrat Badykov
27f3e1479f
lock the selected task record 2021-06-12 15:59:09 +03:00
Ayrat Badykov
506fd1c4cb
insert tasks 2021-06-06 11:44:46 +03:00
Ayrat Badykov
8f1f1cc7fa
start working on storage level 2021-06-05 14:39:19 +03:00
Ayrat Badykov
d31d6096fa
initial commit 2021-05-30 11:35:00 +03:00