forked from spinframework/spin-python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkey_value.py
More file actions
40 lines (28 loc) · 2 KB
/
Copy pathkey_value.py
File metadata and controls
40 lines (28 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""Module for accessing Spin key-value stores"""
from spin_sdk.wit.imports import spin_key_value_key_value_3_0_0 as kv
Store = kv.Store
async def open(name: str) -> Store:
"""
Open the store with the specified name.
If `name` is "default", the default store is opened. Otherwise, `name` must
refer to a store defined and configured in a runtime configuration file
supplied with the application.
A `componentize_py_types.Err(spin_sdk.wit.imports.spin_key_value_key_value_3_0_0.Error_NoSuchStore)` will be raised if the `name` is not recognized.
A `componentize_py_types.Err(spin_sdk.wit.imports.spin_key_value_key_value_3_0_0.Error_AccessDenied)` will be raised if the requesting component does not have
access to the specified store.
A `componentize_py_types.Err(spin_sdk.wit.imports.spin_key_value_key_value_3_0_0.Error_StoreTableFull)` will be raised if too many stores have been opened simultaneously.
Closing one or more previously opened stores might address this using the `__exit__` method.
A `componentize_py_types.Err(spin_sdk.wit.imports.spin_key_value_key_value_3_0_0.Error_Other(str))` will be raised if some implementation specific error has occured (e.g I/O)
"""
return await Store.open(name)
async def open_default() -> Store:
"""
Open the default store.
A `componentize_py_types.Err(spin_sdk.wit.imports.spin_key_value_key_value_3_0_0.Error_AccessDenied)`
will be raised if the requesting component does not have access to the
default store.
A `componentize_py_types.Err(spin_sdk.wit.imports.spin_key_value_key_value_3_0_0.Error_StoreTableFull)` will be raised if too many stores have been opened simultaneously.
Closing one or more previously opened stores might address this using the `__exit__` method.
A `componentize_py_types.Err(spin_sdk.wit.imports.spin_key_value_key_value_3_0_0.Error_Other(str))` will be raised if some implementation specific error has occured (e.g I/O)
"""
return await Store.open("default")