Module: HTTPX::Plugins::FiberConcurrency::RequestMethods

Defined in:
lib/httpx/plugins/fiber_concurrency.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contextObject (readonly)

the execution context (fiber) this request was sent on.



43
44
45
# File 'lib/httpx/plugins/fiber_concurrency.rb', line 43

def context
  @context
end

Instance Method Details

#complete!(response = @response) ⇒ Object



60
61
62
63
# File 'lib/httpx/plugins/fiber_concurrency.rb', line 60

def complete!(response = @response)
  @context = nil
  super
end

#current_context?Boolean

checks whether the current execution context is the one where the request was created.

Returns:

  • (Boolean)


56
57
58
# File 'lib/httpx/plugins/fiber_concurrency.rb', line 56

def current_context?
  @context == Fiber.current
end

#initializeObject



45
46
47
48
# File 'lib/httpx/plugins/fiber_concurrency.rb', line 45

def initialize(*)
  super
  @context = nil
end

#set_context!Object

sets the execution context for this request. the default is the current fiber.



51
52
53
# File 'lib/httpx/plugins/fiber_concurrency.rb', line 51

def set_context!
  @context ||= Fiber.current # rubocop:disable Naming/MemoizedInstanceVariableName
end