Skip to content

Commit

Permalink
Add WithRaftAddress agent option
Browse files Browse the repository at this point in the history
  • Loading branch information
kevburnsjr committed Dec 9, 2023
1 parent b6b7179 commit db749c0
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 10 additions & 0 deletions agent_option.go
Original file line number Diff line number Diff line change
@@ -31,6 +31,13 @@ func WithGossipAddress(advertiseAddress string, bindAddress ...string) AgentOpti
}
}

func WithRaftAddress(raftAddress string) AgentOption {
return func(a *Agent) error {
a.hostConfig.RaftAddress = raftAddress
return nil
}
}

func WithHostConfig(cfg HostConfig) AgentOption {
return func(a *Agent) error {
if len(cfg.Gossip.AdvertiseAddress) == 0 && len(a.hostConfig.Gossip.AdvertiseAddress) > 0 {
@@ -39,6 +46,9 @@ func WithHostConfig(cfg HostConfig) AgentOption {
if len(cfg.Gossip.BindAddress) == 0 && len(a.hostConfig.Gossip.BindAddress) > 0 {
cfg.Gossip.BindAddress = a.hostConfig.Gossip.BindAddress
}
if len(cfg.RaftAddress) == 0 && len(a.hostConfig.RaftAddress) > 0 {
cfg.RaftAddress = a.hostConfig.RaftAddress
}
cfg.Expert.LogDBFactory = DefaultHostConfig.Expert.LogDBFactory
a.hostConfig = cfg
return nil
6 changes: 4 additions & 2 deletions util.go
Original file line number Diff line number Diff line change
@@ -71,15 +71,17 @@ type (
SnapshotFile = statemachine.SnapshotFile
SnapshotFileCollection = statemachine.ISnapshotFileCollection

LogLevel = logger.LogLevel
GetLogger = logger.ILogger
LogLevel = logger.LogLevel
Logger = logger.ILogger

AgentStatus string
HostStatus string
ShardStatus string
ReplicaStatus string
)

var GetLogger = logger.GetLogger

const (
LogLevelCritical = logger.CRITICAL
LogLevelError = logger.ERROR

0 comments on commit db749c0

Please sign in to comment.