Documentation ¶
Overview ¶
Copyright 2023 Shenry Tech AB
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func Close() error
- func Create[T IObject](typeKey TypeKey) (t T, err error)
- func Delete[T IObject](tid TypeId) (T, error)
- func DeleteAll(tk TypeKey) error
- func Get[T IObject](tid TypeId) (T, error)
- func GetAll[T IObject](typeKey TypeKey) ([]T, error)
- func GetFirst[T IObject](typeKey TypeKey, selector func(obj T) bool) (T, error)
- func GetRef[T IObject](ref *ObjRef) (T, error)
- func Init(dbFile string)
- func List[T IObject](ctx context.Context, typ TypeKey, pageSize int32, pageToken string) (result []T, nextPageToken string, err error)
- func LoadSchema() (*descriptorpb.FileDescriptorSet, error)
- func MustNew[T IObject](typeKey TypeKey) T
- func New[T IObject](typeKey TypeKey) (obj T, err error)
- func Put[T IObject](val ...T) error
- func Query[T IObject](ctx context.Context, typ TypeKey, selectFn func(obj T) (bool, error), ...) (result []T, nextPageToken string, err error)
- func RegisterObjectServiceServer(s grpc.ServiceRegistrar, srv ObjectServiceServer)
- func RemoveWatcher(watcherId string) error
- func SearchProto(m proto.Message, query func(s string) bool) (hits []string, err error)
- func StoreSchema(files protoregistry.Files) error
- func Unmarshal[T IObject](kv KeyVal) (T, error)
- func UnmarshalMany[T IObject](kvs []KeyVal) ([]T, error)
- func UnwatchType(watcherId string, typeKeys ...TypeKey) error
- func UnwatchTypeId(watcherId string, tids ...TypeId) error
- func Update[T IObject](tid TypeId, updater func(obj T) (T, error)) (t T, err error)
- func WatchType(watcherId string, eventCh chan *EventInfo, typeKeys ...TypeKey) (string, error)
- func WatchTypeId(watcherId string, eventCh chan *EventInfo, tids ...TypeId) (string, error)
- type Client
- func (c *Client) Create(typ TypeKey) (IObject, error)
- func (c *Client) Delete(tid TypeId) (IObject, error)
- func (c *Client) Get(tid TypeId) (IObject, error)
- func (c *Client) GetTypeNames() (map[string][]string, error)
- func (c *Client) List(tk TypeKey) ([]IObject, error)
- func (c *Client) SearchRef(tk TypeKey, selector func(obj *ObjRef) bool) (chan *ObjRef, error)
- func (c *Client) TypeRegistry() *TypeRegistry
- func (c *Client) Update(obj IObject) (IObject, error)
- type CreateReq
- type DeleteReq
- type DynObject
- type EventInfo
- type GetReq
- type GetTypeNamesRsp
- func (*GetTypeNamesRsp) Descriptor() ([]byte, []int)deprecated
- func (x *GetTypeNamesRsp) GetTypeAliases() []*GetTypeNamesRsp_TypeAliases
- func (*GetTypeNamesRsp) ProtoMessage()
- func (x *GetTypeNamesRsp) ProtoReflect() protoreflect.Message
- func (x *GetTypeNamesRsp) Reset()
- func (x *GetTypeNamesRsp) String() string
- type GetTypeNamesRsp_TypeAliases
- func (*GetTypeNamesRsp_TypeAliases) Descriptor() ([]byte, []int)deprecated
- func (x *GetTypeNamesRsp_TypeAliases) GetAliases() []string
- func (x *GetTypeNamesRsp_TypeAliases) GetFullname() string
- func (*GetTypeNamesRsp_TypeAliases) ProtoMessage()
- func (x *GetTypeNamesRsp_TypeAliases) ProtoReflect() protoreflect.Message
- func (x *GetTypeNamesRsp_TypeAliases) Reset()
- func (x *GetTypeNamesRsp_TypeAliases) String() string
- type IObject
- type KeyVal
- type ListReq
- func (*ListReq) Descriptor() ([]byte, []int)deprecated
- func (x *ListReq) GetPageSize() int32
- func (x *ListReq) GetPageToken() string
- func (x *ListReq) GetType() []byte
- func (*ListReq) ProtoMessage()
- func (x *ListReq) ProtoReflect() protoreflect.Message
- func (x *ListReq) Reset()
- func (x *ListReq) String() string
- type ListRsp
- type MessageInfo
- type Metadata
- func (*Metadata) Descriptor() ([]byte, []int)deprecated
- func (m *Metadata) Fill() error
- func (x *Metadata) GetCreatedAt() *timestamppb.Timestamp
- func (x *Metadata) GetDescription() string
- func (x *Metadata) GetLabels() []string
- func (x *Metadata) GetType() []byte
- func (x *Metadata) GetUpdatedAt() *timestamppb.Timestamp
- func (x *Metadata) GetUuid() []byte
- func (m *Metadata) GetUuidAsString() (string, error)
- func (m *Metadata) GetUuidAsUUID() (uuid.UUID, error)
- func (*Metadata) ProtoMessage()
- func (x *Metadata) ProtoReflect() protoreflect.Message
- func (m *Metadata) Ref() *ObjRef
- func (x *Metadata) Reset()
- func (x *Metadata) String() string
- func (m *Metadata) TypeId() TypeId
- type ObjRef
- func MustParseObjRef(typeKey TypeKey, id interface{}) *ObjRef
- func ObjRefFromUUID(typeKey TypeKey, id string) (*ObjRef, error)
- func ParseObjRef(typeKey TypeKey, id interface{}) (*ObjRef, error)
- func SearchRef(ctx context.Context, selector func(*ObjRef) bool, pageSize int32, ...) (result []*ObjRef, nextPageToken string, err error)
- func UnmarshalObjRef(data []byte) (*ObjRef, error)
- func (*ObjRef) Descriptor() ([]byte, []int)deprecated
- func (r *ObjRef) Equal(other *ObjRef) bool
- func (x *ObjRef) GetType() []byte
- func (x *ObjRef) GetUuid() []byte
- func (r *ObjRef) Marshal() []byte
- func (*ObjRef) ProtoMessage()
- func (x *ObjRef) ProtoReflect() protoreflect.Message
- func (x *ObjRef) Reset()
- func (x *ObjRef) String() string
- func (r *ObjRef) TypeId() *TypeId
- func (r *ObjRef) UUID() uuid.UUID
- type Object
- type ObjectServiceClient
- type ObjectServiceServer
- type ObjectService_StreamRefsClient
- type ObjectService_StreamRefsServer
- type SearchHit
- type SearchResult
- type Server
- func (s *Server) Create(ctx context.Context, req *CreateReq) (*Object, error)
- func (s *Server) Delete(ctx context.Context, req *DeleteReq) (*Object, error)
- func (s *Server) Get(ctx context.Context, req *GetReq) (*Object, error)
- func (s *Server) GetSchema(ctx context.Context, req *emptypb.Empty) (*descriptorpb.FileDescriptorSet, error)
- func (s *Server) GetTypeNames(ctx context.Context, req *emptypb.Empty) (*GetTypeNamesRsp, error)
- func (s *Server) List(ctx context.Context, req *ListReq) (*ListRsp, error)
- func (s *Server) StreamRefs(req *StreamRefReq, stream ObjectService_StreamRefsServer) error
- func (s *Server) Update(ctx context.Context, req *UpdateReq) (*Object, error)
- type Shdb_Message_Options
- func (*Shdb_Message_Options) Descriptor() ([]byte, []int)deprecated
- func (x *Shdb_Message_Options) GetAliases() []string
- func (x *Shdb_Message_Options) GetPrintTemplates() map[string]string
- func (x *Shdb_Message_Options) GetType() string
- func (x *Shdb_Message_Options) GetTypeKey() []byte
- func (*Shdb_Message_Options) ProtoMessage()
- func (x *Shdb_Message_Options) ProtoReflect() protoreflect.Message
- func (x *Shdb_Message_Options) Reset()
- func (x *Shdb_Message_Options) String() string
- type StreamRefReq
- type TObject
- func (*TObject) Descriptor() ([]byte, []int)deprecated
- func (x *TObject) GetAny() *anypb.Any
- func (x *TObject) GetMetadata() *Metadata
- func (x *TObject) GetMyInt() uint64
- func (x *TObject) GetMyString() string
- func (x *TObject) GetTimestamp() *timestamppb.Timestamp
- func (*TObject) ProtoMessage()
- func (x *TObject) ProtoReflect() protoreflect.Message
- func (x *TObject) Reset()
- func (x *TObject) String() string
- type TypeId
- func GetTypeId(obj IObject) *TypeId
- func MarshalTypeId(data []byte) *TypeId
- func MustParseTypeId(typeKey TypeKey, id interface{}) TypeId
- func NewTypeId(typeKey TypeKey, id []byte) *TypeId
- func ParseTypeId(typeKey TypeKey, id interface{}) (tid TypeId, err error)
- func TypeIdFromString(str string) (*TypeId, error)
- func (k *TypeId) Equal(other *TypeId) bool
- func (k *TypeId) Key() []byte
- func (k *TypeId) SetType(keyType TypeKey)
- func (k *TypeId) SetUuid(id uuid.UUID)
- func (k *TypeId) SetUuidBytes(id []byte)
- func (k *TypeId) String() string
- func (k TypeId) TypeKey() TypeKey
- func (k TypeId) Uuid() uuid.UUID
- func (k TypeId) UuidBytes() []byte
- type TypeKey
- type TypeRegistry
- func (r *TypeRegistry) AddFile(fd protoreflect.FileDescriptor) error
- func (r *TypeRegistry) AddFileFromProtoFileDescriptor(fd *descriptorpb.FileDescriptorProto) error
- func (r *TypeRegistry) CreateEmptyObject(tk TypeKey) (IObject, error)
- func (r *TypeRegistry) CreateObject(spec interface{}) (IObject, error)
- func (r *TypeRegistry) GetFileDescriptorSet() *descriptorpb.FileDescriptorSet
- func (r *TypeRegistry) GetMessageInfo(tk TypeKey) (MessageInfo, error)
- func (r *TypeRegistry) GetTypeKeyFromToA(toa string) (TypeKey, error)
- func (r *TypeRegistry) GetTypeNames() map[string][]string
- func (r *TypeRegistry) LoadSchema() (err error)
- func (r *TypeRegistry) StoreSchema() error
- func (r *TypeRegistry) Unmarshal(key []byte, value []byte) (IObject, error)
- func (r *TypeRegistry) UseFileDescriptorSet(fds *descriptorpb.FileDescriptorSet) (err error)
- type UnimplementedObjectServiceServer
- func (UnimplementedObjectServiceServer) Create(context.Context, *CreateReq) (*Object, error)
- func (UnimplementedObjectServiceServer) Delete(context.Context, *DeleteReq) (*Object, error)
- func (UnimplementedObjectServiceServer) Get(context.Context, *GetReq) (*Object, error)
- func (UnimplementedObjectServiceServer) GetSchema(context.Context, *emptypb.Empty) (*descriptorpb.FileDescriptorSet, error)
- func (UnimplementedObjectServiceServer) GetTypeNames(context.Context, *emptypb.Empty) (*GetTypeNamesRsp, error)
- func (UnimplementedObjectServiceServer) List(context.Context, *ListReq) (*ListRsp, error)
- func (UnimplementedObjectServiceServer) StreamRefs(*StreamRefReq, ObjectService_StreamRefsServer) error
- func (UnimplementedObjectServiceServer) Update(context.Context, *UpdateReq) (*Object, error)
- type UnsafeObjectServiceServer
- type UpdateReq
Examples ¶
Constants ¶
const ( InvalidWatchEvent = 0 EventCreated = 1 EventUpdated = 2 EventDeleted = 3 )
Events reflecting life-cycle changes to an object
Variables ¶
var ( ErrNotAnObject = errors.New("not an object type") ErrInvalidType = errors.New("invalid type") ErrNotFound = errors.New("not found") ErrSessionInvalid = errors.New("session invalid") ErrContextCancelled = errors.New("context cancelled") ErrDatabaseCorrupt = errors.New("database corrupt") )
var ( // optional shdb.v1.Shdb_Message_Options shdb_options = 52000; E_ShdbOptions = &file_pb_shdb_v1_shdb_proto_extTypes[0] // optional string shdb_type = 51234; E_ShdbType = &file_pb_shdb_v1_shdb_proto_extTypes[1] // optional string shdb_aliases = 51235; E_ShdbAliases = &file_pb_shdb_v1_shdb_proto_extTypes[2] // optional bytes shdb_type_key = 51236; E_ShdbTypeKey = &file_pb_shdb_v1_shdb_proto_extTypes[3] )
Extension fields to descriptorpb.MessageOptions.
var File_pb_shdb_v1_shdb_proto protoreflect.FileDescriptor
var File_pb_shdb_v1_test_proto protoreflect.FileDescriptor
var ObjectService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "shdb.v1.ObjectService", HandlerType: (*ObjectServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "List", Handler: _ObjectService_List_Handler, }, { MethodName: "Get", Handler: _ObjectService_Get_Handler, }, { MethodName: "Create", Handler: _ObjectService_Create_Handler, }, { MethodName: "Update", Handler: _ObjectService_Update_Handler, }, { MethodName: "Delete", Handler: _ObjectService_Delete_Handler, }, { MethodName: "GetSchema", Handler: _ObjectService_GetSchema_Handler, }, { MethodName: "GetTypeNames", Handler: _ObjectService_GetTypeNames_Handler, }, }, Streams: []grpc.StreamDesc{ { StreamName: "StreamRefs", Handler: _ObjectService_StreamRefs_Handler, ServerStreams: true, }, }, Metadata: "pb/shdb/v1/shdb.proto", }
ObjectService_ServiceDesc is the grpc.ServiceDesc for ObjectService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
var TypeKeyAll = TypeKey{0xff, 0xff, 0xff, 0xff}
Functions ¶
func Delete ¶
Delete an object from the database based on the type and id. The old value is returned
func GetFirst ¶
GetOne returns one of the objects in the database with the specified type that matches the selector function. The selector should return true for a match and false otherwise when presented with an object.
func List ¶
func List[T IObject](ctx context.Context, typ TypeKey, pageSize int32, pageToken string) (result []T, nextPageToken string, err error)
List all objects pertaining to a specific type. For arguments and paging see `Query` method.
func LoadSchema ¶ added in v1.0.2
func LoadSchema() (*descriptorpb.FileDescriptorSet, error)
func Put ¶
Put creates objects in the database. If the object already existed it will be overwritten.
func Query ¶
func Query[T IObject](ctx context.Context, typ TypeKey, selectFn func(obj T) (bool, error), pageSize int32, pageToken string) (result []T, nextPageToken string, err error)
Query returns all objects of a specific type matching a selector function. Paging of the results is implemented using a pageSize and a token. If there are more results available after pageSize items have been returned a non-empty nextPageToken is returned that can be used to retrieve a new page of results. If nextPageToken is the empty string, no more results are available.
Example ¶
Init(path.Join(os.TempDir(), "example_query.db")) 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) }
Output:
func RegisterObjectServiceServer ¶ added in v1.0.2
func RegisterObjectServiceServer(s grpc.ServiceRegistrar, srv ObjectServiceServer)
func RemoveWatcher ¶
RemoveWatcher closes the eventCh for the watcher and removes the watcher.
func SearchProto ¶
SearchProto searches within the fields of the proto message forthe string provided. The result will contain a number of hits in the form - /[fieldName|@idx]/... Examples:
- / - The object contained only one item and it matched
- /myField - {"myField": <match>}
- /field1/field2/@3 {"field1": {"field2": [1,2,<match>]}}
func StoreSchema ¶ added in v1.0.2
func StoreSchema(files protoregistry.Files) error
StoreSchema stores the current state of a protoregistry.Files object in the schema bucket.
func UnmarshalMany ¶
UnmarshalMany unmarshals a list of KeyVal binary representations
func UnwatchType ¶
UnwatchType removes a list of TypeKeys from a watcher
func UnwatchTypeId ¶
UnwatchTypeId removes a list of TypeIds from a watcher
func Update ¶
Update an object in the database by using an updater function. The updated object is returned.
func WatchType ¶
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. If watcherId is non-empty, then the eventCh can be set to nil The watcherId is returned.
func WatchTypeId ¶
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. If watcherId is non-empty, then the eventCh can be set to nil The watcherId is returned.
Types ¶
type Client ¶ added in v1.0.2
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶ added in v1.0.2
func NewClient(ctx context.Context, cc *grpc.ClientConn) *Client
NewClient returns a new client for use with the API
func (*Client) GetTypeNames ¶ added in v1.0.2
func (*Client) TypeRegistry ¶ added in v1.0.2
func (c *Client) TypeRegistry() *TypeRegistry
type CreateReq ¶ added in v1.0.2
type CreateReq struct { Type []byte `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` // contains filtered or unexported fields }
func (*CreateReq) Descriptor
deprecated
added in
v1.0.2
func (*CreateReq) ProtoMessage ¶ added in v1.0.2
func (*CreateReq) ProtoMessage()
func (*CreateReq) ProtoReflect ¶ added in v1.0.2
func (x *CreateReq) ProtoReflect() protoreflect.Message
type DeleteReq ¶ added in v1.0.2
type DeleteReq struct { Ref *ObjRef `protobuf:"bytes,1,opt,name=ref,proto3" json:"ref,omitempty"` // contains filtered or unexported fields }
func (*DeleteReq) Descriptor
deprecated
added in
v1.0.2
func (*DeleteReq) ProtoMessage ¶ added in v1.0.2
func (*DeleteReq) ProtoMessage()
func (*DeleteReq) ProtoReflect ¶ added in v1.0.2
func (x *DeleteReq) ProtoReflect() protoreflect.Message
type DynObject ¶ added in v1.0.2
func (*DynObject) GetMetadata ¶ added in v1.0.2
type GetReq ¶ added in v1.0.2
type GetReq struct { Ref *ObjRef `protobuf:"bytes,1,opt,name=ref,proto3" json:"ref,omitempty"` // contains filtered or unexported fields }
func (*GetReq) Descriptor
deprecated
added in
v1.0.2
func (*GetReq) ProtoMessage ¶ added in v1.0.2
func (*GetReq) ProtoMessage()
func (*GetReq) ProtoReflect ¶ added in v1.0.2
func (x *GetReq) ProtoReflect() protoreflect.Message
type GetTypeNamesRsp ¶ added in v1.0.2
type GetTypeNamesRsp struct { TypeAliases []*GetTypeNamesRsp_TypeAliases `protobuf:"bytes,1,rep,name=type_aliases,json=typeAliases,proto3" json:"type_aliases,omitempty"` // contains filtered or unexported fields }
func (*GetTypeNamesRsp) Descriptor
deprecated
added in
v1.0.2
func (*GetTypeNamesRsp) Descriptor() ([]byte, []int)
Deprecated: Use GetTypeNamesRsp.ProtoReflect.Descriptor instead.
func (*GetTypeNamesRsp) GetTypeAliases ¶ added in v1.0.2
func (x *GetTypeNamesRsp) GetTypeAliases() []*GetTypeNamesRsp_TypeAliases
func (*GetTypeNamesRsp) ProtoMessage ¶ added in v1.0.2
func (*GetTypeNamesRsp) ProtoMessage()
func (*GetTypeNamesRsp) ProtoReflect ¶ added in v1.0.2
func (x *GetTypeNamesRsp) ProtoReflect() protoreflect.Message
func (*GetTypeNamesRsp) Reset ¶ added in v1.0.2
func (x *GetTypeNamesRsp) Reset()
func (*GetTypeNamesRsp) String ¶ added in v1.0.2
func (x *GetTypeNamesRsp) String() string
type GetTypeNamesRsp_TypeAliases ¶ added in v1.0.2
type GetTypeNamesRsp_TypeAliases struct { Fullname string `protobuf:"bytes,1,opt,name=fullname,proto3" json:"fullname,omitempty"` Aliases []string `protobuf:"bytes,2,rep,name=aliases,proto3" json:"aliases,omitempty"` // contains filtered or unexported fields }
func (*GetTypeNamesRsp_TypeAliases) Descriptor
deprecated
added in
v1.0.2
func (*GetTypeNamesRsp_TypeAliases) Descriptor() ([]byte, []int)
Deprecated: Use GetTypeNamesRsp_TypeAliases.ProtoReflect.Descriptor instead.
func (*GetTypeNamesRsp_TypeAliases) GetAliases ¶ added in v1.0.2
func (x *GetTypeNamesRsp_TypeAliases) GetAliases() []string
func (*GetTypeNamesRsp_TypeAliases) GetFullname ¶ added in v1.0.2
func (x *GetTypeNamesRsp_TypeAliases) GetFullname() string
func (*GetTypeNamesRsp_TypeAliases) ProtoMessage ¶ added in v1.0.2
func (*GetTypeNamesRsp_TypeAliases) ProtoMessage()
func (*GetTypeNamesRsp_TypeAliases) ProtoReflect ¶ added in v1.0.2
func (x *GetTypeNamesRsp_TypeAliases) ProtoReflect() protoreflect.Message
func (*GetTypeNamesRsp_TypeAliases) Reset ¶ added in v1.0.2
func (x *GetTypeNamesRsp_TypeAliases) Reset()
func (*GetTypeNamesRsp_TypeAliases) String ¶ added in v1.0.2
func (x *GetTypeNamesRsp_TypeAliases) String() string
type IObject ¶
IObject is the interface for all objects in the dataabase. They all should stem from a protobuf message that looks like this:
message TObject { shdb.Metadata metadata = 1; string my_field = 2; uint64 my_int = 3; }
type KeyVal ¶
KeyVal is the binary representation of an IObject as it is stored in the database
type ListReq ¶ added in v1.0.2
type ListReq struct { Type []byte `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` PageSize int32 `protobuf:"varint,2,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` PageToken string `protobuf:"bytes,3,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` // contains filtered or unexported fields }
func (*ListReq) Descriptor
deprecated
added in
v1.0.2
func (*ListReq) GetPageSize ¶ added in v1.0.2
func (*ListReq) GetPageToken ¶ added in v1.0.2
func (*ListReq) ProtoMessage ¶ added in v1.0.2
func (*ListReq) ProtoMessage()
func (*ListReq) ProtoReflect ¶ added in v1.0.2
func (x *ListReq) ProtoReflect() protoreflect.Message
type ListRsp ¶ added in v1.0.2
type ListRsp struct { Objects []*Object `protobuf:"bytes,1,rep,name=objects,proto3" json:"objects,omitempty"` NextPageToken string `protobuf:"bytes,2,opt,name=next_page_token,json=nextPageToken,proto3" json:"next_page_token,omitempty"` // contains filtered or unexported fields }
func (*ListRsp) Descriptor
deprecated
added in
v1.0.2
func (*ListRsp) GetNextPageToken ¶ added in v1.0.2
func (*ListRsp) GetObjects ¶ added in v1.0.2
func (*ListRsp) ProtoMessage ¶ added in v1.0.2
func (*ListRsp) ProtoMessage()
func (*ListRsp) ProtoReflect ¶ added in v1.0.2
func (x *ListRsp) ProtoReflect() protoreflect.Message
type MessageInfo ¶ added in v1.0.2
type MessageInfo struct { Fullname string Aliases []string PrintTemplates map[string]string TypeKey TypeKey MessageType protoreflect.MessageType IsDynamic bool }
type Metadata ¶
type Metadata struct { Type []byte `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` Uuid []byte `protobuf:"bytes,2,opt,name=uuid,proto3" json:"uuid,omitempty"` Labels []string `protobuf:"bytes,3,rep,name=labels,proto3" json:"labels,omitempty"` Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"` CreatedAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"` // contains filtered or unexported fields }
func (*Metadata) Descriptor
deprecated
func (*Metadata) GetCreatedAt ¶
func (x *Metadata) GetCreatedAt() *timestamppb.Timestamp
func (*Metadata) GetDescription ¶
func (*Metadata) GetUpdatedAt ¶
func (x *Metadata) GetUpdatedAt() *timestamppb.Timestamp
func (*Metadata) GetUuidAsString ¶ added in v1.0.1
GetUuidAsString returns the UUID as a string
func (*Metadata) GetUuidAsUUID ¶ added in v1.0.1
GetUuidAsUUID returns the UUID as a uuid.UUID
func (*Metadata) ProtoMessage ¶
func (*Metadata) ProtoMessage()
func (*Metadata) ProtoReflect ¶
func (x *Metadata) ProtoReflect() protoreflect.Message
type ObjRef ¶ added in v1.0.1
type ObjRef struct { Type []byte `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` Uuid []byte `protobuf:"bytes,2,opt,name=uuid,proto3" json:"uuid,omitempty"` // contains filtered or unexported fields }
func MustParseObjRef ¶ added in v1.0.2
func ObjRefFromUUID ¶ added in v1.0.2
func ParseObjRef ¶ added in v1.0.2
func SearchRef ¶ added in v1.0.2
func SearchRef(ctx context.Context, selector func(*ObjRef) bool, pageSize int32, pageToken string) (result []*ObjRef, nextPageToken string, err error)
SearchRef searches the Ref of objects For paging functionality see `Query` method.
func UnmarshalObjRef ¶ added in v1.0.1
UnmarshalObjRef a byte slice into ObjRef
func (*ObjRef) Descriptor
deprecated
added in
v1.0.1
func (*ObjRef) ProtoMessage ¶ added in v1.0.1
func (*ObjRef) ProtoMessage()
func (*ObjRef) ProtoReflect ¶ added in v1.0.1
func (x *ObjRef) ProtoReflect() protoreflect.Message
type Object ¶ added in v1.0.2
type Object struct { Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` // contains filtered or unexported fields }
func (*Object) Descriptor
deprecated
added in
v1.0.2
func (*Object) ProtoMessage ¶ added in v1.0.2
func (*Object) ProtoMessage()
func (*Object) ProtoReflect ¶ added in v1.0.2
func (x *Object) ProtoReflect() protoreflect.Message
type ObjectServiceClient ¶ added in v1.0.2
type ObjectServiceClient interface { List(ctx context.Context, in *ListReq, opts ...grpc.CallOption) (*ListRsp, error) Get(ctx context.Context, in *GetReq, opts ...grpc.CallOption) (*Object, error) Create(ctx context.Context, in *CreateReq, opts ...grpc.CallOption) (*Object, error) Update(ctx context.Context, in *UpdateReq, opts ...grpc.CallOption) (*Object, error) Delete(ctx context.Context, in *DeleteReq, opts ...grpc.CallOption) (*Object, error) StreamRefs(ctx context.Context, in *StreamRefReq, opts ...grpc.CallOption) (ObjectService_StreamRefsClient, error) GetSchema(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*descriptorpb.FileDescriptorSet, error) GetTypeNames(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*GetTypeNamesRsp, error) }
ObjectServiceClient is the client API for ObjectService service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
func NewObjectServiceClient ¶ added in v1.0.2
func NewObjectServiceClient(cc grpc.ClientConnInterface) ObjectServiceClient
type ObjectServiceServer ¶ added in v1.0.2
type ObjectServiceServer interface { List(context.Context, *ListReq) (*ListRsp, error) Get(context.Context, *GetReq) (*Object, error) Create(context.Context, *CreateReq) (*Object, error) Update(context.Context, *UpdateReq) (*Object, error) Delete(context.Context, *DeleteReq) (*Object, error) StreamRefs(*StreamRefReq, ObjectService_StreamRefsServer) error GetSchema(context.Context, *emptypb.Empty) (*descriptorpb.FileDescriptorSet, error) GetTypeNames(context.Context, *emptypb.Empty) (*GetTypeNamesRsp, error) // contains filtered or unexported methods }
ObjectServiceServer is the server API for ObjectService service. All implementations must embed UnimplementedObjectServiceServer for forward compatibility
type ObjectService_StreamRefsClient ¶ added in v1.0.2
type ObjectService_StreamRefsClient interface { Recv() (*ObjRef, error) grpc.ClientStream }
type ObjectService_StreamRefsServer ¶ added in v1.0.2
type ObjectService_StreamRefsServer interface { Send(*ObjRef) error grpc.ServerStream }
type SearchHit ¶
type SearchHit struct { Metadata *Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"` Hits []string `protobuf:"bytes,2,rep,name=hits,proto3" json:"hits,omitempty"` // contains filtered or unexported fields }
func (*SearchHit) Descriptor
deprecated
func (*SearchHit) GetMetadata ¶
func (*SearchHit) ProtoMessage ¶
func (*SearchHit) ProtoMessage()
func (*SearchHit) ProtoReflect ¶
func (x *SearchHit) ProtoReflect() protoreflect.Message
type SearchResult ¶
type SearchResult struct { Hits []*SearchHit `protobuf:"bytes,1,rep,name=hits,proto3" json:"hits,omitempty"` // contains filtered or unexported fields }
func Search ¶
func Search(ctx context.Context, typ TypeKey, selector func(string) bool, pageSize int32, pageToken string) (result *SearchResult, nextPageToken string, err error)
Search searches the values of the fields of objects pertaining to a type by calling a selector function for each field in all objects. For paging functionality see `Query` method.
func (*SearchResult) Descriptor
deprecated
func (*SearchResult) Descriptor() ([]byte, []int)
Deprecated: Use SearchResult.ProtoReflect.Descriptor instead.
func (*SearchResult) GetHits ¶
func (x *SearchResult) GetHits() []*SearchHit
func (*SearchResult) ProtoMessage ¶
func (*SearchResult) ProtoMessage()
func (*SearchResult) ProtoReflect ¶
func (x *SearchResult) ProtoReflect() protoreflect.Message
func (*SearchResult) Reset ¶
func (x *SearchResult) Reset()
func (*SearchResult) String ¶
func (x *SearchResult) String() string
type Server ¶ added in v1.0.2
type Server struct { UnimplementedObjectServiceServer // contains filtered or unexported fields }
func (*Server) GetSchema ¶ added in v1.0.2
func (s *Server) GetSchema(ctx context.Context, req *emptypb.Empty) (*descriptorpb.FileDescriptorSet, error)
func (*Server) GetTypeNames ¶ added in v1.0.2
func (*Server) StreamRefs ¶ added in v1.0.2
func (s *Server) StreamRefs(req *StreamRefReq, stream ObjectService_StreamRefsServer) error
type Shdb_Message_Options ¶ added in v1.0.2
type Shdb_Message_Options struct { Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` Aliases []string `protobuf:"bytes,2,rep,name=aliases,proto3" json:"aliases,omitempty"` TypeKey []byte `protobuf:"bytes,3,opt,name=type_key,json=typeKey,proto3" json:"type_key,omitempty"` PrintTemplates map[string]string `` /* 191-byte string literal not displayed */ // contains filtered or unexported fields }
func (*Shdb_Message_Options) Descriptor
deprecated
added in
v1.0.2
func (*Shdb_Message_Options) Descriptor() ([]byte, []int)
Deprecated: Use Shdb_Message_Options.ProtoReflect.Descriptor instead.
func (*Shdb_Message_Options) GetAliases ¶ added in v1.0.2
func (x *Shdb_Message_Options) GetAliases() []string
func (*Shdb_Message_Options) GetPrintTemplates ¶ added in v1.0.2
func (x *Shdb_Message_Options) GetPrintTemplates() map[string]string
func (*Shdb_Message_Options) GetType ¶ added in v1.0.2
func (x *Shdb_Message_Options) GetType() string
func (*Shdb_Message_Options) GetTypeKey ¶ added in v1.0.2
func (x *Shdb_Message_Options) GetTypeKey() []byte
func (*Shdb_Message_Options) ProtoMessage ¶ added in v1.0.2
func (*Shdb_Message_Options) ProtoMessage()
func (*Shdb_Message_Options) ProtoReflect ¶ added in v1.0.2
func (x *Shdb_Message_Options) ProtoReflect() protoreflect.Message
func (*Shdb_Message_Options) Reset ¶ added in v1.0.2
func (x *Shdb_Message_Options) Reset()
func (*Shdb_Message_Options) String ¶ added in v1.0.2
func (x *Shdb_Message_Options) String() string
type StreamRefReq ¶ added in v1.0.2
type StreamRefReq struct { TypeKey []byte `protobuf:"bytes,1,opt,name=type_key,json=typeKey,proto3" json:"type_key,omitempty"` // contains filtered or unexported fields }
func (*StreamRefReq) Descriptor
deprecated
added in
v1.0.2
func (*StreamRefReq) Descriptor() ([]byte, []int)
Deprecated: Use StreamRefReq.ProtoReflect.Descriptor instead.
func (*StreamRefReq) GetTypeKey ¶ added in v1.0.2
func (x *StreamRefReq) GetTypeKey() []byte
func (*StreamRefReq) ProtoMessage ¶ added in v1.0.2
func (*StreamRefReq) ProtoMessage()
func (*StreamRefReq) ProtoReflect ¶ added in v1.0.2
func (x *StreamRefReq) ProtoReflect() protoreflect.Message
func (*StreamRefReq) Reset ¶ added in v1.0.2
func (x *StreamRefReq) Reset()
func (*StreamRefReq) String ¶ added in v1.0.2
func (x *StreamRefReq) String() string
type TObject ¶
type TObject struct { Metadata *Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"` MyInt uint64 `protobuf:"varint,2,opt,name=my_int,json=myInt,proto3" json:"my_int,omitempty"` MyString string `protobuf:"bytes,3,opt,name=my_string,json=myString,proto3" json:"my_string,omitempty"` Timestamp *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=timestamp,proto3" json:"timestamp,omitempty"` Any *anypb.Any `protobuf:"bytes,5,opt,name=any,proto3" json:"any,omitempty"` // contains filtered or unexported fields }
func (*TObject) Descriptor
deprecated
func (*TObject) GetMetadata ¶
func (*TObject) GetMyString ¶ added in v1.0.2
func (*TObject) GetTimestamp ¶ added in v1.0.2
func (x *TObject) GetTimestamp() *timestamppb.Timestamp
func (*TObject) ProtoMessage ¶
func (*TObject) ProtoMessage()
func (*TObject) ProtoReflect ¶
func (x *TObject) ProtoReflect() protoreflect.Message
type TypeId ¶
type TypeId struct {
// contains filtered or unexported fields
}
TypeId is the key in the key-value database that is used to store IObjects. It has a memory layout like:
[b0 .. b3] TypeKey [b4 .. b20] Binary representation of an UUID
func MarshalTypeId ¶
MarshalTypeId creates a TypeId from a []byte slice
func MustParseTypeId ¶ added in v1.0.2
func ParseTypeId ¶ added in v1.0.2
func TypeIdFromString ¶
TypeIdFromString returns a TypeId from an URL-encoded string
func (*TypeId) SetUuidBytes ¶
SetUuidBytes sets the Id (as bytes) of a TypeId
type TypeKey ¶
type TypeKey = [4]byte
TypeKey is the four bytes that identifies the type of an object
type TypeRegistry ¶ added in v1.0.2
type TypeRegistry struct {
// contains filtered or unexported fields
}
func NewTypeRegistry ¶ added in v1.0.2
func NewTypeRegistry() *TypeRegistry
func (*TypeRegistry) AddFile ¶ added in v1.0.2
func (r *TypeRegistry) AddFile(fd protoreflect.FileDescriptor) error
func (*TypeRegistry) AddFileFromProtoFileDescriptor ¶ added in v1.0.2
func (r *TypeRegistry) AddFileFromProtoFileDescriptor(fd *descriptorpb.FileDescriptorProto) error
func (*TypeRegistry) CreateEmptyObject ¶ added in v1.0.2
func (r *TypeRegistry) CreateEmptyObject(tk TypeKey) (IObject, error)
func (*TypeRegistry) CreateObject ¶ added in v1.0.2
func (r *TypeRegistry) CreateObject(spec interface{}) (IObject, error)
func (*TypeRegistry) GetFileDescriptorSet ¶ added in v1.0.2
func (r *TypeRegistry) GetFileDescriptorSet() *descriptorpb.FileDescriptorSet
func (*TypeRegistry) GetMessageInfo ¶ added in v1.0.2
func (r *TypeRegistry) GetMessageInfo(tk TypeKey) (MessageInfo, error)
func (*TypeRegistry) GetTypeKeyFromToA ¶ added in v1.0.2
func (r *TypeRegistry) GetTypeKeyFromToA(toa string) (TypeKey, error)
func (*TypeRegistry) GetTypeNames ¶ added in v1.0.2
func (r *TypeRegistry) GetTypeNames() map[string][]string
func (*TypeRegistry) LoadSchema ¶ added in v1.0.2
func (r *TypeRegistry) LoadSchema() (err error)
func (*TypeRegistry) StoreSchema ¶ added in v1.0.2
func (r *TypeRegistry) StoreSchema() error
func (*TypeRegistry) Unmarshal ¶ added in v1.0.2
func (r *TypeRegistry) Unmarshal(key []byte, value []byte) (IObject, error)
func (*TypeRegistry) UseFileDescriptorSet ¶ added in v1.0.2
func (r *TypeRegistry) UseFileDescriptorSet(fds *descriptorpb.FileDescriptorSet) (err error)
type UnimplementedObjectServiceServer ¶ added in v1.0.2
type UnimplementedObjectServiceServer struct { }
UnimplementedObjectServiceServer must be embedded to have forward compatible implementations.
func (UnimplementedObjectServiceServer) GetSchema ¶ added in v1.0.2
func (UnimplementedObjectServiceServer) GetSchema(context.Context, *emptypb.Empty) (*descriptorpb.FileDescriptorSet, error)
func (UnimplementedObjectServiceServer) GetTypeNames ¶ added in v1.0.2
func (UnimplementedObjectServiceServer) GetTypeNames(context.Context, *emptypb.Empty) (*GetTypeNamesRsp, error)
func (UnimplementedObjectServiceServer) StreamRefs ¶ added in v1.0.2
func (UnimplementedObjectServiceServer) StreamRefs(*StreamRefReq, ObjectService_StreamRefsServer) error
type UnsafeObjectServiceServer ¶ added in v1.0.2
type UnsafeObjectServiceServer interface {
// contains filtered or unexported methods
}
UnsafeObjectServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to ObjectServiceServer will result in compilation errors.
type UpdateReq ¶ added in v1.0.2
type UpdateReq struct { Object *Object `protobuf:"bytes,1,opt,name=object,proto3" json:"object,omitempty"` // contains filtered or unexported fields }
func (*UpdateReq) Descriptor
deprecated
added in
v1.0.2
func (*UpdateReq) ProtoMessage ¶ added in v1.0.2
func (*UpdateReq) ProtoMessage()
func (*UpdateReq) ProtoReflect ¶ added in v1.0.2
func (x *UpdateReq) ProtoReflect() protoreflect.Message