From 05277e020e682290214064ac2003a5ffa3a43efe Mon Sep 17 00:00:00 2001 From: Fran Bull Date: Mon, 24 Feb 2025 08:45:10 -0800 Subject: [PATCH] move package doc to right place --- tsconsensus/tsconsensus.go | 45 +++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/tsconsensus/tsconsensus.go b/tsconsensus/tsconsensus.go index 33d8f17b7..ebaa793a2 100644 --- a/tsconsensus/tsconsensus.go +++ b/tsconsensus/tsconsensus.go @@ -1,6 +1,28 @@ // Copyright (c) Tailscale Inc & AUTHORS // SPDX-License-Identifier: BSD-3-Clause +/* +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 +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 provides: + - cluster peer discovery based on tailscale tags + - executing a command on the leader + - 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. +When changes to state are needed any node may + - create a Command instance with serialized Args. + - call ExecuteCommand with the Command instance + this will propagate the command to the leader, + 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 + returning a CommandResult with an Err or a serialized Result. +*/ package tsconsensus import ( @@ -19,29 +41,6 @@ import ( "tailscale.com/tsnet" ) -/* -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 -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 provides: - * cluster peer discovery based on tailscale tags - * executing a command on the leader - * 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. -When changes to state are needed any node may - * create a Command instance with serialized Args. - * call ExecuteCommand with the Command instance - this will propagate the command to the leader, - 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 - returning a CommandResult with an Err or a serialized Result. -*/ - func addr(host string, port uint16) string { return fmt.Sprintf("%s:%d", host, port) }