Skip to main content

Python starter service

Project description

python-starter-service

This is a starter service project template. Use this template to create a new service project.

Getting started

First you need to provide ENV variables for the service to run.

ENV variables

Main ENV variables:

  • CLIENT_ID - client id of the service
  • REST_API_ENABLED - enable/disable REST API (default: true)

Kafka

  • CONSUME - comma separated list of topics to consume
  • PRODUCE - comma separated list of topics to produce
  • KAFKA_HOST - kafka host
  • SCHEMA_REGISTRY - schema registry host
  • MAX_POLL_INTERVAL_MS - max poll interval in ms (default: 600000)
  • SESSION_TIMEOUT_MS - session timeout in ms (default: 600000)

Usage

Check the provided examples in the examples folder.

Example

from starter_service import StarterService

class ExampleService(StarterService):

    def health(self):
        """ Health check endpoint """
        return "OK"

    def ready(self):
        """ Ready check endpoint """    
        return True

    def process(self, message):
        """ Process message """

    @API.post(consumer="article_raw_en", producer="metadata_item_key_en", doc="Process raw article and return metadata")
    def handle_message(self, message: dict):
        """ Process raw article and return metadata """
        return {
            "articleId": message['id'],
            "origin": "string",
            "data": [
                {
                    "type": "string",
                    "value": "string",
                    "confidence": 0,
                    "metadata": {
                        "string": "string"
                    }
                }
            ]
        }

    if __name__ == '__main__':
        ExampleService()

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

osint-python-starter-service-2.2.3.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file osint-python-starter-service-2.2.3.tar.gz.

File metadata

File hashes

Hashes for osint-python-starter-service-2.2.3.tar.gz
Algorithm Hash digest
SHA256 4cb7c6d9fb7f8d5356e1922a4e0adf8567787a0ab8fbd4e215ad60d52808504e
MD5 326a09a905194e4a4c9f1375b30dc66c
BLAKE2b-256 a24f5079a8cc96bc52035bcb777ae8d7a3bd0951d9be083d32a62308838ede9c

See more details on using hashes here.

File details

Details for the file osint_python_starter_service-2.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for osint_python_starter_service-2.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6677b625e2f625fae2452fabebf899f5fa35365ca9de945ff0dff61fd05137ec
MD5 29a3673c1a9e0f9ebf4764e97523db83
BLAKE2b-256 1a96473663f6eb74f75797a5d2cb1014df213517b28e6c421c2002a94fe08d6f

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