Documentation ¶
Index ¶
- Variables
- type Bounds
- type Chan
- type Channels
- func (ch *Channels) Chans(pattern string) ([]Chan, error)
- func (ch *Channels) DelChan(name string) error
- func (ch *Channels) PDelChan(pattern string) error
- func (ch *Channels) PSubscribe(ctx context.Context, handler func(*GeofenceEvent), pattern string) error
- func (ch *Channels) SetChan(name string, query GeofenceQueryBuilder) SetChannelQueryBuilder
- func (ch *Channels) Subscribe(ctx context.Context, handler func(*GeofenceEvent), Channels ...string) error
- type Client
- type ClientOption
- type DetectAction
- type Executor
- type FSetQueryBuilder
- type Geofence
- type GeofenceAreaSelector
- func (selector GeofenceAreaSelector) Bounds(minlat, minlon, maxlat, maxlon float64) GeofenceQueryBuilder
- func (selector GeofenceAreaSelector) Circle(lat, lon, meters float64) GeofenceQueryBuilder
- func (selector GeofenceAreaSelector) Feature(ft *geojson.Feature) GeofenceQueryBuilder
- func (selector GeofenceAreaSelector) FeatureCollection(fc *geojson.FeatureCollection) GeofenceQueryBuilder
- func (selector GeofenceAreaSelector) Geometry(gm *geojson.Geometry) GeofenceQueryBuilder
- func (selector GeofenceAreaSelector) Get(key, objectID string) GeofenceQueryBuilder
- func (selector GeofenceAreaSelector) Hash(hash string) GeofenceQueryBuilder
- func (selector GeofenceAreaSelector) Quadkey(quadkey string) GeofenceQueryBuilder
- func (selector GeofenceAreaSelector) Tile(x, y, z int) GeofenceQueryBuilder
- type GeofenceEvent
- type GeofenceQueryBuilder
- func (query GeofenceQueryBuilder) Actions(actions ...DetectAction) GeofenceQueryBuilder
- func (query GeofenceQueryBuilder) Clip() GeofenceQueryBuilder
- func (query GeofenceQueryBuilder) Commands(notifyCommands ...NotifyCommand) GeofenceQueryBuilder
- func (query GeofenceQueryBuilder) Cursor(cursor int) GeofenceQueryBuilder
- func (query GeofenceQueryBuilder) Distance() GeofenceQueryBuilder
- func (query GeofenceQueryBuilder) Do(ctx context.Context, handler func(*GeofenceEvent)) error
- func (query GeofenceQueryBuilder) Format(fmt OutputFormat) GeofenceQueryBuilder
- func (query GeofenceQueryBuilder) Limit(limit int) GeofenceQueryBuilder
- func (query GeofenceQueryBuilder) Match(pattern string) GeofenceQueryBuilder
- func (query GeofenceQueryBuilder) NoFields() GeofenceQueryBuilder
- func (query GeofenceQueryBuilder) Sparse(sparse int) GeofenceQueryBuilder
- func (query GeofenceQueryBuilder) Where(field string, min, max float64) GeofenceQueryBuilder
- func (query GeofenceQueryBuilder) WhereEval(script string, args ...string) GeofenceQueryBuilder
- func (query GeofenceQueryBuilder) WhereEvalSHA(sha string, args ...string) GeofenceQueryBuilder
- func (query GeofenceQueryBuilder) Wherein(field string, values ...float64) GeofenceQueryBuilder
- type GetBoundsResponse
- type GetHashResponse
- type GetObjectResponse
- type GetPointResponse
- type Hook
- type Hooks
- type InwAreaSelector
- func (selector InwAreaSelector) Bounds(minlat, minlon, maxlat, maxlon float64) InwQueryBuilder
- func (selector InwAreaSelector) Circle(lat, lon, meters float64) InwQueryBuilder
- func (selector InwAreaSelector) Feature(ft *geojson.Feature) InwQueryBuilder
- func (selector InwAreaSelector) FeatureCollection(fc *geojson.FeatureCollection) InwQueryBuilder
- func (selector InwAreaSelector) Geometry(gm *geojson.Geometry) InwQueryBuilder
- func (selector InwAreaSelector) Get(key, objectID string) InwQueryBuilder
- func (selector InwAreaSelector) Hash(hash string) InwQueryBuilder
- func (selector InwAreaSelector) Quadkey(quadkey string) InwQueryBuilder
- func (selector InwAreaSelector) Tile(x, y, z int) InwQueryBuilder
- type InwQueryBuilder
- func (query InwQueryBuilder) Clip() InwQueryBuilder
- func (query InwQueryBuilder) Cursor(cursor int) InwQueryBuilder
- func (query InwQueryBuilder) Distance() InwQueryBuilder
- func (query InwQueryBuilder) Do() (*SearchResponse, error)
- func (query InwQueryBuilder) Format(fmt OutputFormat) InwQueryBuilder
- func (query InwQueryBuilder) Limit(limit int) InwQueryBuilder
- func (query InwQueryBuilder) Match(pattern string) InwQueryBuilder
- func (query InwQueryBuilder) NoFields() InwQueryBuilder
- func (query InwQueryBuilder) Sparse(sparse int) InwQueryBuilder
- func (query InwQueryBuilder) Where(field string, min, max float64) InwQueryBuilder
- func (query InwQueryBuilder) WhereEval(script string, args ...string) InwQueryBuilder
- func (query InwQueryBuilder) WhereEvalSHA(sha string, args ...string) InwQueryBuilder
- func (query InwQueryBuilder) Wherein(field string, values ...float64) InwQueryBuilder
- type JSetQueryBuilder
- type KeyStats
- type Keys
- func (ks *Keys) Bounds(key string) ([][][]float64, error)
- func (ks *Keys) Del(key, objectID string) error
- func (ks *Keys) Drop(key string) error
- func (ks *Keys) Expire(key, objectID string, seconds int) error
- func (ks *Keys) FSet(key, objectID string) FSetQueryBuilder
- func (ks *Keys) Get(key, objectID string) KeysGetQueryBuilder
- func (ks *Keys) JDel(key, objectID, path string) error
- func (ks *Keys) JGet(key, objectID, path string) ([]byte, error)
- func (ks *Keys) JSet(key, objectID, path, value string) JSetQueryBuilder
- func (ks *Keys) Keys(pattern string) ([]string, error)
- func (ks *Keys) PDel(key, pattern string) error
- func (ks *Keys) Persist(key, objectID string) error
- func (ks *Keys) Rename(key, newKey string) error
- func (ks *Keys) RenameNX(key, newKey string) error
- func (ks *Keys) Set(key, objectID string) SetAreaSelector
- func (ks *Keys) Stats(keys ...string) ([]KeyStats, error)
- func (ks *Keys) TTL(key, objectID string) (int, error)
- type KeysGetQueryBuilder
- func (q KeysGetQueryBuilder) Bounds() (*GetBoundsResponse, error)
- func (q KeysGetQueryBuilder) Hash(precision int) (*GetHashResponse, error)
- func (q KeysGetQueryBuilder) Object() (*GetObjectResponse, error)
- func (q KeysGetQueryBuilder) Point() (*GetPointResponse, error)
- func (q KeysGetQueryBuilder) WithFields() KeysGetQueryBuilder
- type Meta
- type NotifyCommand
- type Object
- type OutputFormat
- type Point
- type RoamObject
- type ScanQueryBuilder
- func (query ScanQueryBuilder) Asc() ScanQueryBuilder
- func (query ScanQueryBuilder) Cursor(cursor int) ScanQueryBuilder
- func (query ScanQueryBuilder) Desc() ScanQueryBuilder
- func (query ScanQueryBuilder) Do() (*SearchResponse, error)
- func (query ScanQueryBuilder) Format(fmt OutputFormat) ScanQueryBuilder
- func (query ScanQueryBuilder) Limit(limit int) ScanQueryBuilder
- func (query ScanQueryBuilder) Match(pattern string) ScanQueryBuilder
- func (query ScanQueryBuilder) NoFields() ScanQueryBuilder
- func (query ScanQueryBuilder) Where(field string, min, max float64) ScanQueryBuilder
- func (query ScanQueryBuilder) Wherein(field string, values ...float64) ScanQueryBuilder
- type Scripting
- func (sc *Scripting) Eval(script string, keys []string, args []string) ([]byte, error)
- func (sc *Scripting) EvalNA(script string, keys []string, args []string) ([]byte, error)
- func (sc *Scripting) EvalNASHA(sha string, keys []string, args []string) ([]byte, error)
- func (sc *Scripting) EvalRO(script string, keys []string, args []string) ([]byte, error)
- func (sc *Scripting) EvalROSHA(sha string, keys []string, args []string) ([]byte, error)
- func (sc *Scripting) EvalSHA(sha string, keys []string, args []string) ([]byte, error)
- func (sc *Scripting) ScriptExists(shas ...string) ([]int, error)
- func (sc *Scripting) ScriptFlush() error
- func (sc *Scripting) ScriptLoad(script string) error
- type Search
- func (search *Search) Intersects(key string) InwAreaSelector
- func (search *Search) Nearby(key string, lat, lon, meters float64) InwQueryBuilder
- func (search *Search) Scan(key string) ScanQueryBuilder
- func (search *Search) Search(key string) SearchQueryBuilder
- func (search *Search) Within(key string) InwAreaSelector
- type SearchQueryBuilder
- func (query SearchQueryBuilder) Asc() SearchQueryBuilder
- func (query SearchQueryBuilder) Cursor(cursor int) SearchQueryBuilder
- func (query SearchQueryBuilder) Desc() SearchQueryBuilder
- func (query SearchQueryBuilder) Do() (*SearchResponse, error)
- func (query SearchQueryBuilder) FormatCount() SearchQueryBuilder
- func (query SearchQueryBuilder) FormatIDs() SearchQueryBuilder
- func (query SearchQueryBuilder) Limit(limit int) SearchQueryBuilder
- func (query SearchQueryBuilder) Match(pattern string) SearchQueryBuilder
- func (query SearchQueryBuilder) NoFields() SearchQueryBuilder
- func (query SearchQueryBuilder) Where(field string, min, max float64) SearchQueryBuilder
- func (query SearchQueryBuilder) Wherein(field string, values ...float64) SearchQueryBuilder
- type SearchResponse
- type Server
- type SetAreaSelector
- func (selector SetAreaSelector) Bounds(lat1, lon1, lat2, lon2 float64) SetQueryBuilder
- func (selector SetAreaSelector) Feature(ft *geojson.Feature) SetQueryBuilder
- func (selector SetAreaSelector) FeatureCollection(fc *geojson.FeatureCollection) SetQueryBuilder
- func (selector SetAreaSelector) Geometry(gm *geojson.Geometry) SetQueryBuilder
- func (selector SetAreaSelector) Hash(hash string) SetQueryBuilder
- func (selector SetAreaSelector) Point(lat, lon float64) SetQueryBuilder
- func (selector SetAreaSelector) PointZ(lat, lon, z float64) SetQueryBuilder
- func (selector SetAreaSelector) String(str string) SetQueryBuilder
- type SetChannelQueryBuilder
- type SetHookQueryBuilder
- type SetQueryBuilder
- func (query SetQueryBuilder) Do() error
- func (query SetQueryBuilder) Expiration(seconds int) SetQueryBuilder
- func (query SetQueryBuilder) Field(name string, value float64) SetQueryBuilder
- func (query SetQueryBuilder) IfExists() SetQueryBuilder
- func (query SetQueryBuilder) IfNotExists() SetQueryBuilder
Constants ¶
This section is empty.
Variables ¶
var ( // FormatCount - Total object count sent in the response. // When LIMIT or CURSOR are provided, COUNT returns the number of results that would otherwise be sent as objects. // When LIMIT is not specified, COUNT totals up all items starting from provided CURSOR position // (or zero if a cursor is omitted). LIMIT and CURSOR options are ignored. FormatCount = OutputFormat(newCmd("COUNT")) // FormatIDs - A list of IDs belonging to the key. Will not return the objects. FormatIDs = OutputFormat(newCmd("IDS")) // FormatPoints - A list of standard latitude, longitude points. FormatPoints = OutputFormat(newCmd("POINTS")) // FormatBounds - A list of minimum bounding rectangle. FormatBounds = OutputFormat(newCmd("BOUNDS")) // FormatHashes - A list of Geohash. Requires a precision of 1 to 22. FormatHashes = func(precision int) OutputFormat { return OutputFormat(newCmd("HASHES", strconv.Itoa(precision))) } )
var Debug = ClientOption(func(c *clientParams) { c.debug = true })
Debug option.
Functions ¶
This section is empty.
Types ¶
type Chan ¶
type Chan struct { Name string `json:"name"` Key string `json:"key"` Command []string `json:"command"` Meta map[string]string `json:"meta"` }
Chan struct
type Channels ¶
type Channels struct {
// contains filtered or unexported fields
}
Channels struct
func (*Channels) PSubscribe ¶
func (ch *Channels) PSubscribe(ctx context.Context, handler func(*GeofenceEvent), pattern string) error
PSubscribe subscribes the client to the given patterns.
func (*Channels) SetChan ¶
func (ch *Channels) SetChan(name string, query GeofenceQueryBuilder) SetChannelQueryBuilder
SetChan creates a Pub/Sub channel which points to a geofenced search. If a channel is already associated to that name, it’ll be overwritten. Once the channel is created a client can then listen for events on that channel with SUBSCRIBE or PSUBSCRIBE. If expiration less than 0, it will be ignored
type Client ¶
type Client struct { Search *Search Keys *Keys Webhooks *Hooks Channels *Channels Scripting *Scripting Geofence *Geofence Server *Server // contains filtered or unexported fields }
Client allows you to interact with the Tile38 server.
func New ¶
func New(addr string, opts ...ClientOption) (*Client, error)
New creates a new Tile38 client. By default uses redis pool with 5 connections. In debug mode will also print commands which will be sent to the server.
func NewWithExecutor ¶
NewWithExecutor creates a new Tile38 client with provided executor. See Executor interface for more information.
func (*Client) Close ¶
Close closes all connections in the pool and rejects future execution calls. Blocks until all streams are closed.
NOTE: custom Executor implementation may change behavior.
type DetectAction ¶
type DetectAction string
DetectAction ...
const ( // Inside is when an object is inside the specified area. Inside DetectAction = "inside" // Outside is when an object is outside the specified area. Outside DetectAction = "outside" // Enter is when an object that was not previously in the fence has entered the area. Enter DetectAction = "enter" // Exit is when an object that was previously in the fence has exited the area. Exit DetectAction = "exit" // Cross is when an object that was not previously in the fence has entered and exited the area. Cross DetectAction = "cross" )
type Executor ¶
type Executor interface { Execute(command string, args ...string) ([]byte, error) ExecuteStream(ctx context.Context, handler func([]byte) error, command string, args ...string) error Close() error }
Executor represents Tile38 connection. Communication should be in JSON format only.
type FSetQueryBuilder ¶
type FSetQueryBuilder struct {
// contains filtered or unexported fields
}
FSetQueryBuilder struct
func (FSetQueryBuilder) Field ¶
func (query FSetQueryBuilder) Field(name string, value float64) FSetQueryBuilder
Field sets the object field
func (FSetQueryBuilder) IfExists ¶
func (query FSetQueryBuilder) IfExists() FSetQueryBuilder
IfExists only set the object if it already exist
type Geofence ¶
type Geofence struct {
// contains filtered or unexported fields
}
Geofence struct
func (*Geofence) Intersects ¶
func (gf *Geofence) Intersects(key string) GeofenceAreaSelector
Intersects geofence
func (*Geofence) Nearby ¶
func (gf *Geofence) Nearby(key string, lat, lon, meters float64) GeofenceQueryBuilder
Nearby geofence
func (*Geofence) Roam ¶
func (gf *Geofence) Roam(key, target, pattern string, meters int) GeofenceQueryBuilder
Roam geofence
func (*Geofence) Within ¶
func (gf *Geofence) Within(key string) GeofenceAreaSelector
Within geofence
type GeofenceAreaSelector ¶
type GeofenceAreaSelector struct {
// contains filtered or unexported fields
}
GeofenceAreaSelector struct
func (GeofenceAreaSelector) Bounds ¶
func (selector GeofenceAreaSelector) Bounds(minlat, minlon, maxlat, maxlon float64) GeofenceQueryBuilder
Bounds - a minimum bounding rectangle.
func (GeofenceAreaSelector) Circle ¶
func (selector GeofenceAreaSelector) Circle(lat, lon, meters float64) GeofenceQueryBuilder
Circle - a circle with the specified center and radius.
func (GeofenceAreaSelector) Feature ¶
func (selector GeofenceAreaSelector) Feature(ft *geojson.Feature) GeofenceQueryBuilder
Feature - GeoJSON Feature object.
func (GeofenceAreaSelector) FeatureCollection ¶
func (selector GeofenceAreaSelector) FeatureCollection(fc *geojson.FeatureCollection) GeofenceQueryBuilder
FeatureCollection - GeoJSON Feature Collection object.
func (GeofenceAreaSelector) Geometry ¶
func (selector GeofenceAreaSelector) Geometry(gm *geojson.Geometry) GeofenceQueryBuilder
Geometry - GeoJSON Geometry object.
func (GeofenceAreaSelector) Get ¶
func (selector GeofenceAreaSelector) Get(key, objectID string) GeofenceQueryBuilder
Get any object that already exists in the database.
func (GeofenceAreaSelector) Hash ¶
func (selector GeofenceAreaSelector) Hash(hash string) GeofenceQueryBuilder
Hash - a Geohash.
func (GeofenceAreaSelector) Quadkey ¶
func (selector GeofenceAreaSelector) Quadkey(quadkey string) GeofenceQueryBuilder
Quadkey - a QuadKey.
func (GeofenceAreaSelector) Tile ¶
func (selector GeofenceAreaSelector) Tile(x, y, z int) GeofenceQueryBuilder
Tile - an XYZ Tile.
type GeofenceEvent ¶
type GeofenceEvent struct { Command string `json:"command"` Hook string `json:"hook,omitempty"` Group string `json:"group"` Detect string `json:"detect"` Key string `json:"key"` Time time.Time `json:"time"` ID string `json:"id"` Object *Object `json:"object,omitempty"` Point *Point `json:"point,omitempty"` Bounds *Bounds `json:"bounds,omitempty"` Hash *string `json:"hash,omitempty"` Nearby *RoamObject `json:"nearby,omitempty"` Faraway *RoamObject `json:"faraway,omitempty"` Fields map[string]float64 `json:"fields,omitempty"` }
GeofenceEvent struct
type GeofenceQueryBuilder ¶
type GeofenceQueryBuilder struct {
// contains filtered or unexported fields
}
GeofenceQueryBuilder optional params
func (GeofenceQueryBuilder) Actions ¶
func (query GeofenceQueryBuilder) Actions(actions ...DetectAction) GeofenceQueryBuilder
Actions sets the geofence actions. All actions used by default.
func (GeofenceQueryBuilder) Clip ¶
func (query GeofenceQueryBuilder) Clip() GeofenceQueryBuilder
Clip tells the server to clip intersecting objects by the bounding box area of the search. It can only be used with these area formats: BOUNDS, TILE, QUADKEY, HASH.
func (GeofenceQueryBuilder) Commands ¶
func (query GeofenceQueryBuilder) Commands(notifyCommands ...NotifyCommand) GeofenceQueryBuilder
Commands sets the geofence commands.
func (GeofenceQueryBuilder) Cursor ¶
func (query GeofenceQueryBuilder) Cursor(cursor int) GeofenceQueryBuilder
Cursor is used to iterate though many objects from the search results. An iteration begins when the CURSOR is set to Zero or not included with the request, and completes when the cursor returned by the server is Zero.
func (GeofenceQueryBuilder) Distance ¶
func (query GeofenceQueryBuilder) Distance() GeofenceQueryBuilder
Distance allows to return between objects. Only for NEARBY tileCmd.
func (GeofenceQueryBuilder) Do ¶
func (query GeofenceQueryBuilder) Do(ctx context.Context, handler func(*GeofenceEvent)) error
Do cmd
func (GeofenceQueryBuilder) Format ¶
func (query GeofenceQueryBuilder) Format(fmt OutputFormat) GeofenceQueryBuilder
Format set response format.
func (GeofenceQueryBuilder) Limit ¶
func (query GeofenceQueryBuilder) Limit(limit int) GeofenceQueryBuilder
Limit can be used to limit the number of objects returned for a single search request.
func (GeofenceQueryBuilder) Match ¶
func (query GeofenceQueryBuilder) Match(pattern string) GeofenceQueryBuilder
Match is similar to WHERE except that it works on the object id instead of fields. There can be multiple MATCH options in a single search. The MATCH value is a simple glob pattern.
func (GeofenceQueryBuilder) NoFields ¶
func (query GeofenceQueryBuilder) NoFields() GeofenceQueryBuilder
NoFields tells the server that you do not want field values returned with the search results.
func (GeofenceQueryBuilder) Sparse ¶
func (query GeofenceQueryBuilder) Sparse(sparse int) GeofenceQueryBuilder
Sparse will distribute the results of a search evenly across the requested area.
func (GeofenceQueryBuilder) Where ¶
func (query GeofenceQueryBuilder) Where(field string, min, max float64) GeofenceQueryBuilder
Where allows for filtering out results based on field values.
func (GeofenceQueryBuilder) WhereEval ¶
func (query GeofenceQueryBuilder) WhereEval(script string, args ...string) GeofenceQueryBuilder
WhereEval similar to WHERE except that matching decision is made by Lua script For example: 'nearby fleet whereeval "return FIELDS.wheels > ARGV[1] or (FIELDS.length * FIELDS.width) > ARGV[2]" 2 8 120 point 33.462 -112.268 6000' will return only the objects in the fleet collection that are within the 6km radius and have a field named wheels that is above 8, or have length and width whose product is greater than 120. Multiple WHEREEVALs are concatenated as and clauses. See EVAL command for more details. Note that, unlike the EVAL command, WHEREVAL Lua environment (1) does not have KEYS global, and (2) has the FIELDS global with the Lua table of the iterated object’s fields.
func (GeofenceQueryBuilder) WhereEvalSHA ¶
func (query GeofenceQueryBuilder) WhereEvalSHA(sha string, args ...string) GeofenceQueryBuilder
WhereEvalSHA similar to WHERE except that matching decision is made by Lua script For example: 'nearby fleet whereeval "return FIELDS.wheels > ARGV[1] or (FIELDS.length * FIELDS.width) > ARGV[2]" 2 8 120 point 33.462 -112.268 6000' will return only the objects in the fleet collection that are within the 6km radius and have a field named wheels that is above 8, or have length and width whose product is greater than 120. Multiple WHEREEVALs are concatenated as and clauses. See EVAL command for more details. Note that, unlike the EVAL command, WHEREVAL Lua environment (1) does not have KEYS global, and (2) has the FIELDS global with the Lua table of the iterated object’s fields.
func (GeofenceQueryBuilder) Wherein ¶
func (query GeofenceQueryBuilder) Wherein(field string, values ...float64) GeofenceQueryBuilder
Wherein is similar to Where except that it checks whether the object’s field value is in a given list.
type GetBoundsResponse ¶ added in v0.10.0
type GetHashResponse ¶ added in v0.10.0
type GetObjectResponse ¶ added in v0.10.0
type GetPointResponse ¶ added in v0.10.0
type Hooks ¶
type Hooks struct {
// contains filtered or unexported fields
}
Hooks struct
func (*Hooks) SetHook ¶
func (hooks *Hooks) SetHook(name, endpoint string, query GeofenceQueryBuilder) SetHookQueryBuilder
SetHook creates a webhook which points to a geofenced search. If a hook is already associated to that name, it’ll be overwritten.
type InwAreaSelector ¶
type InwAreaSelector struct {
// contains filtered or unexported fields
}
InwAreaSelector struct Intersects Nearby Within
func (InwAreaSelector) Bounds ¶
func (selector InwAreaSelector) Bounds(minlat, minlon, maxlat, maxlon float64) InwQueryBuilder
Bounds - a minimum bounding rectangle.
func (InwAreaSelector) Circle ¶
func (selector InwAreaSelector) Circle(lat, lon, meters float64) InwQueryBuilder
Circle - a circle with the specified center and radius.
func (InwAreaSelector) Feature ¶
func (selector InwAreaSelector) Feature(ft *geojson.Feature) InwQueryBuilder
Feature - GeoJSON Feature object.
func (InwAreaSelector) FeatureCollection ¶
func (selector InwAreaSelector) FeatureCollection(fc *geojson.FeatureCollection) InwQueryBuilder
FeatureCollection - GeoJSON Feature Collection object.
func (InwAreaSelector) Geometry ¶
func (selector InwAreaSelector) Geometry(gm *geojson.Geometry) InwQueryBuilder
Geometry - GeoJSON Geometry object.
func (InwAreaSelector) Get ¶
func (selector InwAreaSelector) Get(key, objectID string) InwQueryBuilder
Get any object that already exists in the database.
func (InwAreaSelector) Hash ¶
func (selector InwAreaSelector) Hash(hash string) InwQueryBuilder
Hash - a Geohash.
func (InwAreaSelector) Quadkey ¶
func (selector InwAreaSelector) Quadkey(quadkey string) InwQueryBuilder
Quadkey - a QuadKey.
func (InwAreaSelector) Tile ¶
func (selector InwAreaSelector) Tile(x, y, z int) InwQueryBuilder
Tile - an XYZ Tile.
type InwQueryBuilder ¶
type InwQueryBuilder struct {
// contains filtered or unexported fields
}
InwQueryBuilder struct Intersects Nearby Within
func (InwQueryBuilder) Clip ¶
func (query InwQueryBuilder) Clip() InwQueryBuilder
Clip tells the server to clip intersecting objects by the bounding box area of the search. It can only be used with these area formats: BOUNDS, TILE, QUADKEY, HASH. Only for INTERSECTS command.
func (InwQueryBuilder) Cursor ¶
func (query InwQueryBuilder) Cursor(cursor int) InwQueryBuilder
Cursor is used to iterate though many objects from the search results. An iteration begins when the CURSOR is set to Zero or not included with the request, and completes when the cursor returned by the server is Zero.
func (InwQueryBuilder) Distance ¶
func (query InwQueryBuilder) Distance() InwQueryBuilder
Distance allows to return between objects. Only for NEARBY command.
func (InwQueryBuilder) Format ¶
func (query InwQueryBuilder) Format(fmt OutputFormat) InwQueryBuilder
Format set response format.
func (InwQueryBuilder) Limit ¶
func (query InwQueryBuilder) Limit(limit int) InwQueryBuilder
Limit can be used to limit the number of objects returned for a single search request.
func (InwQueryBuilder) Match ¶
func (query InwQueryBuilder) Match(pattern string) InwQueryBuilder
Match is similar to WHERE except that it works on the object id instead of fields. There can be multiple MATCH options in a single search. The MATCH value is a simple glob pattern.
func (InwQueryBuilder) NoFields ¶
func (query InwQueryBuilder) NoFields() InwQueryBuilder
NoFields tells the server that you do not want field values returned with the search results.
func (InwQueryBuilder) Sparse ¶
func (query InwQueryBuilder) Sparse(sparse int) InwQueryBuilder
Sparse will distribute the results of a search evenly across the requested area.
func (InwQueryBuilder) Where ¶
func (query InwQueryBuilder) Where(field string, min, max float64) InwQueryBuilder
Where allows for filtering out results based on field values.
func (InwQueryBuilder) WhereEval ¶
func (query InwQueryBuilder) WhereEval(script string, args ...string) InwQueryBuilder
WhereEval similar to WHERE except that matching decision is made by Lua script For example: 'nearby fleet whereeval "return FIELDS.wheels > ARGV[1] or (FIELDS.length * FIELDS.width) > ARGV[2]" 2 8 120 point 33.462 -112.268 6000' will return only the objects in the fleet collection that are within the 6km radius and have a field named wheels that is above 8, or have length and width whose product is greater than 120. Multiple WHEREEVALs are concatenated as and clauses. See EVAL command for more details. Note that, unlike the EVAL command, WHEREVAL Lua environment (1) does not have KEYS global, and (2) has the FIELDS global with the Lua table of the iterated object’s fields.
func (InwQueryBuilder) WhereEvalSHA ¶
func (query InwQueryBuilder) WhereEvalSHA(sha string, args ...string) InwQueryBuilder
WhereEvalSHA similar to WHERE except that matching decision is made by Lua script For example: 'nearby fleet whereeval "return FIELDS.wheels > ARGV[1] or (FIELDS.length * FIELDS.width) > ARGV[2]" 2 8 120 point 33.462 -112.268 6000' will return only the objects in the fleet collection that are within the 6km radius and have a field named wheels that is above 8, or have length and width whose product is greater than 120. Multiple WHEREEVALs are concatenated as and clauses. See EVAL command for more details. Note that, unlike the EVAL command, WHEREVAL Lua environment (1) does not have KEYS global, and (2) has the FIELDS global with the Lua table of the iterated object’s fields.
func (InwQueryBuilder) Wherein ¶
func (query InwQueryBuilder) Wherein(field string, values ...float64) InwQueryBuilder
Wherein is similar to Where except that it checks whether the object’s field value is in a given list.
type JSetQueryBuilder ¶
type JSetQueryBuilder struct {
// contains filtered or unexported fields
}
JSetQueryBuilder struct
func (JSetQueryBuilder) Raw ¶
func (query JSetQueryBuilder) Raw() JSetQueryBuilder
Raw allows value to be interpreted as a serialized JSON object
func (JSetQueryBuilder) Str ¶
func (query JSetQueryBuilder) Str() JSetQueryBuilder
Str allows value to be interpreted as a string
type KeyStats ¶
type KeyStats struct { InMemorySize int `json:"in_memory_size"` NumObjects int `json:"num_objects"` NumPoints int `json:"num_points"` }
KeyStats struct
type Keys ¶
type Keys struct {
// contains filtered or unexported fields
}
Keys struct
func (*Keys) FSet ¶
func (ks *Keys) FSet(key, objectID string) FSetQueryBuilder
FSet set the value for one or more fields of an id. Fields are double precision floating points. Normally, FSET will return an error if the field is being set on a non-existent id. However, the option XX can alter this behavior. Specifically, if called with XX option, FSET will return 0 when called on a non-existend id. Note that the non-existent key will still cause an error!
func (*Keys) Get ¶
func (ks *Keys) Get(key, objectID string) KeysGetQueryBuilder
Get returns object of an id.
func (*Keys) JSet ¶
func (ks *Keys) JSet(key, objectID, path, value string) JSetQueryBuilder
JSet set a value in a JSON document.
func (*Keys) Rename ¶
Rename renames collection key to newkey. If newkey already exists, it will be deleted prior to renaming. Returns “OK” for success or “ERR” when key or newkey are actively being used by a geofence or webhook.
func (*Keys) RenameNX ¶
RenameNX renames collection key to newkey, if it does not exist yet. If newkey already exists, this command does nothing. Returns 1 if key was renamed to newkey, 0 if newkey already existed, or “ERR” when key or newkey are actively being used by a geofence or webhook.
func (*Keys) Set ¶
func (ks *Keys) Set(key, objectID string) SetAreaSelector
Set the value of an id. If a value is already associated to that key/id, it’ll be overwritten.
type KeysGetQueryBuilder ¶ added in v0.10.0
type KeysGetQueryBuilder struct {
// contains filtered or unexported fields
}
func (KeysGetQueryBuilder) Bounds ¶ added in v0.10.0
func (q KeysGetQueryBuilder) Bounds() (*GetBoundsResponse, error)
func (KeysGetQueryBuilder) Hash ¶ added in v0.10.0
func (q KeysGetQueryBuilder) Hash(precision int) (*GetHashResponse, error)
func (KeysGetQueryBuilder) Object ¶ added in v0.10.0
func (q KeysGetQueryBuilder) Object() (*GetObjectResponse, error)
func (KeysGetQueryBuilder) Point ¶ added in v0.10.0
func (q KeysGetQueryBuilder) Point() (*GetPointResponse, error)
func (KeysGetQueryBuilder) WithFields ¶ added in v0.10.0
func (q KeysGetQueryBuilder) WithFields() KeysGetQueryBuilder
type NotifyCommand ¶
type NotifyCommand string
NotifyCommand ...
const ( // Del notifies the client that an object has been deleted from the collection that is being fenced. Del NotifyCommand = "del" // Drop notifies the client that the entire collection is dropped. Drop NotifyCommand = "drop" // Set notifies the client that an object has been added or updated, // and when it’s position is detected by the fence. Set NotifyCommand = "set" )
type Object ¶
type Object struct { FeatureCollection *geojson.FeatureCollection `json:"featureCollection,omitempty"` Feature *geojson.Feature `json:"feature,omitempty"` Geometry *geojson.Geometry `json:"geometry,omitempty"` String *string `json:"string,omitempty"` }
Object struct
type RoamObject ¶
type RoamObject struct { Key string `json:"key"` ID string `json:"id"` Object Object `json:"object"` Meters float64 `json:"meters"` }
RoamObject struct
type ScanQueryBuilder ¶
type ScanQueryBuilder struct {
// contains filtered or unexported fields
}
ScanQueryBuilder struct
func (ScanQueryBuilder) Asc ¶
func (query ScanQueryBuilder) Asc() ScanQueryBuilder
Asc order. Only for SEARCH and SCAN commands.
func (ScanQueryBuilder) Cursor ¶
func (query ScanQueryBuilder) Cursor(cursor int) ScanQueryBuilder
Cursor is used to iterate though many objects from the search results. An iteration begins when the CURSOR is set to Zero or not included with the request, and completes when the cursor returned by the server is Zero.
func (ScanQueryBuilder) Desc ¶
func (query ScanQueryBuilder) Desc() ScanQueryBuilder
Desc order. Only for SEARCH and SCAN commands.
func (ScanQueryBuilder) Format ¶
func (query ScanQueryBuilder) Format(fmt OutputFormat) ScanQueryBuilder
Format set response format.
func (ScanQueryBuilder) Limit ¶
func (query ScanQueryBuilder) Limit(limit int) ScanQueryBuilder
Limit can be used to limit the number of objects returned for a single search request.
func (ScanQueryBuilder) Match ¶
func (query ScanQueryBuilder) Match(pattern string) ScanQueryBuilder
Match is similar to WHERE except that it works on the object id instead of fields. There can be multiple MATCH options in a single search. The MATCH value is a simple glob pattern.
func (ScanQueryBuilder) NoFields ¶
func (query ScanQueryBuilder) NoFields() ScanQueryBuilder
NoFields tells the server that you do not want field values returned with the search results.
func (ScanQueryBuilder) Where ¶
func (query ScanQueryBuilder) Where(field string, min, max float64) ScanQueryBuilder
Where allows for filtering out results based on field values.
func (ScanQueryBuilder) Wherein ¶
func (query ScanQueryBuilder) Wherein(field string, values ...float64) ScanQueryBuilder
Wherein is similar to Where except that it checks whether the object’s field value is in a given list.
type Scripting ¶
type Scripting struct {
// contains filtered or unexported fields
}
Scripting struct
func (*Scripting) EvalNA ¶
EvalNA evaluates a Lua script in a non-atomic fashion. The command uses None atomicity level and is otherwise identical to EVAL.
func (*Scripting) EvalNASHA ¶
EvalNASHA evaluates, in a non-atomic fashion, a Lua script cached on the server by its SHA1 digest. Scripts are cached using the SCRIPT LOAD command. The command is otherwise identical to EVALNA.
func (*Scripting) EvalRO ¶
EvalRO evaluates a read-only Lua script. The command uses Read-only atomicity level and is otherwise identical to EVAL.
func (*Scripting) EvalROSHA ¶
EvalROSHA evaluates a read-only Lua script cached on the server by its SHA1 digest. Scripts are cached using the SCRIPT LOAD command. The command is otherwise identical to EVALRO.
func (*Scripting) EvalSHA ¶
EvalSHA evaluates a Lua script cached on the server by its SHA1 digest. Scripts are cached using the SCRIPT LOAD command. The command is otherwise identical to EVAL.
func (*Scripting) ScriptExists ¶
ScriptExists returns information about the existence of the scripts in server cache. This command takes one or more SHA1 digests and returns a list of one/zero integer values to indicate whether or not each SHA1 exists in the server script cache. Scripts are cached using the SCRIPT LOAD command.
func (*Scripting) ScriptFlush ¶
ScriptFlush flushes the server cache of Lua scripts.
func (*Scripting) ScriptLoad ¶
ScriptLoad loads the compiled version of a script into the server cache, without executing. If the parsing and compilation is successful, the command returns the string value of the SHA1 digest of the script. That value can be used for EVALSHA and similar commands that execute scripts based on the SHA1 digest. The script will stay in cache until either the tile38 is restarted or SCRIPT FLUSH is called. If either parsing or compilation fails, the command will return the error response with the detailed traceback of the Lua failure.
type Search ¶
type Search struct {
// contains filtered or unexported fields
}
Search struct
func (*Search) Intersects ¶
func (search *Search) Intersects(key string) InwAreaSelector
Intersects searches a collection for objects that intersect a specified bounding area.
func (*Search) Nearby ¶
func (search *Search) Nearby(key string, lat, lon, meters float64) InwQueryBuilder
Nearby command searches a collection for objects that are close to a specified point. The KNN algorithm is used instead of the standard overlap+Haversine algorithm, sorting the results in order of ascending distance from that point, i.e., nearest first.
func (*Search) Scan ¶
func (search *Search) Scan(key string) ScanQueryBuilder
Scan incrementally iterates though a key.
func (*Search) Search ¶
func (search *Search) Search(key string) SearchQueryBuilder
Search iterates though a key’s string values.
func (*Search) Within ¶
func (search *Search) Within(key string) InwAreaSelector
Within searches a collection for objects that are fully contained inside of a specified bounding area.
type SearchQueryBuilder ¶
type SearchQueryBuilder struct {
// contains filtered or unexported fields
}
SearchQueryBuilder struct
func (SearchQueryBuilder) Asc ¶
func (query SearchQueryBuilder) Asc() SearchQueryBuilder
Asc order. Only for SEARCH and SCAN commands.
func (SearchQueryBuilder) Cursor ¶
func (query SearchQueryBuilder) Cursor(cursor int) SearchQueryBuilder
Cursor is used to iterate though many objects from the search results. An iteration begins when the CURSOR is set to Zero or not included with the request, and completes when the cursor returned by the server is Zero.
func (SearchQueryBuilder) Desc ¶
func (query SearchQueryBuilder) Desc() SearchQueryBuilder
Desc order. Only for SEARCH and SCAN commands.
func (SearchQueryBuilder) FormatCount ¶
func (query SearchQueryBuilder) FormatCount() SearchQueryBuilder
FormatCount - total object count sent in the response.
func (SearchQueryBuilder) FormatIDs ¶
func (query SearchQueryBuilder) FormatIDs() SearchQueryBuilder
FormatIDs - a list of IDs belonging to the key. Will not return the objects.
func (SearchQueryBuilder) Limit ¶
func (query SearchQueryBuilder) Limit(limit int) SearchQueryBuilder
Limit can be used to limit the number of objects returned for a single search request.
func (SearchQueryBuilder) Match ¶
func (query SearchQueryBuilder) Match(pattern string) SearchQueryBuilder
Match is similar to WHERE except that it works on the object id instead of fields. There can be multiple MATCH options in a single search. The MATCH value is a simple glob pattern.
func (SearchQueryBuilder) NoFields ¶
func (query SearchQueryBuilder) NoFields() SearchQueryBuilder
NoFields tells the server that you do not want field values returned with the search results.
func (SearchQueryBuilder) Where ¶
func (query SearchQueryBuilder) Where(field string, min, max float64) SearchQueryBuilder
Where allows for filtering out results based on field values.
func (SearchQueryBuilder) Wherein ¶
func (query SearchQueryBuilder) Wherein(field string, values ...float64) SearchQueryBuilder
Wherein is similar to Where except that it checks whether the object’s field value is in a given list.
type SearchResponse ¶
type SearchResponse struct { Cursor int `json:"cursor"` Count int `json:"count"` Fields []string `json:"fields,omitempty"` Objects []struct { ID string `json:"ID"` Object Object `json:"object"` Fields []float64 `json:"fields,omitempty"` Distance *float64 `json:"distance,omitempty"` } `json:"objects,omitempty"` Points []struct { ID string `json:"ID"` Point Point `json:"point"` Fields []float64 `json:"fields,omitempty"` Distance *float64 `json:"distance,omitempty"` } `json:"points,omitempty"` Bounds []struct { ID string `json:"ID"` Bounds Bounds `json:"bounds"` Fields []float64 `json:"fields,omitempty"` Distance *float64 `json:"distance,omitempty"` } `json:"bounds,omitempty"` Hashes []struct { ID string `json:"id"` Hash string `json:"hash"` Fields []float64 `json:"fields,omitempty"` Distance *float64 `json:"distance,omitempty"` } `json:"hashes,omitempty"` IDs []string `json:"ids,omitempty"` }
SearchResponse struct
type SetAreaSelector ¶
type SetAreaSelector struct {
// contains filtered or unexported fields
}
SetAreaSelector struct
func (SetAreaSelector) Bounds ¶
func (selector SetAreaSelector) Bounds(lat1, lon1, lat2, lon2 float64) SetQueryBuilder
Bounds - a bounding box consists of two points. The first being the southwestern most point and the second is the northeastern most point.
func (SetAreaSelector) Feature ¶
func (selector SetAreaSelector) Feature(ft *geojson.Feature) SetQueryBuilder
Feature - set GeoJSON Feature object.
func (SetAreaSelector) FeatureCollection ¶
func (selector SetAreaSelector) FeatureCollection(fc *geojson.FeatureCollection) SetQueryBuilder
FeatureCollection - set GeoJSON Feature Collection object.
func (SetAreaSelector) Geometry ¶
func (selector SetAreaSelector) Geometry(gm *geojson.Geometry) SetQueryBuilder
Geometry - set GeoJSON Geometry object.
func (SetAreaSelector) Hash ¶
func (selector SetAreaSelector) Hash(hash string) SetQueryBuilder
Hash - A geohash is a convenient way of expressing a location (anywhere in the world) using a short alphanumeric string, with greater precision obtained with longer strings.
func (SetAreaSelector) Point ¶
func (selector SetAreaSelector) Point(lat, lon float64) SetQueryBuilder
Point set a simple point in latitude, longitude.
func (SetAreaSelector) PointZ ¶
func (selector SetAreaSelector) PointZ(lat, lon, z float64) SetQueryBuilder
PointZ - a point with Z coordinate. This is application specific such as elevation, or a timestamp, etc.
func (SetAreaSelector) String ¶
func (selector SetAreaSelector) String(str string) SetQueryBuilder
String - It’s possible to set a raw string. The value of a string type can be plain text or a series of raw bytes. To retrieve a string value you can use GET, SCAN, or SEARCH.
type SetChannelQueryBuilder ¶
type SetChannelQueryBuilder struct {
// contains filtered or unexported fields
}
SetChannelQueryBuilder struct
func (SetChannelQueryBuilder) Expiration ¶
func (query SetChannelQueryBuilder) Expiration(seconds int) SetChannelQueryBuilder
Expiration set the specified expire time, in seconds.
func (SetChannelQueryBuilder) Meta ¶
func (query SetChannelQueryBuilder) Meta(name, value string) SetChannelQueryBuilder
Meta ...
type SetHookQueryBuilder ¶
type SetHookQueryBuilder struct {
// contains filtered or unexported fields
}
SetHookQueryBuilder struct
func (SetHookQueryBuilder) Endpoint ¶
func (query SetHookQueryBuilder) Endpoint(endpoint string) SetHookQueryBuilder
Endpoint appends new endpoint to the hook. Tile38 will try to send a message to the first endpoint. If the send is a failure then the second endpoint is tried, and so on.
func (SetHookQueryBuilder) Expiration ¶
func (query SetHookQueryBuilder) Expiration(seconds int) SetHookQueryBuilder
Expiration set the specified expire time, in seconds.
func (SetHookQueryBuilder) Meta ¶
func (query SetHookQueryBuilder) Meta(name, value string) SetHookQueryBuilder
Meta ...
type SetQueryBuilder ¶
type SetQueryBuilder struct {
// contains filtered or unexported fields
}
SetQueryBuilder struct
func (SetQueryBuilder) Expiration ¶
func (query SetQueryBuilder) Expiration(seconds int) SetQueryBuilder
Expiration sets the specified expire time, in seconds
func (SetQueryBuilder) Field ¶
func (query SetQueryBuilder) Field(name string, value float64) SetQueryBuilder
Field sets the object field
func (SetQueryBuilder) IfExists ¶
func (query SetQueryBuilder) IfExists() SetQueryBuilder
IfExists only set the object if it already exist
func (SetQueryBuilder) IfNotExists ¶
func (query SetQueryBuilder) IfNotExists() SetQueryBuilder
IfNotExists only set the object if it does not already exist
Source Files ¶
- channels.go
- client.go
- connection.go
- executor.go
- fset_query_builder.go
- geofence.go
- geofence_area_selector.go
- geofence_query_builder.go
- hooks.go
- inw_area_selector.go
- inw_query_builder.go
- jset_query_builder.go
- keys.go
- keys_get_query_builder.go
- objects.go
- scan_query_builder.go
- scripting.go
- search.go
- search_opts.go
- search_query_builder.go
- server.go
- set_area_selector.go
- set_channel_query_builder.go
- set_hook_query_builder.go
- set_query_builder.go
- utils.go