Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Readme
Easy Asynchronous Jobs Manager for Developers
Explore the docs »
Website
·
Examples in Python
·
Tutorial in Python
Zenaton helps developers to easily run, monitor and orchestrate background jobs on your workers without managing a queuing system. In addition to this, a monitoring dashboard shows you in real-time tasks executions and helps you to handle errors.
The Zenaton library for Python lets you code and launch tasks using Zenaton platform, as well as write workflows as code. You can sign up for an account on Zenaton and go through the tutorial in python.
This package has been tested with Python 3.5.
You can find all details on Zenaton's website.
To install the Zenaton agent, run the following command:
curl https://install.zenaton.com/ | sh
Then, you need your agent to listen to your application. To do this, you need your Application ID and API Token. You can find both on your Zenaton account.
zenaton listen --app_id=YourApplicationId --api_token=YourApiToken --app_env=YourApplicationEnv --boot=boot.py
To add the latest version of the library to your project, run the following command:
pip install zenaton
If you are using Django, please refer to our dedicated documentation to get started:
To start, you need to initialize the client. To do this, you need your Application ID and API Token. You can find both on your Zenaton account.
Then, initialize your Zenaton client:
from zenaton.client import Client
Client(your_app_id, your_api_token, your_app_env)
A background job in Zenaton is a class implementing the Zenaton.abstracts.task.Task
interface.
Let's start by implementing a first task printing something, and returning a value:
import random
from zenaton.abstracts.task import Task
from zenaton.traits.zenatonable import Zenatonable
class HelloWorldTask(Task, Zenatonable):
def handle(self):
print('Hello World\n')
return random.randint (0, 1)
Now, when you want to run this task as a background job, you need to do the following:
HelloWorldTask().dispatch()
That's all you need to get started. With this, you can run many background jobs. However, the real power of Zenaton is to be able to orchestrate these jobs. The next section will introduce you to job orchestration.
Job orchestration is what allows you to write complex business workflows in a simple way. You can execute jobs sequentially, in parallel, conditionally based on the result of a previous job, and you can even use loops to repeat some tasks.
We wrote about some use-cases of job orchestration, you can take a look at these articles to see how people use job orchestration.
A workflow in Zenaton is a class implementing the Zenaton.abstracts.workflow.Workflow
interface.
We will implement a very simple workflow:
First, it will execute the HelloWorld
task.
The result of the first task will be used to make a condition using an if
statement.
When the returned value will be greater than 0
, we will execute a second task named FinalTask
.
Otherwise, we won't do anything else.
One important thing to remember is that your workflow implementation must be idempotent. You can read more about that in our documentation.
The implementation looks like this:
from tasks.hello_world_task import HelloWorldTask
from tasks.final_task import FinalTask
from zenaton.abstracts.workflow import Workflow
from zenaton.traits.zenatonable import Zenatonable
class MyFirstWorkflow(Workflow, Zenatonable):
def handle(self):
n = HelloWorldTask().execute()
if n > 0:
FinalTask().execute()
Now that your workflow is implemented, you can execute it by calling the dispatch
method:
MyFirstWorkflow().dispatch()
If you really want to run this example, you will need to implement the FinalTask
task.
There are many more features usable in workflows in order to get the orchestration done right. You can learn more in our documentation.
Need help? Feel free to contact us by chat on Zenaton.
Found a bug? You can open a GitHub issue.
Triggering An Email After 3 Days of Cold Weather (Medium Article, Source Code)
Bug reports and pull requests are welcome on GitHub here. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
To test your changes before sending a pull request, first install the tests requirements:
pip install '.[test]'
Then run PyTest:
pytest
The package is available as open source under the terms of the MIT License.
Everyone interacting in the zenaton-Python project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
custom_id
argument for workflow schedule.intent_id
property when dispatching workflows and tasks, sending events to workflows, and
pausing/resuming/killing workflows.on_error_retry_delay
method handling task failures and specifying
how many seconds to wait before retrying.Added a intent_id
property when dispatching workflows and tasks, sending events to workflows, and
pausing/resuming/killing workflows.
Added scheduling: schedule(cron)
day_of_month
on a wait task now waits for to wait for the next day having the requested day number, even if that means waiting for next month. (i.e calling Wait().day_of_month(31) on February, 2nd will wait for March, 31st)event_data
property when sending event.MANIFEST.in
file not included files required by setup.py
.dispatch
on tasks now allows to process tasks asynchronouslyFixed Wait task behavior in some edge cases Encodes HTTP params before sending request
Object Serialization (including circular structures)
Enhanced WithDuration & WithTimestamp classes
Minor enhancements (including the workflow find() method)
New version scheme management
Reorganized modules
Full rewriting of the package
FAQs
Zenaton client library
We found that zenaton demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.