server

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenWithRetry

func ListenWithRetry(addr string) (net.Listener, error)

ListenWithRetry attempts to listen on the given address. If the port is occupied, it tries to find any free port using an exponential backoff strategy for up to 1 minute.

func RunGRPCServer

func RunGRPCServer(ctx context.Context, lis net.Listener, srv *PaxosServer) error

RunGRPCServer starts the gRPC server and registers the Paxos and User APIs.

Types

type BaseData

type BaseData struct {
	Title     string
	AgentName string
	ActiveNav string
}

HTTPServer provides a web dashboard for inspecting agent state and issuing commands.

type CommandData

type CommandData struct {
	BaseData
	Key   string
	Value string
}

type GRPCChannelData

type GRPCChannelData struct {
	ChannelID      int64
	Target         string
	State          string
	CallsStarted   int64
	CallsSucceeded int64
	CallsFailed    int64
}

type GRPCServerData

type GRPCServerData struct {
	ServerID       int64
	CallsStarted   int64
	CallsSucceeded int64
	CallsFailed    int64
	LastCall       string
}

type GRPCStatusData

type GRPCStatusData struct {
	BaseData
	ErrorMsg template.HTML
	Servers  []GRPCServerData
	Channels []GRPCChannelData
}

type HTTPServer

type HTTPServer struct {
	// contains filtered or unexported fields
}

HTTPServer provides a web dashboard for inspecting agent state and issuing commands.

func NewHTTPServer

func NewHTTPServer(addr string, store *state.Store, cell *paxos.Cell) *HTTPServer

NewHTTPServer initializes a new HTTPServer.

func (*HTTPServer) Run

func (s *HTTPServer) Run(lis net.Listener) error

Run starts the HTTP server on the provided listener.

type IndexData

type IndexData struct {
	BaseData
	AgentID      template.HTML
	AgentCert    string
	KeysCount    int
	Participants []Participant
}

type KV

type KV struct {
	Key     template.HTML
	Value   template.HTML
	Type    string
	Version uint64
}

type KnownPeer

type KnownPeer struct {
	ID       string
	Name     string
	GRPCURL  string
	HTTPLink template.HTML
	HasCert  bool
	CertPEM  string
}

type Message

type Message struct {
	ID        int64
	Timestamp string
	Type      string
	Sender    string
	Receiver  string
	Request   template.HTML
	Reply     template.HTML
}

type MessagesData

type MessagesData struct {
	BaseData
	Peers    []Peer
	Messages []Message
}

type OngoingRequest

type OngoingRequest struct {
	// ID is a unique identifier for the request.
	ID string
	// Type indicates the kind of request (e.g., Read, CompareAndWrite).
	Type string
	// Key is the target key path for the request.
	Key string
	// StartTime records when the request was initiated.
	StartTime time.Time
	// Result contains the outcome message or value as a string.
	Result string
	// Finished indicates whether the request has completed.
	Finished bool
	// Success indicates if a finished request was successful.
	Success bool
}

OngoingRequest tracks the state of a User API request initiated via the web dashboard.

type Participant

type Participant struct {
	IDLabel   template.HTML
	ShortName string
	GRPCAddr  string
	HTTPLink  template.HTML
}

type PaxosClient

type PaxosClient struct {
	// contains filtered or unexported fields
}

PaxosClient wraps a gRPC connection to a remote Paxos agent.

func NewPaxosClient

func NewPaxosClient(agentID string, addr string) (*PaxosClient, error)

NewPaxosClient establishes a connection to the specified address.

func (*PaxosClient) Accept

Accept forwards an Accept request.

func (*PaxosClient) AgentID

func (c *PaxosClient) AgentID() string

AgentID returns the remote agent's ID.

func (*PaxosClient) Close

func (c *PaxosClient) Close() error

Close closes the underlying gRPC connection.

func (*PaxosClient) GetKVEntry

GetKVEntry forwards a GetKVEntry request.

func (*PaxosClient) GetPeerEndpoints

GetPeerEndpoints forwards a GetPeerEndpoints request.

func (*PaxosClient) JoinCluster

JoinCluster forwards a JoinCluster request.

func (*PaxosClient) Ping

Ping forwards a Ping request.

func (*PaxosClient) Prepare

Prepare forwards a Prepare request.

func (*PaxosClient) Sync

Sync forwards a Sync request.

type PaxosServer

type PaxosServer struct {
	paxosv1.UnimplementedPaxosServiceServer
	paxosv1.UnimplementedUserServiceServer
	// contains filtered or unexported fields
}

PaxosServer implements both the internal PaxosService and the client-facing UserService over gRPC.

func NewPaxosServer

func NewPaxosServer(agentID string, ident *identity.Identity, store *state.Store, acceptor *paxos.Acceptor, cell *paxos.Cell) *PaxosServer

NewPaxosServer initializes a new PaxosServer.

func (*PaxosServer) Accept

Accept handles the Phase 2a of the Paxos protocol.

func (*PaxosServer) AcquireLock

AcquireLock handles a client request to acquire a distributed lock.

func (*PaxosServer) CompareAndWrite

CompareAndWrite handles a client request to atomically update a key's value.

func (*PaxosServer) GetKVEntry

GetKVEntry returns the current state of a specific key from the local store.

func (*PaxosServer) GetPeerEndpoints

GetPeerEndpoints returns a snapshot of all known peers and their endpoints.

func (*PaxosServer) JoinCluster

JoinCluster processes a request from a new node attempting to join the cluster.

func (*PaxosServer) Ping

Ping responds to a liveness check and exchanges endpoint information.

func (*PaxosServer) Prepare

Prepare handles the Phase 1a of the Paxos protocol.

func (*PaxosServer) Read

Read handles a client request to read a key with a specified consistency quorum.

func (*PaxosServer) ReadPrefix

ReadPrefix handles a client request to read all entries with a specified prefix.

func (*PaxosServer) ReleaseLock

ReleaseLock handles a client request to release a distributed lock.

func (*PaxosServer) RenewLock

RenewLock handles a client request to extend a distributed lock's duration.

func (*PaxosServer) Shutdown

func (*PaxosServer) Sync

Sync returns the highest known version numbers for all keys in the local store.

type Peer

type Peer struct {
	Label     template.HTML
	AgentID   string
	Endpoints template.HTML
}

type PeersData

type PeersData struct {
	BaseData
	Peers []KnownPeer
}

type StoreData

type StoreData struct {
	BaseData
	KVs []KV
}

type SystemData

type SystemData struct {
	BaseData
	NumCPU        int
	NumGoroutines int
	Alloc         uint64
	AllocMB       float64
	TotalAlloc    uint64
	TotalAllocMB  float64
	Sys           uint64
	SysMB         float64
	NumGC         uint32
	ShowDump      bool
	Dump          string
}

type UserAPIData

type UserAPIData struct {
	BaseData
	StatusMsg   template.HTML
	OngoingHTML template.HTML
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL