Skip to content

Commit

Permalink
More doc comment fixes
Browse files Browse the repository at this point in the history
This mostly corrects missing periods and typos.
  • Loading branch information
cespare committed Jun 30, 2015
1 parent b293109 commit c250ec8
Show file tree
Hide file tree
Showing 19 changed files with 122 additions and 122 deletions.
12 changes: 6 additions & 6 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (
// Config provides any necessary configuration to
// the Raft server
type Config struct {
// Time in follower state without a leader before we attempt an election
// Time in follower state without a leader before we attempt an election.
HeartbeatTimeout time.Duration

// Time in candidate state without a leader before we attempt an election
// Time in candidate state without a leader before we attempt an election.
ElectionTimeout time.Duration

// Time without an Apply() operation before we heartbeat to ensure
Expand All @@ -24,7 +24,7 @@ type Config struct {
// MaxAppendEntries controls the maximum number of append entries
// to send at once. We want to strike a balance between efficiency
// and avoiding waste if the follower is going to reject because of
// an inconsistent log
// an inconsistent log.
MaxAppendEntries int

// If we are a member of a cluster, and RemovePeer is invoked for the
Expand All @@ -37,7 +37,7 @@ type Config struct {
// after the node is elected. This is used to prevent self-election
// if the node is removed from the Raft cluster via RemovePeer. Setting
// it to false will keep the bootstrap mode, allowing the node to self-elect
// and potentially bootstrap a seperate cluster.
// and potentially bootstrap a separate cluster.
DisableBootstrapAfterElect bool

// TrailingLogs controls how many logs we leave after a snapshot. This is
Expand All @@ -47,7 +47,7 @@ type Config struct {

// SnapshotInterval controls how often we check if we should perform a snapshot.
// We randomly stagger between this value and 2x this value to avoid the entire
// cluster from performing a snapshot at once
// cluster from performing a snapshot at once.
SnapshotInterval time.Duration

// SnapshotThreshold controls how many outstanding logs there must be before
Expand All @@ -56,7 +56,7 @@ type Config struct {
SnapshotThreshold uint64

// EnableSingleNode allows for a single node mode of operation. This
// is false by default, which prevents a lone node from electing itself
// is false by default, which prevents a lone node from electing itself.
// leader.
EnableSingleNode bool

Expand Down
4 changes: 2 additions & 2 deletions discard_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io"
)

// DiscardSnapshotStore is used to succesfully snapshot while
// DiscardSnapshotStore is used to successfully snapshot while
// always discarding the snapshot. This is useful for when the
// log should be truncated but no snapshot should be retained.
// This should never be used for production use, and is only
Expand All @@ -14,7 +14,7 @@ type DiscardSnapshotStore struct{}

type DiscardSnapshotSink struct{}

// NewDiscardSnapshotStore is used to create a new DiscardSnapshotStore
// NewDiscardSnapshotStore is used to create a new DiscardSnapshotStore.
func NewDiscardSnapshotStore() *DiscardSnapshotStore {
return &DiscardSnapshotStore{}
}
Expand Down
20 changes: 10 additions & 10 deletions file_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type FileSnapshotSink struct {
}

// fileSnapshotMeta is stored on disk. We also put a CRC
// on disk so that we can verify the snapshot
// on disk so that we can verify the snapshot.
type fileSnapshotMeta struct {
SnapshotMeta
CRC []byte
Expand Down Expand Up @@ -102,7 +102,7 @@ func NewFileSnapshotStore(base string, retain int, logOutput io.Writer) (*FileSn
return store, nil
}

// testPermissions tries to touch a file in our path to see if it works
// testPermissions tries to touch a file in our path to see if it works.
func (f *FileSnapshotStore) testPermissions() error {
path := filepath.Join(f.path, testPath)
fh, err := os.Create(path)
Expand All @@ -114,7 +114,7 @@ func (f *FileSnapshotStore) testPermissions() error {
return nil
}

// snapshotName generate s name for the snapshot
// snapshotName generates a name for the snapshot.
func snapshotName(term, index uint64) string {
now := time.Now()
msec := now.UnixNano() / int64(time.Millisecond)
Expand Down Expand Up @@ -195,7 +195,7 @@ func (f *FileSnapshotStore) List() ([]*SnapshotMeta, error) {
return snapMeta, nil
}

// getSnapshots returns all the known snapshots
// getSnapshots returns all the known snapshots.
func (f *FileSnapshotStore) getSnapshots() ([]*fileSnapshotMeta, error) {
// Get the eligible snapshots
snapshots, err := ioutil.ReadDir(f.path)
Expand Down Expand Up @@ -337,12 +337,12 @@ func (s *FileSnapshotSink) ID() string {
}

// Write is used to append to the state file. We write to the
// buffered IO object to reduce the amount of context switches
// buffered IO object to reduce the amount of context switches.
func (s *FileSnapshotSink) Write(b []byte) (int, error) {
return s.buffered.Write(b)
}

// Close is used to indicate a successful end
// Close is used to indicate a successful end.
func (s *FileSnapshotSink) Close() error {
// Make sure close is idempotent
if s.closed {
Expand Down Expand Up @@ -374,7 +374,7 @@ func (s *FileSnapshotSink) Close() error {
return nil
}

// Cancel is used to indicate an unsuccessful end
// Cancel is used to indicate an unsuccessful end.
func (s *FileSnapshotSink) Cancel() error {
// Make sure close is idempotent
if s.closed {
Expand All @@ -392,7 +392,7 @@ func (s *FileSnapshotSink) Cancel() error {
return os.RemoveAll(s.dir)
}

// finalize is used to close all of our resources
// finalize is used to close all of our resources.
func (s *FileSnapshotSink) finalize() error {
// Flush any remaining data
if err := s.buffered.Flush(); err != nil {
Expand All @@ -418,7 +418,7 @@ func (s *FileSnapshotSink) finalize() error {
return nil
}

// writeMeta is used to write out the metadata we have
// writeMeta is used to write out the metadata we have.
func (s *FileSnapshotSink) writeMeta() error {
// Open the meta file
metaPath := filepath.Join(s.dir, metaFilePath)
Expand All @@ -440,7 +440,7 @@ func (s *FileSnapshotSink) writeMeta() error {
return nil
}

// Implement the sort interface for []*fileSnapshotMeta
// Implement the sort interface for []*fileSnapshotMeta.
func (s snapMetaSlice) Len() int {
return len(s)
}
Expand Down
8 changes: 4 additions & 4 deletions fsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
)

// FSM provides an interface that can be implemented by
// clients to make use of the replicated log
// clients to make use of the replicated log.
type FSM interface {
// Apply log is invoked once a log entry is commited
// Apply log is invoked once a log entry is committed.
Apply(*Log) interface{}

// Snapshot is used to support log compaction. This call should
Expand All @@ -26,12 +26,12 @@ type FSM interface {

// FSMSnapshot is returned by an FSM in response to a Snapshot
// It must be safe to invoke FSMSnapshot methods with concurrent
// calls to Apply
// calls to Apply.
type FSMSnapshot interface {
// Persist should dump all necessary state to the WriteCloser 'sink',
// and call sink.Close() when finished or call sink.Cancel() on error.
Persist(sink SnapshotSink) error

// Release is invoked when we are finished with the snapshot
// Release is invoked when we are finished with the snapshot.
Release()
}
18 changes: 9 additions & 9 deletions future.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ import (
"time"
)

// Future is used to represent an action that may occur in the future
// Future is used to represent an action that may occur in the future.
type Future interface {
Error() error
}

// ApplyFuture is used for Apply() and can returns the FSM response
// ApplyFuture is used for Apply() and can returns the FSM response.
type ApplyFuture interface {
Future
Response() interface{}
}

// errorFuture is used to return a static error
// errorFuture is used to return a static error.
type errorFuture struct {
err error
}
Expand All @@ -30,7 +30,7 @@ func (e errorFuture) Response() interface{} {
}

// deferError can be embedded to allow a future
// to provide an error in the future
// to provide an error in the future.
type deferError struct {
err error
errCh chan error
Expand Down Expand Up @@ -65,7 +65,7 @@ func (d *deferError) respond(err error) {
}

// logFuture is used to apply a log entry and waits until
// the log is considered committed
// the log is considered committed.
type logFuture struct {
deferError
log Log
Expand Down Expand Up @@ -94,13 +94,13 @@ func (s *shutdownFuture) Error() error {
return nil
}

// snapshotFuture is used for waiting on a snapshot to complete
// snapshotFuture is used for waiting on a snapshot to complete.
type snapshotFuture struct {
deferError
}

// reqSnapshotFuture is used for requesting a snapshot start.
// It is only used internally
// It is only used internally.
type reqSnapshotFuture struct {
deferError

Expand Down Expand Up @@ -129,7 +129,7 @@ type verifyFuture struct {
}

// vote is used to respond to a verifyFuture.
// This may block when responding on the notifyCh
// This may block when responding on the notifyCh.
func (v *verifyFuture) vote(leader bool) {
v.voteLock.Lock()
defer v.voteLock.Unlock()
Expand All @@ -152,7 +152,7 @@ func (v *verifyFuture) vote(leader bool) {
}

// appendFuture is used for waiting on a pipelined append
// entries RPC
// entries RPC.
type appendFuture struct {
deferError
start time.Time
Expand Down
20 changes: 10 additions & 10 deletions inflight.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

// QuorumPolicy allows individual logFutures to have different
// commitment rules while still using the inflight mechanism
// commitment rules while still using the inflight mechanism.
type quorumPolicy interface {
// Checks if a commit from a given peer is enough to
// satisfy the commitment rules
Expand All @@ -17,7 +17,7 @@ type quorumPolicy interface {
}

// MajorityQuorum is used by Apply transactions and requires
// a simple majority of nodes
// a simple majority of nodes.
type majorityQuorum struct {
count int
votesNeeded int
Expand All @@ -37,7 +37,7 @@ func (m *majorityQuorum) IsCommitted() bool {
return m.count >= m.votesNeeded
}

// Inflight is used to track operations that are still in-flight
// Inflight is used to track operations that are still in-flight.
type inflight struct {
sync.Mutex
committed *list.List
Expand All @@ -49,7 +49,7 @@ type inflight struct {
}

// NewInflight returns an inflight struct that notifies
// the provided channel when logs are finished commiting.
// the provided channel when logs are finished committing.
func newInflight(commitCh chan struct{}) *inflight {
return &inflight{
committed: list.New(),
Expand Down Expand Up @@ -82,7 +82,7 @@ func (i *inflight) StartAll(logs []*logFuture) {
}

// start is used to mark a single entry as inflight,
// must be invoked with the lock held
// must be invoked with the lock held.
func (i *inflight) start(l *logFuture) {
idx := l.log.Index
i.operations[idx] = l
Expand Down Expand Up @@ -131,7 +131,7 @@ func (i *inflight) Cancel(err error) {
i.maxCommit = 0
}

// Committed returns all the committed operations in order
// Committed returns all the committed operations in order.
func (i *inflight) Committed() (l *list.List) {
i.Lock()
l, i.committed = i.committed, list.New()
Expand All @@ -140,15 +140,15 @@ func (i *inflight) Committed() (l *list.List) {
}

// Commit is used by leader replication routines to indicate that
// a follower was finished commiting a log to disk.
// a follower was finished committing a log to disk.
func (i *inflight) Commit(index uint64) {
i.Lock()
defer i.Unlock()
i.commit(index)
}

// CommitRange is used to commit a range of indexes inclusively
// It optimized to avoid commits for indexes that are not tracked
// CommitRange is used to commit a range of indexes inclusively.
// It optimized to avoid commits for indexes that are not tracked.
func (i *inflight) CommitRange(minIndex, maxIndex uint64) {
i.Lock()
defer i.Unlock()
Expand All @@ -166,7 +166,7 @@ func (i *inflight) CommitRange(minIndex, maxIndex uint64) {
func (i *inflight) commit(index uint64) {
op, ok := i.operations[index]
if !ok {
// Ignore if not in the map, as it may be commited already
// Ignore if not in the map, as it may be committed already
return
}

Expand Down
2 changes: 1 addition & 1 deletion inflight_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestInflight_StartCommit(t *testing.T) {
t.Fatalf("should be commited")
}

// Already commited but should work anyways
// Already committed but should work anyways
in.Commit(1)
}

Expand Down
2 changes: 1 addition & 1 deletion inmem_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type InmemStore struct {
kvInt map[string]uint64
}

// NewInmemStore returns a new inmemory backend. Do not ever
// NewInmemStore returns a new in-memory backend. Do not ever
// use for production. Only for testing.
func NewInmemStore() *InmemStore {
i := &InmemStore{
Expand Down
4 changes: 2 additions & 2 deletions inmem_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
)

// NewInmemAddr returns a new in-memory addr with
// a randomly generate UUID as the ID
// a randomly generate UUID as the ID.
func NewInmemAddr() string {
return generateUUID()
}

// inmemPipeline is used to pipeline requests for the in-mem transport
// inmemPipeline is used to pipeline requests for the in-mem transport.
type inmemPipeline struct {
trans *InmemTransport
peer *InmemTransport
Expand Down
Loading

0 comments on commit c250ec8

Please sign in to comment.