Skip to main content

A Python HTTP client wrapper for CronyxServer, seamlessly integrating the power of Cronyx across platforms using a familiar API interface.

Project description

CronyxClient.py PyPI version CI/CD

API | Code of Conduct | Contributing | Changelog

A Python HTTP client wrapper for CronyxServer, seamlessly integrating the power of Cronyx across platforms using a familiar API interface.

🌟 Features

icon

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.

Why CronyxClient.py?

🌐 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.

🚀 Getting Started

Installation

Install the CronyxClient.py package using pip:

$ pip install cronyx-client
# or
# $ poetry add cronyx-client

Basic Usage

1. Manually Handling Job Execution:

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()

2. Using the Shorthand Callback:

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
)

Integrations and Compatibilities

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.

💻 Development

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.

  1. Install the Dev Containers extension in Visual Studio Code.

  2. Clone the repository:

git clone https://github.com/yujiosaka/CronyxClient.py.git
  1. Open the cloned repository in Visual Studio Code.

  2. When prompted by Visual Studio Code, click "Reopen in Container" to open the project inside the Docker container.

  3. The extension will build the Docker container and set up the development environment for you. This may take a few minutes.

  4. Build and run the Docker container with Docker Compose:

$ docker-compose up --build

This will start testing in watch mode.

🧑‍💻️ API reference

See here for the API reference.

🐞 Debugging tips

Enable debug logging

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.

💳 License

This project is licensed under the MIT License. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cronyx_client-1.0.0.tar.gz (8.0 kB view hashes)

Uploaded Source

Built Distribution

cronyx_client-1.0.0-py3-none-any.whl (8.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page