Commit Graph

9 Commits

Author SHA1 Message Date
Fabio Manganiello 8ccf3e804d
Added utility get_entities_engine() function. 2023-03-10 11:49:23 +01:00
Fabio Manganiello c4efec6832
Several fixes and improvements on the entities engine.
- Support for an optional callback on `publish_entities` to get notified
  when the published object are flushed to the db.

- Use `lazy='selectin'` for the entity parent -> children relationship -
  it is more efficient and it ensures that all the data the application
  needs is loaded upfront.

- `Entity.entity_key` rolled back to `<external_id, plugin>`. The
  fallback logic on `<id, plugin>` created more problems than those it
  as supposed to solve.

- Added `expire_on_commit=False` to the entities engine session to make
  sure that we don't get errors on detached/expired instances.
2023-03-09 01:16:04 +01:00
Fabio Manganiello b0cc80ceb0
Rewriting `bluetooth.ble` plugin to use `bleak` instead of `gattlib`. 2023-02-10 17:40:20 +01:00
Fabio Manganiello be3b99326f
[WIP] Refactoring `@manages` annotation into a proper `EntityManager` hierarchy 2023-02-02 23:21:12 +01:00
Fabio Manganiello 59eb0742a1
s/warnings/logger.debug/ if publish_entities is called with no engine registered 2023-01-29 21:52:12 +01:00
Fabio Manganiello 86edd70d93
Fixed session/concurrency management on the main SQLite db
- The `declarative_base` instance should be shared
- Database `session_locks` should be stored at module, not instance
  level
- Better isolation of scoped sessions
- Enclapsulated `get_session` method in `UserManager`
2022-11-12 15:36:17 +01:00
Fabio Manganiello 6b7933cd33
Using a different SQLite database for entities
This prevents multiprocessing/concurrency issues when modifying the same
database file both from the main process and from the web server process
2022-11-12 02:00:55 +01:00
Fabio Manganiello 26ffc0b0e1
Use Redis instead of an in-process map to store the entity/plugin registry
This is particularly useful when we want to access the registry from
another process, like the web server or an external script.
2022-04-07 00:18:11 +02:00
Fabio Manganiello 4ee7e4db29
Basic support for entities on the local db and implemented support for switch entities on the tplink plugin 2022-04-04 16:50:17 +02:00