Documentation ¶
Overview ¶
Package queries implements all the queries needed by this specific implementation of the Paxos algorithm.
Index ¶
- func GetAllLearntValues() []messages.LearntWithTid
- func GetAllProposals() []messages.ProposalWithTid
- func GetDanglingProposals() *map[int]proposal.Proposal
- func GetLastTurnID() int
- func GetLearntValue(turnID int) string
- func GetLearntValuesTurnID() *map[int]bool
- func GetProposal(turnID int) (proposal.Proposal, bool)
- func GetProposalsTurnID() *map[int]bool
- func InitDatabase()
- func PrepareDBConn()
- func ResetAllLearntValues() error
- func ResetAllProposals() error
- func ResetLearntValue(turnID int) error
- func ResetProposal(turnID int) error
- func SetLearntValue(turnID int, v string) (err error)
- func SetProposal(turnID int, p proposal.Proposal, isAcceptRequest bool) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAllLearntValues ¶
func GetAllLearntValues() []messages.LearntWithTid
GetAllLearntValues returns a list of all the entries stored in the 'learnt' table. Each entry is mapped onto a LearntWithTid object.
func GetAllProposals ¶
func GetAllProposals() []messages.ProposalWithTid
GetAllProposals returns a list of all the entries stored in the 'proposal' table. Each entry is mapped onto a messages.ProposalWithTid object.
func GetDanglingProposals ¶
GetDanglingProposals returns a map of the proposals found in the 'proposal' whose turn ID does not have an entry 'learnt' table. The map uses the turn ID as the key and a Proposal object as the value.
func GetLastTurnID ¶
func GetLastTurnID() int
GetLastTurnID returns the highest turn ID found in the `learnt` table. 0 is returned if table is empty.
func GetLearntValue ¶
GetLearntValue returns the 'v' field of the 'learnt' table where the field 'turn_id' is equal to @turnID. If no value has been learnt for the requested @turnID, an empty string is returned.
func GetLearntValuesTurnID ¶
GetLearntValuesTurnID is a map used as a set, the keys are the turnIDs of the learnt values. map[int]interface{} is said to be more efficient than map[int]bool, doesn't really matter.
func GetProposal ¶
GetProposal returns the entry of the 'proposal' table where the field 'turn_id' is equal to @turnID. If the wanted proposal does not exist OR is not valid (i.e. pid and seq are 0) an empty proposal is returned together with a false boolean value. Please note that proposals with @pid or @seq = 0 should not exist, the user should not issue such values. If the wanted proposal exists AND is valid, it will be returned together with a positive boolean value. If the field 'v' is NULL, @v will be assigned the empty string "". The entry will be mapped onto a proposal.Proposal object.
func GetProposalsTurnID ¶
GetProposalsTurnID is a map used as a set, the keys are the turnIDs of the proposals we know. map[int]interface{} is said to be more efficient than map[int]bool, doesn't really matter.
func InitDatabase ¶
func InitDatabase()
InitDatabase executes the command needed to initialize the database.
func PrepareDBConn ¶ added in v1.0.6
func PrepareDBConn()
func ResetAllLearntValues ¶
func ResetAllLearntValues() error
ResetAllLearntValues empties the `learnt` table.
func ResetAllProposals ¶
func ResetAllProposals() error
ResetAllProposals empties the `proposal` table.
func ResetLearntValue ¶
ResetLearntValue deletes the entry from the 'learnt' table where the field 'turn_id' is equal to @turnID.
func ResetProposal ¶
ResetProposal deletes the entry from the 'proposal' table where the field 'turn_id' is equal to @turnID.
func SetLearntValue ¶
SetLearntValue inserts/updates an entry in the 'learnt' table where the field 'turn_id' is equal to @turnID. If the requested @turnID does not exist, a new entry is created. If the learnt value for the requested @turnID is already present, it will be overwritten.
func SetProposal ¶
SetProposal inserts/updates an entry in the 'proposal' table where the field 'turn_id' is equal to @turnID. If isAcceptRequest is false, only the value "n" (i.e. Pid and Seq) will be overwritten, while "v" will be left untouched. If isAcceptRequest is true, both "v" and "n" will be overwritten by the value requested.
Types ¶
This section is empty.