Skip to main content

Run arbitrary code on a remote http server through a simple API. This greatly facilitates communication and sharing workloads across nodes in a JSON application.

INSTALLATION

pip install pop-gate

USAGE

Run the gate server from the command line and expose specific patterns of hub references. The ‘–refs’ represent patters on the hub that are allowlisted. The ‘–prefix’ tells gate to assume that all refs are under a specific dynamic namespace.

In this example we will use a prefix of “gate” and allow all refs under ‘hub.gate.init’

gate --prefix gate --refs "init.*"

Use curl to run hub.gate.init.test() on the remote server like so:

curl http://localhost:8080 -H "Content-Type: application/json" -d '{"ref": "init.test"}'

Keyword arguments can be passed by adding extra keys to the call:

curl http://localhost:8080 -H "Content-Type: application/json" -d '{"ref": "init.test", "kwarg1": "value1", "kwarg2": "value2"}'

TESTING

Install gate locally with testing libraries:

git clone git@gitlab.com:saltstack/pop/gate.git
pip install -e gate -r requirements-test.txt

Run the tests with pytest

pytest tests

INTEGRATION

In order to use gate in your own project add the gate config to your conf.py like so:

my_project/conf.py

CLI_CONFIG = {
    # Gate options
    "host": {"source": "gate"},
    "port": {"source": "gate"},
    "server": {"source": "gate"},
    "matcher": {"source": "gate"},
    "prefix": {"source": "gate"},
    "refs": {"source": "gate", "default": ["gate.init.test"]},
}

Add gate startup code to your project’s initializer like so:

my_project/my_project/init.py

def __init__(hub):
    # Horizontally merge the gate dynamic namespace into your project
    hub.pop.sub.add(dyne_name="gate")

def cli(hub):
    # Load the config from gate onto hub.OPT
    hub.pop.config.load(["my_project", "gate"], cli="my_project")

    # Create the asyncio loop
    hub.pop.loop.create()

    # Get the default gate server, and other options from hub.OPT.gate
    gate_server = hub.OPT.gate.server

    # Create the server coroutine
    coro = hub.gate.init.start(gate_server=gate_server)

    # Start the gate server
    hub.pop.Loop.run_until_complete(coro)

Metadata

Release files for pop-gate 1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pop-gate 1
File Size Uploaded
pop-gate-1.tar.gz 6.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pop-gate 1
File Interpreter ABI Platform
pop_gate-1-py3-none-any.whl Python 3 none any Details

Total release size: 13.6 kB

Release files / pop-gate-1.tar.gz

Download URL pop-gate-1.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
cfbbce8917977b98e9248c90cd7bb70c60ffb77fbad2196cd43e35048d4c5808
BLAKE2b-256 checksum
How to use checksums
39465fb1a5dab9f6ee45f459fa12e01a6740677a123e2a154198be7c52f9171e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release files / pop_gate-1-py3-none-any.whl

Download URL pop_gate-1-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e07c9e15f652638d2bc946c38577d90eb7df319dc84bfec9d04d4d1425183f81
BLAKE2b-256 checksum
How to use checksums
2c957acad812939b3a7dfd82718e68ba08dd561b2a2904f7177c7a507d4ddcd9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release history Release notifications | RSS feed

6.0.2

2 release files

6.0.1

2 release files

6.0.0

2 release files

5

2 release files

4

2 release files

2

2 release files

1.2

2 release files

1.1

2 release files

This release

1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page