Skip to content

Conversation

@stuppy
Copy link
Contributor

@stuppy stuppy commented Sep 6, 2022

module Converter
module Payload
class ProtoJSON
class InvalidPayload < RuntimeError; end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look like this is used anywhere. Should we add error handling as mentioned in the TODO? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d'oh ya was going to add handling, but then noticed the JSON deserializer didn't have anything explicit so didn't follow up. removed the error class.

end

def to_payload(data)
return unless data&.is_a?(Google::Protobuf::MessageExts)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: no need for &. since is_a? is defined on a NilClass as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 done

@@ -0,0 +1,22 @@
require 'temporal/connection/converter/payload/json'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a wrong require, you need proto_json

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d'oh Done

it 'converts' do
input = Temporal::Api::Common::V1::Payload.new(
metadata: { 'hello' => 'world' },
data: 'hello world',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This data type won't get picked by the target converter, right? It's not a subclass of Google::Protobuf::MessageExts

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added comment. using Temporal::Api::Common::V1::Payload as the input given it's an available proto message. to_payload wraps it, so the result data is the json'd input w/ the metadata

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see, makes sense. It might be a bit clearer if you were to pick a proto that has nothing to do with payloads. But the comment solves this issue

Copy link
Contributor Author

@stuppy stuppy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

module Converter
module Payload
class ProtoJSON
class InvalidPayload < RuntimeError; end
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d'oh ya was going to add handling, but then noticed the JSON deserializer didn't have anything explicit so didn't follow up. removed the error class.

end

def to_payload(data)
return unless data&.is_a?(Google::Protobuf::MessageExts)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 done

@@ -0,0 +1,22 @@
require 'temporal/connection/converter/payload/json'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d'oh Done

it 'converts' do
input = Temporal::Api::Common::V1::Payload.new(
metadata: { 'hello' => 'world' },
data: 'hello world',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added comment. using Temporal::Api::Common::V1::Payload as the input given it's an available proto message. to_payload wraps it, so the result data is the json'd input w/ the metadata

@stuppy stuppy requested a review from antstorm September 12, 2022 19:50
Copy link
Contributor

@antstorm antstorm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you for the PR

it 'converts' do
input = Temporal::Api::Common::V1::Payload.new(
metadata: { 'hello' => 'world' },
data: 'hello world',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see, makes sense. It might be a bit clearer if you were to pick a proto that has nothing to do with payloads. But the comment solves this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants