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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/business_flow/cacheable.rb +12 -2
- data/lib/business_flow/dsl.rb +4 -0
- data/lib/business_flow/instrument.rb +21 -0
- data/lib/business_flow/instrumented_executor.rb +2 -2
- data/lib/business_flow/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd72338d1a50d4e2597d104d79a249faac06b5a9
|
4
|
+
data.tar.gz: 58a7c0c6680cb8ebc91ff6d40152191352d6cf16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af2687926347dbc52c4a7a3040f34366b75e3b99e95fe23afc07b2e7efa78aec92c5439b6d7866e82f66bd52ea613269482d550eac5db8d63b91a5034de8bd4a
|
7
|
+
data.tar.gz: f08c8deb55ca25440d726f928df1edec81eee3972d88b599460f83b0026b7c1022f06575d8c556dde46c46834050f218d98707a5ceed60366714c037e094f571
|
data/Gemfile.lock
CHANGED
@@ -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
|
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?
|
data/lib/business_flow/dsl.rb
CHANGED
@@ -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.
|
21
|
+
@flow_name ||= flow.class.instrumentation_name
|
22
22
|
end
|
23
23
|
|
24
24
|
def flow_event_name
|
25
|
-
@flow_event_name ||=
|
25
|
+
@flow_event_name ||= flow.class.event_name
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|