id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
24,900
rqlite/rqlite
store/store.go
Open
func (s *Store) Open(enableSingle bool) error { s.closedMu.Lock() defer s.closedMu.Unlock() if s.closed { return ErrStoreInvalidState } s.logger.Printf("opening store with node ID %s", s.raftID) s.logger.Printf("ensuring directory at %s exists", s.raftDir) if err := os.MkdirAll(s.raftDir, 0755); err != nil {...
go
func (s *Store) Open(enableSingle bool) error { s.closedMu.Lock() defer s.closedMu.Unlock() if s.closed { return ErrStoreInvalidState } s.logger.Printf("opening store with node ID %s", s.raftID) s.logger.Printf("ensuring directory at %s exists", s.raftDir) if err := os.MkdirAll(s.raftDir, 0755); err != nil {...
[ "func", "(", "s", "*", "Store", ")", "Open", "(", "enableSingle", "bool", ")", "error", "{", "s", ".", "closedMu", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "closedMu", ".", "Unlock", "(", ")", "\n", "if", "s", ".", "closed", "{", "return",...
// Open opens the store. If enableSingle is set, and there are no existing peers, // then this node becomes the first node, and therefore leader, of the cluster.
[ "Open", "opens", "the", "store", ".", "If", "enableSingle", "is", "set", "and", "there", "are", "no", "existing", "peers", "then", "this", "node", "becomes", "the", "first", "node", "and", "therefore", "leader", "of", "the", "cluster", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L244-L327
24,901
rqlite/rqlite
store/store.go
Connect
func (s *Store) Connect(opt *ConnectionOptions) (*Connection, error) { // Randomly-selected connection ID must be part of command so // that all nodes use the same value as connection ID. connID := func() uint64 { s.connsMu.Lock() defer s.connsMu.Unlock() for { // Make sure we get an unused ID. id := s.r...
go
func (s *Store) Connect(opt *ConnectionOptions) (*Connection, error) { // Randomly-selected connection ID must be part of command so // that all nodes use the same value as connection ID. connID := func() uint64 { s.connsMu.Lock() defer s.connsMu.Unlock() for { // Make sure we get an unused ID. id := s.r...
[ "func", "(", "s", "*", "Store", ")", "Connect", "(", "opt", "*", "ConnectionOptions", ")", "(", "*", "Connection", ",", "error", ")", "{", "// Randomly-selected connection ID must be part of command so", "// that all nodes use the same value as connection ID.", "connID", ...
// Connect returns a new connection to the database. Changes made to the database // through this connection are applied via the Raft consensus system. The Store // must have been opened first. Must be called on the leader or an error will // we returned. // // Any connection returned by this call are READ_COMMITTED is...
[ "Connect", "returns", "a", "new", "connection", "to", "the", "database", ".", "Changes", "made", "to", "the", "database", "through", "this", "connection", "are", "applied", "via", "the", "Raft", "consensus", "system", ".", "The", "Store", "must", "have", "be...
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L336-L381
24,902
rqlite/rqlite
store/store.go
Execute
func (s *Store) Execute(ex *ExecuteRequest) (*ExecuteResponse, error) { return s.execute(nil, ex) }
go
func (s *Store) Execute(ex *ExecuteRequest) (*ExecuteResponse, error) { return s.execute(nil, ex) }
[ "func", "(", "s", "*", "Store", ")", "Execute", "(", "ex", "*", "ExecuteRequest", ")", "(", "*", "ExecuteResponse", ",", "error", ")", "{", "return", "s", ".", "execute", "(", "nil", ",", "ex", ")", "\n", "}" ]
// Execute executes queries that return no rows, but do modify the database. // Changes made to the database through this call are applied via the Raft // consensus system. The Store must have been opened first. Must be called // on the leader or an error will we returned. The changes are made using // the database con...
[ "Execute", "executes", "queries", "that", "return", "no", "rows", "but", "do", "modify", "the", "database", ".", "Changes", "made", "to", "the", "database", "through", "this", "call", "are", "applied", "via", "the", "Raft", "consensus", "system", ".", "The",...
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L388-L390
24,903
rqlite/rqlite
store/store.go
ExecuteOrAbort
func (s *Store) ExecuteOrAbort(ex *ExecuteRequest) (resp *ExecuteResponse, retErr error) { return s.executeOrAbort(nil, ex) }
go
func (s *Store) ExecuteOrAbort(ex *ExecuteRequest) (resp *ExecuteResponse, retErr error) { return s.executeOrAbort(nil, ex) }
[ "func", "(", "s", "*", "Store", ")", "ExecuteOrAbort", "(", "ex", "*", "ExecuteRequest", ")", "(", "resp", "*", "ExecuteResponse", ",", "retErr", "error", ")", "{", "return", "s", ".", "executeOrAbort", "(", "nil", ",", "ex", ")", "\n", "}" ]
// ExecuteOrAbort executes the requests, but aborts any active transaction // on the underlying database in the case of any error. Any changes are made // using the database connection built-in to the Store.
[ "ExecuteOrAbort", "executes", "the", "requests", "but", "aborts", "any", "active", "transaction", "on", "the", "underlying", "database", "in", "the", "case", "of", "any", "error", ".", "Any", "changes", "are", "made", "using", "the", "database", "connection", ...
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L395-L397
24,904
rqlite/rqlite
store/store.go
Query
func (s *Store) Query(qr *QueryRequest) (*QueryResponse, error) { return s.query(nil, qr) }
go
func (s *Store) Query(qr *QueryRequest) (*QueryResponse, error) { return s.query(nil, qr) }
[ "func", "(", "s", "*", "Store", ")", "Query", "(", "qr", "*", "QueryRequest", ")", "(", "*", "QueryResponse", ",", "error", ")", "{", "return", "s", ".", "query", "(", "nil", ",", "qr", ")", "\n", "}" ]
// Query executes queries that return rows, and do not modify the database. // The queries are made using the database connection built-in to the Store. // Depending on the read consistency requested, it may or may not need to be // called on the leader.
[ "Query", "executes", "queries", "that", "return", "rows", "and", "do", "not", "modify", "the", "database", ".", "The", "queries", "are", "made", "using", "the", "database", "connection", "built", "-", "in", "to", "the", "Store", ".", "Depending", "on", "th...
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L403-L405
24,905
rqlite/rqlite
store/store.go
Close
func (s *Store) Close(wait bool) error { s.closedMu.Lock() defer s.closedMu.Unlock() if s.closed { return nil } defer func() { s.closed = true }() close(s.done) s.wg.Wait() // XXX CLOSE OTHER CONNECTIONS if err := s.dbConn.Close(); err != nil { return err } s.dbConn = nil s.db = nil if s.raft != ...
go
func (s *Store) Close(wait bool) error { s.closedMu.Lock() defer s.closedMu.Unlock() if s.closed { return nil } defer func() { s.closed = true }() close(s.done) s.wg.Wait() // XXX CLOSE OTHER CONNECTIONS if err := s.dbConn.Close(); err != nil { return err } s.dbConn = nil s.db = nil if s.raft != ...
[ "func", "(", "s", "*", "Store", ")", "Close", "(", "wait", "bool", ")", "error", "{", "s", ".", "closedMu", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "closedMu", ".", "Unlock", "(", ")", "\n", "if", "s", ".", "closed", "{", "return", "nil...
// Close closes the store. If wait is true, waits for a graceful shutdown. // Once closed, a Store may not be re-opened.
[ "Close", "closes", "the", "store", ".", "If", "wait", "is", "true", "waits", "for", "a", "graceful", "shutdown", ".", "Once", "closed", "a", "Store", "may", "not", "be", "re", "-", "opened", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L409-L448
24,906
rqlite/rqlite
store/store.go
WaitForApplied
func (s *Store) WaitForApplied(timeout time.Duration) error { if timeout == 0 { return nil } s.logger.Printf("waiting for up to %s for application of initial logs", timeout) if err := s.WaitForAppliedIndex(s.raft.LastIndex(), timeout); err != nil { return ErrOpenTimeout } return nil }
go
func (s *Store) WaitForApplied(timeout time.Duration) error { if timeout == 0 { return nil } s.logger.Printf("waiting for up to %s for application of initial logs", timeout) if err := s.WaitForAppliedIndex(s.raft.LastIndex(), timeout); err != nil { return ErrOpenTimeout } return nil }
[ "func", "(", "s", "*", "Store", ")", "WaitForApplied", "(", "timeout", "time", ".", "Duration", ")", "error", "{", "if", "timeout", "==", "0", "{", "return", "nil", "\n", "}", "\n", "s", ".", "logger", ".", "Printf", "(", "\"", "\"", ",", "timeout"...
// WaitForApplied waits for all Raft log entries to to be applied to the // underlying database.
[ "WaitForApplied", "waits", "for", "all", "Raft", "log", "entries", "to", "to", "be", "applied", "to", "the", "underlying", "database", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L452-L461
24,907
rqlite/rqlite
store/store.go
State
func (s *Store) State() ClusterState { state := s.raft.State() switch state { case raft.Leader: return Leader case raft.Candidate: return Candidate case raft.Follower: return Follower case raft.Shutdown: return Shutdown default: return Unknown } }
go
func (s *Store) State() ClusterState { state := s.raft.State() switch state { case raft.Leader: return Leader case raft.Candidate: return Candidate case raft.Follower: return Follower case raft.Shutdown: return Shutdown default: return Unknown } }
[ "func", "(", "s", "*", "Store", ")", "State", "(", ")", "ClusterState", "{", "state", ":=", "s", ".", "raft", ".", "State", "(", ")", "\n", "switch", "state", "{", "case", "raft", ".", "Leader", ":", "return", "Leader", "\n", "case", "raft", ".", ...
// State returns the current node's Raft state
[ "State", "returns", "the", "current", "node", "s", "Raft", "state" ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L469-L483
24,908
rqlite/rqlite
store/store.go
Connection
func (s *Store) Connection(id uint64) (*Connection, bool) { s.connsMu.RLock() defer s.connsMu.RUnlock() c, ok := s.conns[id] return c, ok }
go
func (s *Store) Connection(id uint64) (*Connection, bool) { s.connsMu.RLock() defer s.connsMu.RUnlock() c, ok := s.conns[id] return c, ok }
[ "func", "(", "s", "*", "Store", ")", "Connection", "(", "id", "uint64", ")", "(", "*", "Connection", ",", "bool", ")", "{", "s", ".", "connsMu", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "connsMu", ".", "RUnlock", "(", ")", "\n", "c", ",...
// Connection returns the connection for the given ID.
[ "Connection", "returns", "the", "connection", "for", "the", "given", "ID", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L501-L506
24,909
rqlite/rqlite
store/store.go
LeaderID
func (s *Store) LeaderID() (string, error) { addr := s.LeaderAddr() configFuture := s.raft.GetConfiguration() if err := configFuture.Error(); err != nil { s.logger.Printf("failed to get raft configuration: %v", err) return "", err } for _, srv := range configFuture.Configuration().Servers { if srv.Address =...
go
func (s *Store) LeaderID() (string, error) { addr := s.LeaderAddr() configFuture := s.raft.GetConfiguration() if err := configFuture.Error(); err != nil { s.logger.Printf("failed to get raft configuration: %v", err) return "", err } for _, srv := range configFuture.Configuration().Servers { if srv.Address =...
[ "func", "(", "s", "*", "Store", ")", "LeaderID", "(", ")", "(", "string", ",", "error", ")", "{", "addr", ":=", "s", ".", "LeaderAddr", "(", ")", "\n", "configFuture", ":=", "s", ".", "raft", ".", "GetConfiguration", "(", ")", "\n", "if", "err", ...
// LeaderID returns the node ID of the Raft leader. Returns a // blank string if there is no leader, or an error.
[ "LeaderID", "returns", "the", "node", "ID", "of", "the", "Raft", "leader", ".", "Returns", "a", "blank", "string", "if", "there", "is", "no", "leader", "or", "an", "error", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L516-L530
24,910
rqlite/rqlite
store/store.go
Nodes
func (s *Store) Nodes() ([]*Server, error) { f := s.raft.GetConfiguration() if f.Error() != nil { return nil, f.Error() } rs := f.Configuration().Servers servers := make([]*Server, len(rs)) for i := range rs { servers[i] = &Server{ ID: string(rs[i].ID), Addr: string(rs[i].Address), } } sort.Sort...
go
func (s *Store) Nodes() ([]*Server, error) { f := s.raft.GetConfiguration() if f.Error() != nil { return nil, f.Error() } rs := f.Configuration().Servers servers := make([]*Server, len(rs)) for i := range rs { servers[i] = &Server{ ID: string(rs[i].ID), Addr: string(rs[i].Address), } } sort.Sort...
[ "func", "(", "s", "*", "Store", ")", "Nodes", "(", ")", "(", "[", "]", "*", "Server", ",", "error", ")", "{", "f", ":=", "s", ".", "raft", ".", "GetConfiguration", "(", ")", "\n", "if", "f", ".", "Error", "(", ")", "!=", "nil", "{", "return",...
// Nodes returns the slice of nodes in the cluster, sorted by ID ascending.
[ "Nodes", "returns", "the", "slice", "of", "nodes", "in", "the", "cluster", "sorted", "by", "ID", "ascending", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L533-L550
24,911
rqlite/rqlite
store/store.go
WaitForLeader
func (s *Store) WaitForLeader(timeout time.Duration) (string, error) { tck := time.NewTicker(leaderWaitDelay) defer tck.Stop() tmr := time.NewTimer(timeout) defer tmr.Stop() for { select { case <-tck.C: l := s.LeaderAddr() if l != "" { return l, nil } case <-tmr.C: return "", fmt.Errorf("tim...
go
func (s *Store) WaitForLeader(timeout time.Duration) (string, error) { tck := time.NewTicker(leaderWaitDelay) defer tck.Stop() tmr := time.NewTimer(timeout) defer tmr.Stop() for { select { case <-tck.C: l := s.LeaderAddr() if l != "" { return l, nil } case <-tmr.C: return "", fmt.Errorf("tim...
[ "func", "(", "s", "*", "Store", ")", "WaitForLeader", "(", "timeout", "time", ".", "Duration", ")", "(", "string", ",", "error", ")", "{", "tck", ":=", "time", ".", "NewTicker", "(", "leaderWaitDelay", ")", "\n", "defer", "tck", ".", "Stop", "(", ")"...
// WaitForLeader blocks until a leader is detected, or the timeout expires.
[ "WaitForLeader", "blocks", "until", "a", "leader", "is", "detected", "or", "the", "timeout", "expires", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L553-L570
24,912
rqlite/rqlite
store/store.go
WaitForAppliedIndex
func (s *Store) WaitForAppliedIndex(idx uint64, timeout time.Duration) error { tck := time.NewTicker(appliedWaitDelay) defer tck.Stop() tmr := time.NewTimer(timeout) defer tmr.Stop() for { select { case <-tck.C: if s.raft.AppliedIndex() >= idx { return nil } case <-tmr.C: return fmt.Errorf("tim...
go
func (s *Store) WaitForAppliedIndex(idx uint64, timeout time.Duration) error { tck := time.NewTicker(appliedWaitDelay) defer tck.Stop() tmr := time.NewTimer(timeout) defer tmr.Stop() for { select { case <-tck.C: if s.raft.AppliedIndex() >= idx { return nil } case <-tmr.C: return fmt.Errorf("tim...
[ "func", "(", "s", "*", "Store", ")", "WaitForAppliedIndex", "(", "idx", "uint64", ",", "timeout", "time", ".", "Duration", ")", "error", "{", "tck", ":=", "time", ".", "NewTicker", "(", "appliedWaitDelay", ")", "\n", "defer", "tck", ".", "Stop", "(", "...
// WaitForAppliedIndex blocks until a given log index has been applied, // or the timeout expires.
[ "WaitForAppliedIndex", "blocks", "until", "a", "given", "log", "index", "has", "been", "applied", "or", "the", "timeout", "expires", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L574-L590
24,913
rqlite/rqlite
store/store.go
Stats
func (s *Store) Stats() (map[string]interface{}, error) { fkEnabled, err := s.dbConn.FKConstraints() if err != nil { return nil, err } dbStatus := map[string]interface{}{ "dsn": s.dbConf.DSN, "fk_constraints": enabledFromBool(fkEnabled), "version": sdb.DBVersion, } if !s.dbConf.Memory {...
go
func (s *Store) Stats() (map[string]interface{}, error) { fkEnabled, err := s.dbConn.FKConstraints() if err != nil { return nil, err } dbStatus := map[string]interface{}{ "dsn": s.dbConf.DSN, "fk_constraints": enabledFromBool(fkEnabled), "version": sdb.DBVersion, } if !s.dbConf.Memory {...
[ "func", "(", "s", "*", "Store", ")", "Stats", "(", ")", "(", "map", "[", "string", "]", "interface", "{", "}", ",", "error", ")", "{", "fkEnabled", ",", "err", ":=", "s", ".", "dbConn", ".", "FKConstraints", "(", ")", "\n", "if", "err", "!=", "...
// Stats returns stats for the store.
[ "Stats", "returns", "stats", "for", "the", "store", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L593-L669
24,914
rqlite/rqlite
store/store.go
Backup
func (s *Store) Backup(leader bool, fmt BackupFormat, dst io.Writer) error { s.restoreMu.RLock() defer s.restoreMu.RUnlock() if leader && s.raft.State() != raft.Leader { return ErrNotLeader } var err error if fmt == BackupBinary { err = s.database(leader, dst) if err != nil { return err } } else if ...
go
func (s *Store) Backup(leader bool, fmt BackupFormat, dst io.Writer) error { s.restoreMu.RLock() defer s.restoreMu.RUnlock() if leader && s.raft.State() != raft.Leader { return ErrNotLeader } var err error if fmt == BackupBinary { err = s.database(leader, dst) if err != nil { return err } } else if ...
[ "func", "(", "s", "*", "Store", ")", "Backup", "(", "leader", "bool", ",", "fmt", "BackupFormat", ",", "dst", "io", ".", "Writer", ")", "error", "{", "s", ".", "restoreMu", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "restoreMu", ".", "RUnlock...
// Backup writes a snapshot of the underlying database to dst // // If leader is true, this operation is performed with a read consistency // level equivalent to "weak". Otherwise no guarantees are made about the // read consistency level.
[ "Backup", "writes", "a", "snapshot", "of", "the", "underlying", "database", "to", "dst", "If", "leader", "is", "true", "this", "operation", "is", "performed", "with", "a", "read", "consistency", "level", "equivalent", "to", "weak", ".", "Otherwise", "no", "g...
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L676-L699
24,915
rqlite/rqlite
store/store.go
Join
func (s *Store) Join(id, addr string, metadata map[string]string) error { s.logger.Printf("received request to join node at %s", addr) if s.raft.State() != raft.Leader { return ErrNotLeader } configFuture := s.raft.GetConfiguration() if err := configFuture.Error(); err != nil { s.logger.Printf("failed to get ...
go
func (s *Store) Join(id, addr string, metadata map[string]string) error { s.logger.Printf("received request to join node at %s", addr) if s.raft.State() != raft.Leader { return ErrNotLeader } configFuture := s.raft.GetConfiguration() if err := configFuture.Error(); err != nil { s.logger.Printf("failed to get ...
[ "func", "(", "s", "*", "Store", ")", "Join", "(", "id", ",", "addr", "string", ",", "metadata", "map", "[", "string", "]", "string", ")", "error", "{", "s", ".", "logger", ".", "Printf", "(", "\"", "\"", ",", "addr", ")", "\n", "if", "s", ".", ...
// Join joins a node, identified by id and located at addr, to this store. // The node must be ready to respond to Raft communications at that address.
[ "Join", "joins", "a", "node", "identified", "by", "id", "and", "located", "at", "addr", "to", "this", "store", ".", "The", "node", "must", "be", "ready", "to", "respond", "to", "Raft", "communications", "at", "that", "address", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L703-L747
24,916
rqlite/rqlite
store/store.go
Remove
func (s *Store) Remove(id string) error { s.logger.Printf("received request to remove node %s", id) if err := s.remove(id); err != nil { s.logger.Printf("failed to remove node %s: %s", id, err.Error()) return err } s.logger.Printf("node %s removed successfully", id) return nil }
go
func (s *Store) Remove(id string) error { s.logger.Printf("received request to remove node %s", id) if err := s.remove(id); err != nil { s.logger.Printf("failed to remove node %s: %s", id, err.Error()) return err } s.logger.Printf("node %s removed successfully", id) return nil }
[ "func", "(", "s", "*", "Store", ")", "Remove", "(", "id", "string", ")", "error", "{", "s", ".", "logger", ".", "Printf", "(", "\"", "\"", ",", "id", ")", "\n", "if", "err", ":=", "s", ".", "remove", "(", "id", ")", ";", "err", "!=", "nil", ...
// Remove removes a node from the store, specified by ID.
[ "Remove", "removes", "a", "node", "from", "the", "store", "specified", "by", "ID", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L750-L759
24,917
rqlite/rqlite
store/store.go
Metadata
func (s *Store) Metadata(id, key string) string { s.metaMu.RLock() defer s.metaMu.RUnlock() if _, ok := s.meta[id]; !ok { return "" } v, ok := s.meta[id][key] if ok { return v } return "" }
go
func (s *Store) Metadata(id, key string) string { s.metaMu.RLock() defer s.metaMu.RUnlock() if _, ok := s.meta[id]; !ok { return "" } v, ok := s.meta[id][key] if ok { return v } return "" }
[ "func", "(", "s", "*", "Store", ")", "Metadata", "(", "id", ",", "key", "string", ")", "string", "{", "s", ".", "metaMu", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "metaMu", ".", "RUnlock", "(", ")", "\n\n", "if", "_", ",", "ok", ":=", ...
// Metadata returns the value for a given key, for a given node ID.
[ "Metadata", "returns", "the", "value", "for", "a", "given", "key", "for", "a", "given", "node", "ID", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L762-L774
24,918
rqlite/rqlite
store/store.go
SetMetadata
func (s *Store) SetMetadata(md map[string]string) error { return s.setMetadata(s.raftID, md) }
go
func (s *Store) SetMetadata(md map[string]string) error { return s.setMetadata(s.raftID, md) }
[ "func", "(", "s", "*", "Store", ")", "SetMetadata", "(", "md", "map", "[", "string", "]", "string", ")", "error", "{", "return", "s", ".", "setMetadata", "(", "s", ".", "raftID", ",", "md", ")", "\n", "}" ]
// SetMetadata adds the metadata md to any existing metadata for // this node.
[ "SetMetadata", "adds", "the", "metadata", "md", "to", "any", "existing", "metadata", "for", "this", "node", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L778-L780
24,919
rqlite/rqlite
store/store.go
setMetadata
func (s *Store) setMetadata(id string, md map[string]string) error { // Check local data first. if func() bool { s.metaMu.RLock() defer s.metaMu.RUnlock() if _, ok := s.meta[id]; ok { for k, v := range md { if s.meta[id][k] != v { return false } } return true } return false }() { //...
go
func (s *Store) setMetadata(id string, md map[string]string) error { // Check local data first. if func() bool { s.metaMu.RLock() defer s.metaMu.RUnlock() if _, ok := s.meta[id]; ok { for k, v := range md { if s.meta[id][k] != v { return false } } return true } return false }() { //...
[ "func", "(", "s", "*", "Store", ")", "setMetadata", "(", "id", "string", ",", "md", "map", "[", "string", "]", "string", ")", "error", "{", "// Check local data first.", "if", "func", "(", ")", "bool", "{", "s", ".", "metaMu", ".", "RLock", "(", ")",...
// setMetadata adds the metadata md to any existing metadata for // the given node ID.
[ "setMetadata", "adds", "the", "metadata", "md", "to", "any", "existing", "metadata", "for", "the", "given", "node", "ID", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L784-L821
24,920
rqlite/rqlite
store/store.go
disconnect
func (s *Store) disconnect(c *Connection) error { d := &connectionSub{ ConnID: c.ID, } cmd, err := newCommand(disconnect, d) if err != nil { return err } b, err := json.Marshal(cmd) if err != nil { return err } f := s.raft.Apply(b, s.ApplyTimeout) if e := f.(raft.Future); e.Error() != nil { if e.Erro...
go
func (s *Store) disconnect(c *Connection) error { d := &connectionSub{ ConnID: c.ID, } cmd, err := newCommand(disconnect, d) if err != nil { return err } b, err := json.Marshal(cmd) if err != nil { return err } f := s.raft.Apply(b, s.ApplyTimeout) if e := f.(raft.Future); e.Error() != nil { if e.Erro...
[ "func", "(", "s", "*", "Store", ")", "disconnect", "(", "c", "*", "Connection", ")", "error", "{", "d", ":=", "&", "connectionSub", "{", "ConnID", ":", "c", ".", "ID", ",", "}", "\n", "cmd", ",", "err", ":=", "newCommand", "(", "disconnect", ",", ...
// disconnect removes a connection to the database, a connection // which was previously established via Raft consensus.
[ "disconnect", "removes", "a", "connection", "to", "the", "database", "a", "connection", "which", "was", "previously", "established", "via", "Raft", "consensus", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L825-L847
24,921
rqlite/rqlite
store/store.go
execute
func (s *Store) execute(c *Connection, ex *ExecuteRequest) (*ExecuteResponse, error) { if c == nil { s.connsMu.RLock() c = s.conns[defaultConnID] s.connsMu.RUnlock() } c.SetLastUsedNow() start := time.Now() d := &databaseSub{ ConnID: c.ID, Atomic: ex.Atomic, Queries: ex.Queries, Timings: ex.Timin...
go
func (s *Store) execute(c *Connection, ex *ExecuteRequest) (*ExecuteResponse, error) { if c == nil { s.connsMu.RLock() c = s.conns[defaultConnID] s.connsMu.RUnlock() } c.SetLastUsedNow() start := time.Now() d := &databaseSub{ ConnID: c.ID, Atomic: ex.Atomic, Queries: ex.Queries, Timings: ex.Timin...
[ "func", "(", "s", "*", "Store", ")", "execute", "(", "c", "*", "Connection", ",", "ex", "*", "ExecuteRequest", ")", "(", "*", "ExecuteResponse", ",", "error", ")", "{", "if", "c", "==", "nil", "{", "s", ".", "connsMu", ".", "RLock", "(", ")", "\n...
// Execute executes queries that return no rows, but do modify the database. If connection // is nil then the utility connection is used.
[ "Execute", "executes", "queries", "that", "return", "no", "rows", "but", "do", "modify", "the", "database", ".", "If", "connection", "is", "nil", "then", "the", "utility", "connection", "is", "used", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L851-L896
24,922
rqlite/rqlite
store/store.go
query
func (s *Store) query(c *Connection, qr *QueryRequest) (*QueryResponse, error) { if c == nil { s.connsMu.RLock() c = s.conns[defaultConnID] s.connsMu.RUnlock() } c.SetLastUsedNow() s.restoreMu.RLock() defer s.restoreMu.RUnlock() start := time.Now() if qr.Lvl == Strong { d := &databaseSub{ ConnID: c...
go
func (s *Store) query(c *Connection, qr *QueryRequest) (*QueryResponse, error) { if c == nil { s.connsMu.RLock() c = s.conns[defaultConnID] s.connsMu.RUnlock() } c.SetLastUsedNow() s.restoreMu.RLock() defer s.restoreMu.RUnlock() start := time.Now() if qr.Lvl == Strong { d := &databaseSub{ ConnID: c...
[ "func", "(", "s", "*", "Store", ")", "query", "(", "c", "*", "Connection", ",", "qr", "*", "QueryRequest", ")", "(", "*", "QueryResponse", ",", "error", ")", "{", "if", "c", "==", "nil", "{", "s", ".", "connsMu", ".", "RLock", "(", ")", "\n", "...
// Query executes queries that return rows, and do not modify the database. If // connection is nil, then the utility connection is used.
[ "Query", "executes", "queries", "that", "return", "rows", "and", "do", "not", "modify", "the", "database", ".", "If", "connection", "is", "nil", "then", "the", "utility", "connection", "is", "used", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L927-L986
24,923
rqlite/rqlite
store/store.go
createDatabase
func (s *Store) createDatabase() error { var db *sdb.DB var err error if !s.dbConf.Memory { // as it will be rebuilt from (possibly) a snapshot and committed log entries. if err := os.Remove(s.dbPath); err != nil && !os.IsNotExist(err) { return err } db, err = sdb.New(s.dbPath, s.dbConf.DSN, false) if e...
go
func (s *Store) createDatabase() error { var db *sdb.DB var err error if !s.dbConf.Memory { // as it will be rebuilt from (possibly) a snapshot and committed log entries. if err := os.Remove(s.dbPath); err != nil && !os.IsNotExist(err) { return err } db, err = sdb.New(s.dbPath, s.dbConf.DSN, false) if e...
[ "func", "(", "s", "*", "Store", ")", "createDatabase", "(", ")", "error", "{", "var", "db", "*", "sdb", ".", "DB", "\n", "var", "err", "error", "\n", "if", "!", "s", ".", "dbConf", ".", "Memory", "{", "// as it will be rebuilt from (possibly) a snapshot an...
// createDatabase creates the the in-memory or file-based database.
[ "createDatabase", "creates", "the", "the", "in", "-", "memory", "or", "file", "-", "based", "database", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L989-L1011
24,924
rqlite/rqlite
store/store.go
remove
func (s *Store) remove(id string) error { if s.raft.State() != raft.Leader { return ErrNotLeader } f := s.raft.RemoveServer(raft.ServerID(id), 0, 0) if f.Error() != nil { if f.Error() == raft.ErrNotLeader { return ErrNotLeader } return f.Error() } c, err := newCommand(metadataDelete, id) if err != n...
go
func (s *Store) remove(id string) error { if s.raft.State() != raft.Leader { return ErrNotLeader } f := s.raft.RemoveServer(raft.ServerID(id), 0, 0) if f.Error() != nil { if f.Error() == raft.ErrNotLeader { return ErrNotLeader } return f.Error() } c, err := newCommand(metadataDelete, id) if err != n...
[ "func", "(", "s", "*", "Store", ")", "remove", "(", "id", "string", ")", "error", "{", "if", "s", ".", "raft", ".", "State", "(", ")", "!=", "raft", ".", "Leader", "{", "return", "ErrNotLeader", "\n", "}", "\n\n", "f", ":=", "s", ".", "raft", "...
// remove removes the node, with the given ID, from the cluster.
[ "remove", "removes", "the", "node", "with", "the", "given", "ID", "from", "the", "cluster", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L1014-L1044
24,925
rqlite/rqlite
store/store.go
raftConfig
func (s *Store) raftConfig() *raft.Config { config := raft.DefaultConfig() if s.SnapshotThreshold != 0 { config.SnapshotThreshold = s.SnapshotThreshold } if s.SnapshotInterval != 0 { config.SnapshotInterval = s.SnapshotInterval } if s.HeartbeatTimeout != 0 { config.HeartbeatTimeout = s.HeartbeatTimeout } ...
go
func (s *Store) raftConfig() *raft.Config { config := raft.DefaultConfig() if s.SnapshotThreshold != 0 { config.SnapshotThreshold = s.SnapshotThreshold } if s.SnapshotInterval != 0 { config.SnapshotInterval = s.SnapshotInterval } if s.HeartbeatTimeout != 0 { config.HeartbeatTimeout = s.HeartbeatTimeout } ...
[ "func", "(", "s", "*", "Store", ")", "raftConfig", "(", ")", "*", "raft", ".", "Config", "{", "config", ":=", "raft", ".", "DefaultConfig", "(", ")", "\n", "if", "s", ".", "SnapshotThreshold", "!=", "0", "{", "config", ".", "SnapshotThreshold", "=", ...
// raftConfig returns a new Raft config for the store.
[ "raftConfig", "returns", "a", "new", "Raft", "config", "for", "the", "store", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L1047-L1059
24,926
rqlite/rqlite
store/store.go
checkConnections
func (s *Store) checkConnections() { s.wg.Add(1) ticker := time.NewTicker(s.connPollPeriod) go func() { defer s.wg.Done() defer ticker.Stop() for { select { case <-s.done: return case <-ticker.C: // This is not a 100% correct check, but is right almost all // the time, and saves the node f...
go
func (s *Store) checkConnections() { s.wg.Add(1) ticker := time.NewTicker(s.connPollPeriod) go func() { defer s.wg.Done() defer ticker.Stop() for { select { case <-s.done: return case <-ticker.C: // This is not a 100% correct check, but is right almost all // the time, and saves the node f...
[ "func", "(", "s", "*", "Store", ")", "checkConnections", "(", ")", "{", "s", ".", "wg", ".", "Add", "(", "1", ")", "\n", "ticker", ":=", "time", ".", "NewTicker", "(", "s", ".", "connPollPeriod", ")", "\n", "go", "func", "(", ")", "{", "defer", ...
// checkConnections periodically checks which connections should // close due to timeouts.
[ "checkConnections", "periodically", "checks", "which", "connections", "should", "close", "due", "to", "timeouts", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L1063-L1110
24,927
rqlite/rqlite
store/store.go
database
func (s *Store) database(leader bool, dst io.Writer) error { if leader && s.raft.State() != raft.Leader { return ErrNotLeader } f, err := ioutil.TempFile("", "rqlilte-snap-") if err != nil { return err } if err := f.Close(); err != nil { return err } os.Remove(f.Name()) db, err := sdb.New(f.Name(), "", ...
go
func (s *Store) database(leader bool, dst io.Writer) error { if leader && s.raft.State() != raft.Leader { return ErrNotLeader } f, err := ioutil.TempFile("", "rqlilte-snap-") if err != nil { return err } if err := f.Close(); err != nil { return err } os.Remove(f.Name()) db, err := sdb.New(f.Name(), "", ...
[ "func", "(", "s", "*", "Store", ")", "database", "(", "leader", "bool", ",", "dst", "io", ".", "Writer", ")", "error", "{", "if", "leader", "&&", "s", ".", "raft", ".", "State", "(", ")", "!=", "raft", ".", "Leader", "{", "return", "ErrNotLeader", ...
// Database copies contents of the underlying SQLite file to dst
[ "Database", "copies", "contents", "of", "the", "underlying", "SQLite", "file", "to", "dst" ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L1222-L1259
24,928
rqlite/rqlite
store/store.go
Snapshot
func (s *Store) Snapshot() (raft.FSMSnapshot, error) { s.restoreMu.RLock() defer s.restoreMu.RUnlock() // Snapshots are not permitted while any connection has a transaction // in progress, because it's not possible (not without a lot of extra // code anyway) to capture the state of a connection during a transacti...
go
func (s *Store) Snapshot() (raft.FSMSnapshot, error) { s.restoreMu.RLock() defer s.restoreMu.RUnlock() // Snapshots are not permitted while any connection has a transaction // in progress, because it's not possible (not without a lot of extra // code anyway) to capture the state of a connection during a transacti...
[ "func", "(", "s", "*", "Store", ")", "Snapshot", "(", ")", "(", "raft", ".", "FSMSnapshot", ",", "error", ")", "{", "s", ".", "restoreMu", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "restoreMu", ".", "RUnlock", "(", ")", "\n\n", "// Snapshots...
// Snapshot returns a snapshot of the store. The caller must ensure that // no Raft transaction is taking place during this call. Hashicorp Raft // guarantees that this function will not be called concurrently with Apply.
[ "Snapshot", "returns", "a", "snapshot", "of", "the", "store", ".", "The", "caller", "must", "ensure", "that", "no", "Raft", "transaction", "is", "taking", "place", "during", "this", "call", ".", "Hashicorp", "Raft", "guarantees", "that", "this", "function", ...
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L1264-L1315
24,929
rqlite/rqlite
store/store.go
RegisterObserver
func (s *Store) RegisterObserver(o *raft.Observer) { s.raft.RegisterObserver(o) }
go
func (s *Store) RegisterObserver(o *raft.Observer) { s.raft.RegisterObserver(o) }
[ "func", "(", "s", "*", "Store", ")", "RegisterObserver", "(", "o", "*", "raft", ".", "Observer", ")", "{", "s", ".", "raft", ".", "RegisterObserver", "(", "o", ")", "\n", "}" ]
// RegisterObserver registers an observer of Raft events
[ "RegisterObserver", "registers", "an", "observer", "of", "Raft", "events" ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L1410-L1412
24,930
rqlite/rqlite
store/store.go
DeregisterObserver
func (s *Store) DeregisterObserver(o *raft.Observer) { s.raft.DeregisterObserver(o) }
go
func (s *Store) DeregisterObserver(o *raft.Observer) { s.raft.DeregisterObserver(o) }
[ "func", "(", "s", "*", "Store", ")", "DeregisterObserver", "(", "o", "*", "raft", ".", "Observer", ")", "{", "s", ".", "raft", ".", "DeregisterObserver", "(", "o", ")", "\n", "}" ]
// DeregisterObserver deregisters an observer of Raft events
[ "DeregisterObserver", "deregisters", "an", "observer", "of", "Raft", "events" ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L1415-L1417
24,931
rqlite/rqlite
store/store.go
pathExists
func pathExists(p string) bool { if _, err := os.Lstat(p); err != nil && os.IsNotExist(err) { return false } return true }
go
func pathExists(p string) bool { if _, err := os.Lstat(p); err != nil && os.IsNotExist(err) { return false } return true }
[ "func", "pathExists", "(", "p", "string", ")", "bool", "{", "if", "_", ",", "err", ":=", "os", ".", "Lstat", "(", "p", ")", ";", "err", "!=", "nil", "&&", "os", ".", "IsNotExist", "(", "err", ")", "{", "return", "false", "\n", "}", "\n", "retur...
// pathExists returns true if the given path exists.
[ "pathExists", "returns", "true", "if", "the", "given", "path", "exists", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L1473-L1478
24,932
rqlite/rqlite
store/store.go
tempfile
func tempfile() (*os.File, error) { f, err := ioutil.TempFile("", "rqlilte-snap-") if err != nil { return nil, err } return f, nil }
go
func tempfile() (*os.File, error) { f, err := ioutil.TempFile("", "rqlilte-snap-") if err != nil { return nil, err } return f, nil }
[ "func", "tempfile", "(", ")", "(", "*", "os", ".", "File", ",", "error", ")", "{", "f", ",", "err", ":=", "ioutil", ".", "TempFile", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n"...
// tempfile returns a temporary file for use
[ "tempfile", "returns", "a", "temporary", "file", "for", "use" ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L1481-L1487
24,933
rqlite/rqlite
http/service.go
New
func New(addr string, store Store, credentials CredentialStore) *Service { return &Service{ addr: addr, store: store, start: time.Now(), statuses: make(map[string]Statuser), credentialStore: credentials, logger: log.New(os.Stderr, "[http] ", log.LstdFlags), }...
go
func New(addr string, store Store, credentials CredentialStore) *Service { return &Service{ addr: addr, store: store, start: time.Now(), statuses: make(map[string]Statuser), credentialStore: credentials, logger: log.New(os.Stderr, "[http] ", log.LstdFlags), }...
[ "func", "New", "(", "addr", "string", ",", "store", "Store", ",", "credentials", "CredentialStore", ")", "*", "Service", "{", "return", "&", "Service", "{", "addr", ":", "addr", ",", "store", ":", "store", ",", "start", ":", "time", ".", "Now", "(", ...
// New returns an uninitialized HTTP service. If credentials is nil, then // the service performs no authentication and authorization checks.
[ "New", "returns", "an", "uninitialized", "HTTP", "service", ".", "If", "credentials", "is", "nil", "then", "the", "service", "performs", "no", "authentication", "and", "authorization", "checks", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/http/service.go#L190-L199
24,934
rqlite/rqlite
http/service.go
ServeHTTP
func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request) { s.rootHandler.Handler(s).ServeHTTP(w, r) }
go
func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request) { s.rootHandler.Handler(s).ServeHTTP(w, r) }
[ "func", "(", "s", "*", "Service", ")", "ServeHTTP", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "s", ".", "rootHandler", ".", "Handler", "(", "s", ")", ".", "ServeHTTP", "(", "w", ",", "r", ")", "\n",...
// ServeHTTP allows Service to serve HTTP requests.
[ "ServeHTTP", "allows", "Service", "to", "serve", "HTTP", "requests", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/http/service.go#L245-L247
24,935
rqlite/rqlite
http/service.go
RegisterStatus
func (s *Service) RegisterStatus(key string, stat Statuser) error { s.statusMu.Lock() defer s.statusMu.Unlock() if _, ok := s.statuses[key]; ok { return fmt.Errorf("status already registered with key %s", key) } s.statuses[key] = stat return nil }
go
func (s *Service) RegisterStatus(key string, stat Statuser) error { s.statusMu.Lock() defer s.statusMu.Unlock() if _, ok := s.statuses[key]; ok { return fmt.Errorf("status already registered with key %s", key) } s.statuses[key] = stat return nil }
[ "func", "(", "s", "*", "Service", ")", "RegisterStatus", "(", "key", "string", ",", "stat", "Statuser", ")", "error", "{", "s", ".", "statusMu", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "statusMu", ".", "Unlock", "(", ")", "\n\n", "if", "_",...
// RegisterStatus allows other modules to register status for serving over HTTP.
[ "RegisterStatus", "allows", "other", "modules", "to", "register", "status", "for", "serving", "over", "HTTP", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/http/service.go#L250-L260
24,936
rqlite/rqlite
http/service.go
createConnection
func (s *Service) createConnection(w http.ResponseWriter, r *http.Request) { opts := store.ConnectionOptions{ IdleTimeout: s.ConnIdleTimeout, TxTimeout: s.ConnTxTimeout, } d, b, err := txTimeout(r) if err != nil { w.WriteHeader(http.StatusBadRequest) return } if b { opts.TxTimeout = d } d, b, err ...
go
func (s *Service) createConnection(w http.ResponseWriter, r *http.Request) { opts := store.ConnectionOptions{ IdleTimeout: s.ConnIdleTimeout, TxTimeout: s.ConnTxTimeout, } d, b, err := txTimeout(r) if err != nil { w.WriteHeader(http.StatusBadRequest) return } if b { opts.TxTimeout = d } d, b, err ...
[ "func", "(", "s", "*", "Service", ")", "createConnection", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "opts", ":=", "store", ".", "ConnectionOptions", "{", "IdleTimeout", ":", "s", ".", "ConnIdleTimeout", ",...
// createConnection creates a connection and returns its ID.
[ "createConnection", "creates", "a", "connection", "and", "returns", "its", "ID", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/http/service.go#L263-L294
24,937
rqlite/rqlite
http/service.go
deleteConnection
func (s *Service) deleteConnection(id uint64) error { conn, ok := s.store.Connection(id) if !ok { return nil } return conn.Close() }
go
func (s *Service) deleteConnection(id uint64) error { conn, ok := s.store.Connection(id) if !ok { return nil } return conn.Close() }
[ "func", "(", "s", "*", "Service", ")", "deleteConnection", "(", "id", "uint64", ")", "error", "{", "conn", ",", "ok", ":=", "s", ".", "store", ".", "Connection", "(", "id", ")", "\n", "if", "!", "ok", "{", "return", "nil", "\n", "}", "\n", "retur...
// deleteConnection closes a connection and makes it unavailable for // future use.
[ "deleteConnection", "closes", "a", "connection", "and", "makes", "it", "unavailable", "for", "future", "use", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/http/service.go#L298-L304
24,938
rqlite/rqlite
http/service.go
handleJoin
func (s *Service) handleJoin(w http.ResponseWriter, r *http.Request) { b, err := ioutil.ReadAll(r.Body) defer r.Body.Close() if err != nil { w.WriteHeader(http.StatusBadRequest) return } md := map[string]interface{}{} if err := json.Unmarshal(b, &md); err != nil { w.WriteHeader(http.StatusBadRequest) retu...
go
func (s *Service) handleJoin(w http.ResponseWriter, r *http.Request) { b, err := ioutil.ReadAll(r.Body) defer r.Body.Close() if err != nil { w.WriteHeader(http.StatusBadRequest) return } md := map[string]interface{}{} if err := json.Unmarshal(b, &md); err != nil { w.WriteHeader(http.StatusBadRequest) retu...
[ "func", "(", "s", "*", "Service", ")", "handleJoin", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "b", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "r", ".", "Body", ")", "\n", "defer", "r", ".", ...
// handleJoin handles cluster-join requests from other nodes.
[ "handleJoin", "handles", "cluster", "-", "join", "requests", "from", "other", "nodes", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/http/service.go#L307-L356
24,939
rqlite/rqlite
http/service.go
handleRemove
func (s *Service) handleRemove(w http.ResponseWriter, r *http.Request) { b, err := ioutil.ReadAll(r.Body) defer r.Body.Close() if err != nil { w.WriteHeader(http.StatusBadRequest) return } m := map[string]string{} if err := json.Unmarshal(b, &m); err != nil { w.WriteHeader(http.StatusBadRequest) return }...
go
func (s *Service) handleRemove(w http.ResponseWriter, r *http.Request) { b, err := ioutil.ReadAll(r.Body) defer r.Body.Close() if err != nil { w.WriteHeader(http.StatusBadRequest) return } m := map[string]string{} if err := json.Unmarshal(b, &m); err != nil { w.WriteHeader(http.StatusBadRequest) return }...
[ "func", "(", "s", "*", "Service", ")", "handleRemove", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "b", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "r", ".", "Body", ")", "\n", "defer", "r", ".",...
// handleRemove handles cluster-remove requests.
[ "handleRemove", "handles", "cluster", "-", "remove", "requests", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/http/service.go#L359-L399
24,940
rqlite/rqlite
http/service.go
handleBackup
func (s *Service) handleBackup(w http.ResponseWriter, r *http.Request) { noLeader, err := noLeader(r) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } bf, err := backupFormat(w, r) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } err...
go
func (s *Service) handleBackup(w http.ResponseWriter, r *http.Request) { noLeader, err := noLeader(r) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } bf, err := backupFormat(w, r) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } err...
[ "func", "(", "s", "*", "Service", ")", "handleBackup", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "noLeader", ",", "err", ":=", "noLeader", "(", "r", ")", "\n", "if", "err", "!=", "nil", "{", "http", ...
// handleBackup returns the consistent database snapshot.
[ "handleBackup", "returns", "the", "consistent", "database", "snapshot", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/http/service.go#L402-L422
24,941
rqlite/rqlite
http/service.go
handleLoad
func (s *Service) handleLoad(w http.ResponseWriter, r *http.Request) { timings, err := timings(r) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } b, err := ioutil.ReadAll(r.Body) defer r.Body.Close() if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) ret...
go
func (s *Service) handleLoad(w http.ResponseWriter, r *http.Request) { timings, err := timings(r) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } b, err := ioutil.ReadAll(r.Body) defer r.Body.Close() if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) ret...
[ "func", "(", "s", "*", "Service", ")", "handleLoad", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "timings", ",", "err", ":=", "timings", "(", "r", ")", "\n", "if", "err", "!=", "nil", "{", "http", "."...
// handleLoad loads the state contained in a .dump output.
[ "handleLoad", "loads", "the", "state", "contained", "in", "a", ".", "dump", "output", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/http/service.go#L425-L463
24,942
rqlite/rqlite
http/service.go
handleStatus
func (s *Service) handleStatus(w http.ResponseWriter, r *http.Request) { results, err := s.store.Stats() if err != nil { w.WriteHeader(http.StatusInternalServerError) return } rt := map[string]interface{}{ "GOARCH": runtime.GOARCH, "GOOS": runtime.GOOS, "GOMAXPROCS": runtime.GOMAXPROCS...
go
func (s *Service) handleStatus(w http.ResponseWriter, r *http.Request) { results, err := s.store.Stats() if err != nil { w.WriteHeader(http.StatusInternalServerError) return } rt := map[string]interface{}{ "GOARCH": runtime.GOARCH, "GOOS": runtime.GOOS, "GOMAXPROCS": runtime.GOMAXPROCS...
[ "func", "(", "s", "*", "Service", ")", "handleStatus", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "results", ",", "err", ":=", "s", ".", "store", ".", "Stats", "(", ")", "\n", "if", "err", "!=", "nil...
// handleStatus returns status on the system.
[ "handleStatus", "returns", "status", "on", "the", "system", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/http/service.go#L466-L538
24,943
rqlite/rqlite
http/service.go
handleExecute
func (s *Service) handleExecute(connID uint64, w http.ResponseWriter, r *http.Request) { isAtomic, err := isAtomic(r) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } timings, err := timings(r) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) re...
go
func (s *Service) handleExecute(connID uint64, w http.ResponseWriter, r *http.Request) { isAtomic, err := isAtomic(r) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } timings, err := timings(r) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) re...
[ "func", "(", "s", "*", "Service", ")", "handleExecute", "(", "connID", "uint64", ",", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "isAtomic", ",", "err", ":=", "isAtomic", "(", "r", ")", "\n", "if", "err", "...
// handleExecute handles queries that modify the database.
[ "handleExecute", "handles", "queries", "that", "modify", "the", "database", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/http/service.go#L541-L603
24,944
rqlite/rqlite
http/service.go
handleQuery
func (s *Service) handleQuery(connID uint64, w http.ResponseWriter, r *http.Request) { isAtomic, err := isAtomic(r) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } timings, err := timings(r) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) retu...
go
func (s *Service) handleQuery(connID uint64, w http.ResponseWriter, r *http.Request) { isAtomic, err := isAtomic(r) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } timings, err := timings(r) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) retu...
[ "func", "(", "s", "*", "Service", ")", "handleQuery", "(", "connID", "uint64", ",", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "isAtomic", ",", "err", ":=", "isAtomic", "(", "r", ")", "\n", "if", "err", "!=...
// handleQuery handles queries that do not modify the database.
[ "handleQuery", "handles", "queries", "that", "do", "not", "modify", "the", "database", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/http/service.go#L606-L668
24,945
rqlite/rqlite
http/service.go
FormRedirect
func (s *Service) FormRedirect(r *http.Request, host string) string { rq := r.URL.RawQuery if rq != "" { rq = fmt.Sprintf("?%s", rq) } return fmt.Sprintf("%s://%s%s%s", s.protocol(), host, r.URL.Path, rq) }
go
func (s *Service) FormRedirect(r *http.Request, host string) string { rq := r.URL.RawQuery if rq != "" { rq = fmt.Sprintf("?%s", rq) } return fmt.Sprintf("%s://%s%s%s", s.protocol(), host, r.URL.Path, rq) }
[ "func", "(", "s", "*", "Service", ")", "FormRedirect", "(", "r", "*", "http", ".", "Request", ",", "host", "string", ")", "string", "{", "rq", ":=", "r", ".", "URL", ".", "RawQuery", "\n", "if", "rq", "!=", "\"", "\"", "{", "rq", "=", "fmt", "....
// FormRedirect returns the value for the "Location" header for a 301 response.
[ "FormRedirect", "returns", "the", "value", "for", "the", "Location", "header", "for", "a", "301", "response", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/http/service.go#L676-L682
24,946
rqlite/rqlite
http/service.go
FormConnectionURL
func (s *Service) FormConnectionURL(r *http.Request, id uint64) string { return fmt.Sprintf("%s://%s/db/connections/%d", s.protocol(), r.Host, id) }
go
func (s *Service) FormConnectionURL(r *http.Request, id uint64) string { return fmt.Sprintf("%s://%s/db/connections/%d", s.protocol(), r.Host, id) }
[ "func", "(", "s", "*", "Service", ")", "FormConnectionURL", "(", "r", "*", "http", ".", "Request", ",", "id", "uint64", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "s", ".", "protocol", "(", ")", ",", "r", ".", "Hos...
// FormConnectionURL returns the URL of the new connection.
[ "FormConnectionURL", "returns", "the", "URL", "of", "the", "new", "connection", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/http/service.go#L685-L687
24,947
rqlite/rqlite
http/service.go
CheckRequestPerm
func (s *Service) CheckRequestPerm(r *http.Request, perm string) bool { if s.credentialStore == nil { return true } username, _, ok := r.BasicAuth() if !ok { return false } return s.credentialStore.HasAnyPerm(username, perm, PermAll) }
go
func (s *Service) CheckRequestPerm(r *http.Request, perm string) bool { if s.credentialStore == nil { return true } username, _, ok := r.BasicAuth() if !ok { return false } return s.credentialStore.HasAnyPerm(username, perm, PermAll) }
[ "func", "(", "s", "*", "Service", ")", "CheckRequestPerm", "(", "r", "*", "http", ".", "Request", ",", "perm", "string", ")", "bool", "{", "if", "s", ".", "credentialStore", "==", "nil", "{", "return", "true", "\n", "}", "\n\n", "username", ",", "_",...
// CheckRequestPerm returns true if authentication is enabled and the user contained // in the BasicAuth request has either PermAll, or the given perm.
[ "CheckRequestPerm", "returns", "true", "if", "authentication", "is", "enabled", "and", "the", "user", "contained", "in", "the", "BasicAuth", "request", "has", "either", "PermAll", "or", "the", "given", "perm", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/http/service.go#L691-L701
24,948
rqlite/rqlite
http/service.go
addBuildVersion
func (s *Service) addBuildVersion(w http.ResponseWriter) { // Add version header to every response, if available. version := "unknown" if v, ok := s.BuildInfo["version"].(string); ok { version = v } w.Header().Add(VersionHTTPHeader, version) }
go
func (s *Service) addBuildVersion(w http.ResponseWriter) { // Add version header to every response, if available. version := "unknown" if v, ok := s.BuildInfo["version"].(string); ok { version = v } w.Header().Add(VersionHTTPHeader, version) }
[ "func", "(", "s", "*", "Service", ")", "addBuildVersion", "(", "w", "http", ".", "ResponseWriter", ")", "{", "// Add version header to every response, if available.", "version", ":=", "\"", "\"", "\n", "if", "v", ",", "ok", ":=", "s", ".", "BuildInfo", "[", ...
// addBuildVersion adds the build version to the HTTP response.
[ "addBuildVersion", "adds", "the", "build", "version", "to", "the", "HTTP", "response", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/http/service.go#L712-L719
24,949
rqlite/rqlite
http/service.go
queryParam
func queryParam(req *http.Request, param string) (bool, error) { err := req.ParseForm() if err != nil { return false, err } if _, ok := req.Form[param]; ok { return true, nil } return false, nil }
go
func queryParam(req *http.Request, param string) (bool, error) { err := req.ParseForm() if err != nil { return false, err } if _, ok := req.Form[param]; ok { return true, nil } return false, nil }
[ "func", "queryParam", "(", "req", "*", "http", ".", "Request", ",", "param", "string", ")", "(", "bool", ",", "error", ")", "{", "err", ":=", "req", ".", "ParseForm", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "...
// queryParam returns whether the given query param is set to true.
[ "queryParam", "returns", "whether", "the", "given", "query", "param", "is", "set", "to", "true", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/http/service.go#L788-L797
24,950
rqlite/rqlite
http/service.go
durationParam
func durationParam(req *http.Request, param string) (time.Duration, bool, error) { q := req.URL.Query() t := strings.TrimSpace(q.Get(param)) if t == "" { return 0, false, nil } dur, err := time.ParseDuration(t) if err != nil { return 0, false, err } return dur, true, nil }
go
func durationParam(req *http.Request, param string) (time.Duration, bool, error) { q := req.URL.Query() t := strings.TrimSpace(q.Get(param)) if t == "" { return 0, false, nil } dur, err := time.ParseDuration(t) if err != nil { return 0, false, err } return dur, true, nil }
[ "func", "durationParam", "(", "req", "*", "http", ".", "Request", ",", "param", "string", ")", "(", "time", ".", "Duration", ",", "bool", ",", "error", ")", "{", "q", ":=", "req", ".", "URL", ".", "Query", "(", ")", "\n", "t", ":=", "strings", "....
// durationParam returns the duration of the given query param, if set.
[ "durationParam", "returns", "the", "duration", "of", "the", "given", "query", "param", "if", "set", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/http/service.go#L800-L811
24,951
rqlite/rqlite
http/service.go
stmtParam
func stmtParam(req *http.Request) (string, error) { q := req.URL.Query() return strings.TrimSpace(q.Get("q")), nil }
go
func stmtParam(req *http.Request) (string, error) { q := req.URL.Query() return strings.TrimSpace(q.Get("q")), nil }
[ "func", "stmtParam", "(", "req", "*", "http", ".", "Request", ")", "(", "string", ",", "error", ")", "{", "q", ":=", "req", ".", "URL", ".", "Query", "(", ")", "\n", "return", "strings", ".", "TrimSpace", "(", "q", ".", "Get", "(", "\"", "\"", ...
// stmtParam returns the value for URL param 'q', if present.
[ "stmtParam", "returns", "the", "value", "for", "URL", "param", "q", "if", "present", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/http/service.go#L814-L817
24,952
rqlite/rqlite
http/service.go
isAtomic
func isAtomic(req *http.Request) (bool, error) { // "transaction" is checked for backwards compatibility with // client libraries. for _, q := range []string{"atomic", "transaction"} { if a, err := queryParam(req, q); err != nil || a { return a, err } } return false, nil }
go
func isAtomic(req *http.Request) (bool, error) { // "transaction" is checked for backwards compatibility with // client libraries. for _, q := range []string{"atomic", "transaction"} { if a, err := queryParam(req, q); err != nil || a { return a, err } } return false, nil }
[ "func", "isAtomic", "(", "req", "*", "http", ".", "Request", ")", "(", "bool", ",", "error", ")", "{", "// \"transaction\" is checked for backwards compatibility with", "// client libraries.", "for", "_", ",", "q", ":=", "range", "[", "]", "string", "{", "\"", ...
// isAtomic returns whether the HTTP request is an atomic request.
[ "isAtomic", "returns", "whether", "the", "HTTP", "request", "is", "an", "atomic", "request", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/http/service.go#L831-L840
24,953
rqlite/rqlite
http/service.go
txTimeout
func txTimeout(req *http.Request) (time.Duration, bool, error) { return durationParam(req, "tx_timeout") }
go
func txTimeout(req *http.Request) (time.Duration, bool, error) { return durationParam(req, "tx_timeout") }
[ "func", "txTimeout", "(", "req", "*", "http", ".", "Request", ")", "(", "time", ".", "Duration", ",", "bool", ",", "error", ")", "{", "return", "durationParam", "(", "req", ",", "\"", "\"", ")", "\n", "}" ]
// txTimeout returns the duration of any transaction timeout set.
[ "txTimeout", "returns", "the", "duration", "of", "any", "transaction", "timeout", "set", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/http/service.go#L853-L855
24,954
rqlite/rqlite
http/service.go
level
func level(req *http.Request) (store.ConsistencyLevel, error) { q := req.URL.Query() lvl := strings.TrimSpace(q.Get("level")) switch strings.ToLower(lvl) { case "none": return store.None, nil case "weak": return store.Weak, nil case "strong": return store.Strong, nil default: return store.Weak, nil } }
go
func level(req *http.Request) (store.ConsistencyLevel, error) { q := req.URL.Query() lvl := strings.TrimSpace(q.Get("level")) switch strings.ToLower(lvl) { case "none": return store.None, nil case "weak": return store.Weak, nil case "strong": return store.Strong, nil default: return store.Weak, nil } }
[ "func", "level", "(", "req", "*", "http", ".", "Request", ")", "(", "store", ".", "ConsistencyLevel", ",", "error", ")", "{", "q", ":=", "req", ".", "URL", ".", "Query", "(", ")", "\n", "lvl", ":=", "strings", ".", "TrimSpace", "(", "q", ".", "Ge...
// level returns the requested consistency level for a query
[ "level", "returns", "the", "requested", "consistency", "level", "for", "a", "query" ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/http/service.go#L863-L877
24,955
rqlite/rqlite
http/service.go
backupFormat
func backupFormat(w http.ResponseWriter, r *http.Request) (store.BackupFormat, error) { fmt, err := fmtParam(r) if err != nil { return store.BackupBinary, err } if fmt == "sql" { w.Header().Set("Content-Type", "application/sql") return store.BackupSQL, nil } w.Header().Set("Content-Type", "application/octet...
go
func backupFormat(w http.ResponseWriter, r *http.Request) (store.BackupFormat, error) { fmt, err := fmtParam(r) if err != nil { return store.BackupBinary, err } if fmt == "sql" { w.Header().Set("Content-Type", "application/sql") return store.BackupSQL, nil } w.Header().Set("Content-Type", "application/octet...
[ "func", "backupFormat", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "(", "store", ".", "BackupFormat", ",", "error", ")", "{", "fmt", ",", "err", ":=", "fmtParam", "(", "r", ")", "\n", "if", "err", "!=", "ni...
// backuFormat returns the request backup format, setting the response header // accordingly.
[ "backuFormat", "returns", "the", "request", "backup", "format", "setting", "the", "response", "header", "accordingly", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/http/service.go#L881-L892
24,956
rqlite/rqlite
db/db.go
New
func New(path, dsnQuery string, memory bool) (*DB, error) { q, err := url.ParseQuery(dsnQuery) if err != nil { return nil, err } if memory { q.Set("mode", "memory") q.Set("cache", "shared") } if !strings.HasPrefix(path, "file:") { path = fmt.Sprintf("file:%s", path) } var fqdsn string if len(q) > 0 {...
go
func New(path, dsnQuery string, memory bool) (*DB, error) { q, err := url.ParseQuery(dsnQuery) if err != nil { return nil, err } if memory { q.Set("mode", "memory") q.Set("cache", "shared") } if !strings.HasPrefix(path, "file:") { path = fmt.Sprintf("file:%s", path) } var fqdsn string if len(q) > 0 {...
[ "func", "New", "(", "path", ",", "dsnQuery", "string", ",", "memory", "bool", ")", "(", "*", "DB", ",", "error", ")", "{", "q", ",", "err", ":=", "url", ".", "ParseQuery", "(", "dsnQuery", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil"...
// New returns an instance of the database at path. If the database // has already been created and opened, this database will share // the data of that database when connected.
[ "New", "returns", "an", "instance", "of", "the", "database", "at", "path", ".", "If", "the", "database", "has", "already", "been", "created", "and", "opened", "this", "database", "will", "share", "the", "data", "of", "that", "database", "when", "connected", ...
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/db/db.go#L75-L102
24,957
rqlite/rqlite
db/db.go
Connect
func (d *DB) Connect() (*Conn, error) { drv := sqlite3.SQLiteDriver{} c, err := drv.Open(d.fqdsn) if err != nil { return nil, err } return &Conn{ sqlite: c.(*sqlite3.SQLiteConn), }, nil }
go
func (d *DB) Connect() (*Conn, error) { drv := sqlite3.SQLiteDriver{} c, err := drv.Open(d.fqdsn) if err != nil { return nil, err } return &Conn{ sqlite: c.(*sqlite3.SQLiteConn), }, nil }
[ "func", "(", "d", "*", "DB", ")", "Connect", "(", ")", "(", "*", "Conn", ",", "error", ")", "{", "drv", ":=", "sqlite3", ".", "SQLiteDriver", "{", "}", "\n", "c", ",", "err", ":=", "drv", ".", "Open", "(", "d", ".", "fqdsn", ")", "\n", "if", ...
// Connect returns a connection to the database.
[ "Connect", "returns", "a", "connection", "to", "the", "database", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/db/db.go#L105-L115
24,958
rqlite/rqlite
db/db.go
Execute
func (c *Conn) Execute(queries []string, tx, xTime bool) ([]*Result, error) { stats.Add(numExecutions, int64(len(queries))) if tx { stats.Add(numETx, 1) } type Execer interface { Exec(query string, args []driver.Value) (driver.Result, error) } var allResults []*Result err := func() error { var execer Exe...
go
func (c *Conn) Execute(queries []string, tx, xTime bool) ([]*Result, error) { stats.Add(numExecutions, int64(len(queries))) if tx { stats.Add(numETx, 1) } type Execer interface { Exec(query string, args []driver.Value) (driver.Result, error) } var allResults []*Result err := func() error { var execer Exe...
[ "func", "(", "c", "*", "Conn", ")", "Execute", "(", "queries", "[", "]", "string", ",", "tx", ",", "xTime", "bool", ")", "(", "[", "]", "*", "Result", ",", "error", ")", "{", "stats", ".", "Add", "(", "numExecutions", ",", "int64", "(", "len", ...
// Execute executes queries that modify the database.
[ "Execute", "executes", "queries", "that", "modify", "the", "database", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/db/db.go#L139-L239
24,959
rqlite/rqlite
db/db.go
Query
func (c *Conn) Query(queries []string, tx, xTime bool) ([]*Rows, error) { stats.Add(numQueries, int64(len(queries))) if tx { stats.Add(numQTx, 1) } type Queryer interface { Query(query string, args []driver.Value) (driver.Rows, error) } var allRows []*Rows err := func() (err error) { var queryer Queryer ...
go
func (c *Conn) Query(queries []string, tx, xTime bool) ([]*Rows, error) { stats.Add(numQueries, int64(len(queries))) if tx { stats.Add(numQTx, 1) } type Queryer interface { Query(query string, args []driver.Value) (driver.Rows, error) } var allRows []*Rows err := func() (err error) { var queryer Queryer ...
[ "func", "(", "c", "*", "Conn", ")", "Query", "(", "queries", "[", "]", "string", ",", "tx", ",", "xTime", "bool", ")", "(", "[", "]", "*", "Rows", ",", "error", ")", "{", "stats", ".", "Add", "(", "numQueries", ",", "int64", "(", "len", "(", ...
// Query executes queries that return rows, but don't modify the database.
[ "Query", "executes", "queries", "that", "return", "rows", "but", "don", "t", "modify", "the", "database", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/db/db.go#L242-L320
24,960
rqlite/rqlite
db/db.go
EnableFKConstraints
func (c *Conn) EnableFKConstraints(e bool) error { q := fkChecksEnabled if !e { q = fkChecksDisabled } _, err := c.sqlite.Exec(q, nil) return err }
go
func (c *Conn) EnableFKConstraints(e bool) error { q := fkChecksEnabled if !e { q = fkChecksDisabled } _, err := c.sqlite.Exec(q, nil) return err }
[ "func", "(", "c", "*", "Conn", ")", "EnableFKConstraints", "(", "e", "bool", ")", "error", "{", "q", ":=", "fkChecksEnabled", "\n", "if", "!", "e", "{", "q", "=", "fkChecksDisabled", "\n", "}", "\n", "_", ",", "err", ":=", "c", ".", "sqlite", ".", ...
// EnableFKConstraints allows control of foreign key constraint checks.
[ "EnableFKConstraints", "allows", "control", "of", "foreign", "key", "constraint", "checks", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/db/db.go#L323-L330
24,961
rqlite/rqlite
db/db.go
FKConstraints
func (c *Conn) FKConstraints() (bool, error) { r, err := c.sqlite.Query(fkChecks, nil) if err != nil { return false, err } dest := make([]driver.Value, len(r.Columns())) types := r.(*sqlite3.SQLiteRows).DeclTypes() if err := r.Next(dest); err != nil { return false, err } values := normalizeRowValues(dest,...
go
func (c *Conn) FKConstraints() (bool, error) { r, err := c.sqlite.Query(fkChecks, nil) if err != nil { return false, err } dest := make([]driver.Value, len(r.Columns())) types := r.(*sqlite3.SQLiteRows).DeclTypes() if err := r.Next(dest); err != nil { return false, err } values := normalizeRowValues(dest,...
[ "func", "(", "c", "*", "Conn", ")", "FKConstraints", "(", ")", "(", "bool", ",", "error", ")", "{", "r", ",", "err", ":=", "c", ".", "sqlite", ".", "Query", "(", "fkChecks", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false...
// FKConstraints returns whether FK constraints are set or not.
[ "FKConstraints", "returns", "whether", "FK", "constraints", "are", "set", "or", "not", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/db/db.go#L333-L350
24,962
rqlite/rqlite
db/db.go
Load
func (c *Conn) Load(src *Conn) error { return copyDatabase(c.sqlite, src.sqlite) }
go
func (c *Conn) Load(src *Conn) error { return copyDatabase(c.sqlite, src.sqlite) }
[ "func", "(", "c", "*", "Conn", ")", "Load", "(", "src", "*", "Conn", ")", "error", "{", "return", "copyDatabase", "(", "c", ".", "sqlite", ",", "src", ".", "sqlite", ")", "\n", "}" ]
// Load loads the connected database from the database connected to src. // It overwrites the data contained in this database. It is the caller's // responsibility to ensure that no other connections to this database // are accessed while this operation is in progress.
[ "Load", "loads", "the", "connected", "database", "from", "the", "database", "connected", "to", "src", ".", "It", "overwrites", "the", "data", "contained", "in", "this", "database", ".", "It", "is", "the", "caller", "s", "responsibility", "to", "ensure", "tha...
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/db/db.go#L356-L358
24,963
rqlite/rqlite
db/db.go
Backup
func (c *Conn) Backup(dst *Conn) error { return copyDatabase(dst.sqlite, c.sqlite) }
go
func (c *Conn) Backup(dst *Conn) error { return copyDatabase(dst.sqlite, c.sqlite) }
[ "func", "(", "c", "*", "Conn", ")", "Backup", "(", "dst", "*", "Conn", ")", "error", "{", "return", "copyDatabase", "(", "dst", ".", "sqlite", ",", "c", ".", "sqlite", ")", "\n", "}" ]
// Backup writes a snapshot of the database over the given database // connection, erasing all the contents of the destination database. // The consistency of the snapshot is READ_COMMITTED relative to any // other connections currently open to this database. The caller must // ensure that all connections to the destin...
[ "Backup", "writes", "a", "snapshot", "of", "the", "database", "over", "the", "given", "database", "connection", "erasing", "all", "the", "contents", "of", "the", "destination", "database", ".", "The", "consistency", "of", "the", "snapshot", "is", "READ_COMMITTED...
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/db/db.go#L366-L368
24,964
rqlite/rqlite
db/db.go
Dump
func (c *Conn) Dump(w io.Writer) error { if _, err := w.Write([]byte("PRAGMA foreign_keys=OFF;\nBEGIN TRANSACTION;\n")); err != nil { return err } // Get the schema. query := `SELECT "name", "type", "sql" FROM "sqlite_master" WHERE "sql" NOT NULL AND "type" == 'table' ORDER BY "name"` rows, err :=...
go
func (c *Conn) Dump(w io.Writer) error { if _, err := w.Write([]byte("PRAGMA foreign_keys=OFF;\nBEGIN TRANSACTION;\n")); err != nil { return err } // Get the schema. query := `SELECT "name", "type", "sql" FROM "sqlite_master" WHERE "sql" NOT NULL AND "type" == 'table' ORDER BY "name"` rows, err :=...
[ "func", "(", "c", "*", "Conn", ")", "Dump", "(", "w", "io", ".", "Writer", ")", "error", "{", "if", "_", ",", "err", ":=", "w", ".", "Write", "(", "[", "]", "byte", "(", "\"", "\\n", "\\n", "\"", ")", ")", ";", "err", "!=", "nil", "{", "r...
// Dump writes a snapshot of the database in SQL text format. The consistency // of the snapshot is READ_COMMITTED relative to any other connections // currently open to this database.
[ "Dump", "writes", "a", "snapshot", "of", "the", "database", "in", "SQL", "text", "format", ".", "The", "consistency", "of", "the", "snapshot", "is", "READ_COMMITTED", "relative", "to", "any", "other", "connections", "currently", "open", "to", "this", "database...
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/db/db.go#L373-L450
24,965
rqlite/rqlite
cmd/rqlite/main.go
cliJSON
func cliJSON(ctx *cli.Context, cmd, line, url string, argv *argT) error { // Recursive JSON printer. var pprint func(indent int, m map[string]interface{}) pprint = func(indent int, m map[string]interface{}) { indentation := " " for k, v := range m { if v == nil { continue } switch v.(type) { cas...
go
func cliJSON(ctx *cli.Context, cmd, line, url string, argv *argT) error { // Recursive JSON printer. var pprint func(indent int, m map[string]interface{}) pprint = func(indent int, m map[string]interface{}) { indentation := " " for k, v := range m { if v == nil { continue } switch v.(type) { cas...
[ "func", "cliJSON", "(", "ctx", "*", "cli", ".", "Context", ",", "cmd", ",", "line", ",", "url", "string", ",", "argv", "*", "argT", ")", "error", "{", "// Recursive JSON printer.", "var", "pprint", "func", "(", "indent", "int", ",", "m", "map", "[", ...
// cliJSON fetches JSON from a URL, and displays it at the CLI.
[ "cliJSON", "fetches", "JSON", "from", "a", "URL", "and", "displays", "it", "at", "the", "CLI", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/cmd/rqlite/main.go#L233-L289
24,966
rqlite/rqlite
disco/client.go
New
func New(url string) *Client { return &Client{ url: url, logger: log.New(os.Stderr, "[discovery] ", log.LstdFlags), } }
go
func New(url string) *Client { return &Client{ url: url, logger: log.New(os.Stderr, "[discovery] ", log.LstdFlags), } }
[ "func", "New", "(", "url", "string", ")", "*", "Client", "{", "return", "&", "Client", "{", "url", ":", "url", ",", "logger", ":", "log", ".", "New", "(", "os", ".", "Stderr", ",", "\"", "\"", ",", "log", ".", "LstdFlags", ")", ",", "}", "\n", ...
// New returns an initialized Discovery Service client.
[ "New", "returns", "an", "initialized", "Discovery", "Service", "client", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/disco/client.go#L29-L34
24,967
rqlite/rqlite
disco/client.go
Register
func (c *Client) Register(id, addr string) (*Response, error) { m := map[string]string{ "addr": addr, } url := c.registrationURL(c.url, id) client := &http.Client{} client.CheckRedirect = func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse } for { b, err := json.Marshal(m)...
go
func (c *Client) Register(id, addr string) (*Response, error) { m := map[string]string{ "addr": addr, } url := c.registrationURL(c.url, id) client := &http.Client{} client.CheckRedirect = func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse } for { b, err := json.Marshal(m)...
[ "func", "(", "c", "*", "Client", ")", "Register", "(", "id", ",", "addr", "string", ")", "(", "*", "Response", ",", "error", ")", "{", "m", ":=", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "addr", ",", "}", "\n\n", "url", ":=", ...
// Register attempts to register with the Discovery Service, using the given // address.
[ "Register", "attempts", "to", "register", "with", "the", "Discovery", "Service", "using", "the", "given", "address", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/disco/client.go#L43-L88
24,968
rqlite/rqlite
cmd/rqlited/main.go
startProfile
func startProfile(cpuprofile, memprofile string) { if cpuprofile != "" { f, err := os.Create(cpuprofile) if err != nil { log.Fatalf("failed to create CPU profile file at %s: %s", cpuprofile, err.Error()) } log.Printf("writing CPU profile to: %s\n", cpuprofile) prof.cpu = f pprof.StartCPUProfile(prof.cpu...
go
func startProfile(cpuprofile, memprofile string) { if cpuprofile != "" { f, err := os.Create(cpuprofile) if err != nil { log.Fatalf("failed to create CPU profile file at %s: %s", cpuprofile, err.Error()) } log.Printf("writing CPU profile to: %s\n", cpuprofile) prof.cpu = f pprof.StartCPUProfile(prof.cpu...
[ "func", "startProfile", "(", "cpuprofile", ",", "memprofile", "string", ")", "{", "if", "cpuprofile", "!=", "\"", "\"", "{", "f", ",", "err", ":=", "os", ".", "Create", "(", "cpuprofile", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Fatalf"...
// startProfile initializes the CPU and memory profile, if specified.
[ "startProfile", "initializes", "the", "CPU", "and", "memory", "profile", "if", "specified", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/cmd/rqlited/main.go#L374-L394
24,969
rqlite/rqlite
cmd/rqlited/main.go
stopProfile
func stopProfile() { if prof.cpu != nil { pprof.StopCPUProfile() prof.cpu.Close() log.Println("CPU profiling stopped") } if prof.mem != nil { pprof.Lookup("heap").WriteTo(prof.mem, 0) prof.mem.Close() log.Println("memory profiling stopped") } }
go
func stopProfile() { if prof.cpu != nil { pprof.StopCPUProfile() prof.cpu.Close() log.Println("CPU profiling stopped") } if prof.mem != nil { pprof.Lookup("heap").WriteTo(prof.mem, 0) prof.mem.Close() log.Println("memory profiling stopped") } }
[ "func", "stopProfile", "(", ")", "{", "if", "prof", ".", "cpu", "!=", "nil", "{", "pprof", ".", "StopCPUProfile", "(", ")", "\n", "prof", ".", "cpu", ".", "Close", "(", ")", "\n", "log", ".", "Println", "(", "\"", "\"", ")", "\n", "}", "\n", "i...
// stopProfile closes the CPU and memory profiles if they are running.
[ "stopProfile", "closes", "the", "CPU", "and", "memory", "profiles", "if", "they", "are", "running", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/cmd/rqlited/main.go#L397-L408
24,970
rqlite/rqlite
cluster/join.go
Join
func Join(joinAddr []string, id, addr string, meta map[string]string, skip bool) (string, error) { var err error var j string logger := log.New(os.Stderr, "[cluster-join] ", log.LstdFlags) for i := 0; i < numAttempts; i++ { for _, a := range joinAddr { j, err = join(a, id, addr, meta, skip) if err == nil {...
go
func Join(joinAddr []string, id, addr string, meta map[string]string, skip bool) (string, error) { var err error var j string logger := log.New(os.Stderr, "[cluster-join] ", log.LstdFlags) for i := 0; i < numAttempts; i++ { for _, a := range joinAddr { j, err = join(a, id, addr, meta, skip) if err == nil {...
[ "func", "Join", "(", "joinAddr", "[", "]", "string", ",", "id", ",", "addr", "string", ",", "meta", "map", "[", "string", "]", "string", ",", "skip", "bool", ")", "(", "string", ",", "error", ")", "{", "var", "err", "error", "\n", "var", "j", "st...
// Join attempts to join the cluster at one of the addresses given in joinAddr. // It walks through joinAddr in order, and sets the node ID and Raft address of // the joining node as id addr respectively. It returns the endpoint // successfully used to join the cluster.
[ "Join", "attempts", "to", "join", "the", "cluster", "at", "one", "of", "the", "addresses", "given", "in", "joinAddr", ".", "It", "walks", "through", "joinAddr", "in", "order", "and", "sets", "the", "node", "ID", "and", "Raft", "address", "of", "the", "jo...
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/cluster/join.go#L25-L43
24,971
rqlite/rqlite
cmd/rqlite/query.go
Get
func (r *Rows) Get(i, j int) string { if i == 0 { if j >= len(r.Columns) { return "" } return r.Columns[j] } if r.Values == nil { return "NULL" } if i-1 >= len(r.Values) { return "NULL" } if j >= len(r.Values[i-1]) { return "NULL" } return fmt.Sprintf("%v", r.Values[i-1][j]) }
go
func (r *Rows) Get(i, j int) string { if i == 0 { if j >= len(r.Columns) { return "" } return r.Columns[j] } if r.Values == nil { return "NULL" } if i-1 >= len(r.Values) { return "NULL" } if j >= len(r.Values[i-1]) { return "NULL" } return fmt.Sprintf("%v", r.Values[i-1][j]) }
[ "func", "(", "r", "*", "Rows", ")", "Get", "(", "i", ",", "j", "int", ")", "string", "{", "if", "i", "==", "0", "{", "if", "j", ">=", "len", "(", "r", ".", "Columns", ")", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "r", ".", "C...
// Get implements textutil.Table interface
[ "Get", "implements", "textutil", ".", "Table", "interface" ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/cmd/rqlite/query.go#L33-L52
24,972
rqlite/rqlite
auth/credential_store.go
NewCredentialsStore
func NewCredentialsStore() *CredentialsStore { return &CredentialsStore{ store: make(map[string]string), perms: make(map[string]map[string]bool), } }
go
func NewCredentialsStore() *CredentialsStore { return &CredentialsStore{ store: make(map[string]string), perms: make(map[string]map[string]bool), } }
[ "func", "NewCredentialsStore", "(", ")", "*", "CredentialsStore", "{", "return", "&", "CredentialsStore", "{", "store", ":", "make", "(", "map", "[", "string", "]", "string", ")", ",", "perms", ":", "make", "(", "map", "[", "string", "]", "map", "[", "...
// NewCredentialsStore returns a new instance of a CredentialStore.
[ "NewCredentialsStore", "returns", "a", "new", "instance", "of", "a", "CredentialStore", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/auth/credential_store.go#L31-L36
24,973
rqlite/rqlite
auth/credential_store.go
Load
func (c *CredentialsStore) Load(r io.Reader) error { dec := json.NewDecoder(r) // Read open bracket _, err := dec.Token() if err != nil { return err } var cred Credential for dec.More() { err := dec.Decode(&cred) if err != nil { return err } c.store[cred.Username] = cred.Password c.perms[cred.Use...
go
func (c *CredentialsStore) Load(r io.Reader) error { dec := json.NewDecoder(r) // Read open bracket _, err := dec.Token() if err != nil { return err } var cred Credential for dec.More() { err := dec.Decode(&cred) if err != nil { return err } c.store[cred.Username] = cred.Password c.perms[cred.Use...
[ "func", "(", "c", "*", "CredentialsStore", ")", "Load", "(", "r", "io", ".", "Reader", ")", "error", "{", "dec", ":=", "json", ".", "NewDecoder", "(", "r", ")", "\n", "// Read open bracket", "_", ",", "err", ":=", "dec", ".", "Token", "(", ")", "\n...
// Load loads credential information from a reader.
[ "Load", "loads", "credential", "information", "from", "a", "reader", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/auth/credential_store.go#L39-L67
24,974
rqlite/rqlite
auth/credential_store.go
Check
func (c *CredentialsStore) Check(username, password string) bool { pw, ok := c.store[username] if !ok { return false } return password == pw || bcrypt.CompareHashAndPassword([]byte(pw), []byte(password)) == nil }
go
func (c *CredentialsStore) Check(username, password string) bool { pw, ok := c.store[username] if !ok { return false } return password == pw || bcrypt.CompareHashAndPassword([]byte(pw), []byte(password)) == nil }
[ "func", "(", "c", "*", "CredentialsStore", ")", "Check", "(", "username", ",", "password", "string", ")", "bool", "{", "pw", ",", "ok", ":=", "c", ".", "store", "[", "username", "]", "\n", "if", "!", "ok", "{", "return", "false", "\n", "}", "\n", ...
// Check returns true if the password is correct for the given username.
[ "Check", "returns", "true", "if", "the", "password", "is", "correct", "for", "the", "given", "username", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/auth/credential_store.go#L70-L77
24,975
rqlite/rqlite
auth/credential_store.go
CheckRequest
func (c *CredentialsStore) CheckRequest(b BasicAuther) bool { username, password, ok := b.BasicAuth() if !ok || !c.Check(username, password) { return false } return true }
go
func (c *CredentialsStore) CheckRequest(b BasicAuther) bool { username, password, ok := b.BasicAuth() if !ok || !c.Check(username, password) { return false } return true }
[ "func", "(", "c", "*", "CredentialsStore", ")", "CheckRequest", "(", "b", "BasicAuther", ")", "bool", "{", "username", ",", "password", ",", "ok", ":=", "b", ".", "BasicAuth", "(", ")", "\n", "if", "!", "ok", "||", "!", "c", ".", "Check", "(", "use...
// CheckRequest returns true if b contains a valid username and password.
[ "CheckRequest", "returns", "true", "if", "b", "contains", "a", "valid", "username", "and", "password", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/auth/credential_store.go#L80-L86
24,976
rqlite/rqlite
auth/credential_store.go
HasPerm
func (c *CredentialsStore) HasPerm(username string, perm string) bool { m, ok := c.perms[username] if !ok { return false } if _, ok := m[perm]; !ok { return false } return true }
go
func (c *CredentialsStore) HasPerm(username string, perm string) bool { m, ok := c.perms[username] if !ok { return false } if _, ok := m[perm]; !ok { return false } return true }
[ "func", "(", "c", "*", "CredentialsStore", ")", "HasPerm", "(", "username", "string", ",", "perm", "string", ")", "bool", "{", "m", ",", "ok", ":=", "c", ".", "perms", "[", "username", "]", "\n", "if", "!", "ok", "{", "return", "false", "\n", "}", ...
// HasPerm returns true if username has the given perm. It does not // perform any password checking.
[ "HasPerm", "returns", "true", "if", "username", "has", "the", "given", "perm", ".", "It", "does", "not", "perform", "any", "password", "checking", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/auth/credential_store.go#L90-L100
24,977
rqlite/rqlite
auth/credential_store.go
HasAnyPerm
func (c *CredentialsStore) HasAnyPerm(username string, perm ...string) bool { return func(p []string) bool { for i := range p { if c.HasPerm(username, p[i]) { return true } } return false }(perm) }
go
func (c *CredentialsStore) HasAnyPerm(username string, perm ...string) bool { return func(p []string) bool { for i := range p { if c.HasPerm(username, p[i]) { return true } } return false }(perm) }
[ "func", "(", "c", "*", "CredentialsStore", ")", "HasAnyPerm", "(", "username", "string", ",", "perm", "...", "string", ")", "bool", "{", "return", "func", "(", "p", "[", "]", "string", ")", "bool", "{", "for", "i", ":=", "range", "p", "{", "if", "c...
// HasAnyPerm returns true if username has at least one of the given perms. // It does not perform any password checking.
[ "HasAnyPerm", "returns", "true", "if", "username", "has", "at", "least", "one", "of", "the", "given", "perms", ".", "It", "does", "not", "perform", "any", "password", "checking", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/auth/credential_store.go#L104-L113
24,978
rqlite/rqlite
auth/credential_store.go
HasPermRequest
func (c *CredentialsStore) HasPermRequest(b BasicAuther, perm string) bool { username, _, ok := b.BasicAuth() if !ok { return false } return c.HasPerm(username, perm) }
go
func (c *CredentialsStore) HasPermRequest(b BasicAuther, perm string) bool { username, _, ok := b.BasicAuth() if !ok { return false } return c.HasPerm(username, perm) }
[ "func", "(", "c", "*", "CredentialsStore", ")", "HasPermRequest", "(", "b", "BasicAuther", ",", "perm", "string", ")", "bool", "{", "username", ",", "_", ",", "ok", ":=", "b", ".", "BasicAuth", "(", ")", "\n", "if", "!", "ok", "{", "return", "false",...
// HasPermRequest returns true if the username returned by b has the givem perm. // It does not perform any password checking, but if there is no username // in the request, it returns false.
[ "HasPermRequest", "returns", "true", "if", "the", "username", "returned", "by", "b", "has", "the", "givem", "perm", ".", "It", "does", "not", "perform", "any", "password", "checking", "but", "if", "there", "is", "no", "username", "in", "the", "request", "i...
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/auth/credential_store.go#L118-L124
24,979
rqlite/rqlite
store/connection.go
NewConnection
func NewConnection(c *sdb.Conn, s *Store, id uint64, it, tt time.Duration) *Connection { now := time.Now() conn := Connection{ db: c, store: s, ID: id, CreatedAt: now, LastUsedAt: now, IdleTimeout: it, TxTimeout: tt, logger: log.New(os.Stderr, connectionLogPrefix(id),...
go
func NewConnection(c *sdb.Conn, s *Store, id uint64, it, tt time.Duration) *Connection { now := time.Now() conn := Connection{ db: c, store: s, ID: id, CreatedAt: now, LastUsedAt: now, IdleTimeout: it, TxTimeout: tt, logger: log.New(os.Stderr, connectionLogPrefix(id),...
[ "func", "NewConnection", "(", "c", "*", "sdb", ".", "Conn", ",", "s", "*", "Store", ",", "id", "uint64", ",", "it", ",", "tt", "time", ".", "Duration", ")", "*", "Connection", "{", "now", ":=", "time", ".", "Now", "(", ")", "\n", "conn", ":=", ...
// NewConnection returns a connection to the database.
[ "NewConnection", "returns", "a", "connection", "to", "the", "database", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/connection.go#L41-L54
24,980
rqlite/rqlite
store/connection.go
Restore
func (c *Connection) Restore(dbConn *sdb.Conn, s *Store) { c.dbMu.Lock() defer c.dbMu.Unlock() c.db = dbConn c.store = s c.logger = log.New(os.Stderr, connectionLogPrefix(c.ID), log.LstdFlags) }
go
func (c *Connection) Restore(dbConn *sdb.Conn, s *Store) { c.dbMu.Lock() defer c.dbMu.Unlock() c.db = dbConn c.store = s c.logger = log.New(os.Stderr, connectionLogPrefix(c.ID), log.LstdFlags) }
[ "func", "(", "c", "*", "Connection", ")", "Restore", "(", "dbConn", "*", "sdb", ".", "Conn", ",", "s", "*", "Store", ")", "{", "c", ".", "dbMu", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "dbMu", ".", "Unlock", "(", ")", "\n", "c", ".", ...
// Restore prepares a partially ready connection.
[ "Restore", "prepares", "a", "partially", "ready", "connection", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/connection.go#L57-L63
24,981
rqlite/rqlite
store/connection.go
SetLastUsedNow
func (c *Connection) SetLastUsedNow() { c.timeMu.Lock() defer c.timeMu.Unlock() c.LastUsedAt = time.Now() }
go
func (c *Connection) SetLastUsedNow() { c.timeMu.Lock() defer c.timeMu.Unlock() c.LastUsedAt = time.Now() }
[ "func", "(", "c", "*", "Connection", ")", "SetLastUsedNow", "(", ")", "{", "c", ".", "timeMu", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "timeMu", ".", "Unlock", "(", ")", "\n", "c", ".", "LastUsedAt", "=", "time", ".", "Now", "(", ")", "...
// SetLastUsedNow marks the connection as being used now.
[ "SetLastUsedNow", "marks", "the", "connection", "as", "being", "used", "now", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/connection.go#L66-L70
24,982
rqlite/rqlite
store/connection.go
TransactionActive
func (c *Connection) TransactionActive() bool { c.dbMu.RLock() defer c.dbMu.RUnlock() if c.db == nil { return false } return c.db.TransactionActive() }
go
func (c *Connection) TransactionActive() bool { c.dbMu.RLock() defer c.dbMu.RUnlock() if c.db == nil { return false } return c.db.TransactionActive() }
[ "func", "(", "c", "*", "Connection", ")", "TransactionActive", "(", ")", "bool", "{", "c", ".", "dbMu", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "dbMu", ".", "RUnlock", "(", ")", "\n", "if", "c", ".", "db", "==", "nil", "{", "return", "...
// TransactionActive returns whether a transaction is active on the connection.
[ "TransactionActive", "returns", "whether", "a", "transaction", "is", "active", "on", "the", "connection", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/connection.go#L78-L85
24,983
rqlite/rqlite
store/connection.go
Execute
func (c *Connection) Execute(ex *ExecuteRequest) (*ExecuteResponse, error) { c.dbMu.RLock() defer c.dbMu.RUnlock() if c.db == nil { return nil, ErrConnectionDoesNotExist } return c.store.execute(c, ex) }
go
func (c *Connection) Execute(ex *ExecuteRequest) (*ExecuteResponse, error) { c.dbMu.RLock() defer c.dbMu.RUnlock() if c.db == nil { return nil, ErrConnectionDoesNotExist } return c.store.execute(c, ex) }
[ "func", "(", "c", "*", "Connection", ")", "Execute", "(", "ex", "*", "ExecuteRequest", ")", "(", "*", "ExecuteResponse", ",", "error", ")", "{", "c", ".", "dbMu", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "dbMu", ".", "RUnlock", "(", ")", ...
// Execute executes queries that return no rows, but do modify the database.
[ "Execute", "executes", "queries", "that", "return", "no", "rows", "but", "do", "modify", "the", "database", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/connection.go#L88-L95
24,984
rqlite/rqlite
store/connection.go
ExecuteOrAbort
func (c *Connection) ExecuteOrAbort(ex *ExecuteRequest) (resp *ExecuteResponse, retErr error) { c.dbMu.RLock() defer c.dbMu.RUnlock() if c.db == nil { return nil, ErrConnectionDoesNotExist } return c.store.executeOrAbort(c, ex) }
go
func (c *Connection) ExecuteOrAbort(ex *ExecuteRequest) (resp *ExecuteResponse, retErr error) { c.dbMu.RLock() defer c.dbMu.RUnlock() if c.db == nil { return nil, ErrConnectionDoesNotExist } return c.store.executeOrAbort(c, ex) }
[ "func", "(", "c", "*", "Connection", ")", "ExecuteOrAbort", "(", "ex", "*", "ExecuteRequest", ")", "(", "resp", "*", "ExecuteResponse", ",", "retErr", "error", ")", "{", "c", ".", "dbMu", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "dbMu", ".", ...
// ExecuteOrAbort executes the requests, but aborts any active transaction // on the underlying database in the case of any error.
[ "ExecuteOrAbort", "executes", "the", "requests", "but", "aborts", "any", "active", "transaction", "on", "the", "underlying", "database", "in", "the", "case", "of", "any", "error", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/connection.go#L99-L106
24,985
rqlite/rqlite
store/connection.go
Query
func (c *Connection) Query(qr *QueryRequest) (*QueryResponse, error) { c.dbMu.RLock() defer c.dbMu.RUnlock() if c.db == nil { return nil, ErrConnectionDoesNotExist } return c.store.query(c, qr) }
go
func (c *Connection) Query(qr *QueryRequest) (*QueryResponse, error) { c.dbMu.RLock() defer c.dbMu.RUnlock() if c.db == nil { return nil, ErrConnectionDoesNotExist } return c.store.query(c, qr) }
[ "func", "(", "c", "*", "Connection", ")", "Query", "(", "qr", "*", "QueryRequest", ")", "(", "*", "QueryResponse", ",", "error", ")", "{", "c", ".", "dbMu", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "dbMu", ".", "RUnlock", "(", ")", "\n", ...
// Query executes queries that return rows, and do not modify the database.
[ "Query", "executes", "queries", "that", "return", "rows", "and", "do", "not", "modify", "the", "database", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/connection.go#L109-L116
24,986
rqlite/rqlite
store/connection.go
Close
func (c *Connection) Close() error { c.dbMu.Lock() defer c.dbMu.Unlock() if c.store != nil { if err := c.store.disconnect(c); err != nil { return err } } if c.db == nil { return nil } if err := c.db.Close(); err != nil { return err } c.db = nil return nil }
go
func (c *Connection) Close() error { c.dbMu.Lock() defer c.dbMu.Unlock() if c.store != nil { if err := c.store.disconnect(c); err != nil { return err } } if c.db == nil { return nil } if err := c.db.Close(); err != nil { return err } c.db = nil return nil }
[ "func", "(", "c", "*", "Connection", ")", "Close", "(", ")", "error", "{", "c", ".", "dbMu", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "dbMu", ".", "Unlock", "(", ")", "\n\n", "if", "c", ".", "store", "!=", "nil", "{", "if", "err", ":="...
// Close closes the connection via consensus.
[ "Close", "closes", "the", "connection", "via", "consensus", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/connection.go#L133-L151
24,987
rqlite/rqlite
store/connection.go
Stats
func (c *Connection) Stats() (interface{}, error) { c.dbMu.RLock() defer c.dbMu.RUnlock() c.timeMu.Lock() defer c.timeMu.Unlock() c.txStateMu.Lock() defer c.txStateMu.Unlock() fkEnabled, err := c.db.FKConstraints() if err != nil { return nil, err } m := make(map[string]interface{}) m["last_used_at"] = c....
go
func (c *Connection) Stats() (interface{}, error) { c.dbMu.RLock() defer c.dbMu.RUnlock() c.timeMu.Lock() defer c.timeMu.Unlock() c.txStateMu.Lock() defer c.txStateMu.Unlock() fkEnabled, err := c.db.FKConstraints() if err != nil { return nil, err } m := make(map[string]interface{}) m["last_used_at"] = c....
[ "func", "(", "c", "*", "Connection", ")", "Stats", "(", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "c", ".", "dbMu", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "dbMu", ".", "RUnlock", "(", ")", "\n", "c", ".", "timeMu", "....
// Stats returns the status of the connection.
[ "Stats", "returns", "the", "status", "of", "the", "connection", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/connection.go#L154-L178
24,988
rqlite/rqlite
store/connection.go
IdleTimedOut
func (c *Connection) IdleTimedOut() bool { c.timeMu.Lock() defer c.timeMu.Unlock() return time.Since(c.LastUsedAt) > c.IdleTimeout && c.IdleTimeout != 0 }
go
func (c *Connection) IdleTimedOut() bool { c.timeMu.Lock() defer c.timeMu.Unlock() return time.Since(c.LastUsedAt) > c.IdleTimeout && c.IdleTimeout != 0 }
[ "func", "(", "c", "*", "Connection", ")", "IdleTimedOut", "(", ")", "bool", "{", "c", ".", "timeMu", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "timeMu", ".", "Unlock", "(", ")", "\n", "return", "time", ".", "Since", "(", "c", ".", "LastUsed...
// IdleTimedOut returns if the connection has not been active in the idle time.
[ "IdleTimedOut", "returns", "if", "the", "connection", "has", "not", "been", "active", "in", "the", "idle", "time", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/connection.go#L181-L185
24,989
rqlite/rqlite
store/connection.go
TxTimedOut
func (c *Connection) TxTimedOut() bool { c.timeMu.Lock() defer c.timeMu.Unlock() c.txStateMu.Lock() defer c.txStateMu.Unlock() lau := c.LastUsedAt return !c.TxStartedAt.IsZero() && time.Since(lau) > c.TxTimeout && c.TxTimeout != 0 }
go
func (c *Connection) TxTimedOut() bool { c.timeMu.Lock() defer c.timeMu.Unlock() c.txStateMu.Lock() defer c.txStateMu.Unlock() lau := c.LastUsedAt return !c.TxStartedAt.IsZero() && time.Since(lau) > c.TxTimeout && c.TxTimeout != 0 }
[ "func", "(", "c", "*", "Connection", ")", "TxTimedOut", "(", ")", "bool", "{", "c", ".", "timeMu", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "timeMu", ".", "Unlock", "(", ")", "\n", "c", ".", "txStateMu", ".", "Lock", "(", ")", "\n", "def...
// TxTimedOut returns if the transaction has been open, without activity in // transaction-idle time.
[ "TxTimedOut", "returns", "if", "the", "transaction", "has", "been", "open", "without", "activity", "in", "transaction", "-", "idle", "time", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/connection.go#L189-L196
24,990
rqlite/rqlite
store/connection.go
NewTxStateChange
func NewTxStateChange(c *Connection) *TxStateChange { return &TxStateChange{ c: c, tx: c.TransactionActive(), } }
go
func NewTxStateChange(c *Connection) *TxStateChange { return &TxStateChange{ c: c, tx: c.TransactionActive(), } }
[ "func", "NewTxStateChange", "(", "c", "*", "Connection", ")", "*", "TxStateChange", "{", "return", "&", "TxStateChange", "{", "c", ":", "c", ",", "tx", ":", "c", ".", "TransactionActive", "(", ")", ",", "}", "\n", "}" ]
// NewTxStateChange returns an initialized TxStateChange
[ "NewTxStateChange", "returns", "an", "initialized", "TxStateChange" ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/connection.go#L211-L216
24,991
rqlite/rqlite
store/connection.go
CheckAndSet
func (t *TxStateChange) CheckAndSet() { t.c.txStateMu.Lock() defer t.c.txStateMu.Unlock() defer func() { t.done = true }() if t.done { panic("CheckAndSet should only be called once") } if !t.tx && t.c.TransactionActive() && t.c.TxStartedAt.IsZero() { t.c.TxStartedAt = time.Now() } else if t.tx && !t.c.Tran...
go
func (t *TxStateChange) CheckAndSet() { t.c.txStateMu.Lock() defer t.c.txStateMu.Unlock() defer func() { t.done = true }() if t.done { panic("CheckAndSet should only be called once") } if !t.tx && t.c.TransactionActive() && t.c.TxStartedAt.IsZero() { t.c.TxStartedAt = time.Now() } else if t.tx && !t.c.Tran...
[ "func", "(", "t", "*", "TxStateChange", ")", "CheckAndSet", "(", ")", "{", "t", ".", "c", ".", "txStateMu", ".", "Lock", "(", ")", "\n", "defer", "t", ".", "c", ".", "txStateMu", ".", "Unlock", "(", ")", "\n", "defer", "func", "(", ")", "{", "t...
// CheckAndSet sets whether a transaction has begun or ended on the // connection since the TxStateChange was created. Once CheckAndSet // has been called, this function will panic if called a second time.
[ "CheckAndSet", "sets", "whether", "a", "transaction", "has", "begun", "or", "ended", "on", "the", "connection", "since", "the", "TxStateChange", "was", "created", ".", "Once", "CheckAndSet", "has", "been", "called", "this", "function", "will", "panic", "if", "...
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/connection.go#L221-L235
24,992
rqlite/rqlite
store/db_config.go
NewDBConfig
func NewDBConfig(dsn string, memory bool) *DBConfig { return &DBConfig{DSN: dsn, Memory: memory} }
go
func NewDBConfig(dsn string, memory bool) *DBConfig { return &DBConfig{DSN: dsn, Memory: memory} }
[ "func", "NewDBConfig", "(", "dsn", "string", ",", "memory", "bool", ")", "*", "DBConfig", "{", "return", "&", "DBConfig", "{", "DSN", ":", "dsn", ",", "Memory", ":", "memory", "}", "\n", "}" ]
// NewDBConfig returns a new DB config instance.
[ "NewDBConfig", "returns", "a", "new", "DB", "config", "instance", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/db_config.go#L10-L12
24,993
Shopify/go-lua
string.go
StringOpen
func StringOpen(l *State) int { NewLibrary(l, stringLibrary) l.CreateTable(0, 1) l.PushString("") l.PushValue(-2) l.SetMetaTable(-2) l.Pop(1) l.PushValue(-2) l.SetField(-2, "__index") l.Pop(1) return 1 }
go
func StringOpen(l *State) int { NewLibrary(l, stringLibrary) l.CreateTable(0, 1) l.PushString("") l.PushValue(-2) l.SetMetaTable(-2) l.Pop(1) l.PushValue(-2) l.SetField(-2, "__index") l.Pop(1) return 1 }
[ "func", "StringOpen", "(", "l", "*", "State", ")", "int", "{", "NewLibrary", "(", "l", ",", "stringLibrary", ")", "\n", "l", ".", "CreateTable", "(", "0", ",", "1", ")", "\n", "l", ".", "PushString", "(", "\"", "\"", ")", "\n", "l", ".", "PushVal...
// StringOpen opens the string library. Usually passed to Require.
[ "StringOpen", "opens", "the", "string", "library", ".", "Usually", "passed", "to", "Require", "." ]
48449c60c0a91cdc83cf554aa0931380393b9b02
https://github.com/Shopify/go-lua/blob/48449c60c0a91cdc83cf554aa0931380393b9b02/string.go#L235-L246
24,994
Shopify/go-lua
lua.go
AtPanic
func AtPanic(l *State, panicFunction Function) Function { panicFunction, l.global.panicFunction = l.global.panicFunction, panicFunction return panicFunction }
go
func AtPanic(l *State, panicFunction Function) Function { panicFunction, l.global.panicFunction = l.global.panicFunction, panicFunction return panicFunction }
[ "func", "AtPanic", "(", "l", "*", "State", ",", "panicFunction", "Function", ")", "Function", "{", "panicFunction", ",", "l", ".", "global", ".", "panicFunction", "=", "l", ".", "global", ".", "panicFunction", ",", "panicFunction", "\n", "return", "panicFunc...
// AtPanic sets a new panic function and returns the old one.
[ "AtPanic", "sets", "a", "new", "panic", "function", "and", "returns", "the", "old", "one", "." ]
48449c60c0a91cdc83cf554aa0931380393b9b02
https://github.com/Shopify/go-lua/blob/48449c60c0a91cdc83cf554aa0931380393b9b02/lua.go#L628-L631
24,995
Shopify/go-lua
lua.go
UpValue
func UpValue(l *State, function, index int) (name string, ok bool) { if c, isClosure := l.indexToValue(function).(closure); isClosure { if ok = 1 <= index && index <= c.upValueCount(); ok { if c, isLua := c.(*luaClosure); isLua { name = c.prototype.upValues[index-1].name } l.apiPush(c.upValue(index - 1)...
go
func UpValue(l *State, function, index int) (name string, ok bool) { if c, isClosure := l.indexToValue(function).(closure); isClosure { if ok = 1 <= index && index <= c.upValueCount(); ok { if c, isLua := c.(*luaClosure); isLua { name = c.prototype.upValues[index-1].name } l.apiPush(c.upValue(index - 1)...
[ "func", "UpValue", "(", "l", "*", "State", ",", "function", ",", "index", "int", ")", "(", "name", "string", ",", "ok", "bool", ")", "{", "if", "c", ",", "isClosure", ":=", "l", ".", "indexToValue", "(", "function", ")", ".", "(", "closure", ")", ...
// UpValue returns the name of the upvalue at index away from function, // where index cannot be greater than the number of upvalues. // // Returns an empty string and false if the index is greater than the number // of upvalues.
[ "UpValue", "returns", "the", "name", "of", "the", "upvalue", "at", "index", "away", "from", "function", "where", "index", "cannot", "be", "greater", "than", "the", "number", "of", "upvalues", ".", "Returns", "an", "empty", "string", "and", "false", "if", "...
48449c60c0a91cdc83cf554aa0931380393b9b02
https://github.com/Shopify/go-lua/blob/48449c60c0a91cdc83cf554aa0931380393b9b02/lua.go#L1258-L1268
24,996
Shopify/go-lua
lua.go
UpValueJoin
func UpValueJoin(l *State, f1, n1, f2, n2 int) { u1 := l.upValue(f1, n1) u2 := l.upValue(f2, n2) *u1 = *u2 }
go
func UpValueJoin(l *State, f1, n1, f2, n2 int) { u1 := l.upValue(f1, n1) u2 := l.upValue(f2, n2) *u1 = *u2 }
[ "func", "UpValueJoin", "(", "l", "*", "State", ",", "f1", ",", "n1", ",", "f2", ",", "n2", "int", ")", "{", "u1", ":=", "l", ".", "upValue", "(", "f1", ",", "n1", ")", "\n", "u2", ":=", "l", ".", "upValue", "(", "f2", ",", "n2", ")", "\n", ...
// UpValueJoin makes the n1-th upvalue of the Lua closure at index f1 refer to // the n2-th upvalue of the Lua closure at index f2.
[ "UpValueJoin", "makes", "the", "n1", "-", "th", "upvalue", "of", "the", "Lua", "closure", "at", "index", "f1", "refer", "to", "the", "n2", "-", "th", "upvalue", "of", "the", "Lua", "closure", "at", "index", "f2", "." ]
48449c60c0a91cdc83cf554aa0931380393b9b02
https://github.com/Shopify/go-lua/blob/48449c60c0a91cdc83cf554aa0931380393b9b02/lua.go#L1315-L1319
24,997
Shopify/go-lua
math.go
MathOpen
func MathOpen(l *State) int { NewLibrary(l, mathLibrary) l.PushNumber(3.1415926535897932384626433832795) // TODO use math.Pi instead? Values differ. l.SetField(-2, "pi") l.PushNumber(math.MaxFloat64) l.SetField(-2, "huge") return 1 }
go
func MathOpen(l *State) int { NewLibrary(l, mathLibrary) l.PushNumber(3.1415926535897932384626433832795) // TODO use math.Pi instead? Values differ. l.SetField(-2, "pi") l.PushNumber(math.MaxFloat64) l.SetField(-2, "huge") return 1 }
[ "func", "MathOpen", "(", "l", "*", "State", ")", "int", "{", "NewLibrary", "(", "l", ",", "mathLibrary", ")", "\n", "l", ".", "PushNumber", "(", "3.1415926535897932384626433832795", ")", "// TODO use math.Pi instead? Values differ.", "\n", "l", ".", "SetField", ...
// MathOpen opens the math library. Usually passed to Require.
[ "MathOpen", "opens", "the", "math", "library", ".", "Usually", "passed", "to", "Require", "." ]
48449c60c0a91cdc83cf554aa0931380393b9b02
https://github.com/Shopify/go-lua/blob/48449c60c0a91cdc83cf554aa0931380393b9b02/math.go#L112-L119
24,998
Shopify/go-lua
io.go
IOOpen
func IOOpen(l *State) int { NewLibrary(l, ioLibrary) NewMetaTable(l, fileHandle) l.PushValue(-1) l.SetField(-2, "__index") SetFunctions(l, fileHandleMethods, 0) l.Pop(1) registerStdFile(l, os.Stdin, input, "stdin") registerStdFile(l, os.Stdout, output, "stdout") registerStdFile(l, os.Stderr, "", "stderr") ...
go
func IOOpen(l *State) int { NewLibrary(l, ioLibrary) NewMetaTable(l, fileHandle) l.PushValue(-1) l.SetField(-2, "__index") SetFunctions(l, fileHandleMethods, 0) l.Pop(1) registerStdFile(l, os.Stdin, input, "stdin") registerStdFile(l, os.Stdout, output, "stdout") registerStdFile(l, os.Stderr, "", "stderr") ...
[ "func", "IOOpen", "(", "l", "*", "State", ")", "int", "{", "NewLibrary", "(", "l", ",", "ioLibrary", ")", "\n\n", "NewMetaTable", "(", "l", ",", "fileHandle", ")", "\n", "l", ".", "PushValue", "(", "-", "1", ")", "\n", "l", ".", "SetField", "(", ...
// IOOpen opens the io library. Usually passed to Require.
[ "IOOpen", "opens", "the", "io", "library", ".", "Usually", "passed", "to", "Require", "." ]
48449c60c0a91cdc83cf554aa0931380393b9b02
https://github.com/Shopify/go-lua/blob/48449c60c0a91cdc83cf554aa0931380393b9b02/io.go#L310-L324
24,999
Shopify/go-lua
auxiliary.go
Traceback
func Traceback(l, l1 *State, message string, level int) { const levels1, levels2 = 12, 10 levels := countLevels(l1) mark := 0 if levels > levels1+levels2 { mark = levels1 } buf := message if buf != "" { buf += "\n" } buf += "stack traceback:" for f, ok := Stack(l1, level); ok; f, ok = Stack(l1, level) { ...
go
func Traceback(l, l1 *State, message string, level int) { const levels1, levels2 = 12, 10 levels := countLevels(l1) mark := 0 if levels > levels1+levels2 { mark = levels1 } buf := message if buf != "" { buf += "\n" } buf += "stack traceback:" for f, ok := Stack(l1, level); ok; f, ok = Stack(l1, level) { ...
[ "func", "Traceback", "(", "l", ",", "l1", "*", "State", ",", "message", "string", ",", "level", "int", ")", "{", "const", "levels1", ",", "levels2", "=", "12", ",", "10", "\n", "levels", ":=", "countLevels", "(", "l1", ")", "\n", "mark", ":=", "0",...
// Traceback creates and pushes a traceback of the stack l1. If message is not // nil it is appended at the beginning of the traceback. The level parameter // tells at which level to start the traceback.
[ "Traceback", "creates", "and", "pushes", "a", "traceback", "of", "the", "stack", "l1", ".", "If", "message", "is", "not", "nil", "it", "is", "appended", "at", "the", "beginning", "of", "the", "traceback", ".", "The", "level", "parameter", "tells", "at", ...
48449c60c0a91cdc83cf554aa0931380393b9b02
https://github.com/Shopify/go-lua/blob/48449c60c0a91cdc83cf554aa0931380393b9b02/auxiliary.go#L48-L77