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

[prism] Add internal/config package #25406

Merged
merged 2 commits into from
Feb 9, 2023
Merged

Conversation

lostluck
Copy link
Contributor

@lostluck lostluck commented Feb 9, 2023

Add internal/config package, which is the core for configuring the Runner with variants and handlers.

Uber PR for all changes: #25391

See #24789


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI.

@lostluck
Copy link
Contributor Author

lostluck commented Feb 9, 2023

Looks like this depends on something not in the go.mod file yet. So while this is good to review, it shouldn't be merged until we get that green after #25404 is merged.

@lostluck
Copy link
Contributor Author

lostluck commented Feb 9, 2023

R: @jrmccluskey

@lostluck
Copy link
Contributor Author

lostluck commented Feb 9, 2023

Run Go PreCommit

@lostluck
Copy link
Contributor Author

lostluck commented Feb 9, 2023

Run GoPortable PreCommit

return &Variant{parent: r, name: name, handlers: vs.Handlers}
}

type Variant struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I don't love the naming collision of the internal, little-v variant and the exported Variant, it doesn't read particularly clearly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed variants to configFile, since it's logically the whole file.
Renamed variant to rawVariant, since it's the raw struct being decoded into by YAML.

variantIDs, handerIDs []string
}

func NewHandlerwRegistry() *HandlerRegistry {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a naming convention reason why this is NewHandlerwRegistry() instead of NewHandlerRegistry()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A typo. Whoops. Thanks. This isn't yet used, so it wasn't caught. Soon!

Comment on lines 186 to 204
// Variants returns the IDs of all registered variations.
func (r *HandlerRegistry) Variants() []string {
return r.variantIDs
}

// Handlers returns the IDs of all handlers used in variations.
func (r *HandlerRegistry) UsedHandlers() []string {
return r.handerIDs
}

// GetVariant returns the Variant witn the given name.
// If none exist, GetVariant returns nil.
func (r *HandlerRegistry) GetVariant(name string) *Variant {
vs, ok := r.variations[name]
if !ok {
return nil
}
return &Variant{parent: r, name: name, handlers: vs.Handlers}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: could we move these to be contiguous with the rest of the HandlerRegistry fns?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@lostluck
Copy link
Contributor Author

lostluck commented Feb 9, 2023

PTAL. Reordered the types & methods in top down order where definitions are involved. This puts HandlerRegistry at the bottom.

Added missing exported type comments, as well as the renames.

@lostluck
Copy link
Contributor Author

lostluck commented Feb 9, 2023

PS. These are exactly the kind of comments I'm looking for at this stage of Prism.

Copy link
Contributor

@jrmccluskey jrmccluskey left a comment

Choose a reason for hiding this comment

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

LGTM!

@lostluck
Copy link
Contributor Author

lostluck commented Feb 9, 2023

Run Go PreCommit

@lostluck
Copy link
Contributor Author

lostluck commented Feb 9, 2023

Thanks! Gonna wait until the automated jobs pick up. It seems there's a bit of a Queue at present.

@lostluck
Copy link
Contributor Author

lostluck commented Feb 9, 2023

https://ci-beam.apache.org/job/beam_PreCommit_Go_Phrase/226/console

This was the run for this PR after the most recent commit. Merging.

Thanks for the quick reviews! Now it gets fun.

@lostluck lostluck merged commit 8283e4f into apache:master Feb 9, 2023
@github-actions
Copy link
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control

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.

2 participants