Class: AgentClientProtocol::Decoder
- Inherits:
-
Object
- Object
- AgentClientProtocol::Decoder
- Defined in:
- lib/agent_client_protocol/decoder.rb
Defined Under Namespace
Classes: DecodedPayload
Constant Summary collapse
- VALID_SIDES =
%i[agent client protocol].freeze
Instance Attribute Summary collapse
-
#side ⇒ Object
readonly
Returns the value of attribute side.
-
#unstable ⇒ Object
readonly
Returns the value of attribute unstable.
-
#validate_schema ⇒ Object
readonly
Returns the value of attribute validate_schema.
Instance Method Summary collapse
- #decode_notification(method:, params:) ⇒ Object
- #decode_request(method:, params:) ⇒ Object
- #decode_response(method:, result:) ⇒ Object
-
#initialize(side:, unstable: false, validate_schema: true) ⇒ Decoder
constructor
A new instance of Decoder.
Constructor Details
#initialize(side:, unstable: false, validate_schema: true) ⇒ Decoder
Returns a new instance of Decoder.
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/agent_client_protocol/decoder.rb', line 42 def initialize(side:, unstable: false, validate_schema: true) normalized_side = side.to_sym unless VALID_SIDES.include?(normalized_side) raise ArgumentError, "side must be one of: #{VALID_SIDES.join(', ')}" end @side = normalized_side @unstable = unstable @validate_schema = validate_schema @catalog = SchemaRegistry.method_catalog(unstable: unstable).fetch(normalized_side, {}) end |
Instance Attribute Details
#side ⇒ Object (readonly)
Returns the value of attribute side.
40 41 42 |
# File 'lib/agent_client_protocol/decoder.rb', line 40 def side @side end |
#unstable ⇒ Object (readonly)
Returns the value of attribute unstable.
40 41 42 |
# File 'lib/agent_client_protocol/decoder.rb', line 40 def unstable @unstable end |
#validate_schema ⇒ Object (readonly)
Returns the value of attribute validate_schema.
40 41 42 |
# File 'lib/agent_client_protocol/decoder.rb', line 40 def validate_schema @validate_schema end |
Instance Method Details
#decode_notification(method:, params:) ⇒ Object
58 59 60 |
# File 'lib/agent_client_protocol/decoder.rb', line 58 def decode_notification(method:, params:) decode(kind: :notification, method: method, payload: params, require_payload: true) end |
#decode_request(method:, params:) ⇒ Object
54 55 56 |
# File 'lib/agent_client_protocol/decoder.rb', line 54 def decode_request(method:, params:) decode(kind: :request, method: method, payload: params, require_payload: true) end |
#decode_response(method:, result:) ⇒ Object
62 63 64 |
# File 'lib/agent_client_protocol/decoder.rb', line 62 def decode_response(method:, result:) decode(kind: :response, method: method, payload: result, require_payload: false) end |