queries

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package queries implements all the queries needed by this specific implementation of the Paxos algorithm.

Index

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

func GetDanglingProposals() *map[int]proposal.Proposal

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

func GetLearntValue(turnID int) string

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

func GetLearntValuesTurnID() *map[int]bool

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

func GetProposal(turnID int) (proposal.Proposal, bool)

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

func GetProposalsTurnID() *map[int]bool

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

func ResetLearntValue(turnID int) error

ResetLearntValue deletes the entry from the 'learnt' table where the field 'turn_id' is equal to @turnID.

func ResetProposal

func ResetProposal(turnID int) error

ResetProposal deletes the entry from the 'proposal' table where the field 'turn_id' is equal to @turnID.

func SetLearntValue

func SetLearntValue(turnID int, v string) (err error)

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

func SetProposal(turnID int, p proposal.Proposal, isAcceptRequest bool) (err error)

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.

Jump to

Keyboard shortcuts

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