Class: NATS::Service::Request
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
Attributes inherited from Msg
#data, #header, #nc, #reply, #sub, #subject
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Request
constructor
A new instance of Request.
- #inspect ⇒ Object
- #respond_with_error(error) ⇒ Object
Methods inherited from Msg
Methods included from JetStream::Msg::AckMethods
#ack, #ack_sync, #in_progress, #metadata, #nak, #term
Constructor Details
#initialize(opts = {}) ⇒ Request
Returns a new instance of Request.
21 22 23 24 25 |
# File 'lib/nats/service/endpoint.rb', line 21 def initialize(opts = {}) super @endpoint = opts[:endpoint] @error = nil end |
Instance Attribute Details
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
19 20 21 |
# File 'lib/nats/service/endpoint.rb', line 19 def endpoint @endpoint end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
19 20 21 |
# File 'lib/nats/service/endpoint.rb', line 19 def error @error end |
Class Method Details
.from_msg(svc, msg) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/nats/service/endpoint.rb', line 50 def from_msg(svc, msg) request = Request.new(endpoint: svc) request.subject = msg.subject request.reply = msg.reply request.data = msg.data request.header = msg.header request.nc = msg.nc request.sub = msg.sub request end |
Instance Method Details
#inspect ⇒ Object
43 44 45 46 47 |
# File 'lib/nats/service/endpoint.rb', line 43 def inspect dot = "..." if @data.length > 10 dat = "#{data.slice(0, 10)}#{dot}" "#<Service::Request(subject: \"#{@subject}\", reply: \"#{@reply}\", data: #{dat.inspect})>" end |
#respond_with_error(error) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/nats/service/endpoint.rb', line 27 def respond_with_error(error) @error = NATS::Service::ErrorWrapper.new(error) = dup .subject = reply .reply = "" .data = @error.data .header = { "Nats-Service-Error" => @error., "Nats-Service-Error-Code" => @error.code } respond_msg() end |