Refactor project layout

Move internal and support packages to pkg directory
This commit is contained in:
Josh Baker 2018-04-19 08:43:32 -07:00
parent 4a200b697c
commit 7e9871bb69
143 changed files with 125 additions and 121 deletions

View File

@ -1,6 +1,6 @@
<p align="center">
<a href="http://tile38.com"><img
src="/doc/logo1500.png"
src="/res/logo1500.png"
width="200" height="200" border="0" alt="Tile38"></a>
</p>
<p align="center">
@ -14,11 +14,11 @@ Tile38 is an open source (MIT licensed), in-memory geolocation data store, spati
<p align="center">
<i>This README is quick start document. You can find detailed documentation at <a href="http://tile38.com">http://tile38.com</a>.</i><br><br>
<a href="#searching"><img src="/doc/search-nearby.png" alt="Nearby" border="0" width="120" height="120"></a>
<a href="#searching"><img src="/doc/search-within.png" alt="Within" border="0" width="120" height="120"></a>
<a href="#searching"><img src="/doc/search-intersects.png" alt="Intersects" border="0" width="120" height="120"></a>
<a href="http://tile38.com/topics/geofencing"><img src="/doc/geofence.gif" alt="Geofencing" border="0" width="120" height="120"></a>
<a href="http://tile38.com/topics/roaming-geofences"><img src="/doc/roaming.gif" alt="Roaming Geofences" border="0" width="120" height="120"></a>
<a href="#searching"><img src="/res/search-nearby.png" alt="Nearby" border="0" width="120" height="120"></a>
<a href="#searching"><img src="/res/search-within.png" alt="Within" border="0" width="120" height="120"></a>
<a href="#searching"><img src="/res/search-intersects.png" alt="Intersects" border="0" width="120" height="120"></a>
<a href="http://tile38.com/topics/geofencing"><img src="/res/geofence.gif" alt="Geofencing" border="0" width="120" height="120"></a>
<a href="http://tile38.com/topics/roaming-geofences"><img src="/res/roaming.gif" alt="Roaming Geofences" border="0" width="120" height="120"></a>
</p>
## Features
@ -142,19 +142,19 @@ To set a field when an object already exists:
Tile38 has support to search for objects and points that are within or intersects other objects. All object types can be searched including Polygons, MultiPolygons, GeometryCollections, etc.
<img src="/doc/search-within.png" width="200" height="200" border="0" alt="Search Within" align="left">
<img src="/res/search-within.png" width="200" height="200" border="0" alt="Search Within" align="left">
#### Within
WITHIN searches a collection for objects that are fully contained inside a specified bounding area.
<BR CLEAR="ALL">
<img src="/doc/search-intersects.png" width="200" height="200" border="0" alt="Search Intersects" align="left">
<img src="/res/search-intersects.png" width="200" height="200" border="0" alt="Search Intersects" align="left">
#### Intersects
INTERSECTS searches a collection for objects that intersect a specified bounding area.
<BR CLEAR="ALL">
<img src="/doc/search-nearby.png" width="200" height="200" border="0" alt="Search Nearby" align="left">
<img src="/res/search-nearby.png" width="200" height="200" border="0" alt="Search Nearby" align="left">
#### Nearby
NEARBY searches a collection for objects that intersect a specified radius.
@ -169,12 +169,12 @@ NEARBY searches a collection for objects that intersect a specified radius.
This is very helpful for example; when you have many (perhaps millions) of objects and do not want them all clustered together on a map. Sparse will limit the number of objects returned and provide them evenly distributed so that your map looks clean.<br><br>
You can choose a value between 1 and 8. The value 1 will result in no more than 4 items. The value 8 will result in no more than 65536. *1=4, 2=16, 3=64, 4=256, 5=1024, 6=4098, 7=16384, 8=65536.*<br><br>
<table>
<td>No Sparsing<img src="/doc/sparse-none.png" width="100" height="100" border="0" alt="Search Within"></td>
<td>Sparse 1<img src="/doc/sparse-1.png" width="100" height="100" border="0" alt="Search Within"></td>
<td>Sparse 2<img src="/doc/sparse-2.png" width="100" height="100" border="0" alt="Search Within"></td>
<td>Sparse 3<img src="/doc/sparse-3.png" width="100" height="100" border="0" alt="Search Within"></td>
<td>Sparse 4<img src="/doc/sparse-4.png" width="100" height="100" border="0" alt="Search Within"></td>
<td>Sparse 5<img src="/doc/sparse-5.png" width="100" height="100" border="0" alt="Search Within"></td>
<td>No Sparsing<img src="/res/sparse-none.png" width="100" height="100" border="0" alt="Search Within"></td>
<td>Sparse 1<img src="/res/sparse-1.png" width="100" height="100" border="0" alt="Search Within"></td>
<td>Sparse 2<img src="/res/sparse-2.png" width="100" height="100" border="0" alt="Search Within"></td>
<td>Sparse 3<img src="/res/sparse-3.png" width="100" height="100" border="0" alt="Search Within"></td>
<td>Sparse 4<img src="/res/sparse-4.png" width="100" height="100" border="0" alt="Search Within"></td>
<td>Sparse 5<img src="/res/sparse-5.png" width="100" height="100" border="0" alt="Search Within"></td>
</table>
*Please note that the higher the sparse value, the slower the performance. Also, LIMIT and CURSOR are not available when using SPARSE.*
@ -191,7 +191,7 @@ You can choose a value between 1 and 8. The value 1 will result in no more than
## Geofencing
<img src="/doc/geofence.gif" width="200" height="200" border="0" alt="Geofence animation" align="left">
<img src="/res/geofence.gif" width="200" height="200" border="0" alt="Geofence animation" align="left">
A <a href="https://en.wikipedia.org/wiki/Geo-fence">geofence</a> is a virtual boundary that can detect when an object enters or exits the area. This boundary can be a radius, bounding box, or a polygon. Tile38 can turn any standard search into a geofence monitor by adding the FENCE keyword to the search.
*Tile38 also allows for [Webhooks](http://tile38.com/commands/sethook) to be assigned to Geofences.*

View File

@ -5,13 +5,13 @@ VERSION="1.12.0"
PROTECTED_MODE="no"
# Hardcode some values to the core package
LDFLAGS="$LDFLAGS -X github.com/tidwall/tile38/core.Version=${VERSION}"
LDFLAGS="$LDFLAGS -X github.com/tidwall/tile38/pkg/core.Version=${VERSION}"
if [ -d ".git" ]; then
LDFLAGS="$LDFLAGS -X github.com/tidwall/tile38/core.GitSHA=$(git rev-parse --short HEAD)"
LDFLAGS="$LDFLAGS -X github.com/tidwall/tile38/pkg/core.GitSHA=$(git rev-parse --short HEAD)"
fi
LDFLAGS="$LDFLAGS -X github.com/tidwall/tile38/core.BuildTime=$(date +%FT%T%z)"
LDFLAGS="$LDFLAGS -X github.com/tidwall/tile38/pkg/core.BuildTime=$(date +%FT%T%z)"
if [ "$PROTECTED_MODE" == "no" ]; then
LDFLAGS="$LDFLAGS -X github.com/tidwall/tile38/core.ProtectedMode=no"
LDFLAGS="$LDFLAGS -X github.com/tidwall/tile38/pkg/core.ProtectedMode=no"
fi
if [ "$1" == "update-version" ]; then
@ -129,6 +129,9 @@ if [ "$NOLINK" != "1" ]; then
cd "$TMP/go/src/github.com/tidwall/tile38"
fi
# generate the core package
pkg/core/gen.sh
# build and store objects into original directory.
go build -ldflags "$LDFLAGS" -o "$OD/tile38-server" cmd/tile38-server/*.go
go build -ldflags "$LDFLAGS" -o "$OD/tile38-cli" cmd/tile38-cli/*.go

View File

@ -11,7 +11,7 @@ import (
"time"
"github.com/tidwall/redbench"
"github.com/tidwall/tile38/core"
"github.com/tidwall/tile38/pkg/core"
)
var (

View File

@ -4,7 +4,7 @@ import (
"bytes"
"fmt"
"github.com/tidwall/tile38/geojson"
"github.com/tidwall/tile38/pkg/geojson"
)
type pointT struct {

View File

@ -15,8 +15,8 @@ import (
"github.com/peterh/liner"
"github.com/tidwall/resp"
"github.com/tidwall/tile38/client"
"github.com/tidwall/tile38/core"
"github.com/tidwall/tile38/pkg/client"
"github.com/tidwall/tile38/pkg/core"
)
func userHomeDir() string {

View File

@ -19,10 +19,10 @@ import (
"google.golang.org/grpc"
"github.com/tidwall/tile38/controller"
"github.com/tidwall/tile38/controller/log"
"github.com/tidwall/tile38/core"
"github.com/tidwall/tile38/hservice"
"github.com/tidwall/tile38/pkg/controller"
"github.com/tidwall/tile38/pkg/core"
"github.com/tidwall/tile38/pkg/hservice"
"github.com/tidwall/tile38/pkg/log"
)
var (

View File

@ -1,4 +1,4 @@
![Tile38 Logo](https://raw.githubusercontent.com/tidwall/tile38/master/doc/logo200.png)
![Tile38 Logo](https://raw.githubusercontent.com/tidwall/tile38/master/res/logo200.png)
Tile38 is an open source (MIT licensed), in-memory geolocation data store, spatial index, and realtime geofence. It supports a variety of object types including lat/lon points, bounding boxes, XYZ tiles, Geohashes, and GeoJSON.
@ -17,6 +17,7 @@ Tile38 is an open source (MIT licensed), in-memory geolocation data store, spati
- In-memory database that persists on disk.
## Contact
Josh Baker [@tidwall](http://twitter.com/tidwall)
## License

View File

@ -4,8 +4,8 @@ import (
"math"
"github.com/tidwall/btree"
"github.com/tidwall/tile38/geojson"
"github.com/tidwall/tile38/index"
"github.com/tidwall/tile38/pkg/geojson"
"github.com/tidwall/tile38/pkg/index"
)
const (

View File

@ -7,7 +7,7 @@ import (
"testing"
"time"
"github.com/tidwall/tile38/geojson"
"github.com/tidwall/tile38/pkg/geojson"
)
func TestCollection(t *testing.T) {

View File

@ -14,8 +14,8 @@ import (
"github.com/tidwall/buntdb"
"github.com/tidwall/redcon"
"github.com/tidwall/resp"
"github.com/tidwall/tile38/controller/log"
"github.com/tidwall/tile38/controller/server"
"github.com/tidwall/tile38/pkg/log"
"github.com/tidwall/tile38/pkg/server"
)
// AsyncHooks indicates that the hooks should happen in the background.

View File

@ -10,7 +10,7 @@ import (
"time"
"github.com/tidwall/resp"
"github.com/tidwall/tile38/controller/log"
"github.com/tidwall/tile38/pkg/log"
)
var errCorruptedAOF = errors.New("corrupted aof file")

View File

@ -8,10 +8,10 @@ import (
"strings"
"time"
"github.com/tidwall/tile38/controller/collection"
"github.com/tidwall/tile38/controller/log"
"github.com/tidwall/tile38/core"
"github.com/tidwall/tile38/geojson"
"github.com/tidwall/tile38/pkg/collection"
"github.com/tidwall/tile38/pkg/core"
"github.com/tidwall/tile38/pkg/geojson"
"github.com/tidwall/tile38/pkg/log"
)
const maxkeys = 8

View File

@ -9,8 +9,8 @@ import (
"time"
"github.com/tidwall/resp"
"github.com/tidwall/tile38/controller/log"
"github.com/tidwall/tile38/core"
"github.com/tidwall/tile38/pkg/core"
"github.com/tidwall/tile38/pkg/log"
)
// checksum performs a simple md5 checksum on the aof file

View File

@ -9,7 +9,7 @@ import (
"time"
"github.com/tidwall/resp"
"github.com/tidwall/tile38/controller/server"
"github.com/tidwall/tile38/pkg/server"
)
// Conn represents a simple resp connection.

View File

@ -12,8 +12,8 @@ import (
"github.com/tidwall/gjson"
"github.com/tidwall/resp"
"github.com/tidwall/tile38/controller/glob"
"github.com/tidwall/tile38/controller/server"
"github.com/tidwall/tile38/pkg/glob"
"github.com/tidwall/tile38/pkg/server"
)
const (

View File

@ -19,12 +19,12 @@ import (
"github.com/tidwall/btree"
"github.com/tidwall/buntdb"
"github.com/tidwall/resp"
"github.com/tidwall/tile38/controller/collection"
"github.com/tidwall/tile38/controller/endpoint"
"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/pkg/collection"
"github.com/tidwall/tile38/pkg/core"
"github.com/tidwall/tile38/pkg/endpoint"
"github.com/tidwall/tile38/pkg/geojson"
"github.com/tidwall/tile38/pkg/log"
"github.com/tidwall/tile38/pkg/server"
)
var errOOM = errors.New("OOM command not allowed when used memory > 'maxmemory'")

View File

@ -9,11 +9,11 @@ import (
"github.com/tidwall/btree"
"github.com/tidwall/resp"
"github.com/tidwall/tile38/controller/collection"
"github.com/tidwall/tile38/controller/glob"
"github.com/tidwall/tile38/controller/server"
"github.com/tidwall/tile38/geojson"
"github.com/tidwall/tile38/geojson/geohash"
"github.com/tidwall/tile38/pkg/collection"
"github.com/tidwall/tile38/pkg/geojson"
"github.com/tidwall/tile38/pkg/geojson/geohash"
"github.com/tidwall/tile38/pkg/glob"
"github.com/tidwall/tile38/pkg/server"
)
type fvt struct {

View File

@ -10,8 +10,8 @@ import (
"time"
"github.com/tidwall/resp"
"github.com/tidwall/tile38/controller/log"
"github.com/tidwall/tile38/controller/server"
"github.com/tidwall/tile38/pkg/log"
"github.com/tidwall/tile38/pkg/server"
)
// MASSINSERT num_keys num_points [minx miny maxx maxy]

View File

@ -7,7 +7,7 @@ import (
"github.com/tidwall/btree"
"github.com/tidwall/resp"
"github.com/tidwall/tile38/controller/server"
"github.com/tidwall/tile38/pkg/server"
)
type exitem struct {

View File

@ -6,9 +6,9 @@ import (
"time"
"github.com/tidwall/gjson"
"github.com/tidwall/tile38/controller/glob"
"github.com/tidwall/tile38/controller/server"
"github.com/tidwall/tile38/geojson"
"github.com/tidwall/tile38/pkg/geojson"
"github.com/tidwall/tile38/pkg/glob"
"github.com/tidwall/tile38/pkg/server"
)
// FenceMatch executes a fence match returns back json messages for fence detection.

View File

@ -10,9 +10,9 @@ import (
"time"
"github.com/tidwall/resp"
"github.com/tidwall/tile38/controller/log"
"github.com/tidwall/tile38/controller/server"
"github.com/tidwall/tile38/core"
"github.com/tidwall/tile38/pkg/core"
"github.com/tidwall/tile38/pkg/log"
"github.com/tidwall/tile38/pkg/server"
)
var errNoLongerFollowing = errors.New("no longer following")

View File

@ -11,10 +11,10 @@ import (
"github.com/tidwall/buntdb"
"github.com/tidwall/resp"
"github.com/tidwall/tile38/controller/endpoint"
"github.com/tidwall/tile38/controller/glob"
"github.com/tidwall/tile38/controller/log"
"github.com/tidwall/tile38/controller/server"
"github.com/tidwall/tile38/pkg/endpoint"
"github.com/tidwall/tile38/pkg/glob"
"github.com/tidwall/tile38/pkg/log"
"github.com/tidwall/tile38/pkg/server"
)
var hookLogSetDefaults = &buntdb.SetOptions{

View File

@ -10,9 +10,9 @@ import (
"github.com/tidwall/gjson"
"github.com/tidwall/resp"
"github.com/tidwall/sjson"
"github.com/tidwall/tile38/controller/collection"
"github.com/tidwall/tile38/controller/server"
"github.com/tidwall/tile38/geojson"
"github.com/tidwall/tile38/pkg/collection"
"github.com/tidwall/tile38/pkg/geojson"
"github.com/tidwall/tile38/pkg/server"
)
func appendJSONString(b []byte, s string) []byte {

View File

@ -7,8 +7,8 @@ import (
"github.com/tidwall/btree"
"github.com/tidwall/resp"
"github.com/tidwall/tile38/controller/glob"
"github.com/tidwall/tile38/controller/server"
"github.com/tidwall/tile38/pkg/glob"
"github.com/tidwall/tile38/pkg/server"
)
func (c *Controller) cmdKeys(msg *server.Message) (res resp.Value, err error) {

View File

@ -8,8 +8,8 @@ import (
"net"
"sync"
"github.com/tidwall/tile38/controller/log"
"github.com/tidwall/tile38/controller/server"
"github.com/tidwall/tile38/pkg/log"
"github.com/tidwall/tile38/pkg/server"
)
type liveBuffer struct {

View File

@ -5,7 +5,7 @@ import (
"time"
"github.com/tidwall/resp"
"github.com/tidwall/tile38/controller/server"
"github.com/tidwall/tile38/pkg/server"
)
func (c *Controller) cmdOutput(msg *server.Message) (res resp.Value, err error) {

View File

@ -5,8 +5,8 @@ import (
"time"
"github.com/tidwall/resp"
"github.com/tidwall/tile38/controller/log"
"github.com/tidwall/tile38/controller/server"
"github.com/tidwall/tile38/pkg/log"
"github.com/tidwall/tile38/pkg/server"
)
func (c *Controller) cmdReadOnly(msg *server.Message) (res resp.Value, err error) {

View File

@ -6,9 +6,9 @@ import (
"time"
"github.com/tidwall/resp"
"github.com/tidwall/tile38/controller/glob"
"github.com/tidwall/tile38/controller/server"
"github.com/tidwall/tile38/geojson"
"github.com/tidwall/tile38/pkg/geojson"
"github.com/tidwall/tile38/pkg/glob"
"github.com/tidwall/tile38/pkg/server"
)
func (c *Controller) cmdScanArgs(vs []resp.Value) (s liveFenceSwitches, err error) {

View File

@ -8,10 +8,10 @@ import (
"sync"
"github.com/tidwall/resp"
"github.com/tidwall/tile38/controller/collection"
"github.com/tidwall/tile38/controller/glob"
"github.com/tidwall/tile38/controller/server"
"github.com/tidwall/tile38/geojson"
"github.com/tidwall/tile38/pkg/collection"
"github.com/tidwall/tile38/pkg/geojson"
"github.com/tidwall/tile38/pkg/glob"
"github.com/tidwall/tile38/pkg/server"
)
const limitItems = 100

View File

@ -14,7 +14,7 @@ import (
"time"
"github.com/tidwall/resp"
"github.com/tidwall/tile38/controller/server"
"github.com/tidwall/tile38/pkg/server"
"github.com/yuin/gopher-lua"
luajson "layeh.com/gopher-json"
)

View File

@ -9,11 +9,11 @@ import (
"time"
"github.com/tidwall/resp"
"github.com/tidwall/tile38/controller/bing"
"github.com/tidwall/tile38/controller/glob"
"github.com/tidwall/tile38/controller/server"
"github.com/tidwall/tile38/geojson"
"github.com/tidwall/tile38/geojson/geohash"
"github.com/tidwall/tile38/pkg/bing"
"github.com/tidwall/tile38/pkg/geojson"
"github.com/tidwall/tile38/pkg/geojson/geohash"
"github.com/tidwall/tile38/pkg/glob"
"github.com/tidwall/tile38/pkg/server"
)
type liveFenceSwitches struct {

View File

@ -12,8 +12,8 @@ import (
"github.com/tidwall/btree"
"github.com/tidwall/resp"
"github.com/tidwall/tile38/controller/server"
"github.com/tidwall/tile38/core"
"github.com/tidwall/tile38/pkg/core"
"github.com/tidwall/tile38/pkg/server"
)
func (c *Controller) cmdStats(msg *server.Message) (res resp.Value, err error) {

View File

@ -8,7 +8,7 @@ import (
"golang.org/x/net/context"
"github.com/tidwall/tile38/hservice"
"github.com/tidwall/tile38/pkg/hservice"
"google.golang.org/grpc"
)

View File

@ -5,7 +5,7 @@ import (
"strconv"
"github.com/tidwall/gjson"
"github.com/tidwall/tile38/geojson/poly"
"github.com/tidwall/tile38/pkg/geojson/poly"
)
// BBox is a bounding box

View File

@ -4,7 +4,7 @@ import (
"encoding/binary"
"github.com/tidwall/gjson"
"github.com/tidwall/tile38/geojson/geohash"
"github.com/tidwall/tile38/pkg/geojson/geohash"
)
// Feature is a geojson object with the type "Feature"

View File

@ -2,7 +2,7 @@ package geojson
import (
"github.com/tidwall/gjson"
"github.com/tidwall/tile38/geojson/geohash"
"github.com/tidwall/tile38/pkg/geojson/geohash"
)
// FeatureCollection is a geojson object with the type "FeatureCollection"

View File

@ -2,7 +2,7 @@ package geojson
import (
"github.com/tidwall/gjson"
"github.com/tidwall/tile38/geojson/geohash"
"github.com/tidwall/tile38/pkg/geojson/geohash"
)
// GeometryCollection is a geojson object with the type "GeometryCollection"

View File

@ -1,6 +1,6 @@
package geojson
import "github.com/tidwall/tile38/geojson/geohash"
import "github.com/tidwall/tile38/pkg/geojson/geohash"
// LineString is a geojson object with the type "LineString"
type LineString struct {

View File

@ -1,8 +1,8 @@
package geojson
import (
"github.com/tidwall/tile38/geojson/geohash"
"github.com/tidwall/tile38/geojson/poly"
"github.com/tidwall/tile38/pkg/geojson/geohash"
"github.com/tidwall/tile38/pkg/geojson/poly"
)
// MultiLineString is a geojson object with the type "MultiLineString"

View File

@ -1,8 +1,8 @@
package geojson
import (
"github.com/tidwall/tile38/geojson/geohash"
"github.com/tidwall/tile38/geojson/poly"
"github.com/tidwall/tile38/pkg/geojson/geohash"
"github.com/tidwall/tile38/pkg/geojson/poly"
)
// MultiPoint is a geojson object with the type "MultiPoint"

View File

@ -1,6 +1,6 @@
package geojson
import "github.com/tidwall/tile38/geojson/geohash"
import "github.com/tidwall/tile38/pkg/geojson/geohash"
// MultiPolygon is a geojson object with the type "MultiPolygon"
type MultiPolygon struct {

View File

@ -6,7 +6,7 @@ import (
"fmt"
"github.com/tidwall/gjson"
"github.com/tidwall/tile38/geojson/poly"
"github.com/tidwall/tile38/pkg/geojson/poly"
)
const (

View File

@ -1,9 +1,9 @@
package geojson
import (
"github.com/tidwall/tile38/geojson/geo"
"github.com/tidwall/tile38/geojson/geohash"
"github.com/tidwall/tile38/geojson/poly"
"github.com/tidwall/tile38/pkg/geojson/geo"
"github.com/tidwall/tile38/pkg/geojson/geohash"
"github.com/tidwall/tile38/pkg/geojson/poly"
)
// Point is a geojson object with the type "Point"

Some files were not shown because too many files have changed in this diff Show More