This repository has been archived by the owner on Mar 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move shutdown timeout into param instead of using viper
- refactored tests - fixed typos in README - moved shutdown timeout into params - moved usage of viper into a new function (prepare to removal of direct call to viper)
- Loading branch information
1 parent
527c540
commit 2e543d1
Showing
4 changed files
with
75 additions
and
40 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 |
---|---|---|
@@ -1,11 +1,34 @@ | ||
package service | ||
|
||
import "github.com/im-kulikov/helium/module" | ||
import ( | ||
"time" | ||
|
||
"github.com/spf13/viper" | ||
"go.uber.org/dig" | ||
|
||
"github.com/im-kulikov/helium/module" | ||
) | ||
|
||
type outParams struct { | ||
dig.Out | ||
|
||
Shutdown time.Duration `name:"service_shutdown_timeout"` | ||
} | ||
|
||
// ShutdownTimeoutParam name for viper setting. | ||
const ShutdownTimeoutParam = "shutdown_timeout" | ||
|
||
var ( | ||
_ = Module // prevent unused | ||
|
||
// Module for group of services | ||
// nolint:gochecknoglobals | ||
Module = module.New(newGroup) | ||
Module = module.Module{ | ||
{Constructor: newParam}, | ||
{Constructor: newGroup}, | ||
} | ||
) | ||
|
||
func newParam(v *viper.Viper) outParams { | ||
return outParams{Shutdown: v.GetDuration(ShutdownTimeoutParam)} | ||
} |
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