Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add googlepubsub bindings #141

Merged
merged 3 commits into from
Sep 27, 2022
Merged

Conversation

whitlockjc
Copy link
Collaborator

@whitlockjc whitlockjc commented Aug 1, 2022

This commit contains two bindings, a Channel Binding Object and a Message Binding Object for Google Cloud Pub/Sub using the googlepubsub protocol name.

Related issue(s)
JSON Schema PR: asyncapi/spec-json-schemas#253
Spec PR: asyncapi/spec#836

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@whitlockjc whitlockjc changed the title feat: Add googlepubsub bindings feat: add googlepubsub bindings Aug 1, 2022
Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

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

@whitlockjc I added few comments. Also general comment is that I'm missing examples in the markdown files, we should have them there too

Side note, to have it in the spec we will also need to add googlepubsub key to the spec in the list of bindings, but this is later, I can guide you and send some examples.

@fmvilas new binding on the way, please review

googlepubsub/README.md Outdated Show resolved Hide resolved
googlepubsub/json_schemas/channel.json Show resolved Hide resolved
googlepubsub/json_schemas/message.json Show resolved Hide resolved

<a name="schema-definition-object"></a>

### Schema Definition Object
Copy link
Member

Choose a reason for hiding this comment

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

This is quite a workaround 😄
Shouldn't we try to fix it on a spec level rather than add such workaround gates on a binding level?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well, it's really not. The whole purpose behind this is to describe the schema Cloud Pub/Sub uses to validate messages. While AsyncAPI does have support for this already in the messages themselves, there is metadata on the schema object from a Cloud Pub/Sub perspective that is still useful for documenting the API. Below is an example of how AsyncAPI's support for Avro and how its lack of Protobuf support would be documented:

# ...
components:
    messages:
        messageAvroAsJSON:
            bindings:
                googlepubsub:
                    schema:
                        definition: |
                            {
                              "type" : "record",
                              "name" : "Message",
                              "fields" : [
                                {
                                  "name" : "message",
                                  "type" : "string"
                                }
                              ]
                            }
                        name: projects/jaydub-testing/schemas/message-avro
                        type: avro
            contentType: application/json
            name: projects/jaydub-testing/schemas/message-avro
            payload:
                fields:
                    - name: message
                      type: string
                name: Message
                type: record
            schemaFormat: application/vnd.apache.avro+yaml;version=1.9.0
        messageProto:
            bindings:
                googlepubsub:
                    schema:
                        definition: |
                            syntax = "proto2";

                            message Message {
                              required string message = 1;
                            }
                        name: projects/jaydub-testing/schemas/message-proto
                        type: protobuf
            contentType: application/octet-stream
            name: projects/jaydub-testing/schemas/message-proto
            payload: true
# ...

name is metadata that could/should be present, but I could see a case where if Protobuf were supported by AsyncAPI natively for Message payloads, maybe it wouldn't need to be present in the binding. Thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree with @derberg: I think we absolutely have to avoid duplicating things in bindings when they should be defined in the message itself. Protobuf support should ideally follow the same approach as for Avro: having a dedicated schemaFormat entry for it. However due to proto syntax, we'll probably not be able to embed it in the AsyncAPI spec itself and use a $ref to external file.

The value you put in name (that should be human-readable according the spec) seems similar to the one put into schemaSettings.name at the Channel level. Is it just a duplication? Does it serve a specific purpose to have it structured like the schema name in your GCP project?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When it comes to embedding versus using a $ref, to me it's six in one hand and half another in the other. Ultimately, we want the API consumer to know as much as they can about the API contract and having a visual representation of unsupported schema types could serve some purpose. As for duplication, I'm all for removing it but if it means inconsistency (duplication is removed for use case X but not use case Y), I personally would rather allow duplication and have consistency. Finally, for name, its structured is by design and a GCP concept.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, agree that's really a workaround. Let's wait until we have Protobuf support at the spec level using schemaFormat.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What do we do if/when GCP supports a new schema format? Do we disallow any sort of representation within the binding in hopes that AsyncAPI supports it? What do you think about making this optional instead of unnecessary?

Copy link
Collaborator

@lbroudoux lbroudoux Aug 26, 2022

Choose a reason for hiding this comment

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

Regarding name: I missed the point that I referred to schemaSettings.name and that it was a different thing than the topic name...

That said I realize that topic technical name was directly in the channel path. However this one should be human-readable, independent of binding (in case of multi-bindings supports) and may also contain parameters!

In other bindings, we decided to add a specific property within the channel binding in order to add the technical name of the destination (look at amqp where we have queue.name or exchange.name ; we also have similar things in ibmmq). I think we should do the same here so that all the technical things related to a binding are kept into this binding.

We'd ended up with something like:

channels:
  my-channel-name-with-business-meaning:
    bindings:
      googlepubsub:
        topic: projects/your-project/topics/topic-avro-schema
        schemaSettings:
          encoding: avro
          name: projects/your-project/schemas/message-avro

Copy link
Member

Choose a reason for hiding this comment

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

What do we do if/when GCP supports a new schema format? Do we disallow any sort of representation within the binding in hopes that AsyncAPI supports it?

@whitlockjc that sounds like a perfect use case for an extension.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can go either way, but ultimately I need your agreement to get this submitted so I don't feel I've got much choice here. Requiring AsyncAPI to support a schema format formally versus allowing a binding to store potentially duplicate information might not be my first choice, the whole point of x-* is to fill the gaps so I don't care enough to push back.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I updated the binding to add topic and to remove definition from schemaSettings per the discussion above.

@whitlockjc
Copy link
Collaborator Author

Feedback responded to, PR updated based on resolved feedback.

@whitlockjc whitlockjc force-pushed the master branch 2 times, most recently from ec7d81c to a7c013c Compare August 18, 2022 16:26
@whitlockjc
Copy link
Collaborator Author

I added examples to the Markdown file, and added x-* support to the JSON Schemas.

Copy link
Collaborator

@lbroudoux lbroudoux left a comment

Choose a reason for hiding this comment

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

Thanks for this PR! I made a few comments on version and Protobuf support.


<a name="schema-definition-object"></a>

### Schema Definition Object
Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree with @derberg: I think we absolutely have to avoid duplicating things in bindings when they should be defined in the message itself. Protobuf support should ideally follow the same approach as for Avro: having a dedicated schemaFormat entry for it. However due to proto syntax, we'll probably not be able to embed it in the AsyncAPI spec itself and use a $ref to external file.

The value you put in name (that should be human-readable according the spec) seems similar to the one put into schemaSettings.name at the Channel level. Is it just a duplication? Does it serve a specific purpose to have it structured like the schema name in your GCP project?


<a name="schema-definition-object"></a>

### Schema Definition Object
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, agree that's really a workaround. Let's wait until we have Protobuf support at the spec level using schemaFormat.

googlepubsub/README.md Show resolved Hide resolved
googlepubsub/README.md Show resolved Hide resolved
googlepubsub/README.md Outdated Show resolved Hide resolved
googlepubsub/README.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@lbroudoux lbroudoux left a comment

Choose a reason for hiding this comment

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

Thanks for the update on PR!

I added a suggestion on moving topic name to specific channel binding property. I also had a more in-depth review and spotted some ids and refs that need to be updated in schemas.


<a name="schema-definition-object"></a>

### Schema Definition Object
Copy link
Collaborator

@lbroudoux lbroudoux Aug 26, 2022

Choose a reason for hiding this comment

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

Regarding name: I missed the point that I referred to schemaSettings.name and that it was a different thing than the topic name...

That said I realize that topic technical name was directly in the channel path. However this one should be human-readable, independent of binding (in case of multi-bindings supports) and may also contain parameters!

In other bindings, we decided to add a specific property within the channel binding in order to add the technical name of the destination (look at amqp where we have queue.name or exchange.name ; we also have similar things in ibmmq). I think we should do the same here so that all the technical things related to a binding are kept into this binding.

We'd ended up with something like:

channels:
  my-channel-name-with-business-meaning:
    bindings:
      googlepubsub:
        topic: projects/your-project/topics/topic-avro-schema
        schemaSettings:
          encoding: avro
          name: projects/your-project/schemas/message-avro

googlepubsub/json_schemas/channel.json Outdated Show resolved Hide resolved
googlepubsub/json_schemas/message.json Outdated Show resolved Hide resolved
googlepubsub/json_schemas/channel.json Outdated Show resolved Hide resolved
googlepubsub/json_schemas/message.json Outdated Show resolved Hide resolved
Copy link
Collaborator

@lbroudoux lbroudoux left a comment

Choose a reason for hiding this comment

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

Requested a few minor changes for updating $id and others + suggest adding a topic name

@whitlockjc
Copy link
Collaborator Author

All feedback has been addressed, please check if there are any places where I messed up the changes or if I missed anything.

@whitlockjc
Copy link
Collaborator Author

whitlockjc commented Aug 31, 2022

I crossed the streams and was using avro and protobuf as valid values for encoding in the SchemaSettings Object when valid values are binary, json and unknown (although we allow any value in there via JSON Schema right now by design to avoid having the currently-supported values hard-coded in for no real benefit). Documentation and examples updated to reflect.

Copy link
Collaborator

@lbroudoux lbroudoux left a comment

Choose a reason for hiding this comment

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

Thanks for the update! This looks good to me. I just add a minor change request on message.name in examples - avoiding Google specific values that should now only live into bindings.googlepubsub.schema.name.

googlepubsub/README.md Outdated Show resolved Hide resolved
googlepubsub/README.md Outdated Show resolved Hide resolved
This commit contains two bindings, a `Channel Binding Object` and a
`Message Binding Object` for Google Cloud Pub/Sub using the
`googlepubsub` protocol name.
Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

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

I think it looks good now 👍🏼

sorry @whitlockjc on the pushback with schema stuff, but AsyncAPI is a mature project with a well-defined contribution guide and a stable release schedule. So I definitely encourage you to help us push forward proto support in the core spec.

once others approve and we merge, I'll explain what you need to do in the main spec to enable this binding. Unless you already know?

Copy link
Member

@fmvilas fmvilas left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@fmvilas
Copy link
Member

fmvilas commented Sep 6, 2022

@char0n this PR can probably be included in 2.5.0. Pinging you so have it on your radar.

@char0n
Copy link
Collaborator

char0n commented Sep 6, 2022

@fmvilas yep, I'm already watching this. Thanks.

@char0n char0n mentioned this pull request Sep 6, 2022
61 tasks
@lbroudoux
Copy link
Collaborator

LGTM 👍 Thanks @whitlockjc for the successive updates.

@whitlockjc
Copy link
Collaborator Author

whitlockjc commented Sep 6, 2022

I think it looks good now 👍🏼

sorry @whitlockjc on the pushback with schema stuff, but AsyncAPI is a mature project with a well-defined contribution guide and a stable release schedule. So I definitely encourage you to help us push forward proto support in the core spec.

once others approve and we merge, I'll explain what you need to do in the main spec to enable this binding. Unless you already know?

No need to explain, I completely understand...although to my defense, I'm not sure where advocating for more documentation (isolated to the binding itself mind you) with the potential for duplication when AsyncAPI doesn't support a native schema format would jeopardize or question AsyncAPI being a "mature project with a well-defined contribution guide and a stable release schedule." I think proto support would be awesome, something I'd love to help with. As for the next step, I think I understand so I will get this sorted when the time comes.

@derberg
Copy link
Member

derberg commented Sep 6, 2022

@whitlockjc hehe, no worries. I mean mature in the way that it is easy to improve, all is transparent, and if you drive things, you do not have to wait 2 years for the release or anything like that 😄

In the case of features, yeah 🤷🏼 we have what the community wants, and believe me or not, proto is not something people talk about all the time 😄 But I definitely agree that support for proto and other formats, like xsd would be huge for AsyncAPI

@whitlockjc
Copy link
Collaborator Author

We're on the same page, thank you so much for your help in getting this all sorted. I'm looking forward to working with AsyncAPI more in the future. ❤️

@derberg
Copy link
Member

derberg commented Sep 6, 2022

ok then, looks like we can merge this one.

but as I wrote, merging doesn't mean it is released as part of the spec.

@whitlockjc if you want it in the September window, released with 2.5.0 then:

@char0n is the release coordinator for the September release. So sync with him in asyncapi/spec#830 as he just started and needs to prepare release branches. So definitely do not open PRs before he is done preparing them 😉

all good?

@char0n
Copy link
Collaborator

char0n commented Sep 6, 2022

@derberg, given asyncapi/spec#734, there's no need for ad-hoc release branches anymore. next-spec and next-major-spec are permanent release branches in my understanding.

@derberg
Copy link
Member

derberg commented Sep 6, 2022

oh, @char0n I had no idea that @smoya already created 2.5.0 copy there https://github.com/asyncapi/spec-json-schemas/tree/next-spec/definitions/2.5.0. Normally you would have to make sure it happens 😄

I still recommend updating these release branches with latest master as last time it was done in June

@char0n
Copy link
Collaborator

char0n commented Sep 6, 2022

I still recommend updating these release branches with latest master as last time it was done in June

Yep, it's on my radar as next task.

@whitlockjc
Copy link
Collaborator Author

I'll get on these other tasks tonight/tomorrow.

whitlockjc added a commit to whitlockjc/spec-json-schemas that referenced this pull request Sep 19, 2022
whitlockjc added a commit to whitlockjc/asyncapi-spec that referenced this pull request Sep 19, 2022
Adds support for Google Cloud Pub/Sub to the `Channel Binding Object`
and `Message Binding Object` lists.

See: asyncapi/bindings#141
@whitlockjc
Copy link
Collaborator Author

All necessary PRs have been created, all referencing the others.

whitlockjc added a commit to whitlockjc/asyncapi-spec that referenced this pull request Sep 21, 2022
Adds support for Google Cloud Pub/Sub bindings.

See: asyncapi/bindings#141
whitlockjc added a commit to whitlockjc/asyncapi-spec that referenced this pull request Sep 21, 2022
Adds support for Google Cloud Pub/Sub bindings.

See: asyncapi/bindings#141
@char0n
Copy link
Collaborator

char0n commented Sep 27, 2022

In order to merge this, we still require code review of one additional code owner. @KhudaDad414 can you please look into this PR? Thanks!

@derberg
Copy link
Member

derberg commented Sep 27, 2022

@whitlockjc I invited you to this repo as maintainer. From now on, you are a CODEOWNER for googlepubsub binding. As a maintainer in one of AsyncAPI projects you also have right to join the AsyncAPI TSC and participate in decision making process for the entire initiative. Just lemme know if you are interested to learn more.

Copy link
Member

@KhudaDad414 KhudaDad414 left a comment

Choose a reason for hiding this comment

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

LGTM!

@char0n
Copy link
Collaborator

char0n commented Sep 27, 2022

Good to go. Merging.

@char0n
Copy link
Collaborator

char0n commented Sep 27, 2022

/rtm

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

Successfully merging this pull request may close these issues.

7 participants