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

[Experimental] Add Subscription Support for the Tanzu Hub Client #195

Merged

Conversation

anujc25
Copy link
Contributor

@anujc25 anujc25 commented Jun 25, 2024

What this PR does / why we need it

Note: This PR is on top of #191

  • Remove dependency on the github.com/Khan/genqlient/graphql client.
  • Implement Interface for HubClient
  • Add Request and Subscribe methods natively
  • Add Subscription support for the testing framework
  • Includes a sample unit test for the subscription support.

Which issue(s) this PR fixes

Fixes #

Describe testing done for PR

  • Added Unit test
  • Manual testing

Release note

[Experimental] Add Subscription Support for the Tanzu Hub Client

Additional information

Special notes for your reviewer

@anujc25 anujc25 force-pushed the add-subscription-support-and-refactor branch 2 times, most recently from 8648cea to c4596c9 Compare June 25, 2024 21:57
@anujc25 anujc25 marked this pull request as ready for review June 26, 2024 21:02
@anujc25 anujc25 requested a review from a team as a code owner June 26, 2024 21:02
@anujc25 anujc25 force-pushed the add-subscription-support-and-refactor branch from c4596c9 to b808850 Compare June 28, 2024 16:10
anujc25 added 2 commits June 28, 2024 11:32
- Refactor the code
- Remove dependency on github.com/Khan/genqlient/graphql client.
- Implement Interface for HubClient
- Add Request and Subscribe methods natively
@anujc25 anujc25 force-pushed the add-subscription-support-and-refactor branch from b808850 to bfacea1 Compare June 28, 2024 18:32
Copy link
Contributor

@vuil vuil left a comment

Choose a reason for hiding this comment

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

This is a nice set of functionality to add to the hub client!
Still looking at the changes, but left some comments of mostly minor things I noticed so far.

@@ -40,3 +39,77 @@ To use this library plugin authors can follow the below steps:
4. Once the initialization is done, you can add your GraphQL queries to the `queries.graphql` file
5. After adding new graphQL queries or updating an existing query, run `make tanzu-hub-stub-generate` to generate a golang stub for the GraphQL queries
* This will create a `generate.go` file under the `hub` package with golang APIs that can be consumed directly by other packages by passing the GraphQLClient available with TanzuHub client

Copy link
Contributor

Choose a reason for hiding this comment

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

Couple of preexisting things I noticed while testing this change:

3 lines up on "main.go": I recall making a comment about not using main.go since it is confusing. Did we run into some issue and decided to stick with it?

nit The tanzuhub.mk's tanzu-hub-stub-init target should be commented with ## instead of # so it shows up in make help

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since the new client does not require developers to use the github.com/Khan/genqlient/graphql library to generate type definitions, I plan to minimize the documentation's specifications.

I intend to simply mention that users can utilize the github.com/Khan/genqlient/graphql library to generate the GoLang stub for type definitions if needed, without providing detailed instructions on its usage. It's likely that most consumers won't need to use this library to generate stubs, as they can define their own type definitions for simple queries. Thoughts?

client/hub/README.md Show resolved Hide resolved
client/hub/client.go Outdated Show resolved Hide resolved
client/hub/client_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@marckhouzam marckhouzam left a comment

Choose a reason for hiding this comment

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

This is really great!
I haven't been able to finish completely and I will continue a little later, but here are some comments to start

client/hub/client.go Show resolved Hide resolved
client/hub/client.go Outdated Show resolved Hide resolved
client/hub/client.go Outdated Show resolved Hide resolved
client/hub/client.go Show resolved Hide resolved
client/hub/client.go Outdated Show resolved Hide resolved
client/hub/testing/operations.go Show resolved Hide resolved
client/hub/testing/server.go Outdated Show resolved Hide resolved
client/hub/testing/operations.go Show resolved Hide resolved
client/hub/testing/operations.go Outdated Show resolved Hide resolved
Copy link
Contributor

@marckhouzam marckhouzam left a comment

Choose a reason for hiding this comment

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

Small nits but besides that LGTM
Nice job!

client/hub/types.go Outdated Show resolved Hide resolved
client/hub/request.go Outdated Show resolved Hide resolved
client/hub/request.go Outdated Show resolved Hide resolved
@marckhouzam marckhouzam added this to the v1.4.0 milestone Jul 10, 2024
Copy link
Contributor

@marckhouzam marckhouzam left a comment

Choose a reason for hiding this comment

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

LGTM
thanks a lot for this!

@anujc25 anujc25 merged commit 88242b5 into vmware-tanzu:main Jul 10, 2024
4 checks passed
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.

4 participants