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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c9730d697b44cd5f35301e1010636cfa941e30db
4
- data.tar.gz: dc7bed10ffed00dc8353e459906014d541738fcc
3
+ metadata.gz: f6ddcb762858bc073f1b5394c9294dff6a391756
4
+ data.tar.gz: 8e11801858eff23d391df93214520a47ea31f8c4
5
5
  SHA512:
6
- metadata.gz: 3b8635533c9b4e6211972ea1d0e3973317553b991dcfd664823ed3cbee5c627b7f68e72d411974d47ceafe8eb241e9137563af6b944f09549b18b56f178c3e45
7
- data.tar.gz: 974eae8a51cc88d2668b07c4baa0f75aa305ab59b283307abea19c7edccc9cf5f84e2567dceb223f96739c820394e597fd0c5deb853172d96fab951de00812c1
6
+ metadata.gz: 7a2cb995431e8db5e5a34f8b9368844fcea25e53cb8519931c04678b88f3c420d89b8191cba17c0ad5967c911011427023b11286b7e4d0f00d49104dd3c77644
7
+ data.tar.gz: 9b0c03fcaa6a819e20f1a1c516f176c240a75351c5e4dde05087b4dc902d2d39e6a9a36b2072ed1fcf4e8f8ef65debbb0d12768afd75d0996f7d9dda2766626f
@@ -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
- @registry = Celluloid::Supervision::Configuration.new
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
- def deregister_service(service)
42
- raies NotImplemented
43
- #raise ArgumentError, "service must be instance of BaseService" unless service.is_a?(BaseService)
44
- #services.delete(service.name)
45
- #unlink service
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
- @registry.deploy
54
+ services.keys.each do |n|
55
+ next if services[n]
50
56
 
51
- services.keys.each do |k|
52
- registry_name = "#{object_id}__#{k}"
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 |k|
60
- services[k].stop if services[k].alive?
61
- services[k] = nil
63
+ services.keys.each do |n|
64
+ services[n].stop if services[n].alive?
65
+ services[n] = nil
62
66
  end
63
67
 
64
- @registry.shutdown
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
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : ascii-8bit -*-
2
2
  module DEVp2p
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.1'
4
4
 
5
5
  VersionString = begin
6
6
  git_describe_re = /^(?<version>v\d+\.\d+\.\d+)-(?<git>\d+-g[a-fA-F0-9]+(?:-dirty)?)$/
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.0
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-06 00:00:00.000000000 Z
11
+ date: 2016-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie