Skip to content

Commit

Permalink
Update readme to include how to run examples with docker compose (#73)
Browse files Browse the repository at this point in the history
* Add black to pre commit hooks

* Update readme to include how to run examples with docker compose
  • Loading branch information
kaypee90 authored Oct 12, 2023
1 parent ca51279 commit 41ae391
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ repos:
hooks:
- id: pyupgrade
args: [--py36-plus]
- repo: https://github.com/ambv/black
rev: 22.6.0
hooks:
- id: black
52 changes: 48 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Brokerless task queue for python based on 0Mq
========================

* Configuring Environment Variables:
- WORKER_HOST=
- WORKER_PORT=
- WORKER_HOST         # The IP address to expose running workers on
- WORKER_PORT               # The port number workers should listen on

-- `If not set defaults to localhost:5690`

Expand Down Expand Up @@ -52,7 +52,51 @@ long_running_task.run(param="dowork")
- Fast
- Open source

### Using a container orchestration technology:

### Running Zebrok examples with docker compose
* First clone the repository using the command `git clone [email protected]:kaypee90/zebrok.git`
* Change directory into the zebrok directory and run `docker compose up` command to start the worker and publisher containers.
* Access the shell for the **worker** container and run the command `python examples/start.py` to start the workers.
* From a different terminal window, access the shell for the running **publisher** container and run the command `python examples/client.py` to queue 2 jobs to be processed.
* Once these commands are executed you should see 2 tasks processed successfully in the publisher terminal.


**Sample output:**
```
** 2 ZEBROK TASKS DISCOVERED!
=====================================================
* long_running_task_one
* long_running_task_two
=====================================================
2023-10-11 23:45:14,227 zebrok.discovery INFO:** 2 ZEBROK TASKS DISCOVERED!
=====================================================
* long_running_task_one
* long_running_task_two
=====================================================
starting worker on: tcp://172.21.0.3:5691
2023-10-11 23:45:14,236 zebrok.worker INFO:starting worker on: tcp://172.21.0.3:5691
starting worker on: tcp://172.21.0.3:5692
2023-10-11 23:45:14,237 zebrok.worker INFO:starting worker on: tcp://172.21.0.3:5692
starting worker on: tcp://172.21.0.3:5693
starting worker on: tcp://172.21.0.3:5690
2023-10-11 23:45:14,238 zebrok.worker INFO:starting worker on: tcp://172.21.0.3:5693
2023-10-11 23:45:14,238 zebrok.worker INFO:starting worker on: tcp://172.21.0.3:5690
sending task to slave worker
2023-10-11 23:48:07,297 zebrok.worker INFO:sending task to slave worker
sending task to slave worker
received task: long_running_task_one
2023-10-11 23:48:07,299 zebrok.worker INFO:sending task to slave worker
2023-10-11 23:48:07,299 zebrok.worker INFO:received task: long_running_task_one
received task: long_running_task_two
2023-10-11 23:48:07,300 zebrok.worker INFO:received task: long_running_task_two
Sent mail to, [email protected]
Hello, Kay Pee
DONE!!!
DONE!!!
```


### Using a container orchestration technology (like Kubernetes):
- `number_of_slaves` must always be set to 0, then you can spin a number of replicas for the workers.
- `WORKER_HOST`Environment variable for a worker must always be `*`
- `WORKER_HOST` Environment variable for a worker must always be `*`

0 comments on commit 41ae391

Please sign in to comment.