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



49
50
51
52
53
54
55
# File 'lib/gruf/outbound/request_context.rb', line 49

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.



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

def call
  @call
end

#metadataObject (readonly)

Returns the value of attribute metadata.



38
39
40
# File 'lib/gruf/outbound/request_context.rb', line 38

def 
  @metadata
end

#methodObject (readonly)

Returns the value of attribute method.



35
36
37
# File 'lib/gruf/outbound/request_context.rb', line 35

def method
  @method
end

#requestsObject (readonly)

Returns the value of attribute requests.



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

def requests
  @requests
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#method_nameString

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

Returns:

  • (String)


62
63
64
# File 'lib/gruf/outbound/request_context.rb', line 62

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

#route_keyString

Return the proper routing key for the request

Returns:

  • (String)


71
72
73
# File 'lib/gruf/outbound/request_context.rb', line 71

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