-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up process lifecycle management in the
entry
package
Before, the interrupt signalling logic (in the `wait_*.go` files) would stop the client and/or process directly. We move this logic to the `RunMain` functions instead, and create a context that gets canceled under the same conditions. This context is then passed to the `innerMain` function, which creates a client just like before, but binds the client's lifetime to the context. This way, we have a more top-down approach, and remove the entry package's dependency on the client. This allows an easy implementation of config reloading in subsequent contributions. PiperOrigin-RevId: 666794830
- Loading branch information
1 parent
74cb012
commit f816f78
Showing
6 changed files
with
204 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Package entry provides platform-specific wrappers around the application's | ||
// entry points to manage its lifecycle. | ||
package entry | ||
|
||
import ( | ||
"context" | ||
"time" | ||
) | ||
|
||
// Timeout for shutting down gracefully. | ||
// | ||
// If the [InnerMain] function does not return within this time, the process | ||
// may be shut down ungracefully. | ||
const shutdownTimeout = 10 * time.Second | ||
|
||
// InnerMain is an inner entry function responsible for creating a | ||
// [client.Client] and managing its configuration and lifecycle. It is called by | ||
// [RunMain] which handles platform-specific mechanics to manage the passed | ||
// Context. | ||
type InnerMain func(ctx context.Context) error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.