Skip to main content

A library for building Finagle-style asynchronous clients and servers

Project description

Crossbill

Description

Crossbill is a Python library focused on building Finagle-style Service-based asynchronous clients and servers. It is very much a work in progress, and as such, does not follow semantic versioning, nor should the APIs be considered stable.

Getting Started

No version of Crossbill has been published to PyPI as of yet, so it needs to be included as a dependency via git. Here's a walkthrough of doing so using uv.

Create a New Project

$ uv init crossbill-demo
$ cd crossbill-demo

Add Crossbill as a Dependency

$ uv add git+https://github.com/ryanoneill/crossbillpy

Code the Example

By default, uv will generate a hello.py file. Replace its contents with the following code:

import asyncio
from crossbill.core import Service
from crossbill.string import (
    StringClient,
    StringRequest,
    StringResponse,
    StringServer,
)
from crossbill.transport import Address


class EchoService(Service[StringRequest, StringResponse]):
    async def __call__(self, request: StringRequest) -> StringResponse:
        return StringResponse(request.value)


async def main() -> None:
    address = Address("localhost", 12345)
    server = StringServer()
    await server.serve(address, EchoService())

    message = "Hello from crossbill-demo!"
    client = StringClient()
    await client.connect(address)
    response = await client(StringRequest(message))
    print(response.value)

    await client.close()
    await server.close()


if __name__ == "__main__":
    asyncio.run(main())

Run the Example

$ uv run hello.py
Hello from crossbill-demo!

Development

The crossbill project uses uv, "[a]n extremely fast Python package and project manager, written in Rust." If you don't have it installed, follow the installation guide in order to do so.

Dependency Installation

With uv installed, run the following from the command line to ensure that all dependencies are properly installed.

$ uv sync

Testing

This project uses pytest along with asyncio in order to run asynchronous tests. A predominant number of tests within this library will fit that criteria due to the nature of the domain space.

To run the existing unit tests, run the following from the command line.

$ uv run pytest

Coverage

This project uses coverage and pytest-cov for measuring code coverage. To generate the report when running tests, run the following from the command line.

$ uv run pytest --cov

If there are lines with missing coverage, to see which lines in particular, run the following from the command line.

$ uv run pytest --cov --cov-report term-missing

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

crossbill-0.1.0.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

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

crossbill-0.1.0-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

Details for the file crossbill-0.1.0.tar.gz.

File metadata

  • Download URL: crossbill-0.1.0.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.26

File hashes

Hashes for crossbill-0.1.0.tar.gz
Algorithm Hash digest
SHA256 127db1e09a1746af829e03d9414f0b8c118d418320bd43da7ef1f3e87c67567f
MD5 62a10a7180f927743fabb3d976c1c585
BLAKE2b-256 265836f159eda6b3188fc1bc3e7b6f6bac936b3697d4ab584114dbd33f3e5f5a

See more details on using hashes here.

File details

Details for the file crossbill-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: crossbill-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.26

File hashes

Hashes for crossbill-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 58ae9e16d81c7aee7a9831900e3d5e7914e480aceec042ff4131b52825e3f83f
MD5 2746f258052407529a19e600e58a43e3
BLAKE2b-256 ee4d7b0566f42c8622df6450f02f3bb5edecd9e48f5d9e84e96b8c25d21bcb4a

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