Skip to content

refactor: simplify http emitter #310

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

Closed
wants to merge 1 commit into from

Conversation

grant
Copy link
Member

@grant grant commented Aug 11, 2020

Proposed Changes

  • Simplifies http emitter to reduce duplicated code. A larger part of making emitter simpler, such that you can simply emit() a CloudEvent.

Signed-off-by: Grant Timmerman <[email protected]>
@grant grant requested a review from lance August 11, 2020 03:33
@grant grant self-assigned this Aug 11, 2020
Copy link
Member

@lance lance left a comment

Choose a reason for hiding this comment

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

I don't think this is a good change to make. It changes the user facing API by moving exports into http/emitter, which will require changes to client code - therefore resulting in at least a minor version bump. A minor version bump is not in itself bad, but there does not appear to be any benefit to this. Nothing has changed other than binary_emitter.ts and structured_emitter.ts have been moved into one file, and you've inlined the emit() function.

I don't see any good reason for this to land.

@grant
Copy link
Member Author

grant commented Aug 11, 2020

Hi, I understand that there are changes to the filename that affect the API.
We used to have many index files that simply imported and exported. We have removed most of them, but this one is left. I agree, refactoring that by itself isn't very meaningful, but it's really part of a larger effort.

I created #314 to describe a bit of what I'm talking about.

I also added more detail to the PR description.


This change is required for eventually creating an easier to use emit function.

@lance
Copy link
Member

lance commented Aug 11, 2020

Simplifies http emitter to reduce duplicated code

This change is not reducing duplicated code.

you can simply emit() a CloudEvent.

You can already simply emit() a CloudEvent.

@grant
Copy link
Member Author

grant commented Aug 11, 2020

There is duplicated code in imports. The diff count is negative.
It has benefit as the interface is simpler and easier to refactor. There are fewer exports, which is a good thing.
It does not attempt to make the emitter static.

What would you like me to change in this PR?

@lance
Copy link
Member

lance commented Aug 11, 2020

What would you like me to change in this PR?

Nothing. I don't want it to land because it's a breaking change with no obvious benefit. If it's in preparation for an actual beneficial change, then submit that actual beneficial change with this included. I'm not opposed to breaking changes in the abstract, but in this case there really is no benefit at all to the end user and so I don't think it should land until there is one.

@grant
Copy link
Member Author

grant commented Aug 11, 2020

I'm purposefully creating small PRs that don't break tests. I can't create a larger PR for this. They would depend on this. (Believe me, I've tried.)

Do you disagree that removing duplicate code and duplicate exports is not a benefit?

@grant grant requested a review from lholmquist August 11, 2020 21:53
@lholmquist
Copy link
Contributor

lholmquist commented Aug 12, 2020

I'm purposefully creating small PRs that don't break tests. I can't create a larger PR for this. They would depend on this. (Believe me, I've tried.)

I'm curious why you can't create a large PR that takes care of all the refactoring you feel is necessary? I know you mentioned not wanting to break tests, but just fix the tests then in that same PR.

When we moved to typescript, that was a fairly large PR, and the tests broke and were re-written to use the new APIs

As for this PR, i get the idea of wanting to remove duplicate code, but this is making a breaking change for the end user, with no added benefit for the end user. It might simplify our life as a maintainer, but the end user is now having to change thier code and they don't know why. yes they had to change there code when updating to 3.x from 2.x, but 1, that was a major release, and 2, they could see the benefit and understood why they needed to change that code.

@grant
Copy link
Member Author

grant commented Aug 17, 2020

Hi folks,
Can you please review the code of this PR. Please request changes with specific requests.

Fundamentally we're replacing 2 exports with 1 export for the same HTTP emitter. We've already done this in other files in different PRs. Besides the not exporting twice, the PR is a refactor.

@lholmquist
Copy link
Contributor

Fundamentally we're replacing 2 exports with 1 export for the same HTTP emitter. We've already done this in other files in different PRs. Besides the not exporting twice, the PR is a refactor.

it is not as simple as that statement. Yes, you are combining 2 exports with 1, but you are also introducing a breaking change for the user, with not really any benefit to them as I mentioned in my previous comment.

Do you disagree that removing duplicate code and duplicate exports is not a benefit?

I also wanted to address this statement. This is not a yes or no answer. it depends on the circumstances. I would say generally yes, less code is good, but only when it doesn't break things for an end user. And in this case, as said before, it is breaking things, for a small cleanup

@grant
Copy link
Member Author

grant commented Aug 17, 2020

I'm not sure what you want me to do.
Yes, many PRs in this repo have been breaking changes.

@lholmquist
Copy link
Contributor

Yes, many PRs in this repo have been breaking changes.

And the PRs that have had breaking changes, have added value to the end user, like the big Typescript re-write.

I think to land this, we would have to wait until a 4.0 release.

@grant
Copy link
Member Author

grant commented Aug 17, 2020

4.0 is fine. How can I help land this in 4.0?

@lance
Copy link
Member

lance commented Aug 17, 2020

4.0 is fine. How can I help land this in 4.0?

I recommend closing this PR and making these changes as a part of another PR that adds tangible value to the user.

@grant
Copy link
Member Author

grant commented Aug 17, 2020

Will just close.

I really really think that small PRs are okay. Eventually whoever tackles #314 can just take this PR and make it a bigger PR.

When I tried to do that, I ran into issues modifying too many tests, so it may take time.

@grant grant closed this Aug 17, 2020
@grant grant deleted the grant_http_emitter branch August 17, 2020 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants