Documentation
¶
Overview ¶
Package tile38 is a client for the Tile38 geospatial database.
It speaks RESP over TCP directly rather than through a Redis library, which is what makes live geofences possible: adding Fence to a search turns the connection into a stream of events instead of a single reply.
The package has no dependencies outside the standard library.
Index ¶
- Constants
- Variables
- func Field(name string, value any) field
- func GlobalBounds() (swLat, swLon, neLat, neLon float64)
- type A5Result
- type Area
- func AreaBounds(swLat, swLon, neLat, neLon float64) Area
- func AreaCircle(lat, lon float64, metres int) Area
- func AreaGet(collection, id string) Area
- func AreaHash(geohash string) Area
- func AreaObject(geojson string) Area
- func AreaPoint(lat, lon float64) Area
- func AreaQuadKey(quadkey string) Area
- func AreaSector(lat, lon float64, metres int, bearing1, bearing2 float64) Area
- func AreaTile(x, y, z int) Area
- type BoundsCmd
- type BoundsResult
- type ChansCmd
- type Client
- func (c *Client) AOFShrink() *StatusCmd
- func (c *Client) Bounds(collection string) *BoundsCmd
- func (c *Client) Chans(pattern string) *ChansCmd
- func (c *Client) Close() error
- func (c *Client) ConfigGet(parameter string) *ConfigGetCmd
- func (c *Client) ConfigRewrite() *StatusCmd
- func (c *Client) ConfigSet(parameter, value string) *StatusCmd
- func (c *Client) DBSize() *DBSizeCmd
- func (c *Client) Del(collection, id string) *DelCmd
- func (c *Client) DelChan(channelName string) *DelChanCmd
- func (c *Client) DelHook(hookName string) *DelHookCmd
- func (c *Client) Do(ctx context.Context, args ...any) (any, error)
- func (c *Client) Drop(collection string) *DropCmd
- func (c *Client) Exists(collection, id string) *ExistsCmd
- func (c *Client) Expire(collection, id string, seconds int) *ExpireCmd
- func (c *Client) FExists(collection, id, field string) *FExistsCmd
- func (c *Client) FGet(collection, id, field string) *FGetCmd
- func (c *Client) FSet(collection, id string) *FSetCmd
- func (c *Client) FlushDB() *FlushDBCmd
- func (c *Client) Follow(host string, port int) *StatusCmd
- func (c *Client) FollowNone() *StatusCmd
- func (c *Client) GC() *StatusCmd
- func (c *Client) Get(collection, id string) *GetCmd
- func (c *Client) Healthz() *StatusCmd
- func (c *Client) Hooks(pattern string) *HooksCmd
- func (c *Client) Intersects(collection string) *IntersectsCmd
- func (c *Client) JDel(collection, id, path string) *JDelCmd
- func (c *Client) JGet(collection, id, path string) *JGetCmd
- func (c *Client) JSet(collection, id, path string, value any) *JSetCmd
- func (c *Client) Keys(pattern string) *KeysCmd
- func (c *Client) Nearby(collection string) *NearbyCmd
- func (c *Client) PDel(collection, pattern string) *PDelCmd
- func (c *Client) PDelChan(pattern string) *PDelChanCmd
- func (c *Client) PDelHook(pattern string) *PDelHookCmd
- func (c *Client) PSubscribe(ctx context.Context, patterns ...string) (*Stream, error)
- func (c *Client) Persist(collection, id string) *PersistCmd
- func (c *Client) Ping(ctx context.Context) error
- func (c *Client) Pipeline() *Pipeline
- func (c *Client) ReadOnly(on bool) *StatusCmd
- func (c *Client) Rename(collection, newCollection string) *RenameCmd
- func (c *Client) Scan(collection string) *ScanCmd
- func (c *Client) Search(collection string) *SearchCmd
- func (c *Client) Set(collection, id string) *SetCmd
- func (c *Client) SetChan(channelName string) *SetChanCmd
- func (c *Client) SetHook(hookName string) *HookCmd
- func (c *Client) Stats(collections ...string) *StatsCmd
- func (c *Client) Subscribe(ctx context.Context, channels ...string) (*Stream, error)
- func (c *Client) TTL(collection, id string) *TTLCmd
- func (c *Client) Test(area Area) *TestCmd
- func (c *Client) Timeout(ctx context.Context, seconds float64, args ...any) (any, error)
- func (c *Client) Within(collection string) *WithinCmd
- type CollectionStats
- type Command
- type ConfigGetCmd
- type DBSizeCmd
- type DelChanCmd
- type DelCmd
- type DelHookCmd
- type DetectState
- type DropCmd
- type ExistsCmd
- type ExpireCmd
- type FExistsCmd
- type FGetCmd
- type FSetCmd
- type FenceEvent
- type Fields
- type FlushDBCmd
- type GetCmd
- func (cmd *GetCmd) A5(ctx context.Context, level int) (string, error)
- func (cmd *GetCmd) Bounds(ctx context.Context) (BoundsResult, error)
- func (cmd *GetCmd) Fields() Fields
- func (cmd *GetCmd) Hash(ctx context.Context, precision int) (string, error)
- func (cmd *GetCmd) Object(ctx context.Context) (string, error)
- func (cmd *GetCmd) Point(ctx context.Context) (lat, lon float64, err error)
- func (cmd *GetCmd) PointZ(ctx context.Context) (lat, lon, z float64, err error)
- func (cmd *GetCmd) WithFields() *GetCmd
- type HashResult
- type HookCmd
- func (cmd *HookCmd) Bounds(swLat, swLon, neLat, neLon float64) *HookCmd
- func (cmd *HookCmd) Circle(lat, lon float64, radius int) *HookCmd
- func (cmd *HookCmd) Commands(commands ...Command) *HookCmd
- func (cmd *HookCmd) Detect(states ...DetectState) *HookCmd
- func (cmd *HookCmd) Distance() *HookCmd
- func (cmd *HookCmd) Do(ctx context.Context) error
- func (cmd *HookCmd) EX(secs int) *HookCmd
- func (cmd *HookCmd) Endpoint(baseURL, subject string) *HookCmd
- func (cmd *HookCmd) EndpointURL(urls ...string) *HookCmd
- func (cmd *HookCmd) Get(collection, id string) *HookCmd
- func (cmd *HookCmd) Hash(geohash string) *HookCmd
- func (cmd *HookCmd) Intersects(collection string) *HookCmd
- func (cmd *HookCmd) Match(pattern string) *HookCmd
- func (cmd *HookCmd) Meta(key, value string) *HookCmd
- func (cmd *HookCmd) Nearby(collection string) *HookCmd
- func (cmd *HookCmd) NoDwell() *HookCmd
- func (cmd *HookCmd) Object(geojson string) *HookCmd
- func (cmd *HookCmd) Point(lat, lon float64) *HookCmd
- func (cmd *HookCmd) QuadKey(quadkey string) *HookCmd
- func (cmd *HookCmd) Radius(metres int) *HookCmd
- func (cmd *HookCmd) Roam(collection string, radiusM int) *HookCmd
- func (cmd *HookCmd) Sector(lat, lon float64, metres int, bearing1, bearing2 float64) *HookCmd
- func (cmd *HookCmd) Where(expr string) *HookCmd
- func (cmd *HookCmd) Within(collection string) *HookCmd
- type HookInfo
- type HooksCmd
- type IntersectsCmd
- func (cmd *IntersectsCmd) A5(cellID string) *IntersectsCmd
- func (cmd *IntersectsCmd) A5Cells(ctx context.Context, level int) ([]A5Result, error)
- func (cmd *IntersectsCmd) Bounds(swLat, swLon, neLat, neLon float64) *IntersectsCmd
- func (cmd *IntersectsCmd) Buffer(metres int) *IntersectsCmd
- func (cmd *IntersectsCmd) Circle(lat, lon float64, radius int) *IntersectsCmd
- func (cmd *IntersectsCmd) Clip() *IntersectsCmd
- func (cmd *IntersectsCmd) Commands(commands ...Command) *IntersectsCmd
- func (cmd *IntersectsCmd) Count(ctx context.Context) (int, error)
- func (cmd *IntersectsCmd) Cursor(n uint64) *IntersectsCmd
- func (cmd *IntersectsCmd) Detect(states ...DetectState) *IntersectsCmd
- func (cmd *IntersectsCmd) Distance() *IntersectsCmd
- func (cmd *IntersectsCmd) Fence(ctx context.Context) (*Stream, error)
- func (cmd *IntersectsCmd) Get(collection, id string) *IntersectsCmd
- func (cmd *IntersectsCmd) Hash(geohash string) *IntersectsCmd
- func (cmd *IntersectsCmd) Hashes(ctx context.Context, precision int) ([]HashResult, error)
- func (cmd *IntersectsCmd) IDs(ctx context.Context) ([]string, error)
- func (cmd *IntersectsCmd) Limit(n int) *IntersectsCmd
- func (cmd *IntersectsCmd) Match(pattern string) *IntersectsCmd
- func (cmd *IntersectsCmd) NextCursor() uint64
- func (cmd *IntersectsCmd) NoFields() *IntersectsCmd
- func (cmd *IntersectsCmd) Object(geojson string) *IntersectsCmd
- func (cmd *IntersectsCmd) Objects(ctx context.Context) ([]SearchObject, error)
- func (cmd *IntersectsCmd) Points(ctx context.Context) ([]NearbyResult, error)
- func (cmd *IntersectsCmd) QuadKey(quadkey string) *IntersectsCmd
- func (cmd *IntersectsCmd) Rects(ctx context.Context) ([]RectResult, error)
- func (cmd *IntersectsCmd) Sector(lat, lon float64, metres int, bearing1, bearing2 float64) *IntersectsCmd
- func (cmd *IntersectsCmd) Sparse(depth int) *IntersectsCmd
- func (cmd *IntersectsCmd) Tile(x, y, z int) *IntersectsCmd
- func (cmd *IntersectsCmd) Where(expr string) *IntersectsCmd
- func (cmd *IntersectsCmd) WhereEval(script string, args ...any) *IntersectsCmd
- func (cmd *IntersectsCmd) WhereEvalSha(sha string, args ...any) *IntersectsCmd
- func (cmd *IntersectsCmd) WhereIn(field string, values ...any) *IntersectsCmd
- type JDelCmd
- type JGetCmd
- type JSetCmd
- type KeysCmd
- type NearbyCmd
- func (cmd *NearbyCmd) A5Cells(ctx context.Context, level int) ([]A5Result, error)
- func (cmd *NearbyCmd) Commands(commands ...Command) *NearbyCmd
- func (cmd *NearbyCmd) Count(ctx context.Context) (int, error)
- func (cmd *NearbyCmd) Cursor(n uint64) *NearbyCmd
- func (cmd *NearbyCmd) Detect(states ...DetectState) *NearbyCmd
- func (cmd *NearbyCmd) Distance() *NearbyCmd
- func (cmd *NearbyCmd) Fence(ctx context.Context) (*Stream, error)
- func (cmd *NearbyCmd) Hashes(ctx context.Context, precision int) ([]HashResult, error)
- func (cmd *NearbyCmd) IDs(ctx context.Context) ([]string, error)
- func (cmd *NearbyCmd) Limit(n int) *NearbyCmd
- func (cmd *NearbyCmd) Match(pattern string) *NearbyCmd
- func (cmd *NearbyCmd) NextCursor() uint64
- func (cmd *NearbyCmd) NoDwell() *NearbyCmd
- func (cmd *NearbyCmd) NoFields() *NearbyCmd
- func (cmd *NearbyCmd) Objects(ctx context.Context) ([]SearchObject, error)
- func (cmd *NearbyCmd) Point(lat, lon float64) *NearbyCmd
- func (cmd *NearbyCmd) Points(ctx context.Context) ([]NearbyResult, error)
- func (cmd *NearbyCmd) PointsWithDistance(ctx context.Context) ([]NearbyResultWithDistance, error)
- func (cmd *NearbyCmd) Radius(metres int) *NearbyCmd
- func (cmd *NearbyCmd) Rects(ctx context.Context) ([]RectResult, error)
- func (cmd *NearbyCmd) Roam(collection string, radiusM int) *NearbyCmd
- func (cmd *NearbyCmd) Sparse(depth int) *NearbyCmd
- func (cmd *NearbyCmd) Where(expr string) *NearbyCmd
- func (cmd *NearbyCmd) WhereEval(script string, args ...any) *NearbyCmd
- func (cmd *NearbyCmd) WhereEvalSha(sha string, args ...any) *NearbyCmd
- func (cmd *NearbyCmd) WhereIn(field string, values ...any) *NearbyCmd
- type NearbyResult
- type NearbyResultWithDistance
- type Option
- type PDelChanCmd
- type PDelCmd
- type PDelHookCmd
- type PersistCmd
- type Pipeline
- type PipelineSetCmd
- func (cmd *PipelineSetCmd) EX(secs int) *PipelineSetCmd
- func (cmd *PipelineSetCmd) Field(name string, value any) *PipelineSetCmd
- func (cmd *PipelineSetCmd) Fields(fields ...field) *PipelineSetCmd
- func (cmd *PipelineSetCmd) Point(lat, lon float64) *PipelineSetCmd
- func (cmd *PipelineSetCmd) PointZ(lat, lon, z float64) *PipelineSetCmd
- func (cmd *PipelineSetCmd) Queue()
- type RectResult
- type RenameCmd
- type ScanCmd
- func (cmd *ScanCmd) A5Cells(ctx context.Context, level int) ([]A5Result, error)
- func (cmd *ScanCmd) Asc() *ScanCmd
- func (cmd *ScanCmd) Count(ctx context.Context) (int, error)
- func (cmd *ScanCmd) Cursor(n uint64) *ScanCmd
- func (cmd *ScanCmd) Desc() *ScanCmd
- func (cmd *ScanCmd) Hashes(ctx context.Context, precision int) ([]HashResult, error)
- func (cmd *ScanCmd) IDs(ctx context.Context) ([]string, error)
- func (cmd *ScanCmd) Limit(n int) *ScanCmd
- func (cmd *ScanCmd) Match(pattern string) *ScanCmd
- func (cmd *ScanCmd) NextCursor() uint64
- func (cmd *ScanCmd) NoFields() *ScanCmd
- func (cmd *ScanCmd) Objects(ctx context.Context) ([]SearchObject, error)
- func (cmd *ScanCmd) Points(ctx context.Context) ([]NearbyResult, error)
- func (cmd *ScanCmd) Rects(ctx context.Context) ([]RectResult, error)
- func (cmd *ScanCmd) Where(expr string) *ScanCmd
- func (cmd *ScanCmd) WhereEval(script string, args ...any) *ScanCmd
- func (cmd *ScanCmd) WhereEvalSha(sha string, args ...any) *ScanCmd
- func (cmd *ScanCmd) WhereIn(field string, values ...any) *ScanCmd
- type SearchCmd
- func (cmd *SearchCmd) Asc() *SearchCmd
- func (cmd *SearchCmd) Count(ctx context.Context) (int, error)
- func (cmd *SearchCmd) Cursor(n uint64) *SearchCmd
- func (cmd *SearchCmd) Desc() *SearchCmd
- func (cmd *SearchCmd) IDs(ctx context.Context) ([]string, error)
- func (cmd *SearchCmd) Limit(n int) *SearchCmd
- func (cmd *SearchCmd) Match(pattern string) *SearchCmd
- func (cmd *SearchCmd) NextCursor() uint64
- func (cmd *SearchCmd) NoFields() *SearchCmd
- func (cmd *SearchCmd) Strings(ctx context.Context) ([]StringObject, error)
- func (cmd *SearchCmd) Where(expr string) *SearchCmd
- func (cmd *SearchCmd) WhereEval(script string, args ...any) *SearchCmd
- func (cmd *SearchCmd) WhereEvalSha(sha string, args ...any) *SearchCmd
- func (cmd *SearchCmd) WhereIn(field string, values ...any) *SearchCmd
- type SearchObject
- type ServerError
- type SetChanCmd
- func (cmd *SetChanCmd) Bounds(swLat, swLon, neLat, neLon float64) *SetChanCmd
- func (cmd *SetChanCmd) Circle(lat, lon float64, radius int) *SetChanCmd
- func (cmd *SetChanCmd) Commands(commands ...Command) *SetChanCmd
- func (cmd *SetChanCmd) Detect(states ...DetectState) *SetChanCmd
- func (cmd *SetChanCmd) Distance() *SetChanCmd
- func (cmd *SetChanCmd) Do(ctx context.Context) error
- func (cmd *SetChanCmd) EX(secs int) *SetChanCmd
- func (cmd *SetChanCmd) Get(collection, id string) *SetChanCmd
- func (cmd *SetChanCmd) Hash(geohash string) *SetChanCmd
- func (cmd *SetChanCmd) Intersects(collection string) *SetChanCmd
- func (cmd *SetChanCmd) Meta(key, value string) *SetChanCmd
- func (cmd *SetChanCmd) Nearby(collection string) *SetChanCmd
- func (cmd *SetChanCmd) NoDwell() *SetChanCmd
- func (cmd *SetChanCmd) Object(geojson string) *SetChanCmd
- func (cmd *SetChanCmd) Point(lat, lon float64) *SetChanCmd
- func (cmd *SetChanCmd) QuadKey(quadkey string) *SetChanCmd
- func (cmd *SetChanCmd) Radius(metres int) *SetChanCmd
- func (cmd *SetChanCmd) Roam(collection string, radiusM int) *SetChanCmd
- func (cmd *SetChanCmd) Sector(lat, lon float64, metres int, bearing1, bearing2 float64) *SetChanCmd
- func (cmd *SetChanCmd) Where(expr string) *SetChanCmd
- func (cmd *SetChanCmd) Within(collection string) *SetChanCmd
- type SetCmd
- func (cmd *SetCmd) Bounds(swLat, swLon, neLat, neLon float64) *SetCmd
- func (cmd *SetCmd) Do(ctx context.Context) error
- func (cmd *SetCmd) EX(secs int) *SetCmd
- func (cmd *SetCmd) Field(name string, value any) *SetCmd
- func (cmd *SetCmd) Fields(fields ...field) *SetCmd
- func (cmd *SetCmd) Hash(geohash string) *SetCmd
- func (cmd *SetCmd) NX() *SetCmd
- func (cmd *SetCmd) Object(geojson string) *SetCmd
- func (cmd *SetCmd) Point(lat, lon float64) *SetCmd
- func (cmd *SetCmd) PointZ(lat, lon, z float64) *SetCmd
- func (cmd *SetCmd) String(value string) *SetCmd
- func (cmd *SetCmd) XX() *SetCmd
- type StatsCmd
- type StatusCmd
- type Stream
- type StringObject
- type TTLCmd
- type TestCmd
- type WithinCmd
- func (cmd *WithinCmd) A5(cellID string) *WithinCmd
- func (cmd *WithinCmd) A5Cells(ctx context.Context, level int) ([]A5Result, error)
- func (cmd *WithinCmd) Bounds(swLat, swLon, neLat, neLon float64) *WithinCmd
- func (cmd *WithinCmd) Buffer(metres int) *WithinCmd
- func (cmd *WithinCmd) Circle(lat, lon float64, radius int) *WithinCmd
- func (cmd *WithinCmd) Clip() *WithinCmd
- func (cmd *WithinCmd) Commands(commands ...Command) *WithinCmd
- func (cmd *WithinCmd) Count(ctx context.Context) (int, error)
- func (cmd *WithinCmd) Cursor(n uint64) *WithinCmd
- func (cmd *WithinCmd) Detect(states ...DetectState) *WithinCmd
- func (cmd *WithinCmd) Distance() *WithinCmd
- func (cmd *WithinCmd) Fence(ctx context.Context) (*Stream, error)
- func (cmd *WithinCmd) Get(collection, id string) *WithinCmd
- func (cmd *WithinCmd) Hash(geohash string) *WithinCmd
- func (cmd *WithinCmd) Hashes(ctx context.Context, precision int) ([]HashResult, error)
- func (cmd *WithinCmd) IDs(ctx context.Context) ([]string, error)
- func (cmd *WithinCmd) Limit(n int) *WithinCmd
- func (cmd *WithinCmd) Match(pattern string) *WithinCmd
- func (cmd *WithinCmd) NextCursor() uint64
- func (cmd *WithinCmd) NoFields() *WithinCmd
- func (cmd *WithinCmd) Object(geojson string) *WithinCmd
- func (cmd *WithinCmd) Objects(ctx context.Context) ([]SearchObject, error)
- func (cmd *WithinCmd) Points(ctx context.Context) ([]NearbyResult, error)
- func (cmd *WithinCmd) QuadKey(quadkey string) *WithinCmd
- func (cmd *WithinCmd) Rects(ctx context.Context) ([]RectResult, error)
- func (cmd *WithinCmd) Sector(lat, lon float64, metres int, bearing1, bearing2 float64) *WithinCmd
- func (cmd *WithinCmd) Sparse(depth int) *WithinCmd
- func (cmd *WithinCmd) Tile(x, y, z int) *WithinCmd
- func (cmd *WithinCmd) Where(expr string) *WithinCmd
- func (cmd *WithinCmd) WhereEval(script string, args ...any) *WithinCmd
- func (cmd *WithinCmd) WhereEvalSha(sha string, args ...any) *WithinCmd
- func (cmd *WithinCmd) WhereIn(field string, values ...any) *WithinCmd
Constants ¶
const DefaultTimeout = conn.DefaultTimeout
DefaultTimeout bounds a single command when WithTimeout is not given.
Variables ¶
var ErrClosed = conn.ErrClosed
ErrClosed is returned when a command is issued on a closed Client.
var ErrTruncated = errors.New("tile38: result truncated, more objects match")
ErrTruncated reports that a search returned only part of what matched: Tile38 stopped at the limit and more objects remain.
This is easy to hit unknowingly, because Tile38 caps every search output except COUNT at 100 results when the command carries no LIMIT (limitItems in internal/server/scanner.go). A query that is correct against a small collection therefore starts silently dropping results as that collection grows, which is what this error exists to prevent.
The results returned alongside it are valid, just incomplete. Either page through the rest with Cursor and NextCursor:
cmd := c.Scan("fleet")
for {
ids, err := cmd.IDs(ctx)
if err != nil && !errors.Is(err, ErrTruncated) {
return err
}
use(ids)
if !errors.Is(err, ErrTruncated) {
break
}
cmd = c.Scan("fleet").Cursor(cmd.NextCursor())
}
or set an explicit Limit to say the cap is intended — an explicit Limit or Cursor silences this error, since then the bound is the caller's own.
Functions ¶
func Field ¶
Field creates a key/value field for use with the Field and Fields methods. The field type stays unexported; Field is the only public entry point.
func GlobalBounds ¶
func GlobalBounds() (swLat, swLon, neLat, neLon float64)
GlobalBounds is the whole-world bounding box. Go binds a multi-valued call straight onto a matching parameter list, so it can be handed to any Bounds method as-is:
c.SetChan("zone").Within("fleet").Bounds(tile38.GlobalBounds())
Types ¶
type A5Result ¶ added in v0.2.0
A5Result holds a single result from a search using the A5 output format. A5 is the one output format Tile38 does not attach fields to (scanner.go, hasFieldsOutput).
type Area ¶ added in v0.2.0
type Area struct {
// contains filtered or unexported fields
}
Area is one side of a TEST comparison. TEST takes two areas positionally rather than as chained options, so they are built as values and handed to Client.Test and the verb method:
ok, err := c.Test(tile38.AreaGet("fleet", "truck1")).
Within(tile38.AreaBounds(tile38.GlobalBounds())).Do(ctx)
The same geometries a search takes are available here, except A5: WITHIN and INTERSECTS accept an A5 cell but TEST rejects it on the supported server.
func AreaBounds ¶ added in v0.2.0
AreaBounds is a lat/lon bounding box (BOUNDS keyword). Pass GlobalBounds() for the whole world.
func AreaCircle ¶ added in v0.2.0
AreaCircle is a circle with centre and radius in metres (CIRCLE keyword).
func AreaObject ¶ added in v0.2.0
AreaObject is an inline GeoJSON geometry (OBJECT keyword).
func AreaQuadKey ¶ added in v0.2.0
AreaQuadKey is the tile a Bing Maps quadkey names (QUADKEY keyword).
func AreaSector ¶ added in v0.2.0
AreaSector is a circle clipped to the arc between two compass bearings in degrees (SECTOR keyword).
type BoundsCmd ¶
type BoundsCmd struct {
// contains filtered or unexported fields
}
BoundsCmd builds a Tile38 BOUNDS command to get the bounding box of a collection.
type BoundsResult ¶
BoundsResult holds the SW and NE corners of a bounding box.
type ChansCmd ¶
type ChansCmd struct {
// contains filtered or unexported fields
}
ChansCmd builds a Tile38 CHANS command to list registered pub/sub channels.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a Tile38 client. It is safe for concurrent use.
Commands take a connection from a small idle pool. Streaming calls (Fence, Subscribe, PSubscribe) get a dedicated connection that never returns to the pool, because the server keeps writing to it.
The zero value is not usable; build one with New.
func New ¶
New creates a Client for addr, the "host:port" of a Tile38 server. No connection is made until the first command.
func (*Client) AOFShrink ¶ added in v0.2.0
AOFShrink starts building a Tile38 AOFSHRINK command, which rewrites the append-only file in the background.
func (*Client) Bounds ¶
Bounds starts building a Tile38 BOUNDS command to get the bounding box of a collection.
func (*Client) Chans ¶
Chans starts building a Tile38 CHANS command to list registered pub/sub channels. Pass "*" to list all channels.
func (*Client) Close ¶
Close closes all pooled connections. Streams opened from this Client are not affected; close those with their own Close.
func (*Client) ConfigGet ¶ added in v0.2.0
func (c *Client) ConfigGet(parameter string) *ConfigGetCmd
ConfigGet starts building a Tile38 CONFIG GET command for one parameter.
func (*Client) ConfigRewrite ¶ added in v0.2.0
ConfigRewrite starts building a Tile38 CONFIG REWRITE command, which writes the running configuration back to the config file.
func (*Client) ConfigSet ¶ added in v0.2.0
ConfigSet starts building a Tile38 CONFIG SET command. The change applies immediately but is lost on restart unless ConfigRewrite persists it.
func (*Client) DBSize ¶
DBSize starts building a query for the total object count across all collections. Tile38 has no DBSIZE command, so this reads num_objects from SERVER.
func (*Client) Del ¶
Del starts building a Tile38 DEL command for the given collection and object ID.
func (*Client) DelChan ¶
func (c *Client) DelChan(channelName string) *DelChanCmd
DelChan starts building a Tile38 DELCHAN command.
func (*Client) DelHook ¶
func (c *Client) DelHook(hookName string) *DelHookCmd
DelHook starts building a Tile38 DELHOOK command for the given hook name.
func (*Client) Do ¶
Do runs a raw Tile38 command and returns the decoded reply — an escape hatch for commands this package does not model. Replies decode to string, int64, []any, or nil.
func (*Client) Exists ¶
Exists starts building a Tile38 EXISTS command to check whether an object exists.
func (*Client) FExists ¶ added in v0.2.0
func (c *Client) FExists(collection, id, field string) *FExistsCmd
FExists starts building a Tile38 FEXISTS command to test whether a field is set on an object.
func (*Client) FSet ¶
FSet starts building a Tile38 FSET command for the given collection and object ID.
func (*Client) FlushDB ¶
func (c *Client) FlushDB() *FlushDBCmd
FlushDB starts building a Tile38 FLUSHDB command to delete all objects and collections.
func (*Client) Follow ¶ added in v0.2.0
Follow starts building a Tile38 FOLLOW command, making this server a replica of the one at host:port. Use FollowNone to stop.
func (*Client) FollowNone ¶ added in v0.2.0
FollowNone starts building "FOLLOW no one", which promotes a replica back to a leader. Tile38 spells it as a host of "no" and a port of "one".
func (*Client) GC ¶ added in v0.2.0
GC starts building a Tile38 GC command, which forces a garbage collection.
func (*Client) Healthz ¶ added in v0.2.0
Healthz starts building a Tile38 HEALTHZ command: a liveness check that takes no read lock, so it answers even while the server is busy. It is the one command besides AUTH and OUTPUT that needs no authentication.
func (*Client) Hooks ¶
Hooks starts building a Tile38 HOOKS command to list registered hooks. Pass "*" to list all hooks.
func (*Client) Intersects ¶
func (c *Client) Intersects(collection string) *IntersectsCmd
Intersects starts building a Tile38 INTERSECTS query for the given collection.
func (*Client) Keys ¶
Keys starts building a Tile38 KEYS command to list collection names matching a glob pattern. Pass "*" to list all collections.
func (*Client) PDel ¶
PDel starts building a Tile38 PDEL command to delete objects matching a glob pattern.
func (*Client) PDelChan ¶
func (c *Client) PDelChan(pattern string) *PDelChanCmd
PDelChan starts building a Tile38 PDELCHAN command (pattern-based channel deletion).
func (*Client) PDelHook ¶
func (c *Client) PDelHook(pattern string) *PDelHookCmd
PDelHook starts building a Tile38 PDELHOOK command (pattern-based hook deletion).
func (*Client) PSubscribe ¶
PSubscribe opens a stream of events from every SETCHAN channel matching the given glob patterns.
func (*Client) Persist ¶
func (c *Client) Persist(collection, id string) *PersistCmd
Persist starts building a Tile38 PERSIST command to remove the TTL from an object.
func (*Client) Pipeline ¶
Pipeline returns a Pipeline for batching multiple SET commands in one round trip.
func (*Client) ReadOnly ¶ added in v0.2.0
ReadOnly starts building a Tile38 READONLY command, turning read-only mode on or off. In read-only mode the server rejects every write.
func (*Client) Search ¶ added in v0.2.0
Search starts building a Tile38 SEARCH query, which matches on the string values "SET … STRING" stores rather than on geometry.
func (*Client) Set ¶
Set starts building a Tile38 SET command for the given collection and object ID.
func (*Client) SetChan ¶
func (c *Client) SetChan(channelName string) *SetChanCmd
SetChan starts building a Tile38 SETCHAN command for a pub/sub geofence channel.
func (*Client) Stats ¶ added in v0.2.0
Stats starts building a Tile38 STATS command for one or more collections.
func (*Client) TTL ¶
TTL starts building a Tile38 TTL command to read the remaining TTL of an object.
func (*Client) Test ¶ added in v0.2.0
Test starts building a Tile38 TEST command comparing area against another, given to Within or Intersects. It touches no stored object.
func (*Client) Timeout ¶ added in v0.2.0
Timeout runs one raw command with a server-side time limit, matching Tile38's TIMEOUT keyword: the server abandons the command after seconds and answers with an error. That is a different guarantee from a context deadline, which only stops this client waiting.
It returns the decoded reply of the wrapped command, as Do does.
type CollectionStats ¶ added in v0.2.0
type CollectionStats struct {
Key string
Exists bool
InMemorySize int64
NumObjects int64
NumPoints int64
NumStrings int64
}
CollectionStats holds the STATS counters for one collection. Exists is false when the collection is not there: Tile38 answers with a null element for a missing key rather than an error.
type Command ¶
type Command string
Command is a Tile38 command that can cause a fence event. Restrict a fence to a subset with Commands.
type ConfigGetCmd ¶ added in v0.2.0
type ConfigGetCmd struct {
// contains filtered or unexported fields
}
ConfigGetCmd builds a Tile38 CONFIG GET command.
type DBSizeCmd ¶
type DBSizeCmd struct {
// contains filtered or unexported fields
}
DBSizeCmd reads the total object count from SERVER.
type DelChanCmd ¶
type DelChanCmd struct {
// contains filtered or unexported fields
}
DelChanCmd builds a Tile38 DELCHAN command.
type DelCmd ¶
type DelCmd struct {
// contains filtered or unexported fields
}
DelCmd builds a Tile38 DEL command.
type DelHookCmd ¶
type DelHookCmd struct {
// contains filtered or unexported fields
}
DelHookCmd builds a Tile38 DELHOOK command.
type DetectState ¶
type DetectState string
DetectState is a geofence transition a fence can report. Restrict a fence to a subset with Detect; omitting it means Tile38's default set.
const ( Inside DetectState = "inside" // object is within the fence Outside DetectState = "outside" // object is outside the fence Enter DetectState = "enter" // object crossed in Exit DetectState = "exit" // object crossed out Cross DetectState = "cross" // object passed through )
Geofence transitions.
type DropCmd ¶
type DropCmd struct {
// contains filtered or unexported fields
}
DropCmd builds a Tile38 DROP command.
type ExistsCmd ¶
type ExistsCmd struct {
// contains filtered or unexported fields
}
ExistsCmd builds a Tile38 EXISTS command.
type ExpireCmd ¶
type ExpireCmd struct {
// contains filtered or unexported fields
}
ExpireCmd builds a Tile38 EXPIRE command.
type FExistsCmd ¶ added in v0.2.0
type FExistsCmd struct {
// contains filtered or unexported fields
}
FExistsCmd builds a Tile38 FEXISTS command.
type FGetCmd ¶
type FGetCmd struct {
// contains filtered or unexported fields
}
FGetCmd builds a Tile38 FGET command.
func (*FGetCmd) Do ¶
Do executes: FGET collection id field
It returns the raw string value of the field. A missing field and an empty one are indistinguishable: Tile38 replies with the zero value of the field either way — "" for a string field, "0" for a numeric one — rather than a null. A missing collection or object does produce an error, so only the field name is ambiguous.
type FSetCmd ¶
type FSetCmd struct {
// contains filtered or unexported fields
}
FSetCmd builds a Tile38 FSET command.
type FenceEvent ¶
type FenceEvent struct {
Command string `json:"command"` // set | del | drop | fset
Group string `json:"group,omitempty"` // correlation group id
Detect string `json:"detect,omitempty"` // enter|exit|inside|outside|cross|roam
Hook string `json:"hook,omitempty"` // hook/channel name
Meta map[string]string `json:"meta,omitempty"` // hook META key/values
Key string `json:"key,omitempty"` // collection key
Time string `json:"time,omitempty"` // RFC3339 timestamp
ID string `json:"id,omitempty"` // object id
Object json.RawMessage `json:"object,omitempty"` // GeoJSON of the object
Fields Fields `json:"fields,omitempty"` // the object's FIELDS at the time of the event
Distance float64 `json:"distance,omitempty"` // metres from the fence centre; only on a fence that asked for DISTANCE
Nearby json.RawMessage `json:"nearby,omitempty"` // roam companion object
Faraway json.RawMessage `json:"faraway,omitempty"` // roam companion object
}
FenceEvent is a decoded Tile38 geofence notification — the JSON payload Tile38 pushes to a webhook endpoint (SETHOOK), broadcasts to a pub/sub channel (SETCHAN), or streams down a live fence connection (Fence) when an object enters, dwells in, or exits a fenced area.
func DecodeFenceEvent ¶
func DecodeFenceEvent(data []byte) (*FenceEvent, error)
DecodeFenceEvent unmarshals a Tile38 geofence notification payload.
type Fields ¶ added in v0.2.0
Fields are an object's Tile38 FIELDS, name → Tile38's own text encoding of the value: the decimal form of a number, the verbatim JSON text of a JSON field. Nil when the object has no non-zero fields, or when the query used NoFields.
Reading them off a result is what makes a whole-collection query one round trip rather than an FGet per field per object.
func (*Fields) UnmarshalJSON ¶ added in v0.2.0
UnmarshalJSON decodes the "fields" object of a geofence notification. Tile38 writes those values as JSON — a string field arrives quoted — where the RESP search replies carry the same values as flat text. Unquoting here means a field reads the same whichever path it arrived on.
type FlushDBCmd ¶
type FlushDBCmd struct {
// contains filtered or unexported fields
}
FlushDBCmd builds a Tile38 FLUSHDB command.
type GetCmd ¶
type GetCmd struct {
// contains filtered or unexported fields
}
GetCmd builds a Tile38 GET command.
func (*GetCmd) A5 ¶
A5 executes: GET collection id A5 level — returns the id of the A5 cell the object's centre falls in, which is what WithinCmd.A5 and IntersectsCmd.A5 take as their area. Requires a server built from upstream master: A5 is merged upstream but has shipped in no release tag as of 1.38.0.
func (*GetCmd) Bounds ¶
func (cmd *GetCmd) Bounds(ctx context.Context) (BoundsResult, error)
Bounds executes: GET collection id BOUNDS — returns the bounding box of the object.
func (*GetCmd) Fields ¶ added in v0.2.0
Fields returns the fields read by the most recent terminal. It is nil until a terminal has run, when WithFields was not chained, or when the object has no non-zero fields — Tile38 omits the fields element entirely in that case.
func (*GetCmd) Hash ¶
Hash executes: GET collection id HASH precision — returns the geohash at the given precision.
func (*GetCmd) Point ¶
Point executes: GET collection id POINT — returns the lat/lon of the object. Use PointZ for an object stored with a third ordinate.
func (*GetCmd) PointZ ¶ added in v0.2.0
PointZ executes: GET collection id POINT — returns the lat/lon of the object along with its third ordinate, which Tile38 appends only when it is non-zero.
func (*GetCmd) WithFields ¶ added in v0.2.0
WithFields asks for the object's fields alongside its geometry, matching Tile38's WITHFIELDS keyword. It applies to every output format; read the fields with Fields once the terminal has returned:
g := c.Get("fleet", "truck1").WithFields()
lat, lon, err := g.Point(ctx)
speed := g.Fields()["speed"]
One GET then answers what would otherwise take an FGet per field.
type HashResult ¶ added in v0.2.0
type HashResult struct {
ID string
Hash string // geohash at the precision the query asked for
Fields Fields
}
HashResult holds a single result from a search using the HASHES output format.
type HookCmd ¶
type HookCmd struct {
// contains filtered or unexported fields
}
HookCmd builds a Tile38 SETHOOK command: an endpoint, a spatial trigger (Nearby/Within), optional Detect/Commands filters, and one fence area (Bounds/Circle/Object/Get, or Roam).
Methods may be chained in any order; the parts are assembled into protocol order when the command runs.
func (*HookCmd) Bounds ¶
Bounds sets the fence area to a lat/lon bounding box. Pass GlobalBounds() to fence the whole world.
func (*HookCmd) Detect ¶
func (cmd *HookCmd) Detect(states ...DetectState) *HookCmd
Detect restricts the hook to the given transitions. When omitted, Tile38's default detect set applies.
func (*HookCmd) Distance ¶ added in v0.2.0
Distance adds each object's distance from the fence centre to every event the fence produces, matching Tile38's DISTANCE keyword. It arrives on FenceEvent as Distance, and applies to the live fence only — a plain query reads the same value through PointsWithDistance.
func (*HookCmd) Endpoint ¶
Endpoint adds a target endpoint built by joining a base URL and a subject or path with "/" — the shape NATS and HTTP endpoints take (e.g. "nats://host:4222" + "subject"). For any other scheme, or for a URL carrying query parameters, use EndpointURL.
Calling Endpoint or EndpointURL more than once registers every endpoint on the hook; Tile38 delivers each event to all of them.
func (*HookCmd) EndpointURL ¶
EndpointURL adds target endpoints verbatim, for schemes whose URL is not a base plus a path — kafka://host:9092/topic, sqs://region/queue, grpc://host:port, or an http:// URL with a query string.
func (*HookCmd) Hash ¶ added in v0.2.0
Hash sets the search area to the box a geohash covers, matching Tile38's HASH keyword. The shorter the hash, the larger the box.
func (*HookCmd) Intersects ¶
Intersects selects the INTERSECTS spatial trigger, which fires on any overlap with the fence area rather than requiring full containment.
func (*HookCmd) Match ¶
Match filters the trigger collection by object ID pattern (glob-style, e.g. "org:*"), matching Tile38's MATCH keyword. It accumulates: each call adds another pattern.
func (*HookCmd) Meta ¶
Meta attaches a key/value pair to the hook, echoed back on every event it produces. It accumulates: each call adds another pair.
func (*HookCmd) Nearby ¶
Nearby selects the NEARBY spatial trigger. Use with Point and Radius, or with Roam.
func (*HookCmd) NoDwell ¶
NoDwell stops a roaming fence from re-reporting objects that stay within range between updates, matching Tile38's NODWELL keyword. It only affects Roam fences, and it is opt-in: dwelling is Tile38's own default.
func (*HookCmd) Point ¶ added in v0.2.0
Point sets the fence area to a point, and is the area a Nearby trigger takes: NEARBY reads "POINT lat lon meters" and rejects CIRCLE, so a hook or channel fencing on NEARBY needs this rather than Circle. Pair it with Radius.
func (*HookCmd) QuadKey ¶ added in v0.2.0
QuadKey sets the search area to the tile a Bing Maps quadkey names, matching Tile38's QUADKEY keyword. Tile is the same area expressed as x/y/z.
func (*HookCmd) Radius ¶ added in v0.2.0
Radius sets the trailing metres of a Point area. Named for the value it carries: Tile38 has no keyword for it, it is the last argument of "POINT lat lon meters".
func (*HookCmd) Roam ¶
Roam fires when objects in the trigger collection come within radiusM metres of an object in collection. Use with Nearby.
Objects that stay in range keep reporting on each update; chain NoDwell to suppress those.
func (*HookCmd) Sector ¶ added in v0.2.0
Sector sets the search area to a circular sector: a circle of radius metres centred on lat/lon, clipped to the arc between two compass bearings in degrees. Matches Tile38's SECTOR keyword, which NEARBY does not accept.
type HookInfo ¶
type HookInfo struct {
Name string // hook or channel name
Key string // collection the fence watches
Endpoints []string // delivery targets; "local://<name>" for channels
Command []string // the fence command tokens the hook was created with
Meta map[string]string // the META pairs the hook was created with
}
HookInfo describes a registered hook (HOOKS) or pub/sub channel (CHANS).
type HooksCmd ¶
type HooksCmd struct {
// contains filtered or unexported fields
}
HooksCmd builds a Tile38 HOOKS command to list registered hooks.
type IntersectsCmd ¶
type IntersectsCmd struct {
// contains filtered or unexported fields
}
IntersectsCmd builds a Tile38 INTERSECTS query. INTERSECTS finds objects whose geometry intersects the search area, whereas WITHIN requires full containment. Methods may be chained in any order; the parts are assembled into protocol order when the command runs.
func (*IntersectsCmd) A5 ¶
func (cmd *IntersectsCmd) A5(cellID string) *IntersectsCmd
A5 sets the search area to a single A5 cell's pentagon, identified by its hex cell id (A5 keyword). Requires a server built from upstream master: A5 is merged upstream but has shipped in no release tag as of 1.38.0. Tile38 accepts A5 as a search area only, not as a hook or channel fence area.
func (*IntersectsCmd) A5Cells ¶ added in v0.2.0
A5Cells executes: INTERSECTS collection [opts] A5 level <area> Each result is the A5 cell a matching object's centre falls in. Named for the output rather than the keyword because A5 is already the search-area method on the builders that take one. Requires a server built from upstream master.
func (*IntersectsCmd) Bounds ¶
func (cmd *IntersectsCmd) Bounds(swLat, swLon, neLat, neLon float64) *IntersectsCmd
Bounds sets the search area to a lat/lon bounding box (BOUNDS keyword).
func (*IntersectsCmd) Buffer ¶ added in v0.2.0
func (cmd *IntersectsCmd) Buffer(metres int) *IntersectsCmd
Buffer grows the search area by the given number of metres before matching, matching Tile38's BUFFER keyword. Tile38 can only buffer point-like areas — it answers "cannot buffer Polygon type" for a Bounds or polygon Object area, and it panics rather than answering on NEARBY, which is why NearbyCmd has no Buffer.
It is appended rather than stored: Tile38 has no duplicate guard for BUFFER, so a repeat is legal and the last one wins.
func (*IntersectsCmd) Circle ¶
func (cmd *IntersectsCmd) Circle(lat, lon float64, radius int) *IntersectsCmd
Circle sets the search area to a circle with centre + radius in metres (CIRCLE keyword).
func (*IntersectsCmd) Clip ¶
func (cmd *IntersectsCmd) Clip() *IntersectsCmd
Clip trims returned objects to the search area rather than returning them whole, matching Tile38's CLIP keyword.
func (*IntersectsCmd) Commands ¶
func (cmd *IntersectsCmd) Commands(commands ...Command) *IntersectsCmd
Commands restricts a live fence to events caused by the given commands. Only meaningful with Fence.
func (*IntersectsCmd) Count ¶
func (cmd *IntersectsCmd) Count(ctx context.Context) (int, error)
Count executes: INTERSECTS collection [opts] COUNT area
func (*IntersectsCmd) Cursor ¶
func (cmd *IntersectsCmd) Cursor(n uint64) *IntersectsCmd
Cursor resumes a search from where a previous one stopped, matching Tile38's CURSOR keyword. Pass the value NextCursor reported. Setting it also means the caller is paging deliberately, so a truncated result no longer reports ErrTruncated. Tile38 rejects CURSOR on a fence, so Fence ignores it.
func (*IntersectsCmd) Detect ¶
func (cmd *IntersectsCmd) Detect(states ...DetectState) *IntersectsCmd
Detect restricts a live fence to the given transitions. Only meaningful with Fence.
func (*IntersectsCmd) Distance ¶ added in v0.2.0
func (cmd *IntersectsCmd) Distance() *IntersectsCmd
Distance adds each object's distance from the fence centre to every event the fence produces, matching Tile38's DISTANCE keyword. It arrives on FenceEvent as Distance, and applies to the live fence only — a plain query reads the same value through PointsWithDistance.
func (*IntersectsCmd) Fence ¶
func (cmd *IntersectsCmd) Fence(ctx context.Context) (*Stream, error)
Fence opens a live geofence: INTERSECTS collection [opts] FENCE [DETECT …] area. The returned Stream holds a dedicated connection and delivers events until it is closed or ctx is cancelled.
func (*IntersectsCmd) Get ¶
func (cmd *IntersectsCmd) Get(collection, id string) *IntersectsCmd
Get sets the search area to an object already stored in Tile38 (GET keyword).
func (*IntersectsCmd) Hash ¶ added in v0.2.0
func (cmd *IntersectsCmd) Hash(geohash string) *IntersectsCmd
Hash sets the search area to the box a geohash covers, matching Tile38's HASH keyword. The shorter the hash, the larger the box.
func (*IntersectsCmd) Hashes ¶ added in v0.2.0
func (cmd *IntersectsCmd) Hashes(ctx context.Context, precision int) ([]HashResult, error)
Hashes executes: INTERSECTS collection [opts] HASHES precision <area> Each result is the geohash of a matching object's centre.
func (*IntersectsCmd) IDs ¶
func (cmd *IntersectsCmd) IDs(ctx context.Context) ([]string, error)
IDs executes: INTERSECTS collection [opts] IDS area
func (*IntersectsCmd) Limit ¶
func (cmd *IntersectsCmd) Limit(n int) *IntersectsCmd
Limit caps the number of results. Zero means no limit.
func (*IntersectsCmd) Match ¶
func (cmd *IntersectsCmd) Match(pattern string) *IntersectsCmd
Match filters results by ID pattern (glob-style, e.g. "truck:*").
func (*IntersectsCmd) NextCursor ¶
func (cmd *IntersectsCmd) NextCursor() uint64
NextCursor reports where to resume after the last executed terminal. It is non-zero only when Tile38 stopped at the limit with more objects matching.
func (*IntersectsCmd) NoFields ¶
func (cmd *IntersectsCmd) NoFields() *IntersectsCmd
NoFields drops field values from the reply, matching Tile38's NOFIELDS keyword.
func (*IntersectsCmd) Object ¶
func (cmd *IntersectsCmd) Object(geojson string) *IntersectsCmd
Object sets the search area to an inline GeoJSON string (OBJECT keyword).
func (*IntersectsCmd) Objects ¶
func (cmd *IntersectsCmd) Objects(ctx context.Context) ([]SearchObject, error)
Objects executes: INTERSECTS collection [opts] OBJECTS area
func (*IntersectsCmd) Points ¶
func (cmd *IntersectsCmd) Points(ctx context.Context) ([]NearbyResult, error)
Points executes: INTERSECTS collection [opts] POINTS area
func (*IntersectsCmd) QuadKey ¶ added in v0.2.0
func (cmd *IntersectsCmd) QuadKey(quadkey string) *IntersectsCmd
QuadKey sets the search area to the tile a Bing Maps quadkey names, matching Tile38's QUADKEY keyword. Tile is the same area expressed as x/y/z.
func (*IntersectsCmd) Rects ¶ added in v0.2.0
func (cmd *IntersectsCmd) Rects(ctx context.Context) ([]RectResult, error)
Rects executes: INTERSECTS collection [opts] BOUNDS <area> Each result is the bounding box of a matching object, lat first.
func (*IntersectsCmd) Sector ¶ added in v0.2.0
func (cmd *IntersectsCmd) Sector(lat, lon float64, metres int, bearing1, bearing2 float64) *IntersectsCmd
Sector sets the search area to a circular sector: a circle of radius metres centred on lat/lon, clipped to the arc between two compass bearings in degrees. Matches Tile38's SECTOR keyword, which NEARBY does not accept.
func (*IntersectsCmd) Sparse ¶
func (cmd *IntersectsCmd) Sparse(depth int) *IntersectsCmd
Sparse spreads results evenly over the search area at the given depth (1-8), matching Tile38's SPARSE keyword. Tile38 rejects SPARSE combined with Limit.
func (*IntersectsCmd) Tile ¶
func (cmd *IntersectsCmd) Tile(x, y, z int) *IntersectsCmd
Tile sets the search area to a single XYZ map tile (TILE keyword).
func (*IntersectsCmd) Where ¶
func (cmd *IntersectsCmd) Where(expr string) *IntersectsCmd
Where sets an optional Tile38 field expression filter.
func (*IntersectsCmd) WhereEval ¶ added in v0.2.0
func (cmd *IntersectsCmd) WhereEval(script string, args ...any) *IntersectsCmd
WhereEval keeps results for which the given Lua script returns true, matching Tile38's WHEREEVAL keyword. The script sees the object's fields as FIELDS and the extra arguments as ARGV. It accumulates: each call adds another filter.
func (*IntersectsCmd) WhereEvalSha ¶ added in v0.2.0
func (cmd *IntersectsCmd) WhereEvalSha(sha string, args ...any) *IntersectsCmd
WhereEvalSha is WhereEval against a script already loaded on the server, matching Tile38's WHEREEVALSHA keyword.
func (*IntersectsCmd) WhereIn ¶
func (cmd *IntersectsCmd) WhereIn(field string, values ...any) *IntersectsCmd
WhereIn keeps results whose field holds one of the given values, matching Tile38's WHEREIN keyword. It accumulates: each call adds another filter.
type JDelCmd ¶
type JDelCmd struct {
// contains filtered or unexported fields
}
JDelCmd builds a Tile38 JDEL command to delete a value at a JSON path.
type JGetCmd ¶
type JGetCmd struct {
// contains filtered or unexported fields
}
JGetCmd builds a Tile38 JGET command to read a value at a JSON path.
type JSetCmd ¶
type JSetCmd struct {
// contains filtered or unexported fields
}
JSetCmd builds a Tile38 JSET command to set a value at a JSON path.
type KeysCmd ¶
type KeysCmd struct {
// contains filtered or unexported fields
}
KeysCmd builds a Tile38 KEYS command to list collection names.
type NearbyCmd ¶
type NearbyCmd struct {
// contains filtered or unexported fields
}
NearbyCmd builds a Tile38 NEARBY command. Methods may be chained in any order; the parts are assembled into protocol order when the command runs.
func (*NearbyCmd) A5Cells ¶ added in v0.2.0
A5Cells executes: NEARBY collection [opts] A5 level POINT lat lon radius Each result is the A5 cell a matching object's centre falls in. Named for the output rather than the keyword because A5 is already the search-area method on the builders that take one. Requires a server built from upstream master.
func (*NearbyCmd) Commands ¶
Commands restricts a live fence to events caused by the given commands. Only meaningful with Fence.
func (*NearbyCmd) Cursor ¶
Cursor resumes a search from where a previous one stopped, matching Tile38's CURSOR keyword. Pass the value NextCursor reported. Setting it also means the caller is paging deliberately, so a truncated result no longer reports ErrTruncated. Tile38 rejects CURSOR on a fence, so Fence ignores it.
func (*NearbyCmd) Detect ¶
func (cmd *NearbyCmd) Detect(states ...DetectState) *NearbyCmd
Detect restricts a live fence to the given transitions. Only meaningful with Fence.
func (*NearbyCmd) Distance ¶ added in v0.2.0
Distance adds each object's distance from the fence centre to every event the fence produces, matching Tile38's DISTANCE keyword. It arrives on FenceEvent as Distance, and applies to the live fence only — a plain query reads the same value through PointsWithDistance.
func (*NearbyCmd) Fence ¶
Fence opens a live geofence: NEARBY collection [opts] FENCE [DETECT …] POINT lat lon radius. The returned Stream holds a dedicated connection and delivers events until it is closed or ctx is cancelled.
func (*NearbyCmd) Hashes ¶ added in v0.2.0
Hashes executes: NEARBY collection [opts] HASHES precision POINT lat lon radius Each result is the geohash of a matching object's centre.
func (*NearbyCmd) NextCursor ¶
NextCursor reports where to resume after the last executed terminal. It is non-zero only when Tile38 stopped at the limit with more objects matching.
func (*NearbyCmd) NoDwell ¶
NoDwell stops a roaming fence from re-reporting objects that stay within range between updates, matching Tile38's NODWELL keyword. It only affects Roam fences.
func (*NearbyCmd) NoFields ¶
NoFields drops field values from the reply, matching Tile38's NOFIELDS keyword.
func (*NearbyCmd) Objects ¶
func (cmd *NearbyCmd) Objects(ctx context.Context) ([]SearchObject, error)
Objects executes: NEARBY collection [opts] OBJECTS POINT lat lon radius
func (*NearbyCmd) Points ¶
func (cmd *NearbyCmd) Points(ctx context.Context) ([]NearbyResult, error)
Points executes: NEARBY collection [opts] POINTS POINT lat lon radius
func (*NearbyCmd) PointsWithDistance ¶
func (cmd *NearbyCmd) PointsWithDistance(ctx context.Context) ([]NearbyResultWithDistance, error)
PointsWithDistance executes: NEARBY collection [opts] DISTANCE POINTS POINT lat lon radius DISTANCE is an option token, so it has to precede the output format.
func (*NearbyCmd) Radius ¶
Radius sets the search radius in metres. It applies to a Point area; a Roam area carries its own radius.
func (*NearbyCmd) Rects ¶ added in v0.2.0
func (cmd *NearbyCmd) Rects(ctx context.Context) ([]RectResult, error)
Rects executes: NEARBY collection [opts] BOUNDS POINT lat lon radius Each result is the bounding box of a matching object, lat first.
func (*NearbyCmd) Roam ¶
Roam turns the fence into a roaming one: it fires as objects in this collection move within radiusM metres of an object in collection. Tile38 accepts ROAM only on a live NEARBY fence, so this needs Fence — the plain query terminators will be rejected by the server.
func (*NearbyCmd) Sparse ¶
Sparse spreads results evenly over the search area at the given depth (1-8), matching Tile38's SPARSE keyword. Tile38 rejects SPARSE combined with Limit.
func (*NearbyCmd) WhereEval ¶ added in v0.2.0
WhereEval keeps results for which the given Lua script returns true, matching Tile38's WHEREEVAL keyword. The script sees the object's fields as FIELDS and the extra arguments as ARGV. It accumulates: each call adds another filter.
func (*NearbyCmd) WhereEvalSha ¶ added in v0.2.0
WhereEvalSha is WhereEval against a script already loaded on the server, matching Tile38's WHEREEVALSHA keyword.
type NearbyResult ¶
type NearbyResult struct {
ID string
Lat float64
Lon float64
// Z is the point's third ordinate — Tile38 stores whatever a caller put
// there, most often an altitude. It is zero both for a two-dimensional point
// and for a z of zero: Tile38 omits the ordinate entirely when it is zero,
// so the two are indistinguishable on the wire.
Z float64
Fields Fields
}
NearbyResult holds a single result from a Nearby or Scan query.
type NearbyResultWithDistance ¶
type NearbyResultWithDistance struct {
NearbyResult
Distance float64 // metres
}
NearbyResultWithDistance extends NearbyResult with the distance from the query centre.
type Option ¶
type Option func(*options)
Option configures a Client. Pass any number of them to New.
func WithDialTimeout ¶
WithDialTimeout caps how long opening a connection may take. Defaults to 5s.
func WithMaxActive ¶
WithMaxActive caps how many commands may be in flight at once. Beyond that, callers wait for a slot rather than opening another connection, which is what keeps a burst of concurrent commands from opening a socket per goroutine. Zero, the default, leaves it uncapped. Streams are not counted: they hold a dedicated connection for as long as they run.
func WithMaxIdle ¶
WithMaxIdle caps the connections kept for reuse. It bounds idle connections, not in-flight ones — use WithMaxActive to bound those. Defaults to 8.
func WithPassword ¶
WithPassword sends AUTH on each new connection.
func WithTimeout ¶
WithTimeout sets a deadline for every command. Whichever of this and the call's context expires first wins. Unset, it defaults to DefaultTimeout, so a command against a wedged server fails instead of hanging forever when the context carries no deadline of its own. Pass a negative duration to opt out and rely on the context alone.
It does not apply to streams, which have no read deadline: a quiet fence may legitimately send nothing for hours.
type PDelChanCmd ¶
type PDelChanCmd struct {
// contains filtered or unexported fields
}
PDelChanCmd builds a Tile38 PDELCHAN command (pattern-based channel deletion).
type PDelCmd ¶
type PDelCmd struct {
// contains filtered or unexported fields
}
PDelCmd builds a Tile38 PDEL command to delete objects matching a glob pattern.
type PDelHookCmd ¶
type PDelHookCmd struct {
// contains filtered or unexported fields
}
PDelHookCmd builds a Tile38 PDELHOOK command (pattern-based hook deletion).
type PersistCmd ¶
type PersistCmd struct {
// contains filtered or unexported fields
}
PersistCmd builds a Tile38 PERSIST command to remove the TTL from an object.
type Pipeline ¶
type Pipeline struct {
// contains filtered or unexported fields
}
Pipeline batches SET commands and executes them in a single round trip. It is not safe for concurrent use.
func (*Pipeline) Flush ¶
Flush writes all queued commands in one batch, reads every reply, and resets the pipeline. It returns the first command error encountered.
func (*Pipeline) Set ¶
func (p *Pipeline) Set(collection, id string) *PipelineSetCmd
Set returns a PipelineSetCmd. Chain modifiers then call Queue to enqueue.
type PipelineSetCmd ¶
type PipelineSetCmd struct {
// contains filtered or unexported fields
}
PipelineSetCmd is a deferred SET command queued onto a Pipeline. Chain modifiers then call Queue to enqueue.
func (*PipelineSetCmd) EX ¶
func (cmd *PipelineSetCmd) EX(secs int) *PipelineSetCmd
EX sets the expiry in seconds, matching Tile38's EX keyword. Zero means no expiry.
func (*PipelineSetCmd) Field ¶
func (cmd *PipelineSetCmd) Field(name string, value any) *PipelineSetCmd
Field appends a single named field to the SET command.
func (*PipelineSetCmd) Fields ¶
func (cmd *PipelineSetCmd) Fields(fields ...field) *PipelineSetCmd
Fields appends multiple named fields to the SET command in one call.
func (*PipelineSetCmd) Point ¶
func (cmd *PipelineSetCmd) Point(lat, lon float64) *PipelineSetCmd
Point sets the POINT coordinates.
func (*PipelineSetCmd) PointZ ¶ added in v0.2.0
func (cmd *PipelineSetCmd) PointZ(lat, lon, z float64) *PipelineSetCmd
PointZ sets the POINT coordinates with a third ordinate. See SetCmd.PointZ.
func (*PipelineSetCmd) Queue ¶
func (cmd *PipelineSetCmd) Queue()
Queue enqueues the command onto the pipeline. Context is supplied at Flush.
type RectResult ¶ added in v0.2.0
type RectResult struct {
ID string
Bounds BoundsResult
Fields Fields
}
RectResult holds a single result from a search using the BOUNDS output format.
type RenameCmd ¶
type RenameCmd struct {
// contains filtered or unexported fields
}
RenameCmd builds a Tile38 RENAME command.
type ScanCmd ¶
type ScanCmd struct {
// contains filtered or unexported fields
}
ScanCmd builds a Tile38 SCAN command.
func (*ScanCmd) A5Cells ¶ added in v0.2.0
A5Cells executes: SCAN collection [opts] A5 level Each result is the A5 cell a matching object's centre falls in. Named for the output rather than the keyword because A5 is already the search-area method on the builders that take one. Requires a server built from upstream master.
func (*ScanCmd) Asc ¶ added in v0.2.0
Asc returns results in ascending ID order, matching Tile38's ASC keyword. Only SCAN and SEARCH take an order — the spatial verbs answer "ASC is not allowed for NEARBY". Asc and Desc overwrite each other: Tile38 rejects a command carrying both.
func (*ScanCmd) Cursor ¶
Cursor resumes a search from where a previous one stopped, matching Tile38's CURSOR keyword. Pass the value NextCursor reported. Setting it also means the caller is paging deliberately, so a truncated result no longer reports ErrTruncated. Tile38 rejects CURSOR on a fence, so Fence ignores it.
func (*ScanCmd) Desc ¶ added in v0.2.0
Desc returns results in descending ID order, matching Tile38's DESC keyword. See Asc for why it is single-use.
func (*ScanCmd) Hashes ¶ added in v0.2.0
Hashes executes: SCAN collection [opts] HASHES precision Each result is the geohash of a matching object's centre.
func (*ScanCmd) NextCursor ¶
NextCursor reports where to resume after the last executed terminal. It is non-zero only when Tile38 stopped at the limit with more objects matching.
func (*ScanCmd) NoFields ¶
NoFields drops field values from the reply, matching Tile38's NOFIELDS keyword. SCAN takes no SPARSE — Tile38 rejects it for this command.
func (*ScanCmd) Objects ¶
func (cmd *ScanCmd) Objects(ctx context.Context) ([]SearchObject, error)
Objects executes: SCAN collection [opts] OBJECTS
func (*ScanCmd) Points ¶
func (cmd *ScanCmd) Points(ctx context.Context) ([]NearbyResult, error)
Points executes: SCAN collection [opts] POINTS
func (*ScanCmd) Rects ¶ added in v0.2.0
func (cmd *ScanCmd) Rects(ctx context.Context) ([]RectResult, error)
Rects executes: SCAN collection [opts] BOUNDS Each result is the bounding box of a matching object, lat first.
func (*ScanCmd) WhereEval ¶ added in v0.2.0
WhereEval keeps results for which the given Lua script returns true, matching Tile38's WHEREEVAL keyword. The script sees the object's fields as FIELDS and the extra arguments as ARGV. It accumulates: each call adds another filter.
func (*ScanCmd) WhereEvalSha ¶ added in v0.2.0
WhereEvalSha is WhereEval against a script already loaded on the server, matching Tile38's WHEREEVALSHA keyword.
type SearchCmd ¶ added in v0.2.0
type SearchCmd struct {
// contains filtered or unexported fields
}
SearchCmd builds a Tile38 SEARCH command, which matches on the string values "SET … STRING" stores rather than on geometry. It takes no area and no fence.
func (*SearchCmd) Asc ¶ added in v0.2.0
Asc returns results in ascending order, matching Tile38's ASC keyword. Asc and Desc overwrite each other: Tile38 rejects a command carrying both.
func (*SearchCmd) Cursor ¶ added in v0.2.0
Cursor resumes a search from where a previous one stopped, matching Tile38's CURSOR keyword. Pass the value NextCursor reported.
func (*SearchCmd) Desc ¶ added in v0.2.0
Desc returns results in descending order, matching Tile38's DESC keyword.
func (*SearchCmd) Match ¶ added in v0.2.0
Match filters results by string value (glob-style, e.g. "*hello*"), matching Tile38's MATCH keyword. It accumulates: each call adds another pattern.
func (*SearchCmd) NextCursor ¶ added in v0.2.0
NextCursor reports where to resume after the last executed terminal. It is non-zero only when Tile38 stopped at the limit with more objects matching.
func (*SearchCmd) NoFields ¶ added in v0.2.0
NoFields drops field values from the reply, matching Tile38's NOFIELDS keyword.
func (*SearchCmd) Strings ¶ added in v0.2.0
func (cmd *SearchCmd) Strings(ctx context.Context) ([]StringObject, error)
Strings executes: SEARCH collection [opts] — the default output, which pairs each id with the string value that matched. Tile38 has no keyword for it, so the method is named for what it returns.
func (*SearchCmd) WhereEval ¶ added in v0.2.0
WhereEval keeps results for which the given Lua script returns true, matching Tile38's WHEREEVAL keyword. It accumulates: each call adds another filter.
func (*SearchCmd) WhereEvalSha ¶ added in v0.2.0
WhereEvalSha is WhereEval against a script already loaded on the server, matching Tile38's WHEREEVALSHA keyword.
type SearchObject ¶
SearchObject holds a single result from a search query using the OBJECTS output format.
type ServerError ¶
ServerError is an error reply from Tile38 ("-ERR ..."). It means the command was rejected, not that the connection broke.
type SetChanCmd ¶
type SetChanCmd struct {
// contains filtered or unexported fields
}
SetChanCmd builds a Tile38 SETCHAN command for a pub/sub geofence channel. SETCHAN is identical to SETHOOK but broadcasts events to Subscribe clients instead of pushing to an endpoint URL: a spatial trigger (Nearby/Within), optional Detect/Commands filters, and one fence area.
Methods may be chained in any order; the parts are assembled into protocol order when the command runs.
func (*SetChanCmd) Bounds ¶
func (cmd *SetChanCmd) Bounds(swLat, swLon, neLat, neLon float64) *SetChanCmd
Bounds sets the fence area to a lat/lon bounding box. Pass GlobalBounds() to fence the whole world.
func (*SetChanCmd) Circle ¶
func (cmd *SetChanCmd) Circle(lat, lon float64, radius int) *SetChanCmd
Circle sets the fence area to a circle with centre + radius in metres.
func (*SetChanCmd) Commands ¶
func (cmd *SetChanCmd) Commands(commands ...Command) *SetChanCmd
Commands restricts the channel to events caused by the given commands.
func (*SetChanCmd) Detect ¶
func (cmd *SetChanCmd) Detect(states ...DetectState) *SetChanCmd
Detect restricts the channel to the given transitions. When omitted, Tile38's default detect set applies.
func (*SetChanCmd) Distance ¶ added in v0.2.0
func (cmd *SetChanCmd) Distance() *SetChanCmd
Distance adds each object's distance from the fence centre to every event the fence produces, matching Tile38's DISTANCE keyword. It arrives on FenceEvent as Distance, and applies to the live fence only — a plain query reads the same value through PointsWithDistance.
func (*SetChanCmd) Do ¶
func (cmd *SetChanCmd) Do(ctx context.Context) error
Do executes the SETCHAN command.
func (*SetChanCmd) EX ¶
func (cmd *SetChanCmd) EX(secs int) *SetChanCmd
EX sets how long the channel lives before Tile38 removes it, in seconds.
func (*SetChanCmd) Get ¶
func (cmd *SetChanCmd) Get(collection, id string) *SetChanCmd
Get sets the fence area to an object already stored in Tile38.
func (*SetChanCmd) Hash ¶ added in v0.2.0
func (cmd *SetChanCmd) Hash(geohash string) *SetChanCmd
Hash sets the search area to the box a geohash covers, matching Tile38's HASH keyword. The shorter the hash, the larger the box.
func (*SetChanCmd) Intersects ¶
func (cmd *SetChanCmd) Intersects(collection string) *SetChanCmd
Intersects selects the INTERSECTS spatial trigger, which fires on any overlap with the fence area rather than requiring full containment.
func (*SetChanCmd) Meta ¶
func (cmd *SetChanCmd) Meta(key, value string) *SetChanCmd
Meta attaches a key/value pair to the channel, echoed back on every event it produces. It accumulates: each call adds another pair.
func (*SetChanCmd) Nearby ¶
func (cmd *SetChanCmd) Nearby(collection string) *SetChanCmd
Nearby selects the NEARBY spatial trigger. Use with Point and Radius, or with Roam.
func (*SetChanCmd) NoDwell ¶
func (cmd *SetChanCmd) NoDwell() *SetChanCmd
NoDwell stops a roaming fence from re-reporting objects that stay within range between updates, matching Tile38's NODWELL keyword. It only affects Roam fences, and it is opt-in: dwelling is Tile38's own default.
func (*SetChanCmd) Object ¶
func (cmd *SetChanCmd) Object(geojson string) *SetChanCmd
Object sets the fence area to an inline GeoJSON string.
func (*SetChanCmd) Point ¶ added in v0.2.0
func (cmd *SetChanCmd) Point(lat, lon float64) *SetChanCmd
Point sets the fence area to a point, and is the area a Nearby trigger takes: NEARBY reads "POINT lat lon meters" and rejects CIRCLE, so a channel fencing on NEARBY needs this rather than Circle. Pair it with Radius.
func (*SetChanCmd) QuadKey ¶ added in v0.2.0
func (cmd *SetChanCmd) QuadKey(quadkey string) *SetChanCmd
QuadKey sets the search area to the tile a Bing Maps quadkey names, matching Tile38's QUADKEY keyword. Tile is the same area expressed as x/y/z.
func (*SetChanCmd) Radius ¶ added in v0.2.0
func (cmd *SetChanCmd) Radius(metres int) *SetChanCmd
Radius sets the trailing metres of a Point area. Named for the value it carries: Tile38 has no keyword for it, it is the last argument of "POINT lat lon meters".
func (*SetChanCmd) Roam ¶
func (cmd *SetChanCmd) Roam(collection string, radiusM int) *SetChanCmd
Roam fires when objects in the trigger collection come within radiusM metres of an object in collection. Use with Nearby.
Objects that stay in range keep reporting on each update; chain NoDwell to suppress those.
func (*SetChanCmd) Sector ¶ added in v0.2.0
func (cmd *SetChanCmd) Sector(lat, lon float64, metres int, bearing1, bearing2 float64) *SetChanCmd
Sector sets the search area to a circular sector: a circle of radius metres centred on lat/lon, clipped to the arc between two compass bearings in degrees. Matches Tile38's SECTOR keyword, which NEARBY does not accept.
func (*SetChanCmd) Where ¶
func (cmd *SetChanCmd) Where(expr string) *SetChanCmd
Where sets an optional Tile38 field expression filter.
func (*SetChanCmd) Within ¶
func (cmd *SetChanCmd) Within(collection string) *SetChanCmd
Within selects the WITHIN spatial trigger. Use with any fence area.
type SetCmd ¶
type SetCmd struct {
// contains filtered or unexported fields
}
SetCmd builds a Tile38 SET command. Ordering contract: chain TTL/NX/XX then Field/Fields then one geometry method (At/Object/Bounds/Hash/String).
func (*SetCmd) EX ¶
EX sets the expiry in seconds, matching Tile38's EX keyword. Zero means no expiry.
func (*SetCmd) PointZ ¶ added in v0.2.0
PointZ stores the object as a POINT carrying a third ordinate, which Tile38 keeps and hands back through PointZ and NearbyResult.Z. A z of zero is stored as a plain two-dimensional point.
type StatsCmd ¶ added in v0.2.0
type StatsCmd struct {
// contains filtered or unexported fields
}
StatsCmd builds a Tile38 STATS command.
func (*StatsCmd) Do ¶ added in v0.2.0
func (cmd *StatsCmd) Do(ctx context.Context) ([]CollectionStats, error)
Do executes: STATS collection… — one CollectionStats per collection asked for, in the same order. A collection that does not exist comes back as a null element, which reads as Exists false rather than as an error.
type StatusCmd ¶ added in v0.2.0
type StatusCmd struct {
// contains filtered or unexported fields
}
StatusCmd is a command that takes no chained options and answers with a status: its entry point fixes every argument. Commands that do take options get a type of their own, so that a builder's methods always describe what that one command accepts.
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Stream is a long-lived connection that receives geofence notifications as they happen: either a live geofence opened with Fence on a search command, or a pub/sub subscription to channels registered with SETCHAN.
A Stream owns a dedicated connection and no read deadline, because a quiet fence may send nothing for hours. Stop it with Close or by cancelling the context it was created with.
A Stream is not safe for concurrent use; call Next from one goroutine.
func (*Stream) Close ¶
Close stops the stream and releases its connection. It is safe to call more than once, and unblocks a concurrent Next.
func (*Stream) Next ¶
func (s *Stream) Next() (*FenceEvent, error)
Next blocks until the next event arrives. It returns io.EOF after Close, and the context error if the stream's context is cancelled. Any other error means the connection failed; the Stream is spent either way.
type StringObject ¶ added in v0.2.0
StringObject holds a single result from a Search query, which matches on the string values "SET … STRING" stores rather than on geometry.
type TTLCmd ¶
type TTLCmd struct {
// contains filtered or unexported fields
}
TTLCmd builds a Tile38 TTL command.
type TestCmd ¶ added in v0.2.0
type TestCmd struct {
// contains filtered or unexported fields
}
TestCmd builds a Tile38 TEST command: a spatial comparison of two areas that touches no stored object and needs no collection.
func (*TestCmd) Clip ¶ added in v0.2.0
Clip executes the comparison with Tile38's CLIP keyword, which also returns the first area clipped to the second as GeoJSON. It is a separate terminal because CLIP changes the reply from a bare integer to [result, geojson].
func (*TestCmd) Intersects ¶ added in v0.2.0
Intersects compares with the INTERSECTS relation: true when the two areas overlap at all.
type WithinCmd ¶
type WithinCmd struct {
// contains filtered or unexported fields
}
WithinCmd builds a Tile38 WITHIN query. Methods may be chained in any order; the parts are assembled into protocol order when the command runs.
func (*WithinCmd) A5 ¶
A5 sets the search area to a single A5 cell's pentagon, identified by its hex cell id (A5 keyword). Requires a server built from upstream master: A5 is merged upstream but has shipped in no release tag as of 1.38.0. Tile38 accepts A5 as a search area only, not as a hook or channel fence area.
func (*WithinCmd) A5Cells ¶ added in v0.2.0
A5Cells executes: WITHIN collection [opts] A5 level <area> Each result is the A5 cell a matching object's centre falls in. Named for the output rather than the keyword because A5 is already the search-area method on the builders that take one. Requires a server built from upstream master.
func (*WithinCmd) Buffer ¶ added in v0.2.0
Buffer grows the search area by the given number of metres before matching, matching Tile38's BUFFER keyword. Tile38 can only buffer point-like areas — it answers "cannot buffer Polygon type" for a Bounds or polygon Object area, and it panics rather than answering on NEARBY, which is why NearbyCmd has no Buffer.
It is appended rather than stored: Tile38 has no duplicate guard for BUFFER, so a repeat is legal and the last one wins.
func (*WithinCmd) Circle ¶
Circle sets the search area to a circle with centre + radius in metres (CIRCLE keyword).
func (*WithinCmd) Clip ¶
Clip trims returned objects to the search area rather than returning them whole, matching Tile38's CLIP keyword.
func (*WithinCmd) Commands ¶
Commands restricts a live fence to events caused by the given commands. Only meaningful with Fence.
func (*WithinCmd) Cursor ¶
Cursor resumes a search from where a previous one stopped, matching Tile38's CURSOR keyword. Pass the value NextCursor reported. Setting it also means the caller is paging deliberately, so a truncated result no longer reports ErrTruncated. Tile38 rejects CURSOR on a fence, so Fence ignores it.
func (*WithinCmd) Detect ¶
func (cmd *WithinCmd) Detect(states ...DetectState) *WithinCmd
Detect restricts a live fence to the given transitions. Only meaningful with Fence.
func (*WithinCmd) Distance ¶ added in v0.2.0
Distance adds each object's distance from the fence centre to every event the fence produces, matching Tile38's DISTANCE keyword. It arrives on FenceEvent as Distance, and applies to the live fence only — a plain query reads the same value through PointsWithDistance.
func (*WithinCmd) Fence ¶
Fence opens a live geofence: WITHIN collection [opts] FENCE [DETECT …] area. The returned Stream holds a dedicated connection and delivers events until it is closed or ctx is cancelled.
func (*WithinCmd) Get ¶
Get sets the search area to an object already stored in Tile38 (GET keyword).
func (*WithinCmd) Hash ¶ added in v0.2.0
Hash sets the search area to the box a geohash covers, matching Tile38's HASH keyword. The shorter the hash, the larger the box.
func (*WithinCmd) Hashes ¶ added in v0.2.0
Hashes executes: WITHIN collection [opts] HASHES precision <area> Each result is the geohash of a matching object's centre.
func (*WithinCmd) NextCursor ¶
NextCursor reports where to resume after the last executed terminal. It is non-zero only when Tile38 stopped at the limit with more objects matching.
func (*WithinCmd) NoFields ¶
NoFields drops field values from the reply, matching Tile38's NOFIELDS keyword.
func (*WithinCmd) Object ¶
Object sets the search area to an inline GeoJSON string (OBJECT keyword).
func (*WithinCmd) Objects ¶
func (cmd *WithinCmd) Objects(ctx context.Context) ([]SearchObject, error)
Objects executes: WITHIN collection [opts] OBJECTS area
func (*WithinCmd) Points ¶
func (cmd *WithinCmd) Points(ctx context.Context) ([]NearbyResult, error)
Points executes: WITHIN collection [opts] POINTS area
func (*WithinCmd) QuadKey ¶ added in v0.2.0
QuadKey sets the search area to the tile a Bing Maps quadkey names, matching Tile38's QUADKEY keyword. Tile is the same area expressed as x/y/z.
func (*WithinCmd) Rects ¶ added in v0.2.0
func (cmd *WithinCmd) Rects(ctx context.Context) ([]RectResult, error)
Rects executes: WITHIN collection [opts] BOUNDS <area> Each result is the bounding box of a matching object, lat first.
func (*WithinCmd) Sector ¶ added in v0.2.0
Sector sets the search area to a circular sector: a circle of radius metres centred on lat/lon, clipped to the arc between two compass bearings in degrees. Matches Tile38's SECTOR keyword, which NEARBY does not accept.
func (*WithinCmd) Sparse ¶
Sparse spreads results evenly over the search area at the given depth (1-8), matching Tile38's SPARSE keyword. Tile38 rejects SPARSE combined with Limit.
func (*WithinCmd) WhereEval ¶ added in v0.2.0
WhereEval keeps results for which the given Lua script returns true, matching Tile38's WHEREEVAL keyword. The script sees the object's fields as FIELDS and the extra arguments as ARGV. It accumulates: each call adds another filter.
func (*WithinCmd) WhereEvalSha ¶ added in v0.2.0
WhereEvalSha is WhereEval against a script already loaded on the server, matching Tile38's WHEREEVALSHA keyword.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
conn
Package conn holds the Tile38 transport: a single connection, and a pool of idle ones for request/response commands.
|
Package conn holds the Tile38 transport: a single connection, and a pool of idle ones for request/response commands. |
|
resp
Package resp implements the subset of the Redis serialization protocol that Tile38 speaks: commands out as arrays of bulk strings, replies in as strings, integers, arrays, and nulls.
|
Package resp implements the subset of the Redis serialization protocol that Tile38 speaks: commands out as arrays of bulk strings, replies in as strings, integers, arrays, and nulls. |