Class: Datadog::Transport::HTTP::Adapters::Test

Inherits:
Object
  • Object
show all
Defined in:
lib/ddtrace/transport/http/adapters/test.rb

Overview

Adapter for testing

Defined Under Namespace

Classes: Response

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(buffer = nil) ⇒ Test

Returns a new instance of Test.



13
14
15
16
17
# File 'lib/ddtrace/transport/http/adapters/test.rb', line 13

def initialize(buffer = nil)
  @buffer = buffer
  @mutex = Mutex.new
  @status = 200
end

Instance Attribute Details

#bufferObject (readonly)

Returns the value of attribute buffer.



9
10
11
# File 'lib/ddtrace/transport/http/adapters/test.rb', line 9

def buffer
  @buffer
end

#statusObject (readonly)

Returns the value of attribute status.



9
10
11
# File 'lib/ddtrace/transport/http/adapters/test.rb', line 9

def status
  @status
end

Instance Method Details

#add_request(env) ⇒ Object



28
29
30
# File 'lib/ddtrace/transport/http/adapters/test.rb', line 28

def add_request(env)
  @mutex.synchronize { buffer << env } if buffer?
end

#buffer?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/ddtrace/transport/http/adapters/test.rb', line 24

def buffer?
  !@buffer.nil?
end

#call(env) ⇒ Object



19
20
21
22
# File 'lib/ddtrace/transport/http/adapters/test.rb', line 19

def call(env)
  add_request(env)
  Response.new(status)
end

#set_status!(status) ⇒ Object



32
33
34
# File 'lib/ddtrace/transport/http/adapters/test.rb', line 32

def set_status!(status)
  @status = status
end