Skip to content

Commit

Permalink
chore: added examples to run via go
Browse files Browse the repository at this point in the history
  • Loading branch information
hitesh22rana committed Dec 23, 2024
1 parent c5348d0 commit 56f23cd
Show file tree
Hide file tree
Showing 15 changed files with 962 additions and 107 deletions.
5 changes: 4 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@ bin
data/

# Exclude the .proto directory.
.proto/
.proto/

# Exclude the examples directory.
examples/
21 changes: 1 addition & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,6 @@ dependencies: generate-proto-go
build-mq: dependencies
@go build -o bin/mq cmd/mq/main.go

.PHONY: build-publisher
build-publisher: dependencies
@go build -o bin/publisher cmd/publisher/main.go

.PHONY: build-subscriber
build-subscriber: dependencies
@go build -o bin/subscriber cmd/subscriber/main.go

.PHONY: build-all
build-all: build-mq build-publisher build-subscriber

.PHONY: mq
mq: build-mq
@./bin/mq

.PHONY: publisher
publisher: build-publisher
@./bin/publisher

.PHONY: subscriber
subscriber: build-subscriber
@./bin/subscriber
@./bin/mq
50 changes: 4 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,6 @@ docker run \
- Generate the protobuf code and build the binaries using the provided `Makefile`:
```bash
make build-mq
make build-publisher
make build-subscriber
```
- Alternatively, you can build all components at once:
```bash
make build-all
```
### Running the MQ
Expand All @@ -172,51 +165,16 @@ docker run \
The broker will start listening on the specified port (default:`50051`).
### Running the Publisher
In a new terminal window, run the publisher:
```bash
make publisher
```
Follow the prompts:
- Enter the channel name you wish to publish messages to.
- Type your messages and press Enter to send them.
- Press `Ctrl+C` to exit.
### Running the Subscriber
In another terminal window, run the subscriber:
```bash
make subscriber
```
Follow the prompts:
- Enter the channel name you wish to subscribe to (this channel should exist).
- The subscriber will receive all the messages published to that channel.
- Press `Ctrl+C` to exit.
### Usage Example
1. **Start the MQ Server**
1. Navigate to `examples` directory.
```bash
make mq
cd /examples
```
2. **Start the Publisher** (In another terminal):
```bash
make publisher
```
- Enter the channel name (e.g., `my-channel`).
- Type messages to send.
3. **Start the Subscriber** (In a new terminal):
```bash
make subscriber
```
- Enter the same channel name (`my-channel`).
2. Start the Publisher and Subscriber from the provided languages examples (In another terminal).
4. The subscriber terminal will display the messages received.
3. The subscriber terminal will display the messages received.
## License
This project is licensed under the MIT License - see the [LICENSE](https://github.com/hitesh22rana/mq/blob/main/LICENSE) file for details.
Binary file modified bin/mq
Binary file not shown.
Loading

0 comments on commit 56f23cd

Please sign in to comment.