devp2p 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/devp2p/base_app.rb +30 -18
- data/lib/devp2p/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6ddcb762858bc073f1b5394c9294dff6a391756
|
4
|
+
data.tar.gz: 8e11801858eff23d391df93214520a47ea31f8c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a2cb995431e8db5e5a34f8b9368844fcea25e53cb8519931c04678b88f3c420d89b8191cba17c0ad5967c911011427023b11286b7e4d0f00d49104dd3c77644
|
7
|
+
data.tar.gz: 9b0c03fcaa6a819e20f1a1c516f176c240a75351c5e4dde05087b4dc902d2d39e6a9a36b2072ed1fcf4e8f8ef65debbb0d12768afd75d0996f7d9dda2766626f
|
data/lib/devp2p/base_app.rb
CHANGED
@@ -16,7 +16,7 @@ module DEVp2p
|
|
16
16
|
|
17
17
|
def initialize(config=default_config)
|
18
18
|
@config = Utils.update_config_with_defaults config, default_config
|
19
|
-
@
|
19
|
+
@container = Celluloid::Supervision::Container.new
|
20
20
|
@services = Hashie::Mash.new
|
21
21
|
end
|
22
22
|
|
@@ -30,38 +30,42 @@ module DEVp2p
|
|
30
30
|
raise ArgumentError, "service #{klass.name} already registered" if services.has_key?(klass.name)
|
31
31
|
|
32
32
|
logger.info "registering service", service: klass.name
|
33
|
-
|
34
|
-
registry_name = "#{object_id}__#{klass.name}"
|
35
|
-
@registry.define type: klass, as: registry_name, args: args
|
33
|
+
@container.add type: klass, as: get_actor_name(klass.name), args: args
|
36
34
|
services[klass.name] = nil
|
37
35
|
|
38
36
|
klass
|
39
37
|
end
|
40
38
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
39
|
+
##
|
40
|
+
# Terminate service instance, remove it from registry.
|
41
|
+
#
|
42
|
+
def deregister_service(klass)
|
43
|
+
raise ArgumentError, "service must be instance of BaseService" unless klass.instance_of?(Class) && klass < BaseService
|
44
|
+
raise ArgumentError, "service #{klass.name} not registered" unless services.has_key?(klass.name)
|
45
|
+
|
46
|
+
logger.info "deregistering service", service: klass.name
|
47
|
+
@container.remove actor(klass.name)
|
48
|
+
services.delete klass.name
|
49
|
+
|
50
|
+
klass
|
46
51
|
end
|
47
52
|
|
48
53
|
def start
|
49
|
-
|
54
|
+
services.keys.each do |n|
|
55
|
+
next if services[n]
|
50
56
|
|
51
|
-
|
52
|
-
|
53
|
-
services[k] = Celluloid::Actor[registry_name]
|
54
|
-
services[k].start
|
57
|
+
services[n] = actor(n)
|
58
|
+
services[n].start
|
55
59
|
end
|
56
60
|
end
|
57
61
|
|
58
62
|
def stop
|
59
|
-
services.keys.each do |
|
60
|
-
services[
|
61
|
-
services[
|
63
|
+
services.keys.each do |n|
|
64
|
+
services[n].stop if services[n].alive?
|
65
|
+
services[n] = nil
|
62
66
|
end
|
63
67
|
|
64
|
-
|
68
|
+
#@container.shutdown
|
65
69
|
end
|
66
70
|
|
67
71
|
def join
|
@@ -76,5 +80,13 @@ module DEVp2p
|
|
76
80
|
@logger ||= Logger.new 'app'
|
77
81
|
end
|
78
82
|
|
83
|
+
def actor(name)
|
84
|
+
Celluloid::Actor[get_actor_name(name)]
|
85
|
+
end
|
86
|
+
|
87
|
+
def get_actor_name(service_name)
|
88
|
+
"#{object_id}_#{service_name}"
|
89
|
+
end
|
90
|
+
|
79
91
|
end
|
80
92
|
end
|
data/lib/devp2p/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devp2p
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Xie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|