-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate leader updates from controller cluster member updates
- Loading branch information
Showing
11 changed files
with
364 additions
and
176 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package handler_ctrl | ||
|
||
import ( | ||
"github.com/michaelquigley/pfxlog" | ||
"github.com/openziti/channel/v3" | ||
"github.com/openziti/ziti/common/pb/ctrl_pb" | ||
"github.com/sirupsen/logrus" | ||
"google.golang.org/protobuf/proto" | ||
) | ||
|
||
var updateClusterLeaderHandlerInstance *updateClusterLeaderHandler | ||
|
||
type updateClusterLeaderHandler struct { | ||
callback CtrlAddressUpdater | ||
currentVersion uint64 | ||
} | ||
|
||
func (handler *updateClusterLeaderHandler) ContentType() int32 { | ||
return int32(ctrl_pb.ContentType_UpdateClusterLeaderRequestType) | ||
} | ||
|
||
func (handler *updateClusterLeaderHandler) HandleReceive(msg *channel.Message, ch channel.Channel) { | ||
log := pfxlog.ContextLogger(ch.Label()).Entry | ||
upd := &ctrl_pb.UpdateClusterLeader{} | ||
if err := proto.Unmarshal(msg.Body, upd); err != nil { | ||
log.WithError(err).Error("error unmarshalling") | ||
return | ||
} | ||
|
||
log = log.WithFields(logrus.Fields{ | ||
"localVersion": handler.currentVersion, | ||
"remoteVersion": upd.Index, | ||
"ctrlId": ch.Id(), | ||
}) | ||
|
||
if handler.currentVersion == 0 || handler.currentVersion < upd.Index { | ||
log.Info("handling update of cluster leader") | ||
handler.callback.UpdateLeader(ch.Id()) | ||
} else { | ||
log.Info("ignoring outdated update cluster leader message") | ||
} | ||
} | ||
|
||
func newUpdateClusterLeaderHandler(callback CtrlAddressUpdater) channel.TypedReceiveHandler { | ||
if updateClusterLeaderHandlerInstance == nil { | ||
updateClusterLeaderHandlerInstance = &updateClusterLeaderHandler{ | ||
callback: callback, | ||
} | ||
} | ||
return updateClusterLeaderHandlerInstance | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters