Skip to content

Commit

Permalink
PR comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Crystal Lemire committed Nov 29, 2023
1 parent c766354 commit 059b00d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 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.MaximumDaemonUnhealthySeconds)*time.Second,
time.Duration(daemonFlags.Shared.MaxDaemonUnhealthySeconds)*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.MaximumDaemonUnhealthySeconds)*time.Second,
time.Duration(daemonFlags.Shared.MaxDaemonUnhealthySeconds)*time.Second,
)
}

Expand All @@ -658,7 +658,7 @@ func New(
go func() {
app.MonitorDaemon(
app.BridgeClient,
time.Duration(daemonFlags.Shared.MaximumDaemonUnhealthySeconds)*time.Second,
time.Duration(daemonFlags.Shared.MaxDaemonUnhealthySeconds)*time.Second,
)
if err := app.BridgeClient.Start(
// The client will use `context.Background` so that it can have a different context from
Expand Down
24 changes: 12 additions & 12 deletions protocol/daemons/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
// List of CLI flags for Server and Client.
const (
// Flag names
FlagUnixSocketAddress = "unix-socket-address"
FlagPanicOnDaemonFailureEnabled = "panic-on-daemon-failure-enabled"
FlagMaximumDaemonUnhealthySeconds = "maximum-daemon-unhealthy-seconds"
FlagUnixSocketAddress = "unix-socket-address"
FlagPanicOnDaemonFailureEnabled = "panic-on-daemon-failure-enabled"
FlagMaxDaemonUnhealthySeconds = "max-daemon-unhealthy-seconds"

FlagPriceDaemonEnabled = "price-daemon-enabled"
FlagPriceDaemonLoopDelayMs = "price-daemon-loop-delay-ms"
Expand All @@ -32,8 +32,8 @@ type SharedFlags struct {
SocketAddress string
// PanicOnDaemonFailureEnabled toggles whether the daemon should panic on failure.
PanicOnDaemonFailureEnabled bool
// MaximumDaemonUnhealthySeconds is the maximum allowable duration for which a daemon can be unhealthy.
MaximumDaemonUnhealthySeconds uint32
// MaxDaemonUnhealthySeconds is the maximum allowable duration for which a daemon can be unhealthy.
MaxDaemonUnhealthySeconds uint32
}

// BridgeFlags contains configuration flags for the Bridge Daemon.
Expand Down Expand Up @@ -80,9 +80,9 @@ func GetDefaultDaemonFlags() DaemonFlags {
if defaultDaemonFlags == nil {
defaultDaemonFlags = &DaemonFlags{
Shared: SharedFlags{
SocketAddress: "/tmp/daemons.sock",
PanicOnDaemonFailureEnabled: true,
MaximumDaemonUnhealthySeconds: 5 * 60,
SocketAddress: "/tmp/daemons.sock",
PanicOnDaemonFailureEnabled: true,
MaxDaemonUnhealthySeconds: 5 * 60,
},
Bridge: BridgeFlags{
Enabled: true,
Expand Down Expand Up @@ -126,8 +126,8 @@ func AddDaemonFlagsToCmd(
"Enables panicking when a daemon fails.",
)
cmd.Flags().Uint32(
FlagMaximumDaemonUnhealthySeconds,
df.Shared.MaximumDaemonUnhealthySeconds,
FlagMaxDaemonUnhealthySeconds,
df.Shared.MaxDaemonUnhealthySeconds,
"Maximum allowable duration for which a daemon can be unhealthy.",
)

Expand Down Expand Up @@ -201,9 +201,9 @@ func GetDaemonFlagValuesFromOptions(
result.Shared.PanicOnDaemonFailureEnabled = v
}
}
if option := appOpts.Get(FlagMaximumDaemonUnhealthySeconds); option != nil {
if option := appOpts.Get(FlagMaxDaemonUnhealthySeconds); option != nil {
if v, err := cast.ToUint32E(option); err == nil {
result.Shared.MaximumDaemonUnhealthySeconds = v
result.Shared.MaxDaemonUnhealthySeconds = 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.FlagPanicOnDaemonFailureEnabled,
flags.FlagMaximumDaemonUnhealthySeconds,
flags.FlagMaxDaemonUnhealthySeconds,

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

optsMap[flags.FlagUnixSocketAddress] = "test-socket-address"
optsMap[flags.FlagPanicOnDaemonFailureEnabled] = false
optsMap[flags.FlagMaximumDaemonUnhealthySeconds] = uint32(1234)
optsMap[flags.FlagMaxDaemonUnhealthySeconds] = 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.FlagPanicOnDaemonFailureEnabled], r.Shared.PanicOnDaemonFailureEnabled)
require.Equal(
t,
optsMap[flags.FlagMaximumDaemonUnhealthySeconds],
r.Shared.MaximumDaemonUnhealthySeconds,
optsMap[flags.FlagMaxDaemonUnhealthySeconds],
r.Shared.MaxDaemonUnhealthySeconds,
)

// 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(s.daemonFlags.Shared.MaximumDaemonUnhealthySeconds)*time.Second,
time.Duration(s.daemonFlags.Shared.MaxDaemonUnhealthySeconds)*time.Second,
)
s.Require().NoError(err)
}
Expand Down

0 comments on commit 059b00d

Please sign in to comment.