Skip to main content

attp-sdk

Project description

attp-sdk

ATTP Software Development Kit

Typing SVG

The robust Python SDK for building distributed services with the ATTP protocol.

Stars Python 3.11+ Ascender Framework PyPI License


📖 Introduction

attp-sdk is the official Python library for integrating with the Ascender ecosystem using the ATTP (Ascender Tool Transmission Protocol). It provides a powerful set of tools to build high-performance, scalable, and reactive microservices.

With attp-sdk, you can effortlessly create controllers, handle RPC calls, manage events, and orchestrate service lifecycles, all while leveraging the robustness of the Ascender Framework.

⚡ Features

  • RPC Decoration: Simple @AttpCall decorators to expose methods as RPC endpoints.
  • Event Driven: Reactive @AttpEvent handlers for asynchronous communication.
  • Lifecycle Management: Hooks for @AttpLifecycle events like connect and disconnect.
  • Error Handling: Centralized @AttpErrorHandler for graceful failure management.
  • Dependency Injection: Seamless integration with Ascender's DI system.
  • Transmitter: Fluent API for sending requests and notifications.

📦 Installation

Install via Poetry:

poetry add attp-sdk

Or using Pip:

pip install attp-sdk

Or using UV:

uv add attp-sdk

⚙️ Configuration

attp-sdk uses a configuration file (usually attp.jsonc or attp.json) to define node identity, authentication, and peer services.

Example attp.jsonc

{
  "node": {
    "name": "my-service",
    "bind": "0.0.0.0:6563"
  },
  "caps": ["schema/msgpack", "streaming"],
  "client": {
    "auth": {
      "mode": "hmac",
      "secret": { "env": "ATTP_SHARED_SECRET" },
      "node_id": "my-service",
      "ttl_seconds": 30
    }
  },
  "services": {
    "peers": [
      { "namespace": "core-service", "uri": "attp://core-api:6563" }
    ]
  }
}

🚀 Usage

Creating a Controller

Define your service logic using a class-based controller.

from ascender.core import Controller
from attp.decorators import AttpCall, AttpEvent, AttpLifecycle
from attp.types.frame import AttpFrameDTO

class EchoRequest(AttpFrameDTO):
    message: str

class EchoResponse(AttpFrameDTO):
    message: str

@Controller(
    standalone=True,
    providers=[],
)
class MyController:
    
    @AttpCall("echo", namespace="core-service")
    async def echo(self, payload: EchoRequest) -> EchoResponse:
        print(f"Received: {payload.message}")
        return EchoResponse(message=payload.message)

    @AttpEvent("user.created")
    async def on_user_created(self, payload: dict):
        print(f"New user: {payload.get('id')}")

    @AttpLifecycle("connect")
    async def on_connect(self, meta: dict):
        print("Connected to ATTP network")

Sending Messages

Use the AttpTransmitter to send requests or emit events.

from attp.shared.transmitter import AttpTransmitter

# In your controller or service
async def trigger_action(self):
    response = await self.transmitter.send(
        "remote_procedure",
        MyPayload(data="foo"),
        namespace="target-service",
        expected_response=MyResponse
    )

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.


Built with ❤️ by the Ascender Team

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

attp_sdk-0.1.1.tar.gz (31.9 kB view details)

Uploaded Source

Built Distribution

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

attp_sdk-0.1.1-py3-none-any.whl (50.4 kB view details)

Uploaded Python 3

File details

Details for the file attp_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: attp_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 31.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.11.13 Linux/6.18.2-arch2-1

File hashes

Hashes for attp_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0a79a3f3b31ae6d56b09d85654881b4da401395dc04a875a3a75b05c089497d9
MD5 bff371e1246aadb432b4c0bc7e25d1f4
BLAKE2b-256 08f5085f22e940174f277bed30aebb5fe16b581ed257ac039368dfc4a944fcb3

See more details on using hashes here.

File details

Details for the file attp_sdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: attp_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 50.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.11.13 Linux/6.18.2-arch2-1

File hashes

Hashes for attp_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e8f557a5127189bed7e6d3c60e3480664f2a484d42ce4d588914427e41ca588a
MD5 07862084c4821a50e15414164fd2a1cb
BLAKE2b-256 ad85272e38a2bf743957ea53630426d2be57f99b24f8d40a1afcc8f8a7950c7c

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