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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file cronyx_client-1.0.0.tar.gz.

File metadata

  • Download URL: cronyx_client-1.0.0.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.0 CPython/3.11.6 Linux/6.2.0-1015-azure

File hashes

Hashes for cronyx_client-1.0.0.tar.gz
Algorithm Hash digest
SHA256 db7220e62e3edfdb62d766b780e112185d3c40a6f80ef7ce959f7053212923fe
MD5 d3464c12a6cb03f9acc0bba0bf494e10
BLAKE2b-256 c5b6ba19e2b1e2eee447f3ff61ebe0bb76dc31e407148bfbdab4b7f089f0cce4

See more details on using hashes here.

File details

Details for the file cronyx_client-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: cronyx_client-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.0 CPython/3.11.6 Linux/6.2.0-1015-azure

File hashes

Hashes for cronyx_client-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fedae2bc3a1bd72b177cc474a95060355387921035a73594f09207d3dfce57b3
MD5 d50018720206081a5577986eb4035c28
BLAKE2b-256 341b3205be7953f755bfaf58d904f4915b8c7ee19cdbf9404eda95e0ed774116

See more details on using hashes here.

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