Class: Operations::Components::Idempotency
- Defined in:
- lib/operations/components/idempotency.rb
Overview
Contains logic to handle idempotency checks.
Idempotency checks are used to skip operation execution in certain conditions.
An idempotency check returns a Result monad. If it returns a Failure, the operation body is skipped but the operation is considered successful. The value or failure will be merged to the result context in order to enrich it (the failure should contain something that operation body would return normally to mimic a proper operation call result).
Component logs the failed check with ‘error_reporter`.
Constant Summary
Constants inherited from Base
Base::DEFAULT_NAMES_MAP, Base::MONADS_DO_WRAPPER_SIGNATURES
Instance Method Summary collapse
Methods inherited from Prechecks
Instance Method Details
#call(params, context) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/operations/components/idempotency.rb', line 19 def call(params, context) failure, failed_check = process_callables(params, context) if failure new_result = result( params: params, context: context.merge(failure.failure) ) report_failure(new_result, failed_check) Failure(new_result) else Success(result( params: params, context: context )) end end |