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

Remove dependency on go-baseapp #152

Merged
merged 5 commits into from
Apr 7, 2022
Merged

Remove dependency on go-baseapp #152

merged 5 commits into from
Apr 7, 2022

Conversation

asvoboda
Copy link
Member

Resolves #121

@asvoboda asvoboda requested a review from a team March 25, 2022 10:30
- os: linux
arch: amd64
- os: darwin
arch: amd64
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure why we ever had the build/disters for this library.

@@ -2,3 +2,6 @@ tags:
integration:
names:
- ^integration$
exclude:
names:
- ^example$
Copy link
Member Author

Choose a reason for hiding this comment

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

Without this,

$ ./godelw test
Error: [go list ./appconfig ./example ./githubapp ./oauth2] failed: main module (github.com/palantir/go-githubapp) does not contain package github.com/palantir/go-githubapp/example
: exit status 1

Should we just skip tests on example? Or is there a more correct way to enable tests and not have godel explode?

@asvoboda
Copy link
Member Author

asvoboda commented Mar 25, 2022

Yuck, is there a nice/correct way to tell godel to ignore the example module or treat it separately other than just a bunch of excludes in the check plugin?

I've added 7b05511, but I don't like it.

@bluekeyes
Copy link
Member

You can exclude directories from all processing using the exclude key in godel/config/godel.yml. While that might solve the problem, I'm not sure it's ideal, because it means we won't get verification for the example project.

No idea if this will work, but I'd try defining multiple projects in Godel, which I think is also the original reason we had the dist-plugin.yml configuration (to define the project.) That should let us build the example project and the library project independently.

Another option is to leave example as part of the same package, but rewrite it to only use the standard library or existing dependencies of githubapp. The real issue is that it pulls in go-baseapp, but there's no reason we have to use that.

@asvoboda asvoboda changed the title Move example package into separate go module Remove dependency on go-baseapp Apr 1, 2022
Copy link
Member

@bluekeyes bluekeyes left a comment

Choose a reason for hiding this comment

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

Removing baseapp was a smaller change than I thought it would be! A few minor suggestions, but otherwise this looks good.

Also, do you think it's worth adding a sentence to the README plugging go-baseapp now that we don't reference it in code? Maybe right before the "Examples" header at the end of the "Usage" section.

@@ -72,7 +72,6 @@ commenting with a copy of the comment body.
To run the app, update `example/config.yml` with appropriate secrets and then
run:

./godelw dep
Copy link
Member

Choose a reason for hiding this comment

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

I guess it's been a while since we updated this... 🙈

@@ -6,7 +6,7 @@ github:
v3_api_url: "https://api.github.com/"
app:
integration_id: 0
webhook_secret: "your-app-webhook-secret-here"
Copy link
Member

Choose a reason for hiding this comment

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

Intentional removal?


cc, err := githubapp.NewDefaultCachingClientCreator(
config.Github,
githubapp.WithClientUserAgent("example-app/1.0.0"),
githubapp.WithClientTimeout(3*time.Second),
githubapp.WithClientCaching(false, func() httpcache.Cache { return httpcache.NewMemoryCache() }),
githubapp.WithClientMiddleware(
githubapp.ClientMetrics(server.Registry()),
Copy link
Member

@bluekeyes bluekeyes Apr 6, 2022

Choose a reason for hiding this comment

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

Might be nice to create a metrics.Registry to pass in here as a demonstration, even if there's nothing exporting the metrics.

example/main.go Outdated
Comment on lines 55 to 56
logger.Info().Msg("Starting server...")
err = http.ListenAndServe(fmt.Sprintf("%s:%d", config.Server.Address, config.Server.Port), nil)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
logger.Info().Msg("Starting server...")
err = http.ListenAndServe(fmt.Sprintf("%s:%d", config.Server.Address, config.Server.Port), nil)
addr := fmt.Sprintf("%s:%d", config.Server.Address, config.Server.Port)
logger.Info().Msgf("Starting server on %s...", addr)
err = http.ListenAndServe(addr, nil)

That way people don't have to refer to the configuration to know what port to use.

if err != nil {
panic(err)
}
zerolog.DefaultContextLogger = &logger
Copy link
Member

Choose a reason for hiding this comment

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

Nice, this is a lot simpler than adding middleware only to put the logger in the context

@asvoboda asvoboda merged commit cfa9b81 into develop Apr 7, 2022
@asvoboda asvoboda deleted the as/example-mod branch April 7, 2022 08:20
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.

Consider defining new module in example package
3 participants