You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+119-8
Original file line number
Diff line number
Diff line change
@@ -12,9 +12,10 @@ Taube is a drop in replacement for cote. Without configuration it functions as a
12
12
1.[Quick start guide](##Quick-start-guide)
13
13
2.[Environment variables](#Environment-variables)
14
14
3.[Migrate from cote](#Migrate-from-cote)
15
-
4.[Readiness](#Readiness)
15
+
4.[Monitoring and Signal Handling](#Monitoring-and-Signal-Handling)
16
16
5.[Sockend](#Sockend)
17
-
6.[Writing unit tests](#Writing-unit-tests)
17
+
6.[Publisher/Subscriber](#Publisher/Subscriber)
18
+
7.[Writing unit tests](#Writing-unit-tests)
18
19
19
20
## Quick start guide
20
21
@@ -82,32 +83,59 @@ The `url` option needs to include `http` or `https` without a `/` at the end.
82
83
| ------------------ |:----------------:| ---
83
84
| TAUBE_HTTP_ENABLED | undefined / true | If set Taube will use HTTP instead of cote (axion). Set to true inside stack services.
84
85
| TAUBE_HTTP_PORT | 4321 | Port of http server
85
-
| TAUBE_HTTP_DEBUG | undefined | Adds debugging information to Taube (e.g. Boolean usedHttp to requesters send() responses)
86
+
| ~~TAUBE_HTTP_DEBUG~~ | ~~undefined~~ | deprecated - ~~Adds debugging information to Taube (e.g. Boolean usedHttp to requesters send() responses)~~
87
+
| TAUBE_DEBUG | undefined | Adds debugging information to Taube responses. See tests for usage. This does change responses and is only designed for development.
86
88
| TAUBE_UNIT_TESTS | undefined | If set all requesters default their uri to <http://localhost>
87
89
| TAUBE_RETRIES | 3 | Number of retries any Requester does before giving up. 3 is maximum value as retry duration would be over timeout.
88
90
| TAUBE_COTE_DISABLED | undefined | If set, taube will not create cote components for responders and requesters
91
+
| TAUBE_AMQP_ENABLED | undefined | If set Taube will use AMQP instead of cote (axion). Does not disable cote publishers sending data
92
+
| TAUBE_AMQP_URI | undefined | AMQP uri (e.g. 'amqp://guest:guest@localhost')
93
+
| TAUBE_AMQP_COTE_DISABLED | undefined | If set, taube will not create cote components for Publishers and Subscribers
89
94
90
95
91
96
## Migrate from cote
92
97
98
+
There is 3 modes you can run taube in while migrating from cote to taube.
99
+
100
+
1. Mode 1: Still use cote. Requesters/Responders and Publisher/Subscribers still use cote for communication
101
+
2. Mode 2: Use taube, but still provide cote. Requesters will use HTTP and Subscribers AMQP. But Responders will still provide cote and Publishers will still publish using cote.
102
+
3. Mode 3: Disable cote. cote components will no longer be created.
The Sockend component will not process any events of the 'data' event type and leave the process up to the custom handler.
231
259
232
-
## Writing unit tests
260
+
## Publisher/Subscriber
261
+
262
+
The Publisher/Subscriber components can be used to connect to a AMQP enabled message broker. They provide the Publisher/Subscriber pattern to taube users.
263
+
264
+
To use these features you need to explicitly activate it using and TAUBE_AMQP_ENABLED and connect taube to a AMQP enabled message broker (e.g. RabbitMQ). `taube.init()` can be called multiple times. It only has an affect once.
265
+
266
+
```
267
+
// Set TAUBE_AMQP_URI environment variable through your orchestration
A Publisher is used to publish the corresponding events:
284
+
285
+
```
286
+
const publisher = new taube.Publisher({ key: 'users' })
287
+
288
+
publisher.publish(`users updated`, { data: {} })
289
+
```
290
+
291
+
Every Publisher/Subscriber creates a Channel to RabbitMQ. There is a maximum number of channels per connection which is defined by your RabbitMQ [configuration](https://www.rabbitmq.com/configure.html). The default is 2047 per connection.
292
+
293
+
## Technical implementation details
294
+
295
+
Overview of the process between Publisher and Subscriber including the RabbitMQ concepts
- exchange: An exchange is the place where the Publishers send their messages. Queues can "listen" on exchanges
324
+
- queue: A queue of messages that listens on an exchange. In Pub/Sub we use non persistant, non worker queues, which function as Pub/Sub does in cote
325
+
- channels: Multiple lightweight connections that share a single TCP connection between a process and RabbitMQ
326
+
327
+
Process:
328
+
329
+
After both the Publisher and Subscriber have registered their components a publish works like this:
330
+
331
+
1. Publisher sends message to exchange
332
+
2. Exchange sends message too all queues that listen to that key and topic (key and route called in RabbitMQ)
333
+
3. All queues trigger their consumers (listeners), which in this case is the taube Subscriber
334
+
335
+
## Writing unit tests for projects using taube
336
+
337
+
Currently does not support Publisher/Subscriber unit testing. Those unit tests will require a usable AMQP message broker connection initialized using `taube.init()`. You will need to call `taube.shutdown()` in
233
338
234
339
taube auto detects running in `NODE_ENV=test` and overwrites all requesters with `uri` = `http://localhost`. This means all Responders can easily be mocked. See `test/unit-test.test.js` for an example. It also uses a random port then which ensures that all Requesters and Responders in a process can only contact each other.
235
340
236
341
You can also force this by setting `TAUBE_UNIT_TESTS`
342
+
343
+
## Contributing to the taube project
344
+
345
+
In order to run the unit tests, you need to run `docker-compose up` inside `.test/`. Then run `npm run test-verbose` to run the unit tests.
346
+
347
+
This project has a unit test line coverage of 100% and everything below that fails the ci jobs.
0 commit comments