-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinterfaces.coffee
81 lines (67 loc) · 2.52 KB
/
interfaces.coffee
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Abstraction of the concrete message queue system used
# Examples: AMQP, MQTT
class MessagingSystem
constructor: (address, options) ->
## Broker connection management
connect: (callback) ->
throw new Error 'Not Implemented'
disconnect: (callback) ->
throw new Error 'Not Implemented'
## Manipulating queues
# @type: inqueue|outqueue
# @options:
# persistent: true|false # if broker should persist the queue or not
createQueue: (type, queueName, options, callback) ->
throw new Error 'Not Implemented'
removeQueue: (type, queueName, callback) ->
throw new Error 'Not Implemented'
## Sending/Receiving messages
# queueName must be created beforehand, and be of correct type
sendTo: (type, name, message, callback) ->
throw new Error 'Not Implemented'
# handler must call ackMessage() on succesful processing of a message
subscribeToQueue: (queueName, handler, callback) ->
throw new Error 'Not Implemented'
## ACK/NACK messages
ackMessage: (message) ->
throw new Error 'Not Implemented'
nackMessage: (message) ->
throw new Error 'Not Implemented'
class MessagingClient extends MessagingSystem
# Participant registration
registerParticipant: (part, callback) ->
throw new Error 'Not Implemented'
exports.MessagingClient = MessagingClient
class MessageBroker extends MessagingSystem
# Manipulating queue bindings
# Binding object:
# {
# type: 'roundrobin'|'pubsub'
# src: 'source queue'
# tgt: 'target queue'
# $type: { 'type-specific-bar': 'foo' }
# deadletter: 'queue name' # only for roundrobin
# }
# Types:
# pubsub: Messages are delivered to all consumers on queue. (default)
# ack/nack does not impact sending
# roundrobin: Messages are delivered to one consumer on queue.
# If not acked or nacked, put to deadletter
addBinding: (binding, callback) ->
throw new Error 'Not Implemented'
removeBinding: (binding, callback) ->
throw new Error 'Not Implemented'
# @callback err, [Binding, Binding, ..]
listBindings: (callback) ->
throw new Error 'Not Implemented'
# Subscribing to data on a binding
subscribeData: (binding, datahandler, callback) ->
throw new Error 'Not Implemented'
unsubscribeData: (binding, datahandler, callback) ->
throw new Error 'Not Implemented'
listSubscriptions: (callback) ->
throw new Error 'Not Implemented'
# Participant registration
subscribeParticipantChange: (handler) ->
throw new Error 'Not Implemented'
exports.MessageBroker = MessageBroker