1
0
Fork 0

Better commenting

master
Philip O'Toole 10 years ago
parent 69a80f2ddd
commit a6d421f31f

@ -12,19 +12,19 @@ type ExecuteCommand struct {
Stmt string `json:"stmt"`
}
// Creates a new write command.
// NewExecuteCommand creates a new Execute command.
func NewExecuteCommand(stmt string) *ExecuteCommand {
return &ExecuteCommand{
Stmt: stmt,
}
}
// The name of the command in the log.
// The name of the ExecuteCommand in the log.
func (c *ExecuteCommand) CommandName() string {
return "write"
}
// Executes an sqlite statement.
// Apply executes an sqlite statement.
func (c *ExecuteCommand) Apply(server raft.Server) (interface{}, error) {
log.Trace("Applying ExecuteCommand: '%s'", c.Stmt)
db := server.Context().(*db.DB)
@ -37,19 +37,20 @@ type TransactionExecuteCommandSet struct {
Stmts []string `json:"stmts"`
}
// Creates a new set of sqlite commands, which execute within a transaction.
// NewTransactionExecuteCommandSet Creates a new set of sqlite commands, which
// execute within a transaction.
func NewTransactionExecuteCommandSet(stmts []string) *TransactionExecuteCommandSet {
return &TransactionExecuteCommandSet{
Stmts: stmts,
}
}
// The name of the command in the log.
// The name of the TransactionExecute command in the log.
func (c *TransactionExecuteCommandSet) CommandName() string {
return "transaction_execute"
}
// Executes a set of sqlite statements, within a transaction. All statements
// Apply executes a set of sqlite statements, within a transaction. All statements
// will take effect, or none.
func (c *TransactionExecuteCommandSet) Apply(server raft.Server) (interface{}, error) {
log.Trace("Applying TransactionExecuteCommandSet of size %d", len(c.Stmts))

@ -110,7 +110,7 @@ func isTransaction(req *http.Request) (bool, error) {
return queryParam(req, "transaction")
}
// Creates a new ServerMetrics object.
// NewServerMetrics creates a new ServerMetrics object.
func NewServerMetrics() *ServerMetrics {
m := &ServerMetrics{
registry: metrics.NewRegistry(),
@ -139,6 +139,7 @@ func NewServerMetrics() *ServerMetrics {
return m
}
// NewServerDiagnostics creates a new NewServerDiagnostics object.
func NewServerDiagnostics() *ServerDiagnostics {
d := &ServerDiagnostics{
startTime: time.Now(),
@ -146,7 +147,7 @@ func NewServerDiagnostics() *ServerDiagnostics {
return d
}
// Creates a new server.
// NewServer creates a new server.
func NewServer(dataDir string, dbfile string, snapAfter int, host string, port int) *Server {
dbPath := path.Join(dataDir, dbfile)
@ -181,7 +182,7 @@ func (s *Server) GetStatistics() (metrics.Registry, error) {
return s.metrics.registry, nil
}
// Returns the connection string.
// connectionString returns the string used to connect to this server.
func (s *Server) connectionString() string {
return fmt.Sprintf("http://%s:%d", s.host, s.port)
}
@ -196,7 +197,7 @@ func (s *Server) logSnapshot(err error, currentIndex, count uint64) {
}
}
// Starts the server.
// ListenAndServe starts the server.
func (s *Server) ListenAndServe(leader string) error {
var err error

Loading…
Cancel
Save