Skip to content

Version parsers - #274

Merged
grant merged 3 commits into
cloudevents:masterfrom
grant:grant_version_parsers
Jul 27, 2020
Merged

grant merged 3 commits into
cloudevents:masterfrom
grant:grant_version_parsers

Conversation

@grant

@grant grant commented Jul 24, 2020 •

Copy link
Copy Markdown
Member

Proposed Changes

  • Simplify parsers
  • Remove duplicate code
  • Reduces file count/complexity over versioning

Description

@grant grant self-assigned this Jul 24, 2020
@grant
grant requested a review from lance July 24, 2020 21:53
@grant grant changed the title Grant version parsers Version parsers Jul 24, 2020

@lance lance left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks OK, but I'm trying to understand the benefit and where you have actually removed duplicate code. I see these three lines being consolidated by combining the two version files:

function parser(name: string, parser = new PassThroughParser()): MappedParser {
  return { name: name, parser: parser };
}

But I think that could addressed by moving that code into https://github.com/cloudevents/sdk-javascript/blob/master/src/parsers.ts and having both versions import it. They already have a dependency on the parsers file anyway. Personally, I prefer to have code for each version in a distinct file. Not sure how others feel about this.

@helio-frota

helio-frota commented Jul 27, 2020 •

Copy link
Copy Markdown
Member

@grant I'm not sure but my view on that is you are trying to "consolidate versions for the future" that approach is good so 👍 to that. So for what I understood when a new v.x spec come out, the project has the structure to add the things without much effort or something (?) also centralizing things in versions.ts ?

In other hand @lance's comment makes sense. So my question is your PR wording not accurate meaning or something ?

anyway I'm trying to get the point

@helio-frota

Copy link
Copy Markdown
Member

I prefer to have code for each version in a distinct file. Not sure how others feel about this.

@lance I have no idea how many times and how often new versions will be created/added. The approach looks good to me but not sure about the benefit related with the occurrence of the future changes/additions in versions.

👍

@grant

grant commented Jul 27, 2020

Copy link
Copy Markdown
Member Author

The PassThroughParser is not stateful and can be reused. It really should be static like I believe most every other function in this library.

Is there something you'd like me to change?

@lholmquist

Copy link
Copy Markdown
Contributor

I don't have any strong feelings on keeping things separate. ATM, since there are only 2 versions, it probably doesn't matter combining them.

@lance

lance commented Jul 27, 2020

Copy link
Copy Markdown
Member

Is there something you'd like me to change?

Not necessarily - was just trying to have some conversation around these questions.

@grant

grant commented Jul 27, 2020

Copy link
Copy Markdown
Member Author

To be clear, I saw a lot of improvements beyond this, but I'd never finish a concrete PR if I went chasing them.

@grant
grant merged commit 3d82fb6 into cloudevents:master Jul 27, 2020
@grant
grant deleted the grant_version_parsers branch July 27, 2020 17:25
@lance lance mentioned this pull request Jul 27, 2020
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.

4 participants