Class: Yrpc::Outbound::RequestContext

Inherits:
Object
  • Object
show all
Defined in:
lib/yrpc/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



42
43
44
45
46
47
48
# File 'lib/yrpc/outbound/request_context.rb', line 42

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.



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

def call
  @call
end

#metadataObject

Returns the value of attribute metadata.



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

def 
  @metadata
end

#methodObject (readonly)

Returns the value of attribute method.



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

def method
  @method
end

#requestsObject (readonly)

Returns the value of attribute requests.



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

def requests
  @requests
end

#typeObject (readonly)

Returns the value of attribute type.



23
24
25
# File 'lib/yrpc/outbound/request_context.rb', line 23

def type
  @type
end

Instance Method Details

#method_nameString

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

Returns:

  • (String)


55
56
57
# File 'lib/yrpc/outbound/request_context.rb', line 55

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

#route_keyString

Return the proper routing key for the request

Returns:

  • (String)


64
65
66
# File 'lib/yrpc/outbound/request_context.rb', line 64

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