business_flow 0.11.1 → 0.12.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 16d25ddb5bb71fa37b36cdf7613fea34a42fb002
4
- data.tar.gz: 0e7d23ca4de021b1c1eee8e6d67a45b3f4e14079
3
+ metadata.gz: fd72338d1a50d4e2597d104d79a249faac06b5a9
4
+ data.tar.gz: 58a7c0c6680cb8ebc91ff6d40152191352d6cf16
5
5
  SHA512:
6
- metadata.gz: c0e76c159e0ee3acbc44519d617510df07a9dab54a5c3d3801c2608555a919306ed2822115363a819638b0fe76e5e6e5c09fe40e92f96e4fe698872bb83e3c81
7
- data.tar.gz: 07bc1f3138665a9957d8695225cdf41c8b135a6f2d706406f68abfade38f531df7f6adfcd0e01037976685109af10d78cf54d6877228684b35729e2869514313
6
+ metadata.gz: af2687926347dbc52c4a7a3040f34366b75e3b99e95fe23afc07b2e7efa78aec92c5439b6d7866e82f66bd52ea613269482d550eac5db8d63b91a5034de8bd4a
7
+ data.tar.gz: f08c8deb55ca25440d726f928df1edec81eee3972d88b599460f83b0026b7c1022f06575d8c556dde46c46834050f218d98707a5ceed60366714c037e094f571
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- business_flow (0.11.1)
4
+ business_flow (0.12.0)
5
5
  activemodel (>= 3.0)
6
6
  activesupport (>= 3.0)
7
7
 
@@ -69,12 +69,22 @@ module BusinessFlow
69
69
  def with_cache(flow, &blk)
70
70
  add_cache_key_to_result_class
71
71
  catch(:halt_step) do
72
- return cache_store.fetch(flow.cache_key,
73
- cache_options.to_store_options(flow), &blk)
72
+ return instrument_cache_fetch(flow, &blk)
74
73
  end
75
74
  raise FlowFailedException, flow
76
75
  end
77
76
 
77
+ def instrument_cache_fetch(flow)
78
+ instrument(:cache, flow) do |payload|
79
+ payload[:cache_hit] = false if payload
80
+ cache_store.fetch(flow.cache_key,
81
+ cache_options.to_store_options(flow)) do
82
+ payload[:cache_hit] = true if payload
83
+ yield
84
+ end
85
+ end
86
+ end
87
+
78
88
  RESULT_FINALIZE = proc do |cache_key|
79
89
  @cache_key = cache_key
80
90
  raise FlowFailedException, self if errors?
@@ -85,6 +85,10 @@ module BusinessFlow
85
85
  end
86
86
  end
87
87
 
88
+ def instrument(_name, _flow)
89
+ yield nil
90
+ end
91
+
88
92
  def result_from(flow)
89
93
  finalize_result_provider
90
94
  # We use instance_variable_get here instead of making it part of
@@ -9,9 +9,30 @@ module BusinessFlow
9
9
 
10
10
  # Contains methods that we add to the DSL
11
11
  module ClassMethods
12
+ INSTRUMENTATION_PREFIX = 'business_flow'.freeze
13
+
14
+ def instrument(name, flow)
15
+ payload = { flow: flow }
16
+ ActiveSupport::Notifications.instrument(
17
+ "#{INSTRUMENTATION_PREFIX}.#{name}.#{instrumentation_name}", payload
18
+ ) do
19
+ yield payload
20
+ end
21
+ end
22
+
12
23
  def instrument_steps
13
24
  step_executor ::BusinessFlow::InstrumentedStepExecutor
14
25
  end
26
+
27
+ def instrumentation_name
28
+ @instrumentation_name ||=
29
+ to_s.underscore.freeze
30
+ end
31
+
32
+ def event_name
33
+ @event_name ||=
34
+ "#{INSTRUMENTATION_PREFIX}.flow.#{instrumentation_name}".freeze
35
+ end
15
36
  end
16
37
  end
17
38
  end
@@ -18,11 +18,11 @@ module BusinessFlow
18
18
  end
19
19
 
20
20
  def flow_name
21
- @flow_name ||= flow.class.to_s.underscore
21
+ @flow_name ||= flow.class.instrumentation_name
22
22
  end
23
23
 
24
24
  def flow_event_name
25
- @flow_event_name ||= "business_flow.flow.#{flow_name}"
25
+ @flow_event_name ||= flow.class.event_name
26
26
  end
27
27
  end
28
28
  end
@@ -1,3 +1,3 @@
1
1
  module BusinessFlow
2
- VERSION = '0.11.1'.freeze
2
+ VERSION = '0.12.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: business_flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.1
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Scarborough