-
Notifications
You must be signed in to change notification settings - Fork 1
/
PubSubAdapterInterface.js
67 lines (59 loc) · 1.27 KB
/
PubSubAdapterInterface.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
'use strict';
/**
* @callback subscriberCallback
* @param {*} message - The message payload received
*/
/**
* PubSubAdapterInterface Interface
*
* @abstract
* @interface
*/
class PubSubAdapterInterface {
/**
* Subscribe a handler to a channel.
*
* @param {string} channel
* @param {subscriberCallback} handler - The callback to run when a message is received
* @example
* adapter.subscribe('my_channel', (message) => {
* console.log(message);
* });
*/
subscribe(channel, handler) {
}
/**
* Publish a message to a channel.
*
* @param {string} channel
* @param {*} message - The message payload
* @return {Promise<*>}
* @example
* // publish a string
* adapter.publish('my_channel', 'Hello World');
*
* // publish an object
* adapter.publish('my_channel', {
* 'id': 1234,
* 'first_name': 'Matthew',
* });
*/
publish(channel, message) {
}
/**
* Publish multiple messages to a channel.
*
* @param {string} channel
* @param {*[]} messages
* @return {Promise<*>}
* @example
* let messages = [
* 'message 1',
* 'message 2',
* ];
* adapter.publishBatch('my_channel', messages);
*/
publishBatch(channel, messages) {
}
}
module.exports = PubSubAdapterInterface;