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
This PR migrates Aedes to use the async persistence interface.
It contains the following sub items:
- [X] replace all callback calls to persistence by `.then()` calls
- [X] move all side effects (setting up persistence, attaching event
handlers etc) to a `listen()` method of Aedes
- [X] update `createBroker()` to be async and make it await `listen()`
as well
- [X] update exports so that they produce a warning if people use old
style calling
- [X] update Typescript typing
- [X] update documentation including examples
- [X] add a `migration.md` to help users migrate.
- [X] do some benchmark tests to see performances are kept
- [X] update node engines version to >=20
- [X] updates all dependencies to current except for Tap and
@sinonjs/fake-timers
BREAKING CHANGES: See
[docs](https://github.com/moscajs/aedes/blob/main/docs/MIGRATION.md)
-[Handler: published (packet, client, callback)](#handler-published-packet-client-callback)
33
35
34
-
## new Aedes([options]) / new Aedes.Server([options])
36
+
## new Aedes([options])
35
37
36
38
- options `<object>`
37
39
-`mq`[`<MQEmitter>`](../README.md#mqemitter) middleware used to deliver messages to subscribed clients. In a cluster environment it is used also to share messages between brokers instances. __Default__: `mqemitter`
38
40
-`concurrency``<number>` maximum number of concurrent messages delivered by `mq`. __Default__: `100`
39
41
-`persistence`[`<Persistence>`](../README.md#persistence) middleware that stores _QoS > 0, retained, will_ packets and _subscriptions_. __Default__: `aedes-persistence` (_in memory_)
42
+
Versions 1.x and above require persistence to support async access,see [MIGRATION.md][MIGRATION] for details.
40
43
-`queueLimit``<number>` maximum number of queued messages before client session is established. If number of queued items exceeds, `connectionError` throws an error `Client queue limit reached`. __Default__: `42`
41
44
-`maxClientsIdLength` option to override MQTT 3.1.0 clients Id length limit. __Default__: `23`
42
45
-`heartbeatInterval``<number>` an interval in millisconds at which server beats its health signal in `$SYS/<aedes.id>/heartbeat` topic. __Default__: `60000`
@@ -45,9 +48,36 @@
45
48
-`keepaliveLimit``<number>` maximum client keep alive time allowed, 0 means no limit. __Default__: `0`
46
49
- Returns `<Aedes>`
47
50
48
-
Create a new Aedes server.
51
+
Create a new Aedes server instance.
49
52
50
-
Aedes is the class and function exposed by this module. It can be created by `Aedes()` or using `new Aedes()`. An variant `aedes.Server` is for TypeScript or ES modules.
53
+
Aedes is the class exported by this module.
54
+
The instance will only start listening after [aedes.listen()](#aedeslisten) is called.
55
+
The recommended way to start an Aedes server is to use [Aedes.createBroker([options])](#aedescreatebrokeroptions) instead.
56
+
57
+
## Aedes.createBroker([options])
58
+
59
+
An async static method in the Aedes class which creates the instance and automatically awaits `listen()`.
60
+
61
+
Using `Aedes.createBroker([options])` is the recommended way to start Aedes, example:
62
+
63
+
```js
64
+
constaedes=awaitAedes.createBroker([options])
65
+
```
66
+
67
+
It uses the same options as [new Aedes([options])](#new-aedesoptions)
68
+
69
+
## aedes.listen()
70
+
71
+
Async method to make the aedes instance start listening.
72
+
Example:
73
+
74
+
```js
75
+
constaedes=newAedes([options])
76
+
awaitaedes.listen()
77
+
```
78
+
79
+
You should typically not need to use this as it is more compact to use
0 commit comments