mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-05 02:16:27 +00:00
change comment style
This commit is contained in:
@@ -1,28 +1,26 @@
|
|||||||
// Copyright (c) Tailscale Inc & AUTHORS
|
// Copyright (c) Tailscale Inc & AUTHORS
|
||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
/*
|
// Package tsconsensus implements a consensus algorithm for a group of tsnet.Servers
|
||||||
Package tsconsensus implements a consensus algorithm for a group of tsnet.Servers
|
//
|
||||||
|
// The Raft consensus algorithm relies on you implementing a state machine that will give the same
|
||||||
The Raft consensus algorithm relies on you implementing a state machine that will give the same
|
// result to a give command as long as the same logs have been applied in the same order.
|
||||||
result to a give command as long as the same logs have been applied in the same order.
|
//
|
||||||
|
// tsconsensus uses the hashicorp/raft library to implement leader elections and log application.
|
||||||
tsconsensus uses the hashicorp/raft library to implement leader elections and log application.
|
//
|
||||||
|
// tsconsensus provides:
|
||||||
tsconsensus provides:
|
// - cluster peer discovery based on tailscale tags
|
||||||
- cluster peer discovery based on tailscale tags
|
// - executing a command on the leader
|
||||||
- executing a command on the leader
|
// - communication between cluster peers over tailscale using tsnet
|
||||||
- communication between cluster peers over tailscale using tsnet
|
//
|
||||||
|
// Users implement a state machine that satisfies the raft.FSM interface, with the business logic they desire.
|
||||||
Users implement a state machine that satisfies the raft.FSM interface, with the business logic they desire.
|
// When changes to state are needed any node may
|
||||||
When changes to state are needed any node may
|
// - create a Command instance with serialized Args.
|
||||||
- create a Command instance with serialized Args.
|
// - call ExecuteCommand with the Command instance
|
||||||
- call ExecuteCommand with the Command instance
|
// this will propagate the command to the leader,
|
||||||
this will propagate the command to the leader,
|
// and then from the reader to every node via raft.
|
||||||
and then from the reader to every node via raft.
|
// - the state machine then can implement raft.Apply, and dispatch commands via the Command.Name
|
||||||
- the state machine then can implement raft.Apply, and dispatch commands via the Command.Name
|
// returning a CommandResult with an Err or a serialized Result.
|
||||||
returning a CommandResult with an Err or a serialized Result.
|
|
||||||
*/
|
|
||||||
package tsconsensus
|
package tsconsensus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -395,7 +393,7 @@ func (c *Consensus) executeCommandLocally(cmd Command) (CommandResult, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return CommandResult{}, err
|
return CommandResult{}, err
|
||||||
}
|
}
|
||||||
f := c.raft.Apply(b, 10*time.Second)
|
f := c.raft.Apply(b, 10*time.Second) // TODO hardcoded timeout
|
||||||
err = f.Error()
|
err = f.Error()
|
||||||
result := f.Response()
|
result := f.Response()
|
||||||
if errors.Is(err, raft.ErrNotLeader) {
|
if errors.Is(err, raft.ErrNotLeader) {
|
||||||
|
Reference in New Issue
Block a user