MCPcopy Create free account
hub / github.com/couchbase/couchbase-python-client / AttemptContext

Class AttemptContext

acouchbase/transactions/transactions.py:159–447  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

157
158
159class AttemptContext(AttemptContextLogic):
160
161 def __init__(self,
162 ctx, # type: TransactionsCapsuleType
163 loop, # type: AbstractEventLoop
164 transcoder, # type: Transcoder
165 opts # type: Optional[transaction_options]
166 ):
167 super().__init__(ctx, transcoder, loop, opts)
168
169 @AsyncWrapper.inject_callbacks(None)
170 def _new_attempt(self,
171 **kwargs # type: Dict[str, Any]
172 ) -> Awaitable[None]:
173 return super()._new_attempt_async(**kwargs)
174
175 @AsyncWrapper.inject_callbacks(None)
176 def _rollback(self,
177 **kwargs # type: Dict[str, Any]
178 ) -> Awaitable[None]:
179 return super()._rollback_async(**kwargs)
180
181 @AsyncWrapper.inject_callbacks(TransactionResult)
182 def _commit(self,
183 **kwargs # type: Dict[str, Any]
184 ) -> Awaitable[TransactionResult]:
185 return super()._commit_async(**kwargs)
186
187 @AsyncWrapper.inject_callbacks(TransactionGetResult)
188 def _get(self,
189 coll, # type: AsyncCollection
190 key, # type: str
191 **kwargs # type: Dict[str, Any]
192 ) -> Awaitable[TransactionGetResult]:
193 return super().get(coll, key, **kwargs)
194
195 def get(self,
196 coll, # type: AsyncCollection
197 key, # type: str
198 options=None, # type: Optional[TransactionGetOptions]
199 **kwargs # type: Dict[str, Any]
200 ) -> Awaitable[TransactionGetResult]:
201 """
202 Get a document within this transaction.
203
204 Args:
205 coll (:class:`couchbase.collection.Collection`): Collection to use to find the document.
206 key (str): document key.
207 options (:class:`~couchbase.options.TransactionGetOptions`): Optional parameters for this operation.
208 **kwargs (Dict[str, Any]): keyword arguments that can be used in place or to
209 override provided :class:`~couchbase.options.TransactionGetOptions`
210
211 Returns:
212 Awaitable[:class:`couchbase.transactions.TransactionGetResult`]: Document in collection, in a form useful
213 for passing to other transaction operations. Or `None` if the document was not found.
214 Raises:
215 :class:`couchbase.exceptions.TransactionOperationFailed`: If the operation failed. In practice, there is
216 no need to handle the exception, as the transaction will rollback regardless.

Callers 1

runMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected