startback 0.17.1 → 0.17.3

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: 47e8ac3b588f01947b8f6850a40ae2777bf3578b8fea2c38d923f9619f7ddf0e
4
+ data.tar.gz: d09a7168a291df2a59b199be072969fad30a1c7ef33d6c78058dfb358fbafd5f
5
5
  SHA512:
6
- metadata.gz: 3f6c961dc645a75b8082444f546db89ec1b2d6cfa72de0145ef475b68f525ea36f2282c4d0496d9cf43ce9d526fe87597e4fc325fb2cf3b9bd6c1e1e4b6224bb
7
- data.tar.gz: a4aece47c0fbae358ee779e50c28764e6acef9e6e0f7e77ed1d57a0956891fb6ba6fa5b8c9bcc6996126abb250231122800b1f7d8bd0aa13f591b3ce127d2de1
6
+ metadata.gz: dddbf9e33df9565c4ec445d107e9decc83c23a7538aba0eac4babd5104c0000ad89a49d657060ac400a9e79418e1c705c2dfb4b3b620b530e932f04977ce98f0
7
+ data.tar.gz: 6fe5a230ac86dc2cd2b8bee70b54df7c3be840f9afd8d871d54d1a31cffa3a1b10bccc0de003201f169436a96b14b32bcd58f2a6aaffddd4a0d67b4a132398db
@@ -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)
@@ -4,6 +4,8 @@ module Startback
4
4
  def self.emits(type, &bl)
5
5
  after_call do
6
6
  event_data = instance_exec(&bl)
7
+ return unless event_data
8
+
7
9
  event = type.new(type.to_s, event_data, context)
8
10
  context.engine.bus.emit(event)
9
11
  end
@@ -2,7 +2,7 @@ module Startback
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 17
5
- TINY = 1
5
+ TINY = 3
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.3
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