diff --git a/broadcast.go b/broadcast.go index b12dc0896..f36533a7a 100644 --- a/broadcast.go +++ b/broadcast.go @@ -17,27 +17,27 @@ type NodeSet interface { Open() error } -// StaticNodeSet represents a basic NodeSet for testing +// StaticNodeSet represents a basic NodeSet for testing. type StaticNodeSet struct { nodes []*Node } -// NewStaticNodeSet creates a static nodeset +// NewStaticNodeSet creates a statically defined NodeSet. func NewStaticNodeSet() *StaticNodeSet { return &StaticNodeSet{} } -// Nodes implements the NodeSet interface and returns a list of nodes in the cluster +// Nodes implements the NodeSet interface and returns a list of nodes in the cluster. func (s *StaticNodeSet) Nodes() []*Node { return s.nodes } -// Open implements the NodeSet interface to start network activity, but is a nop +// Open implements the NodeSet interface to start network activity, but for a static NodeSet it does nothing. func (s *StaticNodeSet) Open() error { return nil } -// Join add nodes from the cluster to the NodeSet +// Join sets the NodeSet nodes to the slices of Nodes passed in. func (s *StaticNodeSet) Join(nodes []*Node) error { s.nodes = nodes return nil @@ -89,10 +89,10 @@ type nopBroadcastReceiver struct{} func (n *nopBroadcastReceiver) Start(b BroadcastHandler) error { return nil } -// NopBroadcastReceiver is a no op implementation of the BroadcastReceiver +// NopBroadcastReceiver is a no-op implementation of the BroadcastReceiver. var NopBroadcastReceiver = &nopBroadcastReceiver{} -// Broadcast message types +// Broadcast message types. const ( MessageTypeCreateSlice = 1 MessageTypeCreateIndex = 2 @@ -101,7 +101,7 @@ const ( MessageTypeDeleteFrame = 5 ) -// MarshalMessage encodes the protobuf message into a byte slice +// MarshalMessage encodes the protobuf message into a byte slice. func MarshalMessage(m proto.Message) ([]byte, error) { var typ uint8 switch obj := m.(type) { @@ -125,7 +125,7 @@ func MarshalMessage(m proto.Message) ([]byte, error) { return append([]byte{typ}, buf...), nil } -// UnmarshalMessage decodes the byte slice into a protobuf message +// UnmarshalMessage decodes the byte slice into a protobuf message. func UnmarshalMessage(buf []byte) (proto.Message, error) { typ, buf := buf[0], buf[1:] diff --git a/cache.go b/cache.go index a83dcdaf4..cd172100b 100644 --- a/cache.go +++ b/cache.go @@ -195,7 +195,7 @@ func (c *RankCache) Invalidate() { c.invalidate() } -// Recalculate rebuilds the cache +// Recalculate rebuilds the cache. func (c *RankCache) Recalculate() { c.mu.Lock() defer c.mu.Unlock() @@ -305,18 +305,18 @@ type PairHeap struct { Pairs } -// Less implemets the Sort interface +// Less implemets the Sort interface. // reports whether the element with index i should sort before the element with index j. func (p PairHeap) Less(i, j int) bool { return p.Pairs[i].Count < p.Pairs[j].Count } -// Push appends the element onto the Pair slice +// Push appends the element onto the Pair slice. func (p *Pairs) Push(x interface{}) { // Push and Pop use pointer receivers because they modify the slice's length, // not just its contents. *p = append(*p, x.(Pair)) } -// Pop removes the minimum element from the Pair slice +// Pop removes the minimum element from the Pair slice. func (p *Pairs) Pop() interface{} { old := *p n := len(old) diff --git a/client.go b/client.go index b4fc2c4d7..2dfc6fadc 100644 --- a/client.go +++ b/client.go @@ -315,7 +315,7 @@ func (c *Client) Import(ctx context.Context, index, frame string, slice uint64, return nil } -// MarshalImportPayload marshalls the import parameters into a protobuf byte slice +// MarshalImportPayload marshalls the import parameters into a protobuf byte slice. func MarshalImportPayload(index, frame string, slice uint64, bits []Bit) ([]byte, error) { // Separate row and column IDs to reduce allocations. rowIDs := Bits(bits).RowIDs() diff --git a/cluster.go b/cluster.go index a6bcade81..e68e57926 100644 --- a/cluster.go +++ b/cluster.go @@ -127,7 +127,7 @@ func NewCluster() *Cluster { } } -// NodeSetHosts returns the list of host strings for NodeSet members +// NodeSetHosts returns the list of host strings for NodeSet members. func (c *Cluster) NodeSetHosts() []string { if c.NodeSet == nil { return []string{} @@ -154,7 +154,7 @@ func (c *Cluster) NodeStates() map[string]string { return h } -// Status returns the internal ClusterState representation. +// Status returns the internal ClusterStatus representation. func (c *Cluster) Status() *internal.ClusterStatus { return &internal.ClusterStatus{ Nodes: encodeClusterStatus(c.Nodes), diff --git a/config.go b/config.go index a0cfb977f..89fd3dc77 100644 --- a/config.go +++ b/config.go @@ -9,10 +9,10 @@ const ( // DefaultPort is the default port use with the hostname. DefaultPort = "10101" - // DefaultClusterType sets the node intercommunication method + // DefaultClusterType sets the node intercommunication method. DefaultClusterType = "static" - // DefaultInternalPort the port the nodes intercommunicate on + // DefaultInternalPort the port the nodes intercommunicate on. DefaultInternalPort = "14000" ) diff --git a/handler.go b/handler.go index b26fdefa8..57b05284b 100644 --- a/handler.go +++ b/handler.go @@ -58,7 +58,7 @@ func NewHandler() *Handler { return handler } -// NewRouter creates a Gorilla Mus http router +// NewRouter creates a Gorilla Mux http router. func NewRouter(handler *Handler) *mux.Router { router := mux.NewRouter() router.HandleFunc("/index", handler.handleGetIndexes).Methods("GET") diff --git a/index.go b/index.go index 378f94ab7..eb207a4a4 100644 --- a/index.go +++ b/index.go @@ -250,7 +250,7 @@ func (i *Index) MaxSlice() uint64 { return max } -// SetRemoteMaxSlice sets the remote max slice value received from another node +// SetRemoteMaxSlice sets the remote max slice value received from another node. func (i *Index) SetRemoteMaxSlice(newmax uint64) { i.mu.Lock() defer i.mu.Unlock() @@ -274,7 +274,7 @@ func (i *Index) MaxInverseSlice() uint64 { return max } -// SetRemoteMaxInverseSlice sets the remote max inverse slice value received from another node +// SetRemoteMaxInverseSlice sets the remote max inverse slice value received from another node. func (i *Index) SetRemoteMaxInverseSlice(v uint64) { i.mu.Lock() defer i.mu.Unlock() diff --git a/pilosa.go b/pilosa.go index 0b5532ff7..1736cccb9 100644 --- a/pilosa.go +++ b/pilosa.go @@ -88,7 +88,7 @@ func decodeColumnAttrSet(pb *internal.ColumnAttrSet) *ColumnAttrSet { // TimeFormat is the go-style time format used to parse string dates. const TimeFormat = "2006-01-02T15:04" -// ValidateName restrict name using regex +// ValidateName ensures that the name is a valid format. func ValidateName(name string) error { validName := nameRegexp.Match([]byte(name)) if validName == false { diff --git a/stats.go b/stats.go index 685a9ce3c..8cd599f2e 100644 --- a/stats.go +++ b/stats.go @@ -12,7 +12,7 @@ func init() { NopStatsClient = &nopStatsClient{} } -// Expvar Global expvar map. +// Expvar global expvar map. var Expvar = expvar.NewMap("index") // StatsClient represents a client to a stats server.