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.
  • NPQ_CA: The CA to authenticate the NPQ against, when using TLS. See (https://docs.nats.io/developing-with-nats/security/tls)
  • NPQ_CERT: The client cert to use signed by the NPQ_CA
  • NPQ_CERT_KEY: The key belonging to NPQ_CERT

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.16.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

neo_python_sdk-1.16.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: neo_python_sdk-1.16.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for neo_python_sdk-1.16.0.tar.gz
Algorithm Hash digest
SHA256 3416b195b30ef64810db6c912ac47885c7e7654fce3a73189e423c7dd661e510
MD5 7936f11f21722cd3d366d539dcddc7f4
BLAKE2b-256 16466bf3d83733b9f2de9092638932d53f5217b162729a718523f674bdfd563e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: neo_python_sdk-1.16.0-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for neo_python_sdk-1.16.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bbce22d40f8fe2aa7b6eb0853fc60d0d0d05748f62a3751d1e7a73b7d057ce72
MD5 deb7af90ac257fa803c7fff7d7890dbb
BLAKE2b-256 018a3c7af4276bb67ebf752d79794c0c259b82f75415315a7dfea210ce3b74a2

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