Top Level Namespace
Defined Under Namespace
Modules: Stately, StatelyCode, StatelyDB
Constant Summary
collapse
- LOGGER =
Logger.new($stdout)
Instance Method Summary
collapse
Instance Method Details
#backoff(attempt, base_backoff) ⇒ Float
backoff returns a duration to wait before retrying a request. ‘attempt` is the current attempt number, starting from 0 (e.g. the first attempt is 0, then 1, then 2…).
116
117
118
119
120
121
122
123
|
# File 'lib/common/auth/token_fetcher.rb', line 116
def backoff(attempt, base_backoff)
exp = 2**attempt
jitter = rand
(exp * jitter * base_backoff)
end
|
#build_filters(item_types: [], cel_filters: []) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/common/build_filters.rb', line 5
def build_filters(item_types: [], cel_filters: [])
filters = item_types.map do |item_type|
Stately::Db::FilterCondition.new(item_type: item_type.respond_to?(:name) ? item_type.name.split("::").last : item_type)
end
filters += cel_filters.map do |filter|
Stately::Db::FilterCondition.new(
cel_expression: {
item_type: filter[0].respond_to?(:name) ? filter[0].name.split("::").last : filter[0],
expression: filter[1]
}
)
end
filters
end
|
#safe_yield(&block) ⇒ Object
20
21
22
23
24
|
# File 'lib/common/error_interceptor.rb', line 20
def safe_yield(*, &block)
block.call(*)
rescue Exception => e
raise StatelyDB::Error.from(e)
end
|
#safe_yield_stream(stream, &block) ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/common/error_interceptor.rb', line 26
def safe_yield_stream(stream, &block)
stream.each do |msg|
safe_yield(msg, &block)
end
rescue Exception => e
raise StatelyDB::Error.from(e)
end
|