Class: A2A::Operation::SendStreamingMessage
- Inherits:
-
Object
- Object
- A2A::Operation::SendStreamingMessage
- Includes:
- Executable
- Defined in:
- lib/a2a/operation/send_streaming_message.rb
Constant Summary collapse
- METHOD =
"SendStreamingMessage"- Configuration =
SendMessage::Configuration
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#tenant ⇒ Object
readonly
Returns the value of attribute tenant.
Instance Method Summary collapse
- #execute_http_json(protocol, &block) ⇒ Object
- #execute_json_rpc(protocol, &block) ⇒ Object
-
#initialize(message, configuration: {}, metadata: nil, tenant: nil) ⇒ SendStreamingMessage
constructor
A new instance of SendStreamingMessage.
- #params ⇒ Object
Methods included from Executable
Constructor Details
#initialize(message, configuration: {}, metadata: nil, tenant: nil) ⇒ SendStreamingMessage
Returns a new instance of SendStreamingMessage.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/a2a/operation/send_streaming_message.rb', line 14 def initialize(, configuration: {}, metadata: nil, tenant: nil) @message = .is_a?(Message) ? : Message.from_h() @configuration = if configuration.is_a?(Configuration) configuration else Configuration.new(**configuration.transform_keys(&:to_sym)) end @metadata = @tenant = tenant end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
12 13 14 |
# File 'lib/a2a/operation/send_streaming_message.rb', line 12 def configuration @configuration end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
12 13 14 |
# File 'lib/a2a/operation/send_streaming_message.rb', line 12 def @message end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
12 13 14 |
# File 'lib/a2a/operation/send_streaming_message.rb', line 12 def @metadata end |
#tenant ⇒ Object (readonly)
Returns the value of attribute tenant.
12 13 14 |
# File 'lib/a2a/operation/send_streaming_message.rb', line 12 def tenant @tenant end |
Instance Method Details
#execute_http_json(protocol, &block) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/a2a/operation/send_streaming_message.rb', line 34 def execute_http_json(protocol, &block) protocol.stream("/message:stream", method: :post, body: params) do |response| sub = Streaming::Subscription.new(response) return sub unless block sub.each(&block) end end |
#execute_json_rpc(protocol, &block) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/a2a/operation/send_streaming_message.rb', line 25 def execute_json_rpc(protocol, &block) protocol.stream(METHOD, params) do |response| sub = Streaming::Subscription.new(response) return sub unless block sub.each(&block) end end |
#params ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/a2a/operation/send_streaming_message.rb', line 43 def params p = { "message" => .to_h } config_h = configuration.to_h p["configuration"] = config_h unless config_h.empty? p["metadata"] = if p["tenant"] = tenant if tenant p end |