# README
Shdb
A simple database for protobuf based objects
Installing
$ go get github.com/shenrytech/shdb
Example
package main
func main() {
Init(path.Join(os.TempDir(), "example_query.db"))
Register(&TObject{
Metadata: &Metadata{Type: TObj[:]},
MyString: "The flying duck is flying low"})
count := 100
pageSize := 10
list := []*TObject{}
for k := 0; k < count; k++ {
tObj := MustNew[*TObject](TObj)
tObj.MyInt = uint64(k)
list = append(list, tObj)
}
if err := Put(list...); err != nil {
panic(err)
}
defer func() {
Close()
os.Remove(path.Join(os.TempDir(), "example_query.db"))
}()
var (
nextPageToken string = ""
partList []*TObject
err error
)
ctx := context.Background()
selectorFn := func(obj *TObject) (bool, error) {
return strings.Contains(obj.MyString, "flying"), nil
}
collected := []*TObject{}
for {
partList, nextPageToken, err = Query(ctx,
TObj, selectorFn, int32(count/pageSize), nextPageToken)
if err != nil {
panic(err)
}
collected = append(collected, partList...)
if nextPageToken == "" {
break
}
}
for idx, obj := range collected {
log.Printf("%d: [%v]\n", idx, obj)
}
}
License
Shdb is released under the Apache 2.0 license. See LICENSE.txt
# Packages
No description provided by the author
No description provided by the author
No description provided by the author
# Functions
Close the backing database.
Create just creates the memory for an IObject without initializing the Metadata.
Delete an object from the database based on the type and id.
Delete all objects of a specific type from the database.
Get an object from the database based on the type and id of the object.
GetAll returns all objects in database of a specific type.
GetAllKV returns all KeyVals of the database.
GetOne returns one of the objects in the database with the specified type that matches the selector function.
GetRef returns an object from the database based on an ObjRef.
GetTypeId returns the TypeID from the Metadata of an IObject.
Init initializes the backing database.
List all objects pertaining to a specific type.
No description provided by the author
Marshal returns a list of KeyVal binary representation representing a list of IObjects.
MarshalTypeId creates a TypeId from a []byte slice.
MustNew is like `New` but panics if there is an error.
No description provided by the author
No description provided by the author
New creates a new IObject based on the type key and initializes the Metadata fields.
NewClient returns a new client for use with the API.
No description provided by the author
No description provided by the author
NewTypeId creates a new TypeId based on TypeKey and UUID (Byte version).
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Put creates objects in the database.
Query returns all objects of a specific type matching a selector function.
No description provided by the author
RemoveWatcher closes the eventCh for the watcher and removes the watcher.
Search searches the values of the fields of objects pertaining to a type by calling a selector function for each field in all objects.
SearchProto searches within the fields of the proto message forthe string provided.
SearchRef searches the Ref of objects For paging functionality see `Query` method.
StoreSchema stores the current state of a protoregistry.Files object in the schema bucket.
TypeIdFromString returns a TypeId from an URL-encoded string.
No description provided by the author
Unmarshal returns the IObject from a KeyVal binary representation.
UnmarshalMany unmarshals a list of KeyVal binary representations.
UnmarshalObjRef a byte slice into ObjRef.
UnwatchType removes a list of TypeKeys from a watcher.
UnwatchTypeId removes a list of TypeIds from a watcher.
Update an object in the database by using an updater function.
WatchType creates or updates a watcher by adding watches to new TypeKeys If the provided watcherId is the empty string, a new watcher is created and the eventCh must be specified.
WatchType creates or updates a watcher by adding watches to new TypeIds If the provided watcherId is the empty string, a new watcher is created and the eventCh must be specified.
# Constants
Events reflecting life-cycle changes to an object.
Events reflecting life-cycle changes to an object.
Events reflecting life-cycle changes to an object.
Events reflecting life-cycle changes to an object.
# Variables
optional string shdb_aliases = 51235;.
optional shdb.v1.Shdb_Message_Options shdb_options = 52000;.
optional string shdb_type = 51234;.
optional bytes shdb_type_key = 51236;.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ObjectService_ServiceDesc is the grpc.ServiceDesc for ObjectService service.
No description provided by the author
# Structs
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
EventInfo contains the information about a specific life cycle event.
No description provided by the author
No description provided by the author
No description provided by the author
KeyVal is the binary representation of an IObject as it is stored in the database.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
TypeId is the key in the key-value database that is used to store IObjects.
No description provided by the author
UnimplementedObjectServiceServer must be embedded to have forward compatible implementations.
No description provided by the author
# Interfaces
IObject is the interface for all objects in the dataabase.
No description provided by the author
No description provided by the author
ObjectServiceClient is the client API for ObjectService service.
ObjectServiceServer is the server API for ObjectService service.
UnsafeObjectServiceServer may be embedded to opt out of forward compatibility for this service.
# Type aliases
TypeKey is the four bytes that identifies the type of an object.