bitbroker 0.1.0

A language agnostic message broker designed for real-time communication.
Documentation
# BitBroker

BitBroker is a lightweight, language agnostic message broker designed for real-time
communication between games and bots. Using TCP sockets for fast, persistent connections
and designed for Protocol Buffers (Protobuf) allowing for compact, schema-based messaging,
BitBroker acts as a reliable middle layer — brokering messages between clients and servers
regardless of their underlying tech stack.

## Running the broker

The broker is implemented as part of the rust package. A basic broker runner is included in
`/broker` and can be run using [cargo](https://www.rust-lang.org/tools/install).

```bash
cargo run -p broker
```

The broker can also be run from a distroless docker image which can either be built from the
`Dockerfile` or pulled from the project's container registry.

```
docker pull registry.gitlab.com/tuck-ab/bitbroker:{version}
```

The `BROKER_NUM_PLAYERS` environment variable must be set for the broker to know how many
player connections to expect.

The image also contains a healthcheck api for use with a compose file.

```yaml
services:
  bitbroker:
    image: registry.gitlab.com/tuck-ab/bitbroker:{version}
    healthcheck:
      test: curl localhost:8080
    environment:
      BROKER_NUM_PLAYERS: 2
```

## Usage

There are currently two language implementations that abstract the messaging protocols.

### Rust

The rust crate provides a trait to implement for a bot `BaseBot` and a function `run_bot`
that takes a `BaseBot`, host, and port of the broker and handles running the bot. Similarly,
there is a `BaseGame` trait and `run_game` function for implementing and running a game.

### Python

The python package provides an abstract base class `BaseBot` with a `run` method that
takes the host and port of the broker. Similarly there is a `BaseGame` abstract base class
with its own `run` method that takes a host and port.

The python package can be installed from the project container registry using pip.

```
pip install bitbroker --index-url https://gitlab.com/api/v4/projects/70133808/packages/pypi/simple
```

## Roadmap

* Creating an installable rust crate
* Creating an installable python package