Store
elva.store
Module holding store components.
Classes:
-
SQLiteStore
–Store component saving Y updates in an ELVA SQLite database.
SQLiteStore(ydoc, identifier, path)
Bases: Component
Store component saving Y updates in an ELVA SQLite database.
Parameters:
-
ydoc
(Doc
) –instance of the synchronized Y Document.
-
identifier
(str
) –identifier of the synchronized Y Document.
-
path
(str
) –path where to store the SQLite database.
Methods:
-
get_metadata
–Retrieve metadata from a given ELVA SQLite database.
-
set_metadata
–Set given metadata in a given ELVA SQLite database.
-
callback
–Hook called on changes in
ydoc
. -
before
–Hook executed before the component sets its
started
signal. -
run
–Hook writing data to the ELVA SQLite database.
-
cleanup
–Hook cancelling subscription to changes and closing the database.
-
read
–Hook to read in metadata and updates from the ELVA SQLite database and apply them.
-
write
–Queue
update
to be written to the ELVA SQLite database.
Attributes:
-
subscription
(Subscription
) –Object holding subscription information to changes in
ydoc
. -
ydoc
(Doc
) –Instance of the synchronized Y Document.
-
identifier
(str
) –Identifier of the synchronized Y Document.
-
path
(Path
) –Path where to store the SQLite database.
-
initialized
(Event
) –Event being set when the SQLite database is ready to be read.
-
lock
(Lock
) –Object for restricted resource management.
Source code in src/elva/store.py
subscription
instance-attribute
Object holding subscription information to changes in ydoc
.
ydoc = ydoc
instance-attribute
Instance of the synchronized Y Document.
identifier = identifier
instance-attribute
Identifier of the synchronized Y Document.
path = Path(path)
instance-attribute
Path where to store the SQLite database.
initialized = None
instance-attribute
Event being set when the SQLite database is ready to be read.
lock = Lock()
instance-attribute
Object for restricted resource management.
get_metadata(path)
staticmethod
Retrieve metadata from a given ELVA SQLite database.
Parameters:
-
path
(str
) –path to the ELVA SQLite database.
Returns:
-
dict
–mapping of metadata keys to values.
Source code in src/elva/store.py
set_metadata(path, metadata)
staticmethod
Set given metadata in a given ELVA SQLite database.
Parameters:
-
path
(str
) –path to the ELVA SQLite database.
-
metadata
(dict[str, str]
) –mapping of metadata keys to values.
Source code in src/elva/store.py
callback(event)
Hook called on changes in ydoc
.
When called, the event
data are written to the ELVA SQLite database.
Parameters:
-
event
(TransactionEvent
) –object holding event information of changes in
ydoc
.
Source code in src/elva/store.py
before()
async
Hook executed before the component sets its started
signal.
The ELVA SQLite database is being initialized and read.
Also, the component subscribes to changes in ydoc
.
Source code in src/elva/store.py
run()
async
Hook writing data to the ELVA SQLite database.
Source code in src/elva/store.py
cleanup()
async
Hook cancelling subscription to changes and closing the database.
read()
async
Hook to read in metadata and updates from the ELVA SQLite database and apply them.
Source code in src/elva/store.py
write(data)
async
Queue update
to be written to the ELVA SQLite database.
Parameters:
-
data
(bytes
) –update to queue for writing to disk.