Skip to main content

Neo SDK for Python with some additional libraries to support the development of Neo Sentinels (NSX).

Project description

Neo SDK: Python 3 🐍

Neo SDK for Python with some additional libraries to support the development of Neo Sentinels (NSX).

Terminology

  • Task: A task (or Sentinel Task) is a job processed or created by so called Sentinels.
  • Sentinel: Fancy name for a worker consuming / producing tasks. They are usually not that evil.
  • Particle: All tasks / messages / responses flowing through the Neo internals are generalized as „particles“. Particles can be the payload for tasks, the response to the Neo client or just some metadata. Particles have to be objects.

Installation

pip install neo_python_sdk

Configuration

The Neo SDK can be configured through environment variables (ENVs in short). The following ENVs are supported:

  • NPQ_DISABLE_AUTOCONNECT: Set to true in order to prevent the SDK from autoconnecting.
  • NPQ_NAME: A identifiable name for your Sentinel.

Usage

To use it you have to import it in Python with the following import:

import neo_python_sdk as Neo

Quick start

Consuming tasks

import neo_python_sdk as Neo
import asyncio

# processing tasks requires a queue name
# the request object will be passed to the provided processor (a function)
# the "processor" should use async / await
async def start_neo_tasks(loop):
    neo = await Neo.init(loop)
    async def process_request(payload):
        res = f"Hi there, {payload["user"]}"
        return res

    await neo.process("nsx.dev.example.sayHello", process_request)

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(start_neo_tasks(loop))
    loop.run_forever()

Creating tasks

import neo_python_sdk as Neo
import asyncio

async def execute_task(loop):
    neo = await Neo.init(loop)
    response = await neo.create("nsx.dev.example.sayHello", {"user": "John"})
    print(f"Server responded: {response}")


if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(execute_task(loop))

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

neo_python_sdk-1.15.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

neo_python_sdk-1.15.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file neo_python_sdk-1.15.0.tar.gz.

File metadata

  • Download URL: neo_python_sdk-1.15.0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for neo_python_sdk-1.15.0.tar.gz
Algorithm Hash digest
SHA256 00dd9a7e3e6a642fdf3c260cd8d53bd519540ca9aea2d1cd07d0b167e61d41f9
MD5 80f757acb71fbf626b9ebb46daa82284
BLAKE2b-256 121da1aefcaba1f9db14c2b6c7d98428205b0e54aa58f843563dc29aef65db05

See more details on using hashes here.

File details

Details for the file neo_python_sdk-1.15.0-py3-none-any.whl.

File metadata

  • Download URL: neo_python_sdk-1.15.0-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for neo_python_sdk-1.15.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fd213765064bedad69e8c04efcfefc8bb32e603946870962ab166eb9c58e8a52
MD5 1cbe1f80587201d4a741b6a21c5a488e
BLAKE2b-256 8c502c4e9dad416a930728ab6b86505fd2b8221ddf60c569088e9f46239cc441

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