Class: Gruf::Outbound::RequestContext

Inherits:
Object
  • Object
show all
Defined in:
lib/gruf/outbound/request_context.rb

Overview

Encapsulates the context of an outbound client request

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, requests:, call:, method:, metadata:) ⇒ RequestContext

Initialize the new request context

Parameters:

  • type (Symbol)

    The type of request

  • requests (Enumerable)

    An enumerable of requests being sent

  • call (GRPC::ActiveCall)

    The GRPC ActiveCall object

  • method (Method)

    The method being called

  • metadata (Hash)

    A hash of outgoing metadata



44
45
46
47
48
49
50
# File 'lib/gruf/outbound/request_context.rb', line 44

def initialize(type:, requests:, call:, method:, metadata:)
  @type = type
  @requests = requests
  @call = call
  @method = method
  @metadata = 
end

Instance Attribute Details

#callObject (readonly)

Returns the value of attribute call.



29
30
31
# File 'lib/gruf/outbound/request_context.rb', line 29

def call
  @call
end

#metadataObject (readonly)

Returns the value of attribute metadata.



33
34
35
# File 'lib/gruf/outbound/request_context.rb', line 33

def 
  @metadata
end

#methodObject (readonly)

Returns the value of attribute method.



31
32
33
# File 'lib/gruf/outbound/request_context.rb', line 31

def method
  @method
end

#requestsObject (readonly)

Returns the value of attribute requests.



27
28
29
# File 'lib/gruf/outbound/request_context.rb', line 27

def requests
  @requests
end

#typeObject (readonly)

Returns the value of attribute type.



25
26
27
# File 'lib/gruf/outbound/request_context.rb', line 25

def type
  @type
end

Instance Method Details

#method_nameString

Return the name of the method being called, e.g. GetThing

Returns:

  • (String)


57
58
59
# File 'lib/gruf/outbound/request_context.rb', line 57

def method_name
  @method.to_s.split('/').last
end

#route_keyString

Return the proper routing key for the request

Returns:

  • (String)


66
67
68
# File 'lib/gruf/outbound/request_context.rb', line 66

def route_key
  @method[1..].underscore.tr('/', '.')
end