Skip to content

Commit 2cd51ae

Browse files
committed
routing: Actually implement removeBinding
1 parent 445497a commit 2cd51ae

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

src/routing.coffee

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,28 @@ class Binder
4040
return callback null if @bindings[id] or from == to
4141

4242
handler = (msg) =>
43+
binding = @bindings[id]
44+
return if not binding?.enabled
4345
debug 'edge message', msg
4446
@transport.sendTo 'outqueue', to, msg.data, (err) ->
4547
throw err if err
4648
@transport.subscribeToQueue from, handler, (err) =>
4749
return callback err if err
48-
@bindings[id] = handler
50+
@bindings[id] =
51+
handler: handler
52+
enabled: true
4953
return callback null
5054

51-
removeBinding: (binding, callback) -> # FIXME: implement
52-
debug 'Binder.removeBinding', binding
55+
removeBinding: (binding, callback) ->
56+
from = binding.src
57+
to = binding.tgt
58+
id = bindingId from, to
59+
debug 'Binder.removeBinding', binding, id
60+
binding = @bindings[id]
61+
return callback new Error "Binding does not exist" if not binding
62+
binding.enabled = false
63+
#FIXME: add an unsubscribeQueue to Client/transport, and use that
64+
return callback null
5365

5466
listBindings: (callback) ->
5567
debug 'Binder.listBindings'

0 commit comments

Comments
 (0)