Unverified Commit e4b42db1 authored by Dan Jones's avatar Dan Jones
Browse files

docs: update changelog and version

+ remove obsolete code
parent f987d4dc
Pipeline #114751 passed with stages
in 1 minute and 17 seconds
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [Unreleased]
## [v0.1.0] - 2023-03-24
### Added
Create a mechanism to exchange messages between multiple clients
Bus
- Implements persistent queues per client
- Implements publish/subscribe message flow between clients
- Implements broadcast message flow between clients
- Listens for and responds to add/remove clients
API
- Implements clients endpoint to manage clients and subscriptions
- Implements token endpoint to manage authentication client credentials grants
- Implements send endpoint for publishing
- Implements notify endpoint for broadcasts
- Implements receive endpoint to get messages
Docker
- Run local dev environment in docker-compose
[v0.1.0]: https://git.noc.ac.uk/communications-backbone-system/communications-backbone/compare/611d9cab...v0.1.0
[unreleased]: https://git.noc.ac.uk/communications-backbone-system/communications-backbone/compare/v0.1.0...dev
#!/usr/bin/env python
import pika
def get_connection():
return pika.BlockingConnection(pika.ConnectionParameters(host="localhost"))
def deliver(body, broadcast_exchange):
print("broadcast")
deliver_connection = get_connection()
deliver_channel = deliver_connection.channel()
deliver_channel.exchange_declare(
exchange=broadcast_exchange, exchange_type="fanout"
)
deliver_channel.basic_publish(
exchange=broadcast_exchange, routing_key="", body=body
)
deliver_connection.close()
def listen(queue_name, broadcast_exchange):
def bcast_callback(ch, method, properties, body):
delivered = deliver(body, broadcast_exchange)
ch.basic_ack(delivery_tag=method.delivery_tag)
listen_connection = get_connection()
listen_channel = listen_connection.channel()
listen_channel.queue_declare(queue=queue_name, durable=True)
listen_channel.basic_consume(queue=queue_name, on_message_callback=bcast_callback)
listen_channel.start_consuming()
def broadcast(queue_name, broadcast_exchange="soar_broadcast"):
listen(queue_name, broadcast_exchange)
#!/usr/bin/env python
import pika
def get_connection():
return pika.BlockingConnection(pika.ConnectionParameters(host="localhost"))
def deliver(body, queue_name):
print("forward to: %s" % queue_name)
deliver_connection = get_connection()
deliver_channel = deliver_connection.channel()
deliver_channel.queue_declare(queue=queue_name, durable=True)
deliver_channel.basic_publish(exchange="", routing_key=queue_name, body=body)
deliver_connection.close()
def listen(from_queue_name, to_queue_name):
def fwd_callback(ch, method, properties, body):
delivered = deliver(body, to_queue_name)
ch.basic_ack(delivery_tag=method.delivery_tag)
listen_connection = get_connection()
listen_channel = listen_connection.channel()
listen_channel.queue_declare(queue=from_queue_name, durable=True)
listen_channel.basic_consume(
queue=from_queue_name, on_message_callback=fwd_callback
)
listen_channel.start_consuming()
def forward(from_queue_name, to_queue_name):
listen(from_queue_name, to_queue_name)
#!/usr/bin/env python
import pika
import json
import sys
def get_connection():
return pika.BlockingConnection(pika.ConnectionParameters(host="localhost"))
def deliver(body, topic, publish_exchange):
print("publish on topic: %s" % topic)
deliver_connection = get_connection()
deliver_channel = deliver_connection.channel()
deliver_channel.exchange_declare(exchange=publish_exchange, exchange_type="topic")
deliver_channel.basic_publish(
exchange=publish_exchange, routing_key=topic, body=body
)
deliver_connection.close()
def listen(queue_name, publish_exchange):
def pub_callback(ch, method, properties, body):
message = json.loads(body.decode())
topic = message["topic"]
deliver(body, topic, publish_exchange)
ch.basic_ack(delivery_tag=method.delivery_tag)
listen_connection = get_connection()
listen_channel = listen_connection.channel()
listen_channel.queue_declare(queue=queue_name, durable=True)
listen_channel.basic_consume(queue=queue_name, on_message_callback=pub_callback)
listen_channel.start_consuming()
def publish(queue_name, publish_exchange="soar_publish"):
listen(queue_name, publish_exchange)
if __name__ == "__main__":
queue_name = sys.argv[1]
publish(queue_name)
#!/usr/bin/env python
import pika
def get_connection():
return pika.BlockingConnection(pika.ConnectionParameters(host="localhost"))
def subscribe(
queue_name,
topic,
publish_exchange="soar_publish",
broadcast_exchange="soar_broadcast",
):
adm_connection = get_connection()
admin_channel = adm_connection.channel()
admin_channel.exchange_declare(exchange=broadcast_exchange, exchange_type="fanout")
admin_channel.queue_bind(exchange=broadcast_exchange, queue=queue_name)
sub_connection = get_connection()
subscriber_channel = sub_connection.channel()
subscriber_channel.exchange_declare(
exchange=publish_exchange, exchange_type="topic"
)
subscriber_channel.queue_bind(
exchange=publish_exchange, queue=queue_name, routing_key=topic
)
......@@ -5,7 +5,7 @@ requirements = [x.strip() for x in open("requirements.txt", "r") if x.strip() !=
setup(
name="communications-backbone",
version="0.0.1",
version="0.1.0",
description="Communications backbone ",
author="NOC C2 Team",
author_email="c2@noc.ac.uk",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment