Class: ScoutApm::Remote::Router

Inherits:
Object
  • Object
show all
Defined in:
lib/scout_apm/remote/router.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(recorder, logger) ⇒ Router

If/When we add different types, this signature should change to a hash of => Object, rather than building it in the initializer here.

Keys of routes should be strings



11
12
13
14
15
16
17
# File 'lib/scout_apm/remote/router.rb', line 11

def initialize(recorder, logger)
  @routes = {
    'record' => recorder
  }

  @logger = logger
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



4
5
6
# File 'lib/scout_apm/remote/router.rb', line 4

def logger
  @logger
end

#routesObject (readonly)

Returns the value of attribute routes.



5
6
7
# File 'lib/scout_apm/remote/router.rb', line 5

def routes
  @routes
end

Instance Method Details

#handle(msg) ⇒ Object

A message is a 2 element array [:type, :command, [args]]. For this first creation, this should be [‘record’, ‘record’, [TrackedRequest]] (the args arg should always be an array, even w/ only 1 item)

Where

type: ['recorder']
command: any function supported on that type of object
args: any array of arguments

Raises on unknown message

Returns whatever the recipient object returns



30
31
32
33
34
# File 'lib/scout_apm/remote/router.rb', line 30

def handle(msg)
  message = Remote::Message.decode(msg)
  assert_type(message)
  call_route(message)
end