startback 0.17.1 → 0.17.2

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
  SHA256:
3
- metadata.gz: 9de1fd87976efe40325061815894cbd43d87e17df52a7da0725fdabb3a361233
4
- data.tar.gz: c4235d1e9281f12a3b4e3e9b913fe2aadaed5c53dc132f403182703f7391edd8
3
+ metadata.gz: 0d2cd78e89f819311eedaa9dc75d71fdfeff685aa2723d16dd50391077be1061
4
+ data.tar.gz: 808cc9194bedab39965ddcd3cc31774470335b264dd938803a5f90233b9fea73
5
5
  SHA512:
6
- metadata.gz: 3f6c961dc645a75b8082444f546db89ec1b2d6cfa72de0145ef475b68f525ea36f2282c4d0496d9cf43ce9d526fe87597e4fc325fb2cf3b9bd6c1e1e4b6224bb
7
- data.tar.gz: a4aece47c0fbae358ee779e50c28764e6acef9e6e0f7e77ed1d57a0956891fb6ba6fa5b8c9bcc6996126abb250231122800b1f7d8bd0aa13f591b3ce127d2de1
6
+ metadata.gz: dfdb0ec227a477d7f543dbb8e615d3f81c453fe6f4f9dc18fc20212e9d0fe476fc1c481b0e1292ff6202e99ae7e99fe670f82113fa7b64e1fa7323e53ba08436
7
+ data.tar.gz: f5405619b93cb20ef492beeba4b01d857dfc0d6adf77e50ff2517cefef953d57897c4082bf7d46708e85ad9f2048a475833f151dc78fb265f06eae86e0f661bc
@@ -14,9 +14,10 @@ module Startback
14
14
  include Support::OperationRunner
15
15
  include Support::Robustness
16
16
 
17
- def initialize(engine)
17
+ def initialize(engine, type = :all)
18
18
  @engine = engine
19
19
  @context = nil
20
+ @type = type
20
21
  install_listeners
21
22
  end
22
23
  attr_reader :engine
@@ -41,6 +42,8 @@ module Startback
41
42
  #
42
43
  # See Bus#listen
43
44
  def async(exchange, queue)
45
+ return unless async?
46
+
44
47
  bus.async.listen(exchange, queue) do |event_data|
45
48
  event = engine.factor_event(event_data)
46
49
  with_context(event.context).call(event)
@@ -51,6 +54,8 @@ module Startback
51
54
  #
52
55
  # See Bus#listen
53
56
  def sync(exchange, queue)
57
+ return unless sync?
58
+
54
59
  bus.listen(exchange, queue) do |event_data|
55
60
  event = engine.factor_event(event_data)
56
61
  with_context(event.context).call(event)
@@ -79,6 +84,16 @@ module Startback
79
84
  super(op).merge(context: context)
80
85
  end
81
86
 
87
+ private
88
+
89
+ def async?
90
+ @type == :async || @type == :all
91
+ end
92
+
93
+ def sync?
94
+ @type == :sync || @type == :all
95
+ end
96
+
82
97
  end # class Agent
83
98
  end # class Event
84
99
  end # module Starback
@@ -62,13 +62,13 @@ module Startback
62
62
  bus.connect
63
63
  end
64
64
 
65
- def create_agents
65
+ def create_agents(type = :all)
66
66
  return unless parent = self.class.auto_create_agents
67
67
 
68
68
  ObjectSpace
69
69
  .each_object(Class)
70
70
  .select { |klass| klass <= parent }
71
- .each { |klass| klass.new(self) }
71
+ .each { |klass| klass.new(self, type) }
72
72
  end
73
73
 
74
74
  def factor_event(event_data)
@@ -2,7 +2,7 @@ module Startback
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 17
5
- TINY = 1
5
+ TINY = 2
6
6
  end
7
7
  VERSION = "#{Version::MAJOR}.#{Version::MINOR}.#{Version::TINY}"
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: startback
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.1
4
+ version: 0.17.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernard Lambeau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-07 00:00:00.000000000 Z
11
+ date: 2023-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec