mirror of https://github.com/tidwall/tile38.git
refactor
This commit is contained in:
parent
4e09ee93a5
commit
72de5cc778
|
@ -1,4 +1,4 @@
|
|||
package kml
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
@ -16,7 +16,7 @@ type KML struct {
|
|||
points []pointT
|
||||
}
|
||||
|
||||
func New() *KML {
|
||||
func NewKML() *KML {
|
||||
return &KML{}
|
||||
}
|
||||
|
|
@ -15,7 +15,6 @@ import (
|
|||
"github.com/peterh/liner"
|
||||
"github.com/tidwall/tile38/client"
|
||||
"github.com/tidwall/tile38/core"
|
||||
"github.com/tidwall/tile38/kml"
|
||||
)
|
||||
|
||||
func userHomeDir() string {
|
||||
|
@ -306,7 +305,7 @@ func main() {
|
|||
}
|
||||
|
||||
func convert2kml(msg []byte) []byte {
|
||||
k := kml.New()
|
||||
k := NewKML()
|
||||
var m map[string]interface{}
|
||||
if err := json.Unmarshal(msg, &m); err == nil {
|
||||
if v, ok := m["points"].([]interface{}); ok {
|
||||
|
|
|
@ -10,9 +10,8 @@ import (
|
|||
"strconv"
|
||||
|
||||
"github.com/tidwall/tile38/controller"
|
||||
"github.com/tidwall/tile38/controller/log"
|
||||
"github.com/tidwall/tile38/core"
|
||||
"github.com/tidwall/tile38/log"
|
||||
"github.com/tidwall/tile38/server"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -42,9 +41,8 @@ func main() {
|
|||
HideDebug: !veryVerbose,
|
||||
HideWarn: !(veryVerbose || verbose),
|
||||
})
|
||||
controller.DevMode = devMode
|
||||
controller.ShowDebugMessages = veryVerbose
|
||||
server.ShowDebugMessages = veryVerbose
|
||||
core.DevMode = devMode
|
||||
core.ShowDebugMessages = veryVerbose
|
||||
|
||||
// _____ _ _ ___ ___
|
||||
// |_ _|_| |___|_ | . |
|
||||
|
|
|
@ -16,7 +16,7 @@ import (
|
|||
"github.com/boltdb/bolt"
|
||||
"github.com/google/btree"
|
||||
"github.com/tidwall/tile38/client"
|
||||
"github.com/tidwall/tile38/log"
|
||||
"github.com/tidwall/tile38/controller/log"
|
||||
)
|
||||
|
||||
const backwardsBufferSize = 50000
|
||||
|
|
|
@ -10,7 +10,8 @@ import (
|
|||
"os"
|
||||
|
||||
"github.com/tidwall/tile38/client"
|
||||
"github.com/tidwall/tile38/log"
|
||||
"github.com/tidwall/tile38/controller/log"
|
||||
"github.com/tidwall/tile38/core"
|
||||
)
|
||||
|
||||
// checksum performs a simple md5 checksum on the aof file
|
||||
|
@ -100,7 +101,7 @@ func (c *Controller) matchChecksums(conn *client.Conn, pos, size int64) (match b
|
|||
// followCheckSome is not a full checksum. It just "checks some" data.
|
||||
// We will do some various checksums on the leader until we find the correct position to start at.
|
||||
func (c *Controller) followCheckSome(addr string, followc uint64) (pos int64, err error) {
|
||||
if ShowDebugMessages {
|
||||
if core.ShowDebugMessages {
|
||||
log.Debug("follow:", addr, ":check some")
|
||||
}
|
||||
c.mu.Lock()
|
||||
|
@ -215,7 +216,7 @@ outer:
|
|||
pos -= bufsz
|
||||
}
|
||||
if pos == fullpos {
|
||||
if ShowDebugMessages {
|
||||
if core.ShowDebugMessages {
|
||||
log.Debug("follow: aof fully intact")
|
||||
}
|
||||
return pos, nil
|
||||
|
|
|
@ -16,19 +16,13 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/google/btree"
|
||||
"github.com/tidwall/tile38/collection"
|
||||
"github.com/tidwall/tile38/controller/collection"
|
||||
"github.com/tidwall/tile38/controller/log"
|
||||
"github.com/tidwall/tile38/controller/server"
|
||||
"github.com/tidwall/tile38/core"
|
||||
"github.com/tidwall/tile38/geojson"
|
||||
"github.com/tidwall/tile38/log"
|
||||
"github.com/tidwall/tile38/server"
|
||||
)
|
||||
|
||||
// DevMode puts application in to dev mode
|
||||
var DevMode = false
|
||||
|
||||
// ShowDebugMessages allows for log.Debug to print to console.
|
||||
var ShowDebugMessages = false
|
||||
|
||||
type collectionT struct {
|
||||
Key string
|
||||
Collection *collection.Collection
|
||||
|
@ -163,7 +157,7 @@ func isReservedFieldName(field string) bool {
|
|||
}
|
||||
|
||||
func (c *Controller) handleInputCommand(line string, w io.Writer) error {
|
||||
if ShowDebugMessages && line != "pInG" {
|
||||
if core.ShowDebugMessages && line != "pInG" {
|
||||
log.Debug(line)
|
||||
}
|
||||
start := time.Now()
|
||||
|
@ -319,7 +313,7 @@ func (c *Controller) command(line string, w io.Writer) (resp string, d commandDe
|
|||
d, err = c.cmdFlushDB(nline)
|
||||
resp = okResp()
|
||||
case "massinsert":
|
||||
if !DevMode {
|
||||
if !core.DevMode {
|
||||
err = fmt.Errorf("unknown command '%s'", cmd)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/google/btree"
|
||||
"github.com/tidwall/tile38/collection"
|
||||
"github.com/tidwall/tile38/controller/collection"
|
||||
"github.com/tidwall/tile38/geojson"
|
||||
"github.com/tidwall/tile38/geojson/geohash"
|
||||
)
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/tidwall/tile38/log"
|
||||
"github.com/tidwall/tile38/controller/log"
|
||||
)
|
||||
|
||||
func (c *Controller) cmdMassInsert(line string) error {
|
||||
|
|
|
@ -11,7 +11,8 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/tidwall/tile38/client"
|
||||
"github.com/tidwall/tile38/log"
|
||||
"github.com/tidwall/tile38/controller/log"
|
||||
"github.com/tidwall/tile38/core"
|
||||
)
|
||||
|
||||
var errNoLongerFollowing = errors.New("no longer following")
|
||||
|
@ -156,7 +157,7 @@ func (c *Controller) followStep(host string, port int, followc uint64) error {
|
|||
}
|
||||
return errors.New("invalid response to aof live request")
|
||||
}
|
||||
if ShowDebugMessages {
|
||||
if core.ShowDebugMessages {
|
||||
log.Debug("follow:", addr, ":read aof")
|
||||
}
|
||||
caughtUp := pos >= int64(stats.Stats.AOFSize)
|
||||
|
|
|
@ -10,9 +10,9 @@ import (
|
|||
"sync"
|
||||
|
||||
"github.com/tidwall/tile38/client"
|
||||
"github.com/tidwall/tile38/collection"
|
||||
"github.com/tidwall/tile38/controller/collection"
|
||||
"github.com/tidwall/tile38/controller/log"
|
||||
"github.com/tidwall/tile38/geojson"
|
||||
"github.com/tidwall/tile38/log"
|
||||
)
|
||||
|
||||
type liveBuffer struct {
|
||||
|
|
|
@ -3,7 +3,7 @@ package controller
|
|||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/tidwall/tile38/log"
|
||||
"github.com/tidwall/tile38/controller/log"
|
||||
)
|
||||
|
||||
func (c *Controller) cmdReadOnly(line string) error {
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"math"
|
||||
"strconv"
|
||||
|
||||
"github.com/tidwall/tile38/collection"
|
||||
"github.com/tidwall/tile38/controller/collection"
|
||||
"github.com/tidwall/tile38/geojson"
|
||||
)
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/tidwall/tile38/bing"
|
||||
"github.com/tidwall/tile38/controller/bing"
|
||||
"github.com/tidwall/tile38/geojson"
|
||||
"github.com/tidwall/tile38/geojson/geohash"
|
||||
)
|
||||
|
|
|
@ -10,14 +10,12 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/tidwall/tile38/client"
|
||||
"github.com/tidwall/tile38/log"
|
||||
"github.com/tidwall/tile38/controller/log"
|
||||
"github.com/tidwall/tile38/core"
|
||||
)
|
||||
|
||||
var errCloseHTTP = errors.New("close http")
|
||||
|
||||
// ShowDebugMessages allows for log.Debug to print to console.
|
||||
var ShowDebugMessages = false
|
||||
|
||||
// ListenAndServe starts a tile38 server at the specified address.
|
||||
func ListenAndServe(
|
||||
host string, port int,
|
||||
|
@ -42,7 +40,7 @@ func handleConn(
|
|||
conn net.Conn,
|
||||
handler func(command []byte, conn net.Conn, rd *bufio.Reader, w io.Writer, websocket bool) error,
|
||||
) {
|
||||
if ShowDebugMessages {
|
||||
if core.ShowDebugMessages {
|
||||
addr := conn.RemoteAddr().String()
|
||||
log.Debugf("opened connection: %s", addr)
|
||||
defer func() {
|
|
@ -0,0 +1,7 @@
|
|||
package core
|
||||
|
||||
// DevMode puts application in to dev mode
|
||||
var DevMode = false
|
||||
|
||||
// ShowDebugMessages allows for log.Debug to print to console.
|
||||
var ShowDebugMessages = false
|
Loading…
Reference in New Issue