This module implements a kvstore for ingrid and is used for state management
docker pull registry-dev.goingrid.io/services/kvstore:latest:v0.0.1
The kvstore service accepts following properties:
Operation | Description |
---|---|
CreateType | Creates the Class given in Data with the Definition of the Config in the Storage |
DeleteType | Deletes the Class from the Storage (Destructive) |
ListType | List all Types available |
Add / Insert / Update | Saves the given Data in the Class on the Storage |
Del / Delete | Deletes the given Object from the Storage |
Get / Fetch | Fetches an Object from the Storage |
List | Lists all Object of a given Class |
Search / Find / Query | Search for all the Keys by the given query Attribute on the Class |
Backup | Backups the current Storage. A Filename can be given via attribute filename |
Creates the Class given in Data. Beside Class / Operation no Data is needed. You can define the Parameter ObjectTypes to create some defaults on service start.
Deletes the Class from the Storage (Destructive)
Besides Class / Operation no Data is needed
Saves the given Data in the Class on the Storage
Key | Multivalue | Required | Description |
---|---|---|---|
key | no | yes | Key for this Object |
* | yes | no | Will be stored as type Class in the Storage |
{
"Class": "state",
"Operation": "add",
"Data": {
"key": ["001"],
"system1": ["ok"],
"system2": ["failed"]
}
}
Response
{
"Code": 200,
"Message": "Success",
"Data": {
"message": [
"Object Saved"
]
},
"List": []
}
Deletes the given Object from the Storage
Key | Multivalue | Required | Description |
---|---|---|---|
key | no | yes | Attribute with the key for the given Class |
If you like to delete an object from the store, you have to pass the class of the object and the key / value pair of it.
{
"Class": "user",
"Operation": "delete",
"Data": {
"key": ["myuser"]
},
}
Response
{
"Code": 200,
"Message": "Success",
"Data": {
"message": [
"Object Deleted"
]
},
"List": []
}
Fetch the given Object from the Storage
Key | Multivalue | Required | Description |
---|---|---|---|
key | no | yes | Attribute with the key for the given Class |
If you like to get / fetch an object from the store, you have to pass the class of the object and the key / value pair of it.
{
"Class": "state",
"Operation": "get",
"Data": {
"key": ["state2356"]
}
}
Lists all Object of a given Class
Key | Multivalue | Required | Description |
---|---|---|---|
start | no | no | |
size | no | no | |
sortdir | no | no |
If you like to list objects from the store, you have to pass the class of the object.
{
"Class": "state",
"Operation": "list",
"Data": {
"size":["100"]
}
}
Response
{
"Code": 200,
"Message": "Success",
"Data": {
"keys": [
"group1",
"group11",
"group12",
"group13",
"group14",
"group7"
]
},
"List": []
}
Search for all the Keys by the given Query on the Class The Parmeters can be passed via Control or Data by the following Names
Key | Multivalue | Required | Logic | Default | Description |
---|---|---|---|---|---|
prefix | yes | no | OR | Prefix for the key to search for | |
suffix | yes | no | OR | Suffix for the key | |
fields | yes | no | fields to retrieve or * for all | ||
keyexists | yes | no | OR | True if the Obj contains this Key | |
keynotexists | yes | no | AND | True if the Obj does not contain the Key | |
valueexists | yes | no | OR | True if the Obj has contains Value | |
valuenotexists | yes | no | AND | True if the Value doe not exist in the Obj | |
haskeyvalue | yes | no | OR | True if the Obj has this Key Value pair | |
hasnotkeyvalue | yes | no | AND | True if the Obj lacks this Key Value pair | |
start | no | no | 0 | Return Objects start from object # | |
size | no | no | 0 | Limit of Objects to retrieve | |
sort | no | no | Sort by this key | ||
sortdir | no | no | ‘de’ | Sort descending or ascending ‘de’ / ‘as’ |
{
"Class": "state",
"Operation": "search",
"Data": {
"suffix": ["113"],
"size": ["100"]
}
}
Or
{
"Class": "state",
"Operation": "search",
"Data": {
"suffix": ["13"],
"sort": ["system1"],
"size": ["10"],
"start": ["0"],
"valueexists": ["ok"],
"haskeyvalue": ["system2=unknown"],
"hasnotkeyvalue": ["system1=error"],
"fields": ["key","system1"]
}
}
or
{
"Class": "state",
"Operation": "search",
"Data": {
"suffix": ["13"],
"fields": ["*"],
"sort": ["system1"],
"size": ["100"],
"start": ["0"],
"valueexists": ["ok"],
"haskeyvalue": ["system2=unknown"],
"hasnotkeyvalue": ["system1=error","system2=error","system3=error","system4=error"]
}
}
Backups the current Storage. A Filename can be given via attribute filename
Key | Multivalue | Required | Description |
---|---|---|---|
filename | no | no | Filename for the Backup. If not given, default will be used |
{
"Operation": "backup",
"Data": {
"filename": ["newbackup.db"]
}
}
Response
{
"Code": 200,
"Message": "Success",
"Data": {
"message": [
"Backup successfuly completed"
]
},
"List": []
}
Like every other service, the log service includes all properties of the service configuration and since it listens on input the input configuration.
The following parameters are specific to this worker. They can be either used environment variables (all uppercase) or within the CLI (-
as prefix).
Parameter | Default | Description |
---|---|---|
BackendConfig | "file://bbolt.cfg" |
Backend Configuration |
Backend | bbolt |
Backend Type. ‘bbolt’ / ‘etcd’ |
ObjectTypes | `` | Default Type to create on service start. Comma delimited. e.G: ‘User,Group’ |
{
"_comment": "BBolt Configuration",
"PathFile" : "test.db",
"BackupPath" : "."
}
https://github.com/etcd-io/etcd/blob/master/clientv3/config.go/
{
"endpoints": [
"localhost:1234"
],
"dial-timeout": 1000000,
"username": "admin",
"password": "placeholder"
}
Timeouts are in usec
docker run -e "LOGLEVEL=INFO" kvstore:latest -ServerURL "hive:c3Iu.....6L@10.0.0.1" -InputChannel kv_store
Rest Tests