Documentation
¶
Index ¶
- func ValidateKey(key string) error
- type KVEntry
- type LogEntry
- type PeerInfo
- type Store
- func (s *Store) AddMember(agentID string, info PeerInfo) error
- func (s *Store) Close() error
- func (s *Store) CommitKV(key string, value []byte, valType string, version uint64) error
- func (s *Store) GetAcceptorState(key string) (promisedID *paxosv1.ProposalID, acceptedID *paxosv1.ProposalID, ...)
- func (s *Store) GetAgentID() (string, error)
- func (s *Store) GetAllKVs() ([]KVEntry, error)
- func (s *Store) GetIdentity(passphrase string) (*identity.Identity, error)
- func (s *Store) GetKVEntry(key string) (value []byte, valType string, version uint64, deleted bool, err error)
- func (s *Store) GetKVState() (map[string]uint64, error)
- func (s *Store) GetKVsByPrefix(prefix string) ([]KVEntry, error)
- func (s *Store) GetMembers() (map[string]PeerInfo, error)
- func (s *Store) GetRecentMessages(limit int) ([]LogEntry, error)
- func (s *Store) GetShortName() (string, error)
- func (s *Store) InitializeAgentID(passphrase string) (string, string, error)
- func (s *Store) LogMessage(msgType, sender, receiver string, message, reply []byte) error
- func (s *Store) RemoveMember(agentID string) error
- func (s *Store) SaveIdentity(ident *identity.Identity, passphrase string) error
- func (s *Store) SetAcceptedValue(key string, id *paxosv1.ProposalID, value []byte) error
- func (s *Store) SetPromisedID(key string, id *paxosv1.ProposalID) error
- func (s *Store) SetShortName(shortName string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateKey ¶
ValidateKey ensures the provided key is a valid absolute Unix path. It does not support '.' or '..' segments.
Types ¶
type KVEntry ¶
type KVEntry struct {
// Key is the unique identifier for the entry.
Key string
// Value is the raw byte content of the entry.
Value []byte
// Type classifies the entry (e.g., "data", "membership").
Type string
// Version is the consensus sequence number for this specific update.
Version uint64
// Deleted indicates whether this entry is marked as deleted.
Deleted bool
}
KVEntry represents a single entry in the Key-Value store.
type LogEntry ¶
type LogEntry struct {
// ID is the sequential identifier for the log entry.
ID int64
// Timestamp is the time the message was recorded.
Timestamp string
// Type classifies the message (e.g., Prepare, Accept).
Type string
// Sender is the agent ID that initiated the message.
Sender string
// Receiver is the agent ID that received the message.
Receiver string
// Message contains a text representation of the request.
Message string
// Reply contains a text representation of the response.
Reply string
}
LogEntry represents a single recorded message exchange.
type PeerInfo ¶
type PeerInfo struct {
// ShortName is the human-readable name of the peer.
ShortName string `json:"short_name"`
// GRPCAddr is the gRPC host:port for the peer.
GRPCAddr string `json:"grpc_addr"`
// HTTPURL is the HTTP dashboard URL for the peer.
HTTPURL string `json:"http_url"`
// Certificate is the DER-encoded X.509 certificate of the peer.
Certificate []byte `json:"certificate"`
}
PeerInfo contains metadata about a cluster member.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store manages the persistence of agent state, including Paxos variables, Key-Value data, cluster membership, and a message log. It is backed by SQLite.
func (*Store) CommitKV ¶
CommitKV saves a value to the Key-Value store after consensus is reached. If the value is empty, the entry is marked as deleted.
func (*Store) GetAcceptorState ¶
func (s *Store) GetAcceptorState(key string) (promisedID *paxosv1.ProposalID, acceptedID *paxosv1.ProposalID, acceptedValue []byte, err error)
GetAcceptorState retrieves the highest promised and accepted proposal IDs, and the accepted value for a given key.
func (*Store) GetAgentID ¶
GetAgentID returns the established agent ID.
func (*Store) GetIdentity ¶
GetIdentity retrieves the cryptographic identity for this agent.
func (*Store) GetKVEntry ¶
func (s *Store) GetKVEntry(key string) (value []byte, valType string, version uint64, deleted bool, err error)
GetKVEntry retrieves the value, type, version, and deletion status of a specific key.
func (*Store) GetKVState ¶
GetKVState returns a map of all keys and their corresponding consensus version numbers.
func (*Store) GetKVsByPrefix ¶
GetKVsByPrefix retrieves all non-deleted entries from the Key-Value store that start with the specified prefix.
func (*Store) GetMembers ¶
GetMembers retrieves the entire local membership list.
func (*Store) GetRecentMessages ¶
GetRecentMessages retrieves the most recent message log entries up to the specified limit.
func (*Store) GetShortName ¶
GetShortName returns the established short name for this agent.
func (*Store) InitializeAgentID ¶
InitializeAgentID retrieves the persistent agent ID and short name for this node. It also initializes the cryptographic identity for this agent if it doesn't exist.
func (*Store) LogMessage ¶
LogMessage records an incoming or outgoing message and its reply to the database.
func (*Store) RemoveMember ¶
RemoveMember removes a peer from the local membership list.
func (*Store) SaveIdentity ¶
SaveIdentity saves the cryptographic identity for this agent to the store.
func (*Store) SetAcceptedValue ¶
SetAcceptedValue records the acceptance of a proposal for a given key.
func (*Store) SetPromisedID ¶
func (s *Store) SetPromisedID(key string, id *paxosv1.ProposalID) error
SetPromisedID records a promise not to accept proposals with a lower ID for a given key.
func (*Store) SetShortName ¶
SetShortName updates the human-readable short name for this node.