goimports cleanup
This commit is contained in:
		| @@ -3,9 +3,10 @@ package atomicheader | ||||
| import ( | ||||
| 	"encoding/binary" | ||||
| 	"hash/crc32" | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| 	"os" | ||||
| 	"sync" | ||||
|  | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| ) | ||||
|  | ||||
| const ( | ||||
|   | ||||
| @@ -6,11 +6,12 @@ import ( | ||||
| 	"crypto/tls" | ||||
| 	"errors" | ||||
| 	"io" | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| 	"net" | ||||
| 	"net/http" | ||||
| 	"net/url" | ||||
| 	"time" | ||||
|  | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| ) | ||||
|  | ||||
| var ErrInvalidStatus = errors.New("invalid status") | ||||
|   | ||||
| @@ -3,10 +3,11 @@ package rep | ||||
| import ( | ||||
| 	"encoding/binary" | ||||
| 	"encoding/json" | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| 	"net" | ||||
| 	"path/filepath" | ||||
| 	"time" | ||||
|  | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| ) | ||||
|  | ||||
| // ---------------------------------------------------------------------------- | ||||
|   | ||||
| @@ -4,12 +4,13 @@ import ( | ||||
| 	"encoding/binary" | ||||
| 	"encoding/json" | ||||
| 	"io" | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| 	"git.crumpington.com/public/jldb/lib/httpconn" | ||||
| 	"git.crumpington.com/public/jldb/lib/wal" | ||||
| 	"net" | ||||
| 	"sync" | ||||
| 	"time" | ||||
|  | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| 	"git.crumpington.com/public/jldb/lib/httpconn" | ||||
| 	"git.crumpington.com/public/jldb/lib/wal" | ||||
| ) | ||||
|  | ||||
| type client struct { | ||||
|   | ||||
| @@ -2,10 +2,11 @@ package rep | ||||
|  | ||||
| import ( | ||||
| 	"crypto/subtle" | ||||
| 	"git.crumpington.com/public/jldb/lib/httpconn" | ||||
| 	"log" | ||||
| 	"net/http" | ||||
| 	"time" | ||||
|  | ||||
| 	"git.crumpington.com/public/jldb/lib/httpconn" | ||||
| ) | ||||
|  | ||||
| const ( | ||||
| @@ -54,6 +55,7 @@ func (rep *Replicator) Handle(w http.ResponseWriter, r *http.Request) { | ||||
| 		switch cmd[0] { | ||||
|  | ||||
| 		case cmdGetInfo: | ||||
|  | ||||
| 			if err := sendJSON(rep.Info(), conn, rep.conf.NetTimeout); err != nil { | ||||
| 				logf("Failed to send info: %s", err) | ||||
| 				return | ||||
| @@ -69,6 +71,7 @@ func (rep *Replicator) Handle(w http.ResponseWriter, r *http.Request) { | ||||
| 			} | ||||
|  | ||||
| 		case cmdStreamWAL: | ||||
|  | ||||
| 			err := rep.wal.Send(conn, rep.conf.NetTimeout) | ||||
| 			if !rep.stopped() { | ||||
| 				logf("Failed when sending WAL: %s", err) | ||||
|   | ||||
| @@ -2,9 +2,10 @@ package rep | ||||
|  | ||||
| import ( | ||||
| 	"io" | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| 	"net" | ||||
| 	"time" | ||||
|  | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| ) | ||||
|  | ||||
| func (rep *Replicator) sendState(conn net.Conn) error { | ||||
|   | ||||
| @@ -1,12 +1,13 @@ | ||||
| package rep | ||||
|  | ||||
| import ( | ||||
| 	"os" | ||||
| 	"time" | ||||
|  | ||||
| 	"git.crumpington.com/public/jldb/lib/atomicheader" | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| 	"git.crumpington.com/public/jldb/lib/flock" | ||||
| 	"git.crumpington.com/public/jldb/lib/wal" | ||||
| 	"os" | ||||
| 	"time" | ||||
| ) | ||||
|  | ||||
| func (rep *Replicator) loadConfigDefaults() { | ||||
|   | ||||
| @@ -2,14 +2,15 @@ package rep | ||||
|  | ||||
| import ( | ||||
| 	"io" | ||||
| 	"git.crumpington.com/public/jldb/lib/atomicheader" | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| 	"git.crumpington.com/public/jldb/lib/wal" | ||||
| 	"net" | ||||
| 	"os" | ||||
| 	"sync" | ||||
| 	"sync/atomic" | ||||
| 	"time" | ||||
|  | ||||
| 	"git.crumpington.com/public/jldb/lib/atomicheader" | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| 	"git.crumpington.com/public/jldb/lib/wal" | ||||
| ) | ||||
|  | ||||
| type Config struct { | ||||
| @@ -161,10 +162,6 @@ func (rep *Replicator) Primary() bool { | ||||
| 	return rep.conf.Primary | ||||
| } | ||||
|  | ||||
| // TODO: Probably remove this. | ||||
| // The caller may call Ack after Apply to acknowledge that the change has also | ||||
| // been applied to the caller's application. Alternatively, the caller may use | ||||
| // follow to apply changes to their application state. | ||||
| func (rep *Replicator) ack(seqNum, timestampMS int64) error { | ||||
| 	state := rep.getState() | ||||
| 	state.SeqNum = seqNum | ||||
|   | ||||
| @@ -5,12 +5,13 @@ import ( | ||||
| 	"encoding/binary" | ||||
| 	"encoding/json" | ||||
| 	"io" | ||||
| 	"git.crumpington.com/public/jldb/lib/wal" | ||||
| 	"math/rand" | ||||
| 	"net" | ||||
| 	"sync" | ||||
| 	"testing" | ||||
| 	"time" | ||||
|  | ||||
| 	"git.crumpington.com/public/jldb/lib/wal" | ||||
| ) | ||||
|  | ||||
| // ---------------------------------------------------------------------------- | ||||
|   | ||||
| @@ -2,8 +2,9 @@ package wal | ||||
|  | ||||
| import ( | ||||
| 	"io" | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| 	"testing" | ||||
|  | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| ) | ||||
|  | ||||
| func TestCorruptWAL(t *testing.T) { | ||||
|   | ||||
| @@ -5,13 +5,14 @@ import ( | ||||
| 	"encoding/binary" | ||||
| 	"errors" | ||||
| 	"io" | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| 	"math/rand" | ||||
| 	"path/filepath" | ||||
| 	"reflect" | ||||
| 	"strings" | ||||
| 	"testing" | ||||
| 	"time" | ||||
|  | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| ) | ||||
|  | ||||
| type waLog interface { | ||||
|   | ||||
| @@ -5,6 +5,7 @@ import ( | ||||
| 	"errors" | ||||
| 	"hash/crc32" | ||||
| 	"io" | ||||
|  | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -4,6 +4,7 @@ import ( | ||||
| 	"encoding/binary" | ||||
| 	"hash/crc32" | ||||
| 	"io" | ||||
|  | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -3,10 +3,11 @@ package wal | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"io" | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| 	"git.crumpington.com/public/jldb/lib/testutil" | ||||
| 	"math/rand" | ||||
| 	"testing" | ||||
|  | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| 	"git.crumpington.com/public/jldb/lib/testutil" | ||||
| ) | ||||
|  | ||||
| func NewRecordForTesting() Record { | ||||
|   | ||||
| @@ -1,10 +1,11 @@ | ||||
| package wal | ||||
|  | ||||
| import ( | ||||
| 	"git.crumpington.com/public/jldb/lib/atomicheader" | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| 	"os" | ||||
| 	"time" | ||||
|  | ||||
| 	"git.crumpington.com/public/jldb/lib/atomicheader" | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| ) | ||||
|  | ||||
| type segmentIterator struct { | ||||
|   | ||||
| @@ -3,11 +3,12 @@ package wal | ||||
| import ( | ||||
| 	"bufio" | ||||
| 	"io" | ||||
| 	"git.crumpington.com/public/jldb/lib/atomicheader" | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| 	"os" | ||||
| 	"sync" | ||||
| 	"time" | ||||
|  | ||||
| 	"git.crumpington.com/public/jldb/lib/atomicheader" | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| ) | ||||
|  | ||||
| type segment struct { | ||||
|   | ||||
| @@ -4,11 +4,12 @@ import ( | ||||
| 	"bytes" | ||||
| 	crand "crypto/rand" | ||||
| 	"io" | ||||
| 	"git.crumpington.com/public/jldb/lib/atomicheader" | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| 	"path/filepath" | ||||
| 	"testing" | ||||
| 	"time" | ||||
|  | ||||
| 	"git.crumpington.com/public/jldb/lib/atomicheader" | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| ) | ||||
|  | ||||
| func newSegmentForTesting(t *testing.T) *segment { | ||||
|   | ||||
| @@ -1,8 +1,9 @@ | ||||
| package wal | ||||
|  | ||||
| import ( | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| 	"time" | ||||
|  | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| ) | ||||
|  | ||||
| type walIterator struct { | ||||
|   | ||||
| @@ -3,9 +3,10 @@ package wal | ||||
| import ( | ||||
| 	"encoding/binary" | ||||
| 	"io" | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| 	"net" | ||||
| 	"time" | ||||
|  | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| ) | ||||
|  | ||||
| func (wal *WAL) Recv(conn net.Conn, timeout time.Duration) error { | ||||
|   | ||||
| @@ -2,9 +2,10 @@ package wal | ||||
|  | ||||
| import ( | ||||
| 	"encoding/binary" | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| 	"net" | ||||
| 	"time" | ||||
|  | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| ) | ||||
|  | ||||
| const ( | ||||
|   | ||||
| @@ -1,8 +1,6 @@ | ||||
| package wal | ||||
|  | ||||
| import ( | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| 	"git.crumpington.com/public/jldb/lib/testutil" | ||||
| 	"log" | ||||
| 	"math/rand" | ||||
| 	"reflect" | ||||
| @@ -11,6 +9,9 @@ import ( | ||||
| 	"sync/atomic" | ||||
| 	"testing" | ||||
| 	"time" | ||||
|  | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| 	"git.crumpington.com/public/jldb/lib/testutil" | ||||
| ) | ||||
|  | ||||
| func TestSendRecvHarness(t *testing.T) { | ||||
|   | ||||
| @@ -2,13 +2,14 @@ package wal | ||||
|  | ||||
| import ( | ||||
| 	"io" | ||||
| 	"git.crumpington.com/public/jldb/lib/atomicheader" | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| 	"os" | ||||
| 	"path/filepath" | ||||
| 	"strconv" | ||||
| 	"sync" | ||||
| 	"time" | ||||
|  | ||||
| 	"git.crumpington.com/public/jldb/lib/atomicheader" | ||||
| 	"git.crumpington.com/public/jldb/lib/errs" | ||||
| ) | ||||
|  | ||||
| type Config struct { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user