Skip to content

Commit

Permalink
refactor: Rename kubernetes config GossipPortName to DiscoveryPortName
Browse files Browse the repository at this point in the history
  • Loading branch information
Tochemey committed Sep 7, 2024
1 parent 67a3457 commit 74f3644
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 31 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ const (
namespace = "default"
applicationName = "accounts"
actorSystemName = "AccountsSystem"
gossipPortName = "gossip-port"
discoveryPortName = "discovery-port"
peersPortName = "peers-port"
remotingPortName = "remoting-port"
)
Expand All @@ -457,7 +457,7 @@ config := kubernetes.Config{
ApplicationName: applicationName,
ActorSystemName: actorSystemName,
Namespace: namespace,
GossipPortName: gossipPortName,
DiscoveryPortName: gossipPortName,
RemotingPortName: remotingPortName,
PeersPortName: peersPortName,
}
Expand Down
6 changes: 3 additions & 3 deletions discovery/kubernetes/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ type Config struct {
Namespace string
// ApplicationName specifies the application name
ApplicationName string
// GossipPortName specifies the gossip port name
GossipPortName string
// DiscoveryPortName specifies the gossip port name
DiscoveryPortName string
// RemotingPortName specifies the remoting port name
RemotingPortName string
// PeersPortName specifies the cluster port name
Expand All @@ -49,7 +49,7 @@ func (x Config) Validate() error {
return validation.New(validation.FailFast()).
AddValidator(validation.NewEmptyStringValidator("Namespace", x.Namespace)).
AddValidator(validation.NewEmptyStringValidator("ApplicationName", x.ApplicationName)).
AddValidator(validation.NewEmptyStringValidator("GossipPortName", x.GossipPortName)).
AddValidator(validation.NewEmptyStringValidator("DiscoveryPortName", x.DiscoveryPortName)).
AddValidator(validation.NewEmptyStringValidator("PeersPortName", x.PeersPortName)).
AddValidator(validation.NewEmptyStringValidator("RemotingPortName", x.RemotingPortName)).
AddValidator(validation.NewEmptyStringValidator("ActorSystemName", x.ActorSystemName)).
Expand Down
24 changes: 12 additions & 12 deletions discovery/kubernetes/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@ import (
func TestConfig(t *testing.T) {
t.Run("With valid configuration", func(t *testing.T) {
config := &Config{
Namespace: "namespace",
ApplicationName: "applicationName",
GossipPortName: "gossipName",
RemotingPortName: "remotingName",
PeersPortName: "peersPortName",
ActorSystemName: "actorSys",
Namespace: "namespace",
ApplicationName: "applicationName",
DiscoveryPortName: "gossipName",
RemotingPortName: "remotingName",
PeersPortName: "peersPortName",
ActorSystemName: "actorSys",
}
assert.NoError(t, config.Validate())
})
t.Run("With invalid configuration", func(t *testing.T) {
config := &Config{
Namespace: "namespace",
ApplicationName: "applicationName",
GossipPortName: "",
RemotingPortName: "remotingName",
PeersPortName: "peersPortName",
ActorSystemName: "actorSys",
Namespace: "namespace",
ApplicationName: "applicationName",
DiscoveryPortName: "",
RemotingPortName: "remotingName",
PeersPortName: "peersPortName",
ActorSystemName: "actorSys",
}
assert.Error(t, config.Validate())
})
Expand Down
4 changes: 2 additions & 2 deletions discovery/kubernetes/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func (d *Discovery) DiscoverPeers() ([]string, error) {
return nil, err
}

validPortNames := []string{d.config.PeersPortName, d.config.GossipPortName, d.config.RemotingPortName}
validPortNames := []string{d.config.PeersPortName, d.config.DiscoveryPortName, d.config.RemotingPortName}

// define the addresses list
addresses := goset.NewSet[string]()
Expand All @@ -174,7 +174,7 @@ MainLoop:
continue
}

if port.Name == d.config.GossipPortName {
if port.Name == d.config.DiscoveryPortName {
addresses.Add(net.JoinHostPort(pod.Status.PodIP, strconv.Itoa(int(port.ContainerPort))))
}
}
Expand Down
24 changes: 12 additions & 12 deletions discovery/kubernetes/discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ func TestDiscovery(t *testing.T) {
ts2 := time.Now()

config := &Config{
Namespace: "test",
ActorSystemName: "test",
ApplicationName: "test",
GossipPortName: gossipPortName,
RemotingPortName: remotingPortName,
PeersPortName: peersPortName,
Namespace: "test",
ActorSystemName: "test",
ApplicationName: "test",
DiscoveryPortName: gossipPortName,
RemotingPortName: remotingPortName,
PeersPortName: peersPortName,
}

// create some bunch of mock pods
Expand Down Expand Up @@ -210,12 +210,12 @@ func TestDiscovery(t *testing.T) {
actorSystemName := "AccountsSystem"

config := &Config{
Namespace: namespace,
ActorSystemName: actorSystemName,
ApplicationName: applicationName,
GossipPortName: gossipPortName,
RemotingPortName: remotingPortName,
PeersPortName: peersPortName,
Namespace: namespace,
ActorSystemName: actorSystemName,
ApplicationName: applicationName,
DiscoveryPortName: gossipPortName,
RemotingPortName: remotingPortName,
PeersPortName: peersPortName,
}

// create the instance of provider
Expand Down

0 comments on commit 74f3644

Please sign in to comment.