Debian Codegraph @

extension/xextension/storage/README.md

raw symbols SCIP
1 # Storage
2
3 **Status: under development; This is currently just the interface**
4
5 A storage extension persists state beyond the collector process. Other components can request a storage client from the storage extension and use it to manage state.
6
7 The `storage.Extension` interface extends `component.Extension` by adding the following method:
8 ```
9 GetClient(context.Context, component.Kind, component.ID, string) (Client, error)
10 ```
11
12 The `storage.Client` interface contains the following methods:
13 ```
14 Get(context.Context, string) ([]byte, error)
15 Set(context.Context, string, []byte) error
16 Delete(context.Context, string) error
17 Close(context.Context) error
18 ```
19
20 It is possible to execute several operations in a single transaction via `Batch`. The method takes a collection of
21 `Operation` arguments (each of which contains `Key`, `Value` and `Type` properties):
22 ```
23 Batch(context.Context, ...Operation) error
24 ```
25
26 The elements itself can be created using:
27
28 ```
29 SetOperation(string, []byte) Operation
30 GetOperation(string) Operation
31 DeleteOperation(string) Operation
32 ```
33
34 Get operation results are stored in-place into the given Operation and can be retrieved using its `Value` property.
35
36 Note: All methods should return error only if a problem occurred. (For example, if a file is no longer accessible, or if a remote service is unavailable.)
37
38 Note: It is the responsibility of each component to `Close` a storage client that it has requested.