rabbitmq 0.2.5 → 1.0.0.pre.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +67 -2
- data/lib/rabbitmq.rb +1 -1
- data/lib/rabbitmq/channel.rb +117 -81
- data/lib/rabbitmq/client.rb +332 -0
- data/lib/rabbitmq/{connection/transport.rb → client/connection.rb} +32 -11
- data/lib/rabbitmq/ffi.rb +486 -483
- data/lib/rabbitmq/util.rb +6 -3
- metadata +6 -7
- data/lib/rabbitmq/connection.rb +0 -382
- data/lib/rabbitmq/connection/channel_manager.rb +0 -61
- data/lib/rabbitmq/connection/event_manager.rb +0 -55
@@ -1,55 +0,0 @@
|
|
1
|
-
|
2
|
-
module RabbitMQ
|
3
|
-
class Connection
|
4
|
-
|
5
|
-
class EventManager
|
6
|
-
def initialize(connection)
|
7
|
-
@connection = connection
|
8
|
-
@event_handlers = Hash.new { |h,k| h[k] = {} }
|
9
|
-
@incoming_events = Hash.new { |h,k| h[k] = {} }
|
10
|
-
end
|
11
|
-
|
12
|
-
def register_handler(id, method, handler)
|
13
|
-
@event_handlers[id][method] = handler
|
14
|
-
end
|
15
|
-
|
16
|
-
def clear_event_handlers(id)
|
17
|
-
@event_handlers.delete(id)
|
18
|
-
end
|
19
|
-
|
20
|
-
def clear_all_event_handlers
|
21
|
-
@event_handlers.clear
|
22
|
-
end
|
23
|
-
|
24
|
-
# Execute the handler for this type of event, if any
|
25
|
-
def handle_incoming_event(event)
|
26
|
-
if (handlers = @event_handlers[event.fetch(:channel)])
|
27
|
-
if (handler = (handlers[event.fetch(:method)]))
|
28
|
-
handler.call(event)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
# Store the event in short-term storage for retrieval by fetch_response.
|
34
|
-
# If another event is received with the same method name, it will
|
35
|
-
# overwrite this one - fetch_response gets the latest or next by method.
|
36
|
-
def store_incoming_event(event)
|
37
|
-
method = event.fetch(:method)
|
38
|
-
|
39
|
-
case method
|
40
|
-
when :channel_close
|
41
|
-
raise_if_server_error!(event)
|
42
|
-
when :connection_close
|
43
|
-
raise_if_server_error!(event)
|
44
|
-
else
|
45
|
-
@incoming_events[event.fetch(:channel)][method] = event
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def fetch_stored_event(channel_id, method)
|
50
|
-
@incoming_events[channel_id].delete(method)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
55
|
-
end
|