Skip to content

Commit

Permalink
Add rpc domain config
Browse files Browse the repository at this point in the history
This may be helpful in cluster settings where the nodes share a common
domain name but have different hostnames.
  • Loading branch information
nuric committed Sep 27, 2023
1 parent 156394e commit 946787a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cluster/clusternode.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ type ClusterNodeConfig struct {
// Root directory for all data
RootDir string `yaml:"rootDir"`
// ---------------------------
RpcHost string `yaml:"rpcHost"`
RpcPort int `yaml:"rpcPort"`
RpcHost string `yaml:"rpcHost"`
RpcDomain string `yaml:"rpcDomain"` // Append to hostname
RpcPort int `yaml:"rpcPort"`
// Timeout in seconds
RpcTimeout int `yaml:"rpcTimeout"`
RpcRetries int `yaml:"rpcRetries"`
Expand Down Expand Up @@ -85,8 +86,8 @@ func NewNode(config ClusterNodeConfig) (*ClusterNode, error) {
log.Warn().Str("hostname", hostname).Msg("host not set, using hostname")
envHostname = hostname
}
rpcPort := config.RpcPort
envHostname = envHostname + ":" + strconv.Itoa(rpcPort)
envHostname = envHostname + config.RpcDomain + ":" + strconv.Itoa(config.RpcPort)
log.Info().Str("hostname", envHostname).Msg("hostname")
}
// ---------------------------
logger := log.With().Str("hostname", envHostname).Str("component", "clusterNode").Logger()
Expand Down
1 change: 1 addition & 0 deletions config/serverA.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ clusterNode:
# -------------------------------
# RPC Parameters
rpcHost: localhost
rpcDomain: ""
rpcPort: 11001
rpcTimeout: 300 # seconds
rpcRetries: 2
Expand Down
1 change: 1 addition & 0 deletions config/serverB.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ clusterNode:
# -------------------------------
# RPC Parameters
rpcHost: localhost
rpcDomain: ""
rpcPort: 11002
rpcTimeout: 300 # seconds
rpcRetries: 2
Expand Down
1 change: 1 addition & 0 deletions config/serverC.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ clusterNode:
# -------------------------------
# RPC Parameters
rpcHost: localhost
rpcDomain: ""
rpcPort: 11003
rpcTimeout: 300 # seconds
rpcRetries: 2
Expand Down
1 change: 1 addition & 0 deletions config/singleServer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ clusterNode:
# -------------------------------
# RPC Parameters
rpcHost: localhost
rpcDomain: ""
rpcPort: 11001
rpcTimeout: 300 # seconds
rpcRetries: 2
Expand Down

0 comments on commit 946787a

Please sign in to comment.