Class: MockDnsServer::ServerContext
- Inherits:
-
Object
- Object
- MockDnsServer::ServerContext
- Extended by:
- Forwardable
- Includes:
- MessageBuilder
- Defined in:
- lib/mock_dns_server/server_context.rb
Instance Attribute Summary collapse
-
#conditional_actions ⇒ Object
readonly
Returns the value of attribute conditional_actions.
-
#history ⇒ Object
readonly
Returns the value of attribute history.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#mutex ⇒ Object
readonly
Returns the value of attribute mutex.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#timeout_secs ⇒ Object
readonly
Returns the value of attribute timeout_secs.
-
#verbose ⇒ Object
readonly
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#initialize(server, options = {}) ⇒ ServerContext
constructor
A new instance of ServerContext.
- #with_mutex(&block) ⇒ Object
Methods included from MessageBuilder
axfr_request, dns_update, dummy_a_response, ixfr_request, ixfr_request_soa_rr, notify_message, ns, rr, serial_value, soa_answer, soa_request, soa_response, specified_a_response
Constructor Details
#initialize(server, options = {}) ⇒ ServerContext
Returns a new instance of ServerContext.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/mock_dns_server/server_context.rb', line 24 def initialize(server, = {}) @server = server @port = [:port] @host = [:host] @timeout_secs = [:timeout_secs] @verbose = [:verbose] @mutex = Mutex.new @conditional_actions = ConditionalActions.new(self) @history = History.new(self) end |
Instance Attribute Details
#conditional_actions ⇒ Object (readonly)
Returns the value of attribute conditional_actions.
17 18 19 |
# File 'lib/mock_dns_server/server_context.rb', line 17 def conditional_actions @conditional_actions end |
#history ⇒ Object (readonly)
Returns the value of attribute history.
17 18 19 |
# File 'lib/mock_dns_server/server_context.rb', line 17 def history @history end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
17 18 19 |
# File 'lib/mock_dns_server/server_context.rb', line 17 def host @host end |
#mutex ⇒ Object (readonly)
Returns the value of attribute mutex.
17 18 19 |
# File 'lib/mock_dns_server/server_context.rb', line 17 def mutex @mutex end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
17 18 19 |
# File 'lib/mock_dns_server/server_context.rb', line 17 def port @port end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
17 18 19 |
# File 'lib/mock_dns_server/server_context.rb', line 17 def server @server end |
#timeout_secs ⇒ Object (readonly)
Returns the value of attribute timeout_secs.
17 18 19 |
# File 'lib/mock_dns_server/server_context.rb', line 17 def timeout_secs @timeout_secs end |
#verbose ⇒ Object (readonly)
Returns the value of attribute verbose.
17 18 19 |
# File 'lib/mock_dns_server/server_context.rb', line 17 def verbose @verbose end |
Instance Method Details
#with_mutex(&block) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/mock_dns_server/server_context.rb', line 36 def with_mutex(&block) start_time = Time.now duration = ->() do now = Time.now elapsed_in_usec = (now - start_time) * 1_000_000 start_time = now "#{elapsed_in_usec} usec" end #puts "#{Thread.current}: Waiting for mutex..." mutex.synchronize do #puts "time to get mutex: #{duration.()}" block.call #puts "time using mutex: #{duration.()}" end end |