Documentation
¶
Overview ¶
Package kv provides the scriptling.runtime.kv library: a thread-safe key-value store (the process-wide default store plus named stores opened with kv.open), backed by snapshotkv. It is independent of the rest of the runtime family, so an application can register it without background tasks or the HTTP server.
Index ¶
Constants ¶
const LibraryName = "scriptling.runtime.kv"
LibraryName is the name scripts import the library by.
Variables ¶
This section is empty.
Functions ¶
func DefaultDB ¶
func DefaultDB() *snapshotkv.DB
DefaultDB returns the system-wide default store opened by InitStore, or nil when none is open.
func InitStore ¶
InitStore initializes the system-wide default KV store. If path is empty, the store operates in memory-only mode. A non-nil log receives snapshot save-failure reports; nil keeps the current logger (a stderr console logger by default). Call it before Register: kv.default is bound when the library is built.
func Register ¶
func Register(registrar object.LibraryRegistrar, allowedPaths []string)
Register registers the scriptling.runtime.kv library. allowedPaths restricts where kv.open may create or open a persistent store, as it does for the filesystem libraries: nil leaves stores unrestricted, an empty slice denies every filesystem path. In-memory stores (":memory:name") are always allowed. A path outside the allowed paths is refused with a PermissionError that a script cannot catch.
When scriptling.runtime is also registered with the same registrar the library is reachable as an attribute of it (`rt.kv`) too. Call InitStore first if scripts should have a kv.default store.
Types ¶
This section is empty.