Commit Graph

23 Commits

Author SHA1 Message Date
tidwall d5c148ca41 Field overhaul 2022-09-19 17:47:38 -07:00
tidwall 1177bbb80c Moved root collection keys into generic btree.
Also updated the background expires logic to remove an extra
allocation.
2022-09-13 08:16:41 -07:00
tidwall f24c251ee6 Allow for multiple MATCH patterns
Each MATCH is inclusive OR, thus

    WITHIN fleet MATCH train* truck* BOUNDS 33 -112 34 -113

will find all trains and trucks that within the provides bounds.
2022-09-01 19:43:30 -07:00
tidwall cc9320e246 Allow for WHERE for on geofence detection 2022-08-26 16:23:28 -07:00
tidwall c8389fe52c Fix memory leak with group id
This commit fixes a memory leak that was being caused by hooks
hanging on to the geofence group ids past the life of the object.
2021-08-20 05:00:14 -07:00
tidwall 9e68703841 Update expiration logic
This commit changes the logic for managing the expiration of
objects in the database.

Before: There was a server-wide hashmap that stored the
collection key, id, and expiration timestamp for all objects
that had a TTL. The hashmap was occasionally probed at 20
random positions, looking for objects that have expired. Those
expired objects were immediately deleted, and if there was 5
or more objects deleted, then the probe happened again, with
no delay. If the number of objects was less than 5 then the
there was a 1/10th of a second delay before the next probe.

Now: Rather than a server-wide hashmap, each collection has
its own ordered priority queue that stores objects with TTLs.
Rather than probing, there is a background routine that
executes every 1/10th of a second, which pops the expired
objects from the collection queues, and deletes them.

The collection/queue method is a more stable approach than
the hashmap/probing method. With probing, we can run into
major cache misses for some cases where there is wide
TTL duration, such as in the hours or days. This may cause
the system to occasionally fall behind, leaving should-be
expired objects in memory. Using a queue, there is no
cache misses, all objects that should be expired will be
right away, regardless of the TTL durations.

Fixes #616
2021-07-12 13:37:50 -07:00
tidwall d2f747933f clear linter messages 2021-07-10 03:59:27 -07:00
tidwall d37ce505f5 Allow for all command types for roaming event
Prior to this commit roaming geofences only registered changes to
the SET command. Now it will work for SET/DEL/FSET, just like
non-roaming geofences.

To opt out of these events, explicitly choose which event you
would like to register when you create the geofences.

For example:

  NEARBY fleet FENCE COMMANDS set,del ROAM fleet * 5000

Will only fire off events from SET and DEL command.

Closes #597
2021-04-01 14:59:12 -07:00
tidwall 40105e6b7e Include "distance" to output when user specifically requests
fixes #599
2021-03-30 11:49:01 -07:00
Lars Wilhelmsen 4fdbade7a4
Fix crash in fenceMatchRoam causing an index out of range panic 2020-06-18 15:43:18 +02:00
tidwall 5162ac5fd7 Stable sort roam notifications 2020-03-25 13:01:11 -07:00
tidwall a99df2892a Fixed false faraway notifications 2020-03-25 12:47:55 -07:00
tidwall ff48054d3d Fixed a missing faraway event for roaming geofences
This commit fixes a case where a roaming geofence will not fire
a "faraway" event when it's supposed to.

The fix required rewriting the nearby/faraway detection logic. It
is now much more accurate and takes overall less memory, but it's
also a little slower per operation because each object proximity
is checked twice per update. Once to compare the old object's
surrounding, and once to evaulated the new object. The two lists
are then used to generate accurate "nearby" and "faraway" results.
2020-03-22 11:54:56 -07:00
tidwall 65943e8f1a Fixed DEL geofence notifications missing "key" field
Closed #538
2020-03-21 17:48:31 -07:00
tidwall c084aeedc2 Code cleanup
This commit cleans up various Go code in the internal directory.
- Ensures comments on exported functions
- Changes all *Server receiver in all files to be "s", instead
  of mixed "c", "s", "server", etc.
- Silenced Go warnings for if/else with returns.
- Cleaned up import ordering.
2019-10-30 10:17:59 -07:00
tidwall 0aecef6a5c Added TIMEOUT command 2019-04-24 05:09:41 -07:00
tidwall bb33467da1 Fix crash with fence ROAM
closes #440
2019-04-23 11:16:55 -07:00
tidwall d7d0baa954 Fix roam fence missing 2019-01-06 10:23:57 -07:00
tidwall f2c217c216 Refactor and comment command details 2018-11-23 15:53:33 -07:00
tidwall 07bae979a5 Added Cursor interface 2018-11-02 06:09:56 -07:00
Alex Roitman 0933c541f4 Refactor cursor/paging. 2018-10-31 22:01:37 -07:00
Alex Roitman b94f3685b6 Move iterating up to the cursor before any tests. 2018-10-31 22:01:24 -07:00
tidwall 555e47036c Replaced net package with evio
- Added threads startup flag
- Replaced net package with evio
- Refactored controller into server
2018-10-28 15:51:47 -07:00