Skip to main content

Framework for rapidly developing a restful API that requires post processing

Project description

Drumpler

Drumpler is a general-purpose application designed to facilitate efficient workflow automation through RESTful API interactions and job processing. Built on Flask and SQLAlchemy, this application serves as a robust backend for capturing, storing, and processing HTTP requests in a scalable manner. The application is split into two main components: drumpler.py for handling RESTful API requests and mammoth.py for querying the API and processing jobs asynchronously.

High Level Overview

Image Description

Features

  • RESTful API Endpoints: Secure and scalable endpoints for handling HTTP requests, including POST, GET, PUT, and DELETE operations.
  • Database Integration: Utilizes SQLAlchemy for ORM-based interactions with Postgres.
  • Job Processing: Facilitates the asynchronous processing of tasks with support for multi-threading and multi-processing, ensuring efficient workflow automation.
  • Event Logging: Detailed event logging for each HTTP request, job processing and related events, allowing for easy tracking and management of tasks.

Prerequisites

Before you begin, ensure you have the following installed:

  • Python 3.6 or later
  • PostgreSQL

Installation

Install Drumpler via pip: pip install Drumpler

Configuration

Create a .env file in the root directory of the application with the following contents:

AUTHORIZATION_KEY=AUTH_KEY_HERE
DRUMPLER_HOST=IP_HERE
DRUMPLER_PORT=PORT_HERE
DRUMPLER_DEBUG=BOOL_FLAG
DB_NAME=DB_NAME_HERE
DB_HOST=DB_HOST_HERE
DB_USER=DB_USER_HERE
DB_PASS=DB_PASS_HERE

Replace your_database_uri_here and your_authorization_key_here with your actual database URI and desired authorization key.

Using the Application - Drumpler

To create a Drumpler RESTful server, the following is a sample implementation:

import drumpler

# Now, you can create an instance of the Drumpler class
app = drumpler.Drumpler(host="0.0.0.0", port=5000, debug=True)  # Adjust as necessary

# And call the run method on this instance
app.run()

API Endpoints

Drumpler exposes the following endpoints for interacting with its system:

  • POST /request: Submit a new request for processing.
  • GET /request/<int:request_id>: Retrieve a specific request by its ID.
  • GET /request/next-unhandled: Fetch the next unhandled request.
  • PUT /request/<int:request_id>: Update the status of a request.
  • DELETE /request/<int:request_id>: Delete a specific request.

Using the Application - Mammoth

To create a Mammoth (request-processor), the following is a sample implementation:

from drumpler.mammoth import Mammoth

def custom_process_function(session, request, job_id):
    # this is the driver method for your customized workflow
    pass

# Initialize Mammoth
DRUMPLER_HOST = "http://127.0.0.1"
DRUMPLER_PORT = 5000  # Adjust the URL/port as necessary
DRUMPLER_URL = f"{DRUMPLER_HOST}:{DRUMPLER_PORT}"  # Adjust the URL/port as necessary
MAMMOTH_WORKERS = 1
mammoth = Mammoth(process_request_data=custom_process_function, drumpler_url=DRUMPLER_URL, workers=MAMMOTH_WORKERS)

if __name__ == "__main__":
    print("Starting Mammoth... Press CTRL+C to stop.")
    mammoth.run()

Contributing

Contributions to Drumpler are welcome! Please follow the standard fork-branch-PR workflow.

License

This project is licensed under the MIT License - see the LICENSE file 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

drumpler-2.2.5.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

Drumpler-2.2.5-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file drumpler-2.2.5.tar.gz.

File metadata

  • Download URL: drumpler-2.2.5.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for drumpler-2.2.5.tar.gz
Algorithm Hash digest
SHA256 d727f0ba2c56e7c37e5de669590ac5e89cb2988e8192fd1493064bfc77bb46d9
MD5 add44485181f13853369b836df35504e
BLAKE2b-256 6dbdd9f8d35a5cc5b00aab9ba06c245b55c10866e4ed84b9f131cb26febcea7f

See more details on using hashes here.

File details

Details for the file Drumpler-2.2.5-py3-none-any.whl.

File metadata

  • Download URL: Drumpler-2.2.5-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for Drumpler-2.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 b0686f8abd4f35752ee091bbbe925a44b47982c9afc5aab2e95b8e0928eec271
MD5 23c56a495973553c291bfcdce2f30177
BLAKE2b-256 dab6c42d01019395f5cae975339154ce0c02473c3cf952f26adf2922f1964165

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