Skip to content

Development Environment Setup for Danube Broker

This document guides you through setting up the development environment, running danube broker instances, and be able to effectively contribute to the code.

Prerequisites

Before you get started, make sure you have the following installed:

  • Rust: Ensure you have Rust installed. You can download and install it from the Rust website.

  • Docker: Install Docker if you haven’t already. Follow the installation instructions on the Docker website.

Contributing to the Repository

  1. Fork the Repository:

  2. Go to the Danube Broker GitHub repository.

  3. Click the "Fork" button on the top right corner of the page to create your own copy of the repository.

  4. Clone Your Fork:

Once you have forked the repository, clone your forked repository:

git clone https://github.com/<your-username>/danube.git
cd danube
  1. Add the Original Repository as a Remote (optional but recommended for keeping up-to-date):
git remote add upstream https://github.com/danrusei/danube.git

Building the Project

  1. Build the Project:

To build the Danube Broker:

cargo build 
or  
cargo build --release

Running ETCD

  1. Start ETCD:

Use the Makefile to start an ETCD instance. This will run ETCD in a Docker container.

make etcd
  1. Clean Up ETCD:

To stop and remove the ETCD instance and its data:

make etcd-clean

Running a Single Broker Instance

  1. Start ETCD:

Ensure ETCD is running. If not, use the make etcd command to start it.

  1. Run the Broker:

Use the following command to start a single broker instance:

RUST_LOG=danube_broker=info target/debug/danube-broker --config-file config/danube_broker.yml

Running Multiple Broker Instances

  1. Start ETCD:

Ensure ETCD is running. Use:

make etcd
  1. Run Multiple Brokers:

Use the following Makefile command to start multiple broker instances:

make brokers

This will start brokers on ports 6650, 6651, and 6652. Logs for each broker will be saved in temp/ directory.

  1. Clean Up Broker Instances:

To stop all running broker instances:

make brokers-clean

Reading Logs

Logs for each broker instance are stored in the temp/ directory. You can view them using:

cat temp/broker_<port>.log

Replace <port> with the actual port number (6650, 6651, or 6652).

Inspecting ETCD Metadata

  1. Set Up etcdctl:

Export the following environment variables:

export ETCDCTL_API=3
export ETCDCTL_ENDPOINTS=http://localhost:2379
  1. Inspect Metadata:

Use etcdctl commands to inspect metadata. For example, to list all keys:

etcdctl get "" --prefix

To get a specific key:

etcdctl get <key>

Makefile Targets Summary

  • make etcd: Starts an ETCD instance in Docker.
  • make etcd-clean: Stops and removes the ETCD instance and its data.
  • make brokers: Builds and starts broker instances on predefined ports.
  • make brokers-clean: Stops and removes all running broker instances.

Troubleshooting

  • ETCD Not Starting: Check Docker logs and ensure no other service is using port 2379.
  • Broker Not Starting: Ensure ETCD is running and accessible at the specified address and port.