Module: Swift::Adapter::Synchrony
Defined Under Namespace
Instance Method Summary collapse
-
#execute(*args) {|res| ... } ⇒ Object
Execute a command asynchronously and pause the Fiber until the command finishes.
- #transaction(&block) ⇒ Object
Instance Method Details
#execute(*args) {|res| ... } ⇒ Object
Execute a command asynchronously and pause the Fiber until the command finishes.
24 25 26 27 28 29 30 31 32 |
# File 'lib/swift/adapter/synchrony.rb', line 24 def execute *args res = ::EM::Synchrony.sync super(*args) if res.kind_of?(Error) res.set_backtrace caller.reject {|subject| subject =~ %r{swift/fiber_connection_pool}} raise res end yield res if block_given? res end |
#transaction(&block) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/swift/adapter/synchrony.rb', line 34 def transaction &block Swift.scopes.push(self) execute('begin') res = yield(self) execute('commit') res rescue => e execute('rollback') raise e ensure Swift.scopes.pop end |