tidwall / tile38

Real-time Geospatial and Geofencing
https://tile38.com
MIT License
9.15k stars 570 forks source link

Lifetime of channels and hooks #474

Open KrishnaPG opened 5 years ago

KrishnaPG commented 5 years ago

When a pubsub channel or hook is created, for example using something as below (from the documentation):

SETCHAN warehouse NEARBY fleet FENCE POINT 33.462 -112.268 6000

one can use SUBSCRIBE warehouse to keep the connection open and listen to those events.

The requirement is:

What is the best way to organize this so that the server does not keep calculating and emitting events for channels and hooks that are being watched by no one? Does Tile38 takes care of it automatically (i.e. stops doing the intersection calculations when there are no subscribers) or should the app manage the lifetime?

The concern is about performance of live-queries when the number of fences is large.

KrishnaPG commented 5 years ago

Also, what happens if the tile38 server crashes or restarts?

Does Tile38 persist the hooks / channels information? Would be subscribers automatically start getting the notifications after the restart?