megaphone-broker

Crates.iomegaphone-broker
lib.rsmegaphone-broker
version0.10.5
sourcesrc
created_at2024-02-25 17:13:19.144288
updated_at2024-04-28 09:13:02.601357
descriptionReverse proxy for long running requests and server streaming
homepage
repositoryhttps://github.com/dghilardi/megaphone
max_upload_size
id1152632
size223,774
Davide Ghilardi (dghilardi)

documentation

README

Megaphone 📣

Test Status Crate API

Megaphone is a reverse proxy that allows clients to connect to a server using long running requests and server streaming. It is useful because it abstracts the complexity of handling long running requests and server streaming from the server, allowing it to focus on the business logic. It also gives the client a single endpoint to connect to, making it easier to manage the connection and reducing the opened connections and the overall traffic overhead.

How it works

Create a channel

To create a channel, the [POST] /create endpoint must be called. Each channel:

  • has a buffer of 100 messages that will be used to keep messages pending if the consumer is not currently connected. If the buffer is full the server will keep eventual write operations pending for 10 seconds, after that it will respond with a 503 Service Unavailable status code.
  • remains alive for 1 minute after the last read operation (or create if no read was performed). After that it is automatically deleted and all buffered messages are lost.
  • has two addresses, namely producerAddress and consumerAddress, the first one can be used to write into the channel, the second one to read from it.

Write into a channel

To write into a channel, the client must call the [POST] /write/{producer-address}/{stream-id} endpoint. The server will respond with a 201 Created status code if the message was successfully written into the channel.

Read from a channel

The only information needed to read from a channel is the consumerAddress returned when the channel was created. At the moment the only supported protocol is http streaming, so to read from a channel the client must call the [GET] /read/{consumer-address} endpoint.

Supported protocols

Http Streaming

To access a channel using http streaming, the client must call the [GET] /read/{consumer-address} endpoint. The server will keep the connection open for 20 seconds and send messages as they arrive.

Other repos

Commit count: 257

cargo fmt