Class: Stripe::APIRequestor::ThreadContext
- Inherits:
-
Object
- Object
- Stripe::APIRequestor::ThreadContext
- Defined in:
- lib/stripe/api_requestor.rb
Overview
A record representing any data that APIRequestor puts into
Thread.current. Making it a class likes this gives us a little extra
type safety and lets us document what each field does.
For internal use only. Does not provide a stable API and may be broken with future non-major changes.
Instance Attribute Summary collapse
-
#active_requestor ⇒ Object
A
APIRequestorthat's been flagged as currently active within a thread byAPIRequestor#request. -
#default_requestor ⇒ Object
A default
APIRequestorobject for the thread. -
#last_responses ⇒ Object
A temporary map of block IDs to responses from last executed API calls.
-
#request_block_stack ⇒ Object
A stack of unique block IDs keeps nested request blocks isolated, including blocks using the same requestor.
Instance Method Summary collapse
-
#default_connection_managers ⇒ Object
A map of connection mangers for the thread.
- #reset_connection_managers ⇒ Object
Instance Attribute Details
#active_requestor ⇒ Object
A APIRequestor that's been flagged as currently active within a
thread by APIRequestor#request. A requestor stays active until the
completion of the request block.
404 405 406 |
# File 'lib/stripe/api_requestor.rb', line 404 def active_requestor @active_requestor end |
#default_requestor ⇒ Object
A default APIRequestor object for the thread. Used in all cases where
the user hasn't specified their own.
408 409 410 |
# File 'lib/stripe/api_requestor.rb', line 408 def default_requestor @default_requestor end |
#last_responses ⇒ Object
A temporary map of block IDs to responses from last executed API
calls. Used to return responses from calls to APIRequestor#request.
Stored in the thread data to make the use of a single APIRequestor
object safe across multiple threads. Each nested block has its own
response entry, independent of the requestors used to make requests.
Responses are only left in as long as they're needed, which means
they're removed as soon as a call leaves APIRequestor#request, and
because that's wrapped in an ensure block, they should never leave
garbage in Thread.current.
425 426 427 |
# File 'lib/stripe/api_requestor.rb', line 425 def last_responses @last_responses end |
#request_block_stack ⇒ Object
A stack of unique block IDs keeps nested request blocks isolated, including blocks using the same requestor.
412 413 414 |
# File 'lib/stripe/api_requestor.rb', line 412 def request_block_stack @request_block_stack end |
Instance Method Details
#default_connection_managers ⇒ Object
A map of connection mangers for the thread. Normally shared between
all APIRequestor objects on a particular thread, and created so as to
minimize the number of open connections that an application needs.
430 431 432 |
# File 'lib/stripe/api_requestor.rb', line 430 def default_connection_managers @default_connection_managers ||= {} end |
#reset_connection_managers ⇒ Object
434 435 436 |
# File 'lib/stripe/api_requestor.rb', line 434 def reset_connection_managers @default_connection_managers = {} end |