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

Add wapp.RunWithRecoveryLogging which does not return errors #49

Merged
merged 3 commits into from
May 17, 2019

Conversation

bmoylan
Copy link
Contributor

@bmoylan bmoylan commented May 12, 2019

It turns out that most usages of wapp.RunWithFatalLogging look something like this:

go func() {
	_ = wapp.RunWithFatalLogging(ctx, func(ctx context.Context) error {
		doAThing(ctx)
		return nil
	})
}

this can be simplified to

go wapp.RunWithRecoveryLogging(ctx, func(ctx context.Context) {
	doAThing(ctx)
})

This change is Reviewable

@bmoylan bmoylan requested a review from nmiyake May 12, 2019 20:04
Copy link
Contributor

@nmiyake nmiyake left a comment

Choose a reason for hiding this comment

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

Is the canonical usage to ignore the error returned over-all? If so, then I think the intent of the change is reasonable.

Reviewed 2 of 2 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @bmoylan)


wlog/wapp/fatal.go, line 30 at r1 (raw file):

// Useful as a "catch all" for applications so that they can log fatal events, perhaps before exiting.
func RunWithRecovery(ctx context.Context, runFn func(ctx context.Context)) {
	defer func() {

Is there a reason this can't just be:

_ = RunWithFatalLogging(ctx, runFn)

?

Copy link
Contributor Author

@bmoylan bmoylan left a comment

Choose a reason for hiding this comment

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

Yeah, most usages ignore the error and handle logging something themselves so they can provide more context than the default log message.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @nmiyake)


wlog/wapp/fatal.go, line 30 at r1 (raw file):

Previously, nmiyake (Nick Miyake) wrote…

Is there a reason this can't just be:

_ = RunWithFatalLogging(ctx, runFn)

?

lol, great call. Done.

Copy link
Contributor

@nmiyake nmiyake left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r2.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@bmoylan bmoylan merged commit 87637ec into develop May 17, 2019
@bmoylan bmoylan deleted the bm/RunWithRecovery branch May 17, 2019 16:49
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.

2 participants