mirror of
https://github.com/datarhei/core.git
synced 2025-12-24 13:07:56 +08:00
Remove api address from join request
This commit is contained in:
@@ -45,7 +45,6 @@ type JoinRequest struct {
|
||||
Origin string `json:"origin"`
|
||||
ID string `json:"id"`
|
||||
RaftAddress string `json:"raft_address"`
|
||||
APIAddress string `json:"api_address"`
|
||||
}
|
||||
|
||||
type LeaveRequest struct {
|
||||
@@ -107,7 +106,7 @@ func NewAPI(config APIConfig) (API, error) {
|
||||
return httpapi.Err(http.StatusLoopDetected, "", "breaking circuit")
|
||||
}
|
||||
|
||||
err := a.cluster.Join(r.Origin, r.ID, r.RaftAddress, r.APIAddress, "")
|
||||
err := a.cluster.Join(r.Origin, r.ID, r.RaftAddress, "")
|
||||
if err != nil {
|
||||
a.logger.Debug().WithError(err).WithField("id", r.ID).Log("unable to join cluster")
|
||||
return httpapi.Err(http.StatusInternalServerError, "unable to join cluster", "%s", err)
|
||||
|
||||
@@ -61,7 +61,7 @@ type Cluster interface {
|
||||
|
||||
About() (ClusterAbout, error)
|
||||
|
||||
Join(origin, id, raftAddress, apiAddress, peerAddress string) error
|
||||
Join(origin, id, raftAddress, peerAddress string) error
|
||||
Leave(origin, id string) error // gracefully remove a node from the cluster
|
||||
Snapshot() (io.ReadCloser, error)
|
||||
|
||||
@@ -250,7 +250,7 @@ func New(config ClusterConfig) (Cluster, error) {
|
||||
case <-c.shutdownCh:
|
||||
return
|
||||
case <-ticker.C:
|
||||
err := c.Join("", c.id, c.raftAddress, c.coreAddress, peerAddress)
|
||||
err := c.Join("", c.id, c.raftAddress, peerAddress)
|
||||
if err != nil {
|
||||
c.logger.Warn().WithError(err).Log("unable to join cluster")
|
||||
continue
|
||||
@@ -475,10 +475,10 @@ func (c *cluster) Leave(origin, id string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *cluster) Join(origin, id, raftAddress, apiAddress, peerAddress string) error {
|
||||
func (c *cluster) Join(origin, id, raftAddress, peerAddress string) error {
|
||||
if !c.IsRaftLeader() {
|
||||
c.logger.Debug().Log("not leader, forwarding to leader")
|
||||
return c.forwarder.Join(origin, id, raftAddress, apiAddress, peerAddress)
|
||||
return c.forwarder.Join(origin, id, raftAddress, peerAddress)
|
||||
}
|
||||
|
||||
c.logger.Debug().Log("leader: joining %s", raftAddress)
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
type Forwarder interface {
|
||||
SetLeader(address string)
|
||||
HasLeader() bool
|
||||
Join(origin, id, raftAddress, apiAddress, peerAddress string) error
|
||||
Join(origin, id, raftAddress, peerAddress string) error
|
||||
Leave(origin, id string) error
|
||||
Snapshot() (io.ReadCloser, error)
|
||||
AddProcess() error
|
||||
@@ -80,7 +80,7 @@ func (f *forwarder) HasLeader() bool {
|
||||
return len(f.client.Address) != 0
|
||||
}
|
||||
|
||||
func (f *forwarder) Join(origin, id, raftAddress, apiAddress, peerAddress string) error {
|
||||
func (f *forwarder) Join(origin, id, raftAddress, peerAddress string) error {
|
||||
if origin == "" {
|
||||
origin = f.id
|
||||
}
|
||||
@@ -89,7 +89,6 @@ func (f *forwarder) Join(origin, id, raftAddress, apiAddress, peerAddress string
|
||||
Origin: origin,
|
||||
ID: id,
|
||||
RaftAddress: raftAddress,
|
||||
APIAddress: apiAddress,
|
||||
}
|
||||
|
||||
f.logger.Debug().WithField("request", r).Log("forwarding to leader")
|
||||
|
||||
Reference in New Issue
Block a user