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: Allow simultaneous services and generic service definitions #512

Merged
merged 19 commits into from
Mar 4, 2022

Conversation

fizx
Copy link
Collaborator

@fizx fizx commented Feb 16, 2022

Hi, we have this as a use case at my company because we use the basic service interfaces yet need runtime reflection, and have been running for a while.

This patch is backwards compatible and covered by an integration test.

I'm hoping to upstream. Please let me know how I can make it easier to accept the patch!

src/main.ts Outdated
: isRepeated(field)
? '[]'
: defaultValue(ctx, field);
? '{}'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

prettier did this, not sure if you want to pick it up cause it does make sense.

Copy link
Owner

Choose a reason for hiding this comment

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

Ah yeah, not sure, but if prettier did it then yeah let's leave it in.

@fizx fizx changed the title Allow simultaneous services and generic service definitions feat: Allow simultaneous services and generic service definitions Feb 16, 2022
Copy link
Owner

@stephenh stephenh left a comment

Choose a reason for hiding this comment

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

Nice, using about using an array of options, but otherwise looks great, and thanks for the PR

src/main.ts Outdated
: isRepeated(field)
? '[]'
: defaultValue(ctx, field);
? '{}'
Copy link
Owner

Choose a reason for hiding this comment

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

Ah yeah, not sure, but if prettier did it then yeah let's leave it in.

src/options.ts Outdated
@@ -25,6 +25,7 @@ export enum ServiceOption {
GRPC = 'grpc-js',
GENERIC = 'generic-definitions',
DEFAULT = 'default',
GENERIC_AND_SERVICES = 'generic-definitions-and-services',
Copy link
Owner

Choose a reason for hiding this comment

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

Hm, kinda think, let's maybe not add a new definition and instead change options.outServices to ServiceOption[]?

I was thinking like outputServices=generic,default, but , is already taken as a separator.

We could list options twice, like outputServices=generic-definitions,outputServices=default... I just made a fix to snakeToCamel that provides a precedent for how to support this "nudged to an array" pattern for options:

#513

Does that seem okay?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Great!

@fizx
Copy link
Collaborator Author

fizx commented Feb 18, 2022

Still working on the PR right now ...

@fizx fizx requested a review from stephenh February 27, 2022 20:06
@fizx
Copy link
Collaborator Author

fizx commented Feb 27, 2022

I implemented your suggestion @stephenh! Tests pass locally, but I don't have permission to run on github.

Note that this PR includes #516 so that I can test locally. We should probably squash and merge them independently.

@fizx fizx marked this pull request as draft February 27, 2022 22:54
@fizx
Copy link
Collaborator Author

fizx commented Feb 27, 2022

Question about anticipated behavior when someone does a conflicting option with serviceOption=false,serviceOption=default. I'm leaving it as undefined, but open to alternatives.

@fizx fizx marked this pull request as ready for review February 27, 2022 23:40
src/options.ts Outdated Show resolved Hide resolved
Copy link
Owner

@stephenh stephenh left a comment

Choose a reason for hiding this comment

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

Looks great @fizx , thanks!

@stephenh stephenh merged commit 680831e into stephenh:main Mar 4, 2022
stephenh pushed a commit that referenced this pull request Mar 4, 2022
# [1.107.0](v1.106.2...v1.107.0) (2022-03-04)

### Features

* Allow simultaneous services and generic service definitions ([#512](#512)) ([680831e](680831e))
@stephenh
Copy link
Owner

stephenh commented Mar 4, 2022

🎉 This PR is included in version 1.107.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

2 participants