sidekick-client 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. data/VERSION +1 -1
  2. data/lib/sidekick/client/sidekick_client.rb +0 -3
  3. data/lib/sidekick/shared/sidekick_queue_publisher.rb +1 -1
  4. data/sidekick-client.gemspec +1 -158
  5. metadata +1 -158
  6. data/lib/ext/eventmachine-0.12.10/.gitignore +0 -14
  7. data/lib/ext/eventmachine-0.12.10/README +0 -82
  8. data/lib/ext/eventmachine-0.12.10/Rakefile +0 -374
  9. data/lib/ext/eventmachine-0.12.10/docs/COPYING +0 -60
  10. data/lib/ext/eventmachine-0.12.10/docs/ChangeLog +0 -211
  11. data/lib/ext/eventmachine-0.12.10/docs/DEFERRABLES +0 -133
  12. data/lib/ext/eventmachine-0.12.10/docs/EPOLL +0 -141
  13. data/lib/ext/eventmachine-0.12.10/docs/GNU +0 -281
  14. data/lib/ext/eventmachine-0.12.10/docs/INSTALL +0 -13
  15. data/lib/ext/eventmachine-0.12.10/docs/KEYBOARD +0 -38
  16. data/lib/ext/eventmachine-0.12.10/docs/LEGAL +0 -25
  17. data/lib/ext/eventmachine-0.12.10/docs/LIGHTWEIGHT_CONCURRENCY +0 -70
  18. data/lib/ext/eventmachine-0.12.10/docs/PURE_RUBY +0 -75
  19. data/lib/ext/eventmachine-0.12.10/docs/RELEASE_NOTES +0 -94
  20. data/lib/ext/eventmachine-0.12.10/docs/SMTP +0 -2
  21. data/lib/ext/eventmachine-0.12.10/docs/SPAWNED_PROCESSES +0 -89
  22. data/lib/ext/eventmachine-0.12.10/docs/TODO +0 -8
  23. data/lib/ext/eventmachine-0.12.10/eventmachine.gemspec +0 -40
  24. data/lib/ext/eventmachine-0.12.10/examples/ex_channel.rb +0 -43
  25. data/lib/ext/eventmachine-0.12.10/examples/ex_queue.rb +0 -2
  26. data/lib/ext/eventmachine-0.12.10/examples/helper.rb +0 -2
  27. data/lib/ext/eventmachine-0.12.10/ext/binder.cpp +0 -125
  28. data/lib/ext/eventmachine-0.12.10/ext/binder.h +0 -46
  29. data/lib/ext/eventmachine-0.12.10/ext/cmain.cpp +0 -827
  30. data/lib/ext/eventmachine-0.12.10/ext/cplusplus.cpp +0 -202
  31. data/lib/ext/eventmachine-0.12.10/ext/ed.cpp +0 -1893
  32. data/lib/ext/eventmachine-0.12.10/ext/ed.h +0 -424
  33. data/lib/ext/eventmachine-0.12.10/ext/em.cpp +0 -2282
  34. data/lib/ext/eventmachine-0.12.10/ext/em.h +0 -232
  35. data/lib/ext/eventmachine-0.12.10/ext/emwin.cpp +0 -300
  36. data/lib/ext/eventmachine-0.12.10/ext/emwin.h +0 -94
  37. data/lib/ext/eventmachine-0.12.10/ext/epoll.cpp +0 -26
  38. data/lib/ext/eventmachine-0.12.10/ext/epoll.h +0 -25
  39. data/lib/ext/eventmachine-0.12.10/ext/eventmachine.h +0 -122
  40. data/lib/ext/eventmachine-0.12.10/ext/eventmachine_cpp.h +0 -96
  41. data/lib/ext/eventmachine-0.12.10/ext/extconf.rb +0 -148
  42. data/lib/ext/eventmachine-0.12.10/ext/fastfilereader/extconf.rb +0 -83
  43. data/lib/ext/eventmachine-0.12.10/ext/fastfilereader/mapper.cpp +0 -214
  44. data/lib/ext/eventmachine-0.12.10/ext/fastfilereader/mapper.h +0 -59
  45. data/lib/ext/eventmachine-0.12.10/ext/fastfilereader/rubymain.cpp +0 -127
  46. data/lib/ext/eventmachine-0.12.10/ext/files.cpp +0 -94
  47. data/lib/ext/eventmachine-0.12.10/ext/files.h +0 -65
  48. data/lib/ext/eventmachine-0.12.10/ext/kb.cpp +0 -81
  49. data/lib/ext/eventmachine-0.12.10/ext/page.cpp +0 -107
  50. data/lib/ext/eventmachine-0.12.10/ext/page.h +0 -51
  51. data/lib/ext/eventmachine-0.12.10/ext/pipe.cpp +0 -349
  52. data/lib/ext/eventmachine-0.12.10/ext/project.h +0 -151
  53. data/lib/ext/eventmachine-0.12.10/ext/rubymain.cpp +0 -1166
  54. data/lib/ext/eventmachine-0.12.10/ext/sigs.cpp +0 -89
  55. data/lib/ext/eventmachine-0.12.10/ext/sigs.h +0 -32
  56. data/lib/ext/eventmachine-0.12.10/ext/ssl.cpp +0 -460
  57. data/lib/ext/eventmachine-0.12.10/ext/ssl.h +0 -94
  58. data/lib/ext/eventmachine-0.12.10/java/.classpath +0 -8
  59. data/lib/ext/eventmachine-0.12.10/java/.project +0 -17
  60. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/EmReactor.java +0 -570
  61. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/EmReactorException.java +0 -40
  62. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/EventableChannel.java +0 -69
  63. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/EventableDatagramChannel.java +0 -189
  64. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/EventableSocketChannel.java +0 -364
  65. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/application/Application.java +0 -194
  66. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/application/Connection.java +0 -74
  67. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/application/ConnectionFactory.java +0 -37
  68. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/application/DefaultConnectionFactory.java +0 -46
  69. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/application/PeriodicTimer.java +0 -38
  70. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/application/Timer.java +0 -54
  71. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/tests/ApplicationTest.java +0 -109
  72. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/tests/ConnectTest.java +0 -148
  73. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/tests/EMTest.java +0 -80
  74. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/tests/TestDatagrams.java +0 -53
  75. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/tests/TestServers.java +0 -75
  76. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/tests/TestTimers.java +0 -90
  77. data/lib/ext/eventmachine-0.12.10/lib/em/buftok.rb +0 -138
  78. data/lib/ext/eventmachine-0.12.10/lib/em/callback.rb +0 -26
  79. data/lib/ext/eventmachine-0.12.10/lib/em/channel.rb +0 -57
  80. data/lib/ext/eventmachine-0.12.10/lib/em/connection.rb +0 -564
  81. data/lib/ext/eventmachine-0.12.10/lib/em/deferrable.rb +0 -192
  82. data/lib/ext/eventmachine-0.12.10/lib/em/file_watch.rb +0 -54
  83. data/lib/ext/eventmachine-0.12.10/lib/em/future.rb +0 -61
  84. data/lib/ext/eventmachine-0.12.10/lib/em/messages.rb +0 -66
  85. data/lib/ext/eventmachine-0.12.10/lib/em/process_watch.rb +0 -44
  86. data/lib/ext/eventmachine-0.12.10/lib/em/processes.rb +0 -119
  87. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/header_and_content.rb +0 -138
  88. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/httpclient.rb +0 -263
  89. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/httpclient2.rb +0 -590
  90. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/line_and_text.rb +0 -125
  91. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/linetext2.rb +0 -161
  92. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/memcache.rb +0 -323
  93. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/object_protocol.rb +0 -45
  94. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/postgres3.rb +0 -247
  95. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/saslauth.rb +0 -175
  96. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/smtpclient.rb +0 -357
  97. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/smtpserver.rb +0 -547
  98. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/socks4.rb +0 -66
  99. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/stomp.rb +0 -200
  100. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/tcptest.rb +0 -53
  101. data/lib/ext/eventmachine-0.12.10/lib/em/protocols.rb +0 -36
  102. data/lib/ext/eventmachine-0.12.10/lib/em/queue.rb +0 -61
  103. data/lib/ext/eventmachine-0.12.10/lib/em/spawnable.rb +0 -85
  104. data/lib/ext/eventmachine-0.12.10/lib/em/streamer.rb +0 -130
  105. data/lib/ext/eventmachine-0.12.10/lib/em/timers.rb +0 -56
  106. data/lib/ext/eventmachine-0.12.10/lib/em/version.rb +0 -3
  107. data/lib/ext/eventmachine-0.12.10/lib/eventmachine.rb +0 -1592
  108. data/lib/ext/eventmachine-0.12.10/lib/evma/callback.rb +0 -32
  109. data/lib/ext/eventmachine-0.12.10/lib/evma/container.rb +0 -75
  110. data/lib/ext/eventmachine-0.12.10/lib/evma/factory.rb +0 -77
  111. data/lib/ext/eventmachine-0.12.10/lib/evma/protocol.rb +0 -87
  112. data/lib/ext/eventmachine-0.12.10/lib/evma/reactor.rb +0 -48
  113. data/lib/ext/eventmachine-0.12.10/lib/evma.rb +0 -32
  114. data/lib/ext/eventmachine-0.12.10/lib/jeventmachine.rb +0 -257
  115. data/lib/ext/eventmachine-0.12.10/lib/pr_eventmachine.rb +0 -1022
  116. data/lib/ext/eventmachine-0.12.10/setup.rb +0 -1585
  117. data/lib/ext/eventmachine-0.12.10/tasks/cpp.rake_example +0 -77
  118. data/lib/ext/eventmachine-0.12.10/tests/client.crt +0 -31
  119. data/lib/ext/eventmachine-0.12.10/tests/client.key +0 -51
  120. data/lib/ext/eventmachine-0.12.10/tests/test_attach.rb +0 -126
  121. data/lib/ext/eventmachine-0.12.10/tests/test_basic.rb +0 -284
  122. data/lib/ext/eventmachine-0.12.10/tests/test_channel.rb +0 -63
  123. data/lib/ext/eventmachine-0.12.10/tests/test_connection_count.rb +0 -35
  124. data/lib/ext/eventmachine-0.12.10/tests/test_defer.rb +0 -47
  125. data/lib/ext/eventmachine-0.12.10/tests/test_epoll.rb +0 -160
  126. data/lib/ext/eventmachine-0.12.10/tests/test_error_handler.rb +0 -35
  127. data/lib/ext/eventmachine-0.12.10/tests/test_errors.rb +0 -82
  128. data/lib/ext/eventmachine-0.12.10/tests/test_exc.rb +0 -55
  129. data/lib/ext/eventmachine-0.12.10/tests/test_file_watch.rb +0 -49
  130. data/lib/ext/eventmachine-0.12.10/tests/test_futures.rb +0 -198
  131. data/lib/ext/eventmachine-0.12.10/tests/test_get_sock_opt.rb +0 -30
  132. data/lib/ext/eventmachine-0.12.10/tests/test_handler_check.rb +0 -37
  133. data/lib/ext/eventmachine-0.12.10/tests/test_hc.rb +0 -218
  134. data/lib/ext/eventmachine-0.12.10/tests/test_httpclient.rb +0 -218
  135. data/lib/ext/eventmachine-0.12.10/tests/test_httpclient2.rb +0 -153
  136. data/lib/ext/eventmachine-0.12.10/tests/test_inactivity_timeout.rb +0 -50
  137. data/lib/ext/eventmachine-0.12.10/tests/test_kb.rb +0 -60
  138. data/lib/ext/eventmachine-0.12.10/tests/test_ltp.rb +0 -182
  139. data/lib/ext/eventmachine-0.12.10/tests/test_ltp2.rb +0 -317
  140. data/lib/ext/eventmachine-0.12.10/tests/test_next_tick.rb +0 -133
  141. data/lib/ext/eventmachine-0.12.10/tests/test_object_protocol.rb +0 -37
  142. data/lib/ext/eventmachine-0.12.10/tests/test_pause.rb +0 -70
  143. data/lib/ext/eventmachine-0.12.10/tests/test_pending_connect_timeout.rb +0 -48
  144. data/lib/ext/eventmachine-0.12.10/tests/test_process_watch.rb +0 -48
  145. data/lib/ext/eventmachine-0.12.10/tests/test_processes.rb +0 -128
  146. data/lib/ext/eventmachine-0.12.10/tests/test_proxy_connection.rb +0 -92
  147. data/lib/ext/eventmachine-0.12.10/tests/test_pure.rb +0 -125
  148. data/lib/ext/eventmachine-0.12.10/tests/test_queue.rb +0 -44
  149. data/lib/ext/eventmachine-0.12.10/tests/test_running.rb +0 -42
  150. data/lib/ext/eventmachine-0.12.10/tests/test_sasl.rb +0 -72
  151. data/lib/ext/eventmachine-0.12.10/tests/test_send_file.rb +0 -242
  152. data/lib/ext/eventmachine-0.12.10/tests/test_servers.rb +0 -76
  153. data/lib/ext/eventmachine-0.12.10/tests/test_smtpclient.rb +0 -83
  154. data/lib/ext/eventmachine-0.12.10/tests/test_smtpserver.rb +0 -85
  155. data/lib/ext/eventmachine-0.12.10/tests/test_spawn.rb +0 -322
  156. data/lib/ext/eventmachine-0.12.10/tests/test_ssl_args.rb +0 -79
  157. data/lib/ext/eventmachine-0.12.10/tests/test_ssl_methods.rb +0 -50
  158. data/lib/ext/eventmachine-0.12.10/tests/test_ssl_verify.rb +0 -82
  159. data/lib/ext/eventmachine-0.12.10/tests/test_timers.rb +0 -162
  160. data/lib/ext/eventmachine-0.12.10/tests/test_ud.rb +0 -36
  161. data/lib/ext/eventmachine-0.12.10/tests/testem.rb +0 -31
  162. data/lib/ext/eventmachine-0.12.10/web/whatis +0 -7
@@ -1,200 +0,0 @@
1
- #--
2
- #
3
- # Author:: Francis Cianfrocca (gmail: blackhedd)
4
- # Homepage:: http://rubyeventmachine.com
5
- # Date:: 15 November 2006
6
- #
7
- # See EventMachine and EventMachine::Connection for documentation and
8
- # usage examples.
9
- #
10
- #----------------------------------------------------------------------------
11
- #
12
- # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
- # Gmail: blackhedd
14
- #
15
- # This program is free software; you can redistribute it and/or modify
16
- # it under the terms of either: 1) the GNU General Public License
17
- # as published by the Free Software Foundation; either version 2 of the
18
- # License, or (at your option) any later version; or 2) Ruby's License.
19
- #
20
- # See the file COPYING for complete licensing information.
21
- #
22
- #---------------------------------------------------------------------------
23
- #
24
- #
25
- #
26
-
27
- module EventMachine
28
- module Protocols
29
-
30
- # Implements Stomp (http://docs.codehaus.org/display/STOMP/Protocol).
31
- #
32
- # == Usage example
33
- #
34
- # module StompClient
35
- # include EM::Protocols::Stomp
36
- #
37
- # def connection_completed
38
- # connect :login => 'guest', :passcode => 'guest'
39
- # end
40
- #
41
- # def receive_msg msg
42
- # if msg.command == "CONNECTED"
43
- # subscribe '/some/topic'
44
- # else
45
- # p ['got a message', msg]
46
- # puts msg.body
47
- # end
48
- # end
49
- # end
50
- #
51
- # EM.run{
52
- # EM.connect 'localhost', 61613, StompClient
53
- # }
54
- #
55
- module Stomp
56
- include LineText2
57
-
58
- class Message
59
- # The command associated with the message, usually 'CONNECTED' or 'MESSAGE'
60
- attr_accessor :command
61
- # Hash containing headers such as destination and message-id
62
- attr_accessor :header
63
- alias :headers :header
64
- # Body of the message
65
- attr_accessor :body
66
-
67
- def initialize # :nodoc:
68
- @header = {}
69
- @state = :precommand
70
- @content_length = nil
71
- end
72
- def consume_line line # :nodoc:
73
- if @state == :precommand
74
- unless line =~ /\A\s*\Z/
75
- @command = line
76
- @state = :headers
77
- end
78
- elsif @state == :headers
79
- if line == ""
80
- if @content_length
81
- yield( [:sized_text, @content_length+1] )
82
- else
83
- @state = :body
84
- yield( [:unsized_text] )
85
- end
86
- elsif line =~ /\A([^:]+):(.+)\Z/
87
- k = $1.dup.strip
88
- v = $2.dup.strip
89
- @header[k] = v
90
- if k == "content-length"
91
- @content_length = v.to_i
92
- end
93
- else
94
- # This is a protocol error. How to signal it?
95
- end
96
- elsif @state == :body
97
- @body = line
98
- yield( [:dispatch] )
99
- end
100
- end
101
- end
102
-
103
- # :stopdoc:
104
-
105
- def send_frame verb, headers={}, body=""
106
- ary = [verb, "\n"]
107
- headers.each {|k,v| ary << "#{k}:#{v}\n" }
108
- ary << "content-length: #{body.to_s.length}\n"
109
- ary << "content-type: text/plain; charset=UTF-8\n"
110
- ary << "\n"
111
- ary << body.to_s
112
- ary << "\0"
113
- send_data ary.join
114
- end
115
-
116
- def receive_line line
117
- @stomp_initialized || init_message_reader
118
- @stomp_message.consume_line(line) {|outcome|
119
- if outcome.first == :sized_text
120
- set_text_mode outcome[1]
121
- elsif outcome.first == :unsized_text
122
- set_delimiter "\0"
123
- elsif outcome.first == :dispatch
124
- receive_msg(@stomp_message) if respond_to?(:receive_msg)
125
- init_message_reader
126
- end
127
- }
128
- end
129
-
130
- def receive_binary_data data
131
- @stomp_message.body = data[0..-2]
132
- receive_msg(@stomp_message) if respond_to?(:receive_msg)
133
- init_message_reader
134
- end
135
-
136
- def init_message_reader
137
- @stomp_initialized = true
138
- set_delimiter "\n"
139
- set_line_mode
140
- @stomp_message = Message.new
141
- end
142
-
143
- # :startdoc:
144
-
145
- # Invoked with an incoming Stomp::Message received from the STOMP server
146
- def receive_msg msg
147
- # stub, overwrite this in your handler
148
- end
149
-
150
- # CONNECT command, for authentication
151
- #
152
- # connect :login => 'guest', :passcode => 'guest'
153
- #
154
- def connect parms={}
155
- send_frame "CONNECT", parms
156
- end
157
-
158
- # SEND command, for publishing messages to a topic
159
- #
160
- # send '/topic/name', 'some message here'
161
- #
162
- def send destination, body, parms={}
163
- send_frame "SEND", parms.merge( :destination=>destination ), body.to_s
164
- end
165
-
166
- # SUBSCRIBE command, for subscribing to topics
167
- #
168
- # subscribe '/topic/name', false
169
- #
170
- def subscribe dest, ack=false
171
- send_frame "SUBSCRIBE", {:destination=>dest, :ack=>(ack ? "client" : "auto")}
172
- end
173
-
174
- # ACK command, for acknowledging receipt of messages
175
- #
176
- # module StompClient
177
- # include EM::P::Stomp
178
- #
179
- # def connection_completed
180
- # connect :login => 'guest', :passcode => 'guest'
181
- # # subscribe with ack mode
182
- # subscribe '/some/topic', true
183
- # end
184
- #
185
- # def receive_msg msg
186
- # if msg.command == "MESSAGE"
187
- # ack msg.headers['message-id']
188
- # puts msg.body
189
- # end
190
- # end
191
- # end
192
- #
193
- def ack msgid
194
- send_frame "ACK", 'message-id'=> msgid
195
- end
196
-
197
- end
198
- end
199
- end
200
-
@@ -1,53 +0,0 @@
1
- #--
2
- #
3
- # Author:: Francis Cianfrocca (gmail: blackhedd)
4
- # Homepage:: http://rubyeventmachine.com
5
- # Date:: 16 July 2006
6
- #
7
- # See EventMachine and EventMachine::Connection for documentation and
8
- # usage examples.
9
- #
10
- #----------------------------------------------------------------------------
11
- #
12
- # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
- # Gmail: blackhedd
14
- #
15
- # This program is free software; you can redistribute it and/or modify
16
- # it under the terms of either: 1) the GNU General Public License
17
- # as published by the Free Software Foundation; either version 2 of the
18
- # License, or (at your option) any later version; or 2) Ruby's License.
19
- #
20
- # See the file COPYING for complete licensing information.
21
- #
22
- #---------------------------------------------------------------------------
23
- #
24
- #
25
- #
26
-
27
- module EventMachine
28
- module Protocols
29
-
30
- class TcpConnectTester < Connection # :nodoc:
31
- include EventMachine::Deferrable
32
-
33
- def self.test( host, port )
34
- EventMachine.connect( host, port, self )
35
- end
36
-
37
- def post_init
38
- @start_time = Time.now
39
- end
40
-
41
- def connection_completed
42
- @completed = true
43
- set_deferred_status :succeeded, (Time.now - @start_time)
44
- close_connection
45
- end
46
-
47
- def unbind
48
- set_deferred_status :failed, (Time.now - @start_time) unless @completed
49
- end
50
- end
51
-
52
- end
53
- end
@@ -1,36 +0,0 @@
1
- module EventMachine
2
- # This module contains various protocol implementations, including:
3
- # - HttpClient and HttpClient2
4
- # - Stomp
5
- # - Memcache
6
- # - SmtpClient and SmtpServer
7
- # - SASLauth and SASLauthclient
8
- # - LineAndTextProtocol and LineText2
9
- # - HeaderAndContentProtocol
10
- # - Postgres3
11
- # - ObjectProtocol
12
- #
13
- # The protocol implementations live in separate files in the protocols/ subdirectory,
14
- # but are auto-loaded when they are first referenced in your application.
15
- #
16
- # EventMachine::Protocols is also aliased to EM::P for easier usage.
17
- #
18
- module Protocols
19
- # TODO : various autotools are completely useless with the lack of naming
20
- # convention, we need to correct that!
21
- autoload :TcpConnectTester, 'em/protocols/tcptest'
22
- autoload :HttpClient, 'em/protocols/httpclient'
23
- autoload :HttpClient2, 'em/protocols/httpclient2'
24
- autoload :LineAndTextProtocol, 'em/protocols/line_and_text'
25
- autoload :HeaderAndContentProtocol, 'em/protocols/header_and_content'
26
- autoload :LineText2, 'em/protocols/linetext2'
27
- autoload :Stomp, 'em/protocols/stomp'
28
- autoload :SmtpClient, 'em/protocols/smtpclient'
29
- autoload :SmtpServer, 'em/protocols/smtpserver'
30
- autoload :SASLauth, 'em/protocols/saslauth'
31
- autoload :Memcache, 'em/protocols/memcache'
32
- autoload :Postgres3, 'em/protocols/postgres3'
33
- autoload :ObjectProtocol, 'em/protocols/object_protocol'
34
- autoload :Socks4, 'em/protocols/socks4'
35
- end
36
- end
@@ -1,61 +0,0 @@
1
- module EventMachine
2
- # A cross thread, reactor scheduled, linear queue.
3
- #
4
- # This class provides a simple "Queue" like abstraction on top of the reactor
5
- # scheduler. It services two primary purposes:
6
- # * API sugar for stateful protocols
7
- # * Pushing processing onto the same thread as the reactor
8
- #
9
- # See examples/ex_queue.rb for a detailed example.
10
- #
11
- # q = EM::Queue.new
12
- # q.push('one', 'two', 'three')
13
- # 3.times do
14
- # q.pop{ |msg| puts(msg) }
15
- # end
16
- #
17
- class Queue
18
- # Create a new queue
19
- def initialize
20
- @items = []
21
- @popq = []
22
- end
23
-
24
- # Pop items off the queue, running the block on the reactor thread. The pop
25
- # will not happen immediately, but at some point in the future, either in
26
- # the next tick, if the queue has data, or when the queue is populated.
27
- def pop(*a, &b)
28
- cb = EM::Callback(*a, &b)
29
- EM.schedule do
30
- if @items.empty?
31
- @popq << cb
32
- else
33
- cb.call @items.shift
34
- end
35
- end
36
- nil # Always returns nil
37
- end
38
-
39
- # Push items onto the queue in the reactor thread. The items will not appear
40
- # in the queue immediately, but will be scheduled for addition during the
41
- # next reactor tick.
42
- def push(*items)
43
- EM.schedule do
44
- @items.push(*items)
45
- @popq.shift.call @items.shift until @items.empty? || @popq.empty?
46
- end
47
- end
48
-
49
- # N.B. This is a peek, it's not thread safe, and may only tend toward
50
- # accuracy.
51
- def empty?
52
- @items.empty?
53
- end
54
-
55
- # N.B. This is a peek, it's not thread safe, and may only tend toward
56
- # accuracy.
57
- def size
58
- @items.size
59
- end
60
- end
61
- end
@@ -1,85 +0,0 @@
1
- #--
2
- #
3
- # Author:: Francis Cianfrocca (gmail: blackhedd)
4
- # Homepage:: http://rubyeventmachine.com
5
- # Date:: 25 Aug 2007
6
- #
7
- # See EventMachine and EventMachine::Connection for documentation and
8
- # usage examples.
9
- #
10
- #----------------------------------------------------------------------------
11
- #
12
- # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
- # Gmail: blackhedd
14
- #
15
- # This program is free software; you can redistribute it and/or modify
16
- # it under the terms of either: 1) the GNU General Public License
17
- # as published by the Free Software Foundation; either version 2 of the
18
- # License, or (at your option) any later version; or 2) Ruby's License.
19
- #
20
- # See the file COPYING for complete licensing information.
21
- #
22
- #---------------------------------------------------------------------------
23
- #
24
- #
25
-
26
- module EventMachine
27
- # Support for Erlang-style processes.
28
- #
29
- class SpawnedProcess
30
- # Send a message to the spawned process
31
- def notify *x
32
- me = self
33
- EM.next_tick {
34
- # A notification executes in the context of this
35
- # SpawnedProcess object. That makes self and notify
36
- # work as one would expect.
37
- #
38
- y = me.call(*x)
39
- if y and y.respond_to?(:pull_out_yield_block)
40
- a,b = y.pull_out_yield_block
41
- set_receiver a
42
- self.notify if b
43
- end
44
- }
45
- end
46
- alias_method :resume, :notify
47
- alias_method :run, :notify # for formulations like (EM.spawn {xxx}).run
48
- #attr_accessor :receiver
49
-
50
- #--
51
- # I know I'm missing something stupid, but the inside of class << s
52
- # can't see locally-bound values. It can see globals, though.
53
- def set_receiver blk
54
- $em______tmpglobal = blk
55
- class << self
56
- define_method :call, $em______tmpglobal.dup
57
- end
58
- end
59
-
60
- end
61
-
62
- class YieldBlockFromSpawnedProcess # :nodoc:
63
- def initialize block, notify
64
- @block = [block,notify]
65
- end
66
- def pull_out_yield_block
67
- @block
68
- end
69
- end
70
-
71
- # Spawn an erlang-style process
72
- def self.spawn &block
73
- s = SpawnedProcess.new
74
- s.set_receiver block
75
- s
76
- end
77
-
78
- def self.yield &block # :nodoc:
79
- return YieldBlockFromSpawnedProcess.new( block, false )
80
- end
81
-
82
- def self.yield_and_notify &block # :nodoc:
83
- return YieldBlockFromSpawnedProcess.new( block, true )
84
- end
85
- end
@@ -1,130 +0,0 @@
1
- #--
2
- #
3
- # Author:: Francis Cianfrocca (gmail: blackhedd)
4
- # Homepage:: http://rubyeventmachine.com
5
- # Date:: 16 Jul 2006
6
- #
7
- # See EventMachine and EventMachine::Connection for documentation and
8
- # usage examples.
9
- #
10
- #----------------------------------------------------------------------------
11
- #
12
- # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
- # Gmail: blackhedd
14
- #
15
- # This program is free software; you can redistribute it and/or modify
16
- # it under the terms of either: 1) the GNU General Public License
17
- # as published by the Free Software Foundation; either version 2 of the
18
- # License, or (at your option) any later version; or 2) Ruby's License.
19
- #
20
- # See the file COPYING for complete licensing information.
21
- #
22
- #---------------------------------------------------------------------------
23
- #
24
- #
25
-
26
-
27
- module EventMachine
28
- class FileStreamer
29
- include Deferrable
30
-
31
- # Use mapped streamer for files bigger than 16k
32
- MappingThreshold = 16384
33
- # Wait until next tick to send more data when 50k is still in the outgoing buffer
34
- BackpressureLevel = 50000
35
- # Send 16k chunks at a time
36
- ChunkSize = 16384
37
-
38
- # Stream a file over a given connection. An optional :http_chunks => true argument will
39
- # use HTTP 1.1 style chunked-encoding semantics.
40
- #
41
- # module FileSender
42
- # def post_init
43
- # streamer = EventMachine::FileStreamer.new(self, '/tmp/bigfile.tar')
44
- # streamer.callback{
45
- # # file was sent successfully
46
- # close_connection_after_writing
47
- # }
48
- # end
49
- # end
50
- #
51
- def initialize connection, filename, args = {}
52
- @connection = connection
53
- @http_chunks = args[:http_chunks]
54
-
55
- if File.exist?(filename)
56
- @size = File.size?(filename)
57
- if @size <= MappingThreshold
58
- stream_without_mapping filename
59
- else
60
- stream_with_mapping filename
61
- end
62
- else
63
- fail "file not found"
64
- end
65
- end
66
-
67
- def stream_without_mapping filename # :nodoc:
68
- if @http_chunks
69
- @connection.send_data "#{@size.to_s(16)}\r\n"
70
- @connection.send_file_data filename
71
- @connection.send_data "\r\n0\r\n\r\n"
72
- else
73
- @connection.send_file_data filename
74
- end
75
- succeed
76
- end
77
- private :stream_without_mapping
78
-
79
- def stream_with_mapping filename # :nodoc:
80
- ensure_mapping_extension_is_present
81
-
82
- @position = 0
83
- @mapping = EventMachine::FastFileReader::Mapper.new filename
84
- stream_one_chunk
85
- end
86
- private :stream_with_mapping
87
-
88
- # Used internally to stream one chunk at a time over multiple reactor ticks
89
- def stream_one_chunk
90
- loop {
91
- if @position < @size
92
- if @connection.get_outbound_data_size > BackpressureLevel
93
- EventMachine::next_tick {stream_one_chunk}
94
- break
95
- else
96
- len = @size - @position
97
- len = ChunkSize if (len > ChunkSize)
98
-
99
- @connection.send_data( "#{len.to_s(16)}\r\n" ) if @http_chunks
100
- @connection.send_data( @mapping.get_chunk( @position, len ))
101
- @connection.send_data("\r\n") if @http_chunks
102
-
103
- @position += len
104
- end
105
- else
106
- @connection.send_data "0\r\n\r\n" if @http_chunks
107
- @mapping.close
108
- succeed
109
- break
110
- end
111
- }
112
- end
113
-
114
- #--
115
- # We use an outboard extension class to get memory-mapped files.
116
- # It's outboard to avoid polluting the core distro, but that means
117
- # there's a "hidden" dependency on it. The first time we get here in
118
- # any run, try to load up the dependency extension. User code will see
119
- # a LoadError if it's not available, but code that doesn't require
120
- # mapped files will work fine without it. This is a somewhat difficult
121
- # compromise between usability and proper modularization.
122
- #
123
- def ensure_mapping_extension_is_present # :nodoc:
124
- @@fastfilereader ||= (require 'fastfilereaderext')
125
- end
126
- private :ensure_mapping_extension_is_present
127
-
128
- end
129
- end
130
-
@@ -1,56 +0,0 @@
1
- module EventMachine
2
- # Creates a one-time timer
3
- #
4
- # timer = EventMachine::Timer.new(5) do
5
- # # this will never fire because we cancel it
6
- # end
7
- # timer.cancel
8
- #
9
- class Timer
10
- # Create a new timer that fires after a given number of seconds
11
- def initialize interval, callback=nil, &block
12
- @signature = EventMachine::add_timer(interval, callback || block)
13
- end
14
-
15
- # Cancel the timer
16
- def cancel
17
- EventMachine.send :cancel_timer, @signature
18
- end
19
- end
20
-
21
- # Creates a periodic timer
22
- #
23
- # n = 0
24
- # timer = EventMachine::PeriodicTimer.new(5) do
25
- # puts "the time is #{Time.now}"
26
- # timer.cancel if (n+=1) > 5
27
- # end
28
- #
29
- class PeriodicTimer
30
- # Create a new periodic timer that executes every interval seconds
31
- def initialize interval, callback=nil, &block
32
- @interval = interval
33
- @code = callback || block
34
- @cancelled = false
35
- schedule
36
- end
37
-
38
- # Cancel the periodic timer
39
- def cancel
40
- @cancelled = true
41
- end
42
-
43
- # Fire the timer every interval seconds
44
- attr_accessor :interval
45
-
46
- def schedule # :nodoc:
47
- EventMachine::add_timer @interval, method(:fire)
48
- end
49
- def fire # :nodoc:
50
- unless @cancelled
51
- @code.call
52
- schedule
53
- end
54
- end
55
- end
56
- end
@@ -1,3 +0,0 @@
1
- module EventMachine
2
- VERSION = "0.12.10"
3
- end