* 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>
* Set task_type when starting a worker pool (#64)
* make queue fields public
* Set task_type when starting a worker pool
* make fields private again
* bump version
* 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>
* 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
* 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>
* 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
* 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