diff --git a/auth/credential_store.go b/auth/credential_store.go index 55f36caf..61d54193 100644 --- a/auth/credential_store.go +++ b/auth/credential_store.go @@ -17,7 +17,7 @@ type Credential struct { Perms []string `json:"perms,omitempty"` } -// CredentialStore stores authentication and authorization information for all users. +// CredentialsStore stores authentication and authorization information for all users. type CredentialsStore struct { store map[string]string perms map[string]map[string]bool diff --git a/cluster/service.go b/cluster/service.go index 883e6e30..d9b868c1 100644 --- a/cluster/service.go +++ b/cluster/service.go @@ -11,7 +11,7 @@ import ( ) const ( - ConnectionTimeout = 10 * time.Second + connectionTimeout = 10 * time.Second ) var respOKMarshalled []byte @@ -105,7 +105,7 @@ func (s *Service) SetPeer(raftAddr, apiAddr string) error { if leader := s.store.Leader(); leader == "" { return fmt.Errorf("no leader available") } - conn, err := s.tn.Dial(s.store.Leader(), ConnectionTimeout) + conn, err := s.tn.Dial(s.store.Leader(), connectionTimeout) if err != nil { return err } diff --git a/db/db.go b/db/db.go index 329ecc77..ebc3b644 100644 --- a/db/db.go +++ b/db/db.go @@ -13,6 +13,7 @@ import ( const bkDelay = 250 +// DBVersion is the SQLite version. var DBVersion string func init() { @@ -49,7 +50,7 @@ func Open(dbPath string) (*DB, error) { return open(fqdsn(dbPath, "")) } -// OpenwithDSN opens a file-based database, creating it if it does not exist. +// OpenWithDSN opens a file-based database, creating it if it does not exist. func OpenWithDSN(dbPath, dsn string) (*DB, error) { return open(fqdsn(dbPath, dsn)) } diff --git a/http/service.go b/http/service.go index b755eb33..d2aa8f9f 100644 --- a/http/service.go +++ b/http/service.go @@ -77,6 +77,7 @@ const ( numQueries = "queries" numBackups = "backups" + // Permissions available to users. PermAll = "all" PermJoin = "join" PermExecute = "execute" @@ -490,6 +491,7 @@ func (s *Service) Addr() net.Addr { return s.ln.Addr() } +// FormRedirect returns the value for the "Location" header for a 301 response. func (s *Service) FormRedirect(r *http.Request, host string) string { protocol := "http" if s.credentialStore != nil { diff --git a/store/store.go b/store/store.go index db7b15c0..acc923a7 100644 --- a/store/store.go +++ b/store/store.go @@ -24,7 +24,7 @@ import ( ) var ( - // ErrFieldsRequired is returned when a node attempts to execute a leader-only + // ErrNotLeader is returned when a node attempts to execute a leader-only // operation. ErrNotLeader = errors.New("not leader") ) @@ -84,6 +84,7 @@ type peersSub map[string]string // ConsistencyLevel represents the available read consistency levels. type ConsistencyLevel int +// Represents the available consistency levels. const ( None ConsistencyLevel = iota Weak @@ -96,7 +97,7 @@ type clusterMeta struct { } // NewClusterMeta returns an initialized cluster meta store. -func NewClusterMeta() *clusterMeta { +func newClusterMeta() *clusterMeta { return &clusterMeta{ APIPeers: make(map[string]string), } @@ -158,7 +159,7 @@ func New(dbConf *DBConfig, dir string, tn Transport) *Store { raftTransport: tn, dbConf: dbConf, dbPath: filepath.Join(dir, sqliteFile), - meta: NewClusterMeta(), + meta: newClusterMeta(), logger: log.New(os.Stderr, "[store] ", log.LstdFlags), } } @@ -262,6 +263,7 @@ func (s *Store) Path() string { return s.raftDir } +// Addr returns the address of the store. func (s *Store) Addr() net.Addr { return s.raftTransport.Addr() } diff --git a/store/store_test.go b/store/store_test.go index a9acf2d0..fde14220 100644 --- a/store/store_test.go +++ b/store/store_test.go @@ -24,7 +24,7 @@ func (m *mockSnapshotSink) Cancel() error { } func Test_ClusterMeta(t *testing.T) { - c := NewClusterMeta() + c := newClusterMeta() c.APIPeers["localhost:4002"] = "localhost:4001" if c.AddrForPeer("localhost:4002") != "localhost:4001" {