tribe_em 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +12 -2
- data/lib/tribe_em/connection.rb +10 -1
- data/lib/tribe_em/tcp_server.rb +7 -0
- data/lib/tribe_em/version.rb +1 -1
- data/tribe_em.gemspec +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -49,13 +49,23 @@ You can test the below code using a utility such as telnet (telnet localhost 900
|
|
49
49
|
Tribe EM is designed to be easily customized through inheritence of Tribe::EM::Connection.
|
50
50
|
Communication between EventMachine and the Tribe actor system is provided by Tribe::EM::ActorProxy.
|
51
51
|
|
52
|
+
## Protocols
|
53
|
+
|
54
|
+
Tribe EM has native TCP server and connection classes built in.
|
55
|
+
Other protocol implementations can be found below.
|
56
|
+
Note that some impmementations are marked as native while others are marked as wrappers.
|
57
|
+
Native implementations are specifically designed to for Tribe EM and thus push most to the actor threads.
|
58
|
+
Wrapper implementations wrap existing EM libraries and usually do more work in the EM thread.
|
59
|
+
This means that native implmentations (when used with real threads via JRuby) will scale better on multi-core systems.
|
60
|
+
None of this really matters much with MRI Ruby since it has a global interpretter lock.
|
61
|
+
|
62
|
+
- [AMF Socket] (https://github.com/chadrem/tribe_em_amfsocket "AMF Socket") (wrapper)
|
63
|
+
|
52
64
|
## TODO - missing features
|
53
65
|
|
54
66
|
- Commonly used server protocols such as HTTP.
|
55
|
-
- Integration with my [AMF Socket] (https://github.com/chadrem/amf_socket_ruby "AMF Socket") gem.
|
56
67
|
- Client side sockets.
|
57
68
|
|
58
|
-
|
59
69
|
## Contributing
|
60
70
|
|
61
71
|
1. Fork it
|
data/lib/tribe_em/connection.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Tribe
|
2
2
|
module EM
|
3
3
|
class Connection < Tribe::Actor
|
4
|
-
# The Proxy class is what
|
4
|
+
# The Proxy class is what separates the EM connection and Tribe actor.
|
5
5
|
def self.proxy_class
|
6
6
|
return Tribe::EM::ActorProxy
|
7
7
|
end
|
@@ -14,21 +14,30 @@ module Tribe
|
|
14
14
|
super
|
15
15
|
end
|
16
16
|
|
17
|
+
# Override and call super as necessary.
|
17
18
|
def on_post_init(event)
|
18
19
|
end
|
19
20
|
|
21
|
+
# Override and call super as necessary.
|
20
22
|
def on_receive_data(event)
|
21
23
|
end
|
22
24
|
|
25
|
+
# Override and call super as necessary.
|
23
26
|
def on_unbind(event)
|
24
27
|
enqueue(:shutdown)
|
25
28
|
end
|
26
29
|
|
30
|
+
# Override and call super as necessary.
|
27
31
|
def exception_handler(e)
|
32
|
+
super
|
33
|
+
|
28
34
|
close
|
29
35
|
end
|
30
36
|
|
37
|
+
# Override and call super as necessary.
|
31
38
|
def shutdown_handler(event)
|
39
|
+
super
|
40
|
+
|
32
41
|
close(true)
|
33
42
|
end
|
34
43
|
|
data/lib/tribe_em/tcp_server.rb
CHANGED
@@ -13,23 +13,30 @@ module Tribe
|
|
13
13
|
start_listener
|
14
14
|
end
|
15
15
|
|
16
|
+
# Override and call super as necessary.
|
16
17
|
def on_start_listener(event)
|
17
18
|
start_listener
|
18
19
|
end
|
19
20
|
|
21
|
+
# Override and call super as necessary.
|
20
22
|
def on_stop_listener(event)
|
21
23
|
stop_listener
|
22
24
|
end
|
23
25
|
|
26
|
+
# Override and call super as necessary.
|
24
27
|
def on_listener_started(event)
|
25
28
|
@server_sig = event.data
|
26
29
|
end
|
27
30
|
|
31
|
+
# Override and call super as necessary.
|
28
32
|
def on_listener_stopped(event)
|
29
33
|
@server_sig = nil
|
30
34
|
end
|
31
35
|
|
36
|
+
# Override and call super as necessary.
|
32
37
|
def shutdown_handler(event)
|
38
|
+
super
|
39
|
+
|
33
40
|
stop_listener if @server_sig
|
34
41
|
end
|
35
42
|
|
data/lib/tribe_em/version.rb
CHANGED
data/tribe_em.gemspec
CHANGED
@@ -17,6 +17,6 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ['lib']
|
19
19
|
|
20
|
-
gem.add_dependency('tribe', '0.0.
|
20
|
+
gem.add_dependency('tribe', '0.0.10')
|
21
21
|
gem.add_dependency('eventmachine', '>= 1.0.0')
|
22
22
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tribe_em
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.0.
|
21
|
+
version: 0.0.10
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - '='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.0.
|
29
|
+
version: 0.0.10
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: eventmachine
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|