Skip to content

Commit

Permalink
Rename flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
Crystal Lemire committed Nov 23, 2023
1 parent d617be3 commit 96b6c25
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions protocol/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ func New(
go func() {
app.MonitorDaemon(
app.LiquidationsClient,
time.Duration(daemonFlags.Shared.MaximumAllowableDaemonUnhealthySeconds)*time.Second,
time.Duration(daemonFlags.Shared.MaximumDaemonUnhealthySeconds)*time.Second,
)
if err := app.LiquidationsClient.Start(
// The client will use `context.Background` so that it can have a different context from
Expand Down Expand Up @@ -647,7 +647,7 @@ func New(
)
app.MonitorDaemon(
app.PriceFeedClient,
time.Duration(daemonFlags.Shared.MaximumAllowableDaemonUnhealthySeconds)*time.Second,
time.Duration(daemonFlags.Shared.MaximumDaemonUnhealthySeconds)*time.Second,
)
}

Expand All @@ -660,7 +660,7 @@ func New(
go func() {
app.MonitorDaemon(
app.BridgeClient,
time.Duration(daemonFlags.Shared.MaximumAllowableDaemonUnhealthySeconds)*time.Second,
time.Duration(daemonFlags.Shared.MaximumDaemonUnhealthySeconds)*time.Second,
)
if err := app.BridgeClient.Start(
// The client will use `context.Background` so that it can have a different context from
Expand Down
22 changes: 11 additions & 11 deletions protocol/daemons/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const (
FlagLiquidationDaemonSubaccountPageLimit = "liquidation-daemon-subaccount-page-limit"
FlagLiquidationDaemonRequestChunkSize = "liquidation-daemon-request-chunk-size"

FlagDisablePanicOnDaemonFailure = "disable-panic-on-daemon-failure"
FlagMaximumAllowableDaemonUnhealthySeconds = "maximum-allowable-daemon-unhealthy-duration"
FlagDisablePanicOnDaemonFailure = "disable-panic-on-daemon-failure"
FlagMaximumDaemonUnhealthySeconds = "maximum-daemon-unhealthy-seconds"
)

// Shared flags contains configuration flags shared by all daemons.
Expand All @@ -33,8 +33,8 @@ type SharedFlags struct {
SocketAddress string
// DisablePanicOnDaemonFailure toggles whether the daemon should panic on failure.
DisablePanicOnDaemonFailure bool
// MaximumAllowableDaemonUnhealthySeconds is the maximum allowable duration for which a daemon can be unhealthy.
MaximumAllowableDaemonUnhealthySeconds uint32
// MaximumDaemonUnhealthySeconds is the maximum allowable duration for which a daemon can be unhealthy.
MaximumDaemonUnhealthySeconds uint32
}

// BridgeFlags contains configuration flags for the Bridge Daemon.
Expand Down Expand Up @@ -81,9 +81,9 @@ func GetDefaultDaemonFlags() DaemonFlags {
if defaultDaemonFlags == nil {
defaultDaemonFlags = &DaemonFlags{
Shared: SharedFlags{
SocketAddress: "/tmp/daemons.sock",
DisablePanicOnDaemonFailure: false,
MaximumAllowableDaemonUnhealthySeconds: 5 * 60,
SocketAddress: "/tmp/daemons.sock",
DisablePanicOnDaemonFailure: false,
MaximumDaemonUnhealthySeconds: 5 * 60,
},
Bridge: BridgeFlags{
Enabled: true,
Expand Down Expand Up @@ -127,8 +127,8 @@ func AddDaemonFlagsToCmd(
"Disables the default behavior of panicking when a daemon fails.",
)
cmd.Flags().Uint32(
FlagMaximumAllowableDaemonUnhealthySeconds,
df.Shared.MaximumAllowableDaemonUnhealthySeconds,
FlagMaximumDaemonUnhealthySeconds,
df.Shared.MaximumDaemonUnhealthySeconds,
"Sets the maximum allowable duration, in seconds, that a daemon can be unhealthy before the app panics.",
)

Expand Down Expand Up @@ -202,9 +202,9 @@ func GetDaemonFlagValuesFromOptions(
result.Shared.DisablePanicOnDaemonFailure = v
}
}
if option := appOpts.Get(FlagMaximumAllowableDaemonUnhealthySeconds); option != nil {
if option := appOpts.Get(FlagMaximumDaemonUnhealthySeconds); option != nil {
if v, err := cast.ToUint32E(option); err == nil {
result.Shared.MaximumAllowableDaemonUnhealthySeconds = v
result.Shared.MaximumDaemonUnhealthySeconds = v
}
}

Expand Down
8 changes: 4 additions & 4 deletions protocol/daemons/flags/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestAddDaemonFlagsToCmd(t *testing.T) {
tests := []string{
flags.FlagUnixSocketAddress,
flags.FlagDisablePanicOnDaemonFailure,
flags.FlagMaximumAllowableDaemonUnhealthySeconds,
flags.FlagMaximumDaemonUnhealthySeconds,

flags.FlagBridgeDaemonEnabled,
flags.FlagBridgeDaemonLoopDelayMs,
Expand All @@ -44,7 +44,7 @@ func TestGetDaemonFlagValuesFromOptions_Custom(t *testing.T) {

optsMap[flags.FlagUnixSocketAddress] = "test-socket-address"
optsMap[flags.FlagDisablePanicOnDaemonFailure] = true
optsMap[flags.FlagMaximumAllowableDaemonUnhealthySeconds] = uint32(1234)
optsMap[flags.FlagMaximumDaemonUnhealthySeconds] = uint32(1234)

optsMap[flags.FlagBridgeDaemonEnabled] = true
optsMap[flags.FlagBridgeDaemonLoopDelayMs] = uint32(1111)
Expand All @@ -71,8 +71,8 @@ func TestGetDaemonFlagValuesFromOptions_Custom(t *testing.T) {
require.Equal(t, optsMap[flags.FlagDisablePanicOnDaemonFailure], r.Shared.DisablePanicOnDaemonFailure)
require.Equal(
t,
optsMap[flags.FlagMaximumAllowableDaemonUnhealthySeconds],
r.Shared.MaximumAllowableDaemonUnhealthySeconds,
optsMap[flags.FlagMaximumDaemonUnhealthySeconds],
r.Shared.MaximumDaemonUnhealthySeconds,
)

// Bridge Daemon.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ func (s *PriceDaemonIntegrationTestSuite) startClient() {
)
err := s.healthMonitor.RegisterService(
s.pricefeedDaemon,
time.Duration(flags.GetDefaultDaemonFlags().Shared.MaximumAllowableDaemonUnhealthySeconds)*time.Second,
time.Duration(flags.GetDefaultDaemonFlags().Shared.MaximumDaemonUnhealthySeconds)*time.Second,
)
s.Require().NoError(err)
}
Expand Down

0 comments on commit 96b6c25

Please sign in to comment.