Skip to main content

Add your description here

Project description

Arkitekt Gateway

A Python library for managing a Tailscale-based sidecar proxy. Arkitekt Gateway bundles a Go binary that handles secure networking via Tailscale, with full Python control over the process lifecycle, signal handling, and log streaming.

Features

  • 🚀 Multi-platform support - Pre-built binaries for Linux, macOS, and Windows (x86_64 and ARM64)
  • 🔄 Async-first API - Full asyncio support with context managers
  • 📡 Signal handling - Send SIGINT, SIGTERM, or any signal to the sidecar
  • 📝 Log streaming - Async iterator and callback-based log access
  • 🖥️ CLI included - Typer-based command-line interface
  • 🔒 Lifecycle management - Python controls when the sidecar starts and stops

Installation

pip install arkitekt-gateway

Or with uv:

uv add arkitekt-gateway

Quick Start

Command Line

# Run the sidecar proxy
arkitekt-gateway run \
  --authkey tskey-auth-xxxxx \
  --coordserver https://your-coordination-server.com \
  --hostname my-proxy \
  --port 8080

# Check binary info
arkitekt-gateway info

Environment variables are also supported:

export TS_AUTHKEY="tskey-auth-xxxxx"
export TS_COORDSERVER="https://your-coordination-server.com"
arkitekt-gateway run

Python API

Basic Usage

import asyncio
from arkitekt_gateway import Sidecar, SidecarConfig

async def main():
    config = SidecarConfig(
        authkey="tskey-auth-xxxxx",
        coordserver="https://your-coordination-server.com",
        hostname="my-proxy",
        port="8080",
    )
    
    async with Sidecar(config) as sidecar:
        print(f"Sidecar running with PID: {sidecar.pid}")
        
        # Wait for it to run (or do other work)
        await asyncio.sleep(10)
    
    # Sidecar is automatically stopped when exiting the context

asyncio.run(main())

Streaming Logs

async def main():
    config = SidecarConfig(
        authkey="tskey-auth-xxxxx",
        coordserver="https://your-coordination-server.com",
    )
    
    async with Sidecar(config) as sidecar:
        async for log in sidecar.logs():
            print(f"[{log.stream}] {log.line}")

asyncio.run(main())

Using Log Callbacks

from arkitekt_gateway import Sidecar, SidecarConfig, LogLine

async def log_handler(log: LogLine):
    if "error" in log.line.lower():
        print(f"ERROR: {log.line}")

async def main():
    config = SidecarConfig(
        authkey="tskey-auth-xxxxx",
        coordserver="https://your-coordination-server.com",
    )
    
    sidecar = Sidecar(config)
    sidecar.on_log(log_handler)
    
    await sidecar.start()
    try:
        await sidecar.wait()
    finally:
        if sidecar.is_running:
            await sidecar.stop()

asyncio.run(main())

Sending Signals

import signal

async def main():
    config = SidecarConfig(
        authkey="tskey-auth-xxxxx",
        coordserver="https://your-coordination-server.com",
    )
    
    async with Sidecar(config) as sidecar:
        # Do some work...
        await asyncio.sleep(5)
        
        # Send interrupt signal
        await sidecar.interrupt()
        
        # Or send any signal
        await sidecar.send_signal(signal.SIGTERM)

asyncio.run(main())

API Reference

SidecarConfig

Configuration dataclass for the sidecar process.

Parameter Type Default Description
authkey str required Tailscale authentication key
coordserver str required Coordination server URL
hostname str "ts-proxy" Hostname in the Tailnet
port str "8080" Port to listen on
statedir str "" State directory for Tailscale data

Sidecar

Async wrapper for the Go sidecar binary.

Properties

Property Type Description
is_running bool Whether the sidecar process is running
pid int | None Process ID of the sidecar
exit_code int | None Exit code if the process has terminated

Methods

Method Description
await start() Start the sidecar process
await stop(timeout=5.0) Stop the sidecar gracefully (SIGTERM, then SIGKILL)
await wait() Wait for the sidecar to exit
await interrupt() Send SIGINT to the sidecar
await send_signal(sig) Send any signal to the sidecar
async for log in logs() Async iterator for log lines
on_log(callback) Register an async callback for log lines

LogLine

Represents a log line from the sidecar.

Field Type Description
stream str Either "stdout" or "stderr"
line str The log message

Development

Local Setup

# Clone the repository
git clone https://github.com/jhnnsrs/arkitekt-gateway.git
cd arkitekt-gateway

# Install dependencies
uv sync --all-extras --dev

# Download the sidecar binary for local development
python dev.py

# Run tests
uv run pytest tests -v

Building

The package uses hatchling with a custom build hook that downloads the appropriate platform-specific binary during wheel building.

uv build

License

License

MIT

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

arkitekt_gateway-1.2.0.tar.gz (33.7 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

arkitekt_gateway-1.2.0-py3-none-win_amd64.whl (16.7 MB view details)

Uploaded Python 3Windows x86-64

arkitekt_gateway-1.2.0-py3-none-macosx_11_0_arm64.whl (16.0 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file arkitekt_gateway-1.2.0.tar.gz.

File metadata

  • Download URL: arkitekt_gateway-1.2.0.tar.gz
  • Upload date:
  • Size: 33.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for arkitekt_gateway-1.2.0.tar.gz
Algorithm Hash digest
SHA256 a2d6c93c97fce6c3be372d9fd9567ba4928dc3f71969558a03f39d93f55bb5a2
MD5 d2823f04953918ef8d4406c1be369b03
BLAKE2b-256 e3c93a51b731c63e42c98f4ca9578149a112bf15c3b58863be445febe5e119a8

See more details on using hashes here.

File details

Details for the file arkitekt_gateway-1.2.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: arkitekt_gateway-1.2.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 16.7 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for arkitekt_gateway-1.2.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 e81636ac67e6e5d2f511e8041a0e15c36604e6f8be9bed1c54a3434b176643b8
MD5 d556fa66ada537c7f5ffd1124d5ccd79
BLAKE2b-256 5c33754f73359062dec1f787be6f81866c0c558c719e4ec34d7db53ddb305389

See more details on using hashes here.

File details

Details for the file arkitekt_gateway-1.2.0-py3-none-manylinux2014_x86_64.whl.

File metadata

  • Download URL: arkitekt_gateway-1.2.0-py3-none-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 16.9 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for arkitekt_gateway-1.2.0-py3-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 63bbfc6e1c05378d38f81774ead6158d102e3b2c2bee8f82bb1170069d1caffe
MD5 b8a053b579a08af1d2550fa777d0a118
BLAKE2b-256 233645c50404ab7a11d29801a0911a343f1a4651a228894e93f75ffd0ef01f89

See more details on using hashes here.

File details

Details for the file arkitekt_gateway-1.2.0-py3-none-macosx_11_0_arm64.whl.

File metadata

  • Download URL: arkitekt_gateway-1.2.0-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 16.0 MB
  • Tags: Python 3, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for arkitekt_gateway-1.2.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 564c90f20d8f45cecd9e9494bfdc643157cece0ba35ecf9dcd5e41e1687ee8c0
MD5 02bede2d9f20f263cca7fff8d5881ca4
BLAKE2b-256 745a11c368705803eb207b761633528f5eb767a8ada946d9660a8832ca42e7d4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page