Add live (redis and websockets)
Add modernised ipynb_tools Add scheduler Fix crs in settings Lots of small fixes
This commit is contained in:
parent
461c31fb6f
commit
47df53f4d1
15 changed files with 1614 additions and 61 deletions
|
@ -90,14 +90,12 @@ class Store:
|
|||
- redis: RedisConnection
|
||||
- pub (/sub) connections
|
||||
"""
|
||||
async def setup(self, app):
|
||||
async def setup(self):
|
||||
"""
|
||||
Setup the live service for the main Gisaf application:
|
||||
- Create connection for the publishers
|
||||
- Create connection for redis listeners (websocket service)
|
||||
"""
|
||||
self.app = app
|
||||
app.extra['store'] = self
|
||||
await self.create_connections()
|
||||
await self.get_live_layer_defs()
|
||||
|
||||
|
@ -187,7 +185,7 @@ class Store:
|
|||
if 'popup' not in gdf.columns:
|
||||
gdf['popup'] = 'Live: ' + live_name + ' #' + gdf.index.astype('U')
|
||||
if len(gdf) > 0:
|
||||
gdf = gdf.to_crs(conf.crs['geojson'])
|
||||
gdf = gdf.to_crs(conf.crs.geojson)
|
||||
gis_type = gdf.geom_type.iloc[0]
|
||||
else:
|
||||
gis_type = 'Point' ## FIXME: cannot be inferred from the gdf?
|
||||
|
@ -240,8 +238,7 @@ class Store:
|
|||
await self.redis.set(self.get_layer_def_channel(store_name), layer_def_data)
|
||||
|
||||
## Update the layers/stores registry
|
||||
if hasattr(self, 'app'):
|
||||
await self.get_live_layer_defs()
|
||||
await self.get_live_layer_defs()
|
||||
|
||||
return geojson
|
||||
|
||||
|
@ -259,8 +256,7 @@ class Store:
|
|||
await self.redis.delete(self.get_mapbox_paint_channel(store_name))
|
||||
|
||||
## Update the layers/stores registry
|
||||
if hasattr(self, 'app'):
|
||||
await self.get_live_layer_defs()
|
||||
await self.get_live_layer_defs()
|
||||
|
||||
async def has_channel(self, store_name):
|
||||
return len(await self.redis.keys(self.get_json_channel(store_name))) > 0
|
||||
|
@ -274,7 +270,7 @@ class Store:
|
|||
async def get_layer_def(self, store_name):
|
||||
return loads(await self.redis.get(self.get_layer_def_channel(store_name)))
|
||||
|
||||
async def get_live_layer_defs(self) -> list[LiveGeoModel]:
|
||||
async def get_live_layer_defs(self): # -> list[LiveGeoModel]:
|
||||
registry.geom_live_defs = {}
|
||||
for channel in sorted(await self.get_live_layer_def_channels()):
|
||||
model_info = loads(await self.redis.get(channel))
|
||||
|
@ -370,8 +366,6 @@ class Store:
|
|||
- listen to the DB event emitter: setup a callback function
|
||||
"""
|
||||
## Setup the function and triggers on tables
|
||||
db = self.app['db']
|
||||
|
||||
## Keep the connection alive: don't use a "with" block
|
||||
## It needs to be closed correctly: see _close_permanant_db_connection
|
||||
self._permanent_conn = await db.acquire()
|
||||
|
@ -419,17 +413,17 @@ class Store:
|
|||
await self._permanent_conn.release()
|
||||
|
||||
|
||||
async def setup_redis(app):
|
||||
async def setup_redis():
|
||||
global store
|
||||
await store.setup(app)
|
||||
await store.setup()
|
||||
|
||||
|
||||
async def setup_redis_cache(app):
|
||||
async def setup_redis_cache():
|
||||
global store
|
||||
await store._setup_db_cache_system()
|
||||
|
||||
|
||||
async def shutdown_redis(app):
|
||||
async def shutdown_redis():
|
||||
global store
|
||||
await store._close_permanant_db_connection()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue