A Python HTTP client wrapper for CronyxServer, seamlessly integrating the power of Cronyx across platforms using a familiar API interface.
![icon](https://private-user-images.githubusercontent.com/2261067/280556347-08e074cf-9256-4b15-ae14-f3e607165f54.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk3ODE4NDUsIm5iZiI6MTczOTc4MTU0NSwicGF0aCI6Ii8yMjYxMDY3LzI4MDU1NjM0Ny0wOGUwNzRjZi05MjU2LTRiMTUtYWUxNC1mM2U2MDcxNjVmNTQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTdUMDgzOTA1WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OTRjYjhiYTUxMzVmZDdlNGMyM2EyNTgzYTY1ZmRjNmVmOWJiYzYxOWM1ZDU4ZjM4Y2I0OGIxNzQ5OTMxODBjZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.w_CsOEmYZO3b__UfRZtAN_BHjBGP1Opq5Unds4hAYo8)
CronyxClient.py bridges the capabilities of Cronyx and CronyxServer, offering a way to schedule and manage tasks without losing the feel of the original Cronyx API.
π Unified Experience: Retain the simplicity and power of the Cronyx API while benefiting from the language-agnostic capabilities of CronyxServer.
π Plug & Play: With just a URL configuration, connect to any running instance of CronyxServer and harness its capabilities without changing your existing Cronyx codebase.
π Familiar API with Async/Await: Use the same API calls you're familiar with from Cronyx, with the added advantage of Python's async
and await
syntax for handling asynchronous operations.
Install the CronyxClient.py package using pip:
$ pip install cronyx-client
# or
# $ poetry add cronyx-client
CronyxClient.py mirrors the usage of Cronyx, with the additional specification of the CronyxServer URL:
from cronyx_client import CronyxClient
cronyx = CronyxClient(url="http://localhost:3000/")
job = await cronyx.request_job_start(
job_name="hourly-job",
job_interval="0 * * * *",
)
# Check if the job is due to run
if job:
try:
print(job.interval_started_at)
print(job.interval_ended_at)
await job.finish()
except Exception as e:
await job.interrupt()
from cronyx_client import CronyxClient
async def task(job):
print(job.interval_started_at)
print(job.interval_ended_at)
cronyx = CronyxClient(url="http://localhost:3000/")
await cronyx.request_job_exec(
job_name="hourly-job",
job_interval="0 * * * *",
task=task
)
CronyxClient.py is built on top of the Cronyx foundation, ensuring compatibility and integration with:
- Cronyx: Maintain the same API functions and structures, ensuring a seamless transition to CronyxClient.py.
- CronyxServer: Directly communicates with the server using its RESTful endpoints, translating your Cronyx API calls to HTTP requests.
Using Visual Studio Code and the Dev Containers extension, you can simplify the development environment setup process. The extension allows you to develop inside a Docker container and automatically sets up the development environment for you.
-
Install the Dev Containers extension in Visual Studio Code.
-
Clone the repository:
git clone https://github.com/yujiosaka/CronyxClient.py.git
-
Open the cloned repository in Visual Studio Code.
-
When prompted by Visual Studio Code, click "Reopen in Container" to open the project inside the Docker container.
-
The extension will build the Docker container and set up the development environment for you. This may take a few minutes.
-
Build and run the Docker container with Docker Compose:
$ docker-compose up --build
This will start testing in watch mode.
See here for the API reference.
Configure the log level using the LOG_LEVEL
environment variable.
env LOG_LEVEL="DEBUG" python script.py
CronyxClient.py utilizes Python's logging
module for logging debug messages. Ensure that you have the logger configured in your application to capture these logs.
This project is licensed under the MIT License. See LICENSE for details.