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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: neo_python_sdk-1.16.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.0 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.1.tar.gz
Algorithm Hash digest
SHA256 20c339c07c2eb8ffe754795e7f2c724dd5ba96dbdc8c87b03211546d7e95191f
MD5 2e990b4ca6be4e2f64039dc46206a0f5
BLAKE2b-256 62d1f747b106c772f570fc1435af28fa492e4b314b1206c7eb402986ae28a070

See more details on using hashes here.

File details

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

File metadata

  • Download URL: neo_python_sdk-1.16.1-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/4.0.0 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1248ef17aa206d7eade7b21af8db528d9f14920c1109af15ed9cefe681bb9100
MD5 490687a9f01fcab4c300955e5f21d024
BLAKE2b-256 2993b76e401851da4397b05cd36e94d9fd0d58601aaa3390407a56f1efec6b22

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