Documentation
¶
Overview ¶
Keyvalue: wasmcloud capability contract for key-value store
Index ¶
- func KeyValueContractId() string
- func KeyValueHandler(actor_ KeyValue) actor.Handler
- type GetResponse
- type IncrementRequest
- type KeyValue
- type KeyValueReceiver
- type KeyValueSender
- func (s *KeyValueSender) Contains(ctx *actor.Context, arg string) (bool, error)
- func (s *KeyValueSender) Del(ctx *actor.Context, arg string) (bool, error)
- func (s *KeyValueSender) Get(ctx *actor.Context, arg string) (*GetResponse, error)
- func (s *KeyValueSender) Increment(ctx *actor.Context, arg IncrementRequest) (int32, error)
- func (s *KeyValueSender) ListAdd(ctx *actor.Context, arg ListAddRequest) (uint32, error)
- func (s *KeyValueSender) ListClear(ctx *actor.Context, arg string) (bool, error)
- func (s *KeyValueSender) ListDel(ctx *actor.Context, arg ListDelRequest) (bool, error)
- func (s *KeyValueSender) ListRange(ctx *actor.Context, arg ListRangeRequest) (*StringList, error)
- func (s *KeyValueSender) Set(ctx *actor.Context, arg SetRequest) error
- func (s *KeyValueSender) SetAdd(ctx *actor.Context, arg SetAddRequest) (uint32, error)
- func (s *KeyValueSender) SetClear(ctx *actor.Context, arg string) (bool, error)
- func (s *KeyValueSender) SetDel(ctx *actor.Context, arg SetDelRequest) (uint32, error)
- func (s *KeyValueSender) SetIntersection(ctx *actor.Context, arg StringList) (*StringList, error)
- func (s *KeyValueSender) SetQuery(ctx *actor.Context, arg string) (*StringList, error)
- func (s *KeyValueSender) SetUnion(ctx *actor.Context, arg StringList) (*StringList, error)
- type ListAddRequest
- type ListDelRequest
- type ListRangeRequest
- type SetAddRequest
- type SetDelRequest
- type SetRequest
- type StringList
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func KeyValueContractId ¶
func KeyValueContractId() string
KeyValueContractId returns the capability contract id for this interface
func KeyValueHandler ¶
func KeyValueHandler(actor_ KeyValue) actor.Handler
KeyValueHandler is called by an actor during `main` to generate a dispatch handler The output of this call should be passed into `actor.RegisterHandlers`
Types ¶
type GetResponse ¶
type GetResponse struct { // the value, if it existed Value string // whether or not the value existed Exists bool }
Response to get request
func CDecodeGetResponse ¶
func CDecodeGetResponse(d *cbor.Decoder) (GetResponse, error)
CDecodeGetResponse deserializes a GetResponse using cbor
func MDecodeGetResponse ¶
func MDecodeGetResponse(d *msgpack.Decoder) (GetResponse, error)
MDecodeGetResponse deserializes a GetResponse using msgpack
type IncrementRequest ¶
type IncrementRequest struct { // name of value to increment Key string // amount to add to value Value int32 }
func CDecodeIncrementRequest ¶
func CDecodeIncrementRequest(d *cbor.Decoder) (IncrementRequest, error)
CDecodeIncrementRequest deserializes a IncrementRequest using cbor
func MDecodeIncrementRequest ¶
func MDecodeIncrementRequest(d *msgpack.Decoder) (IncrementRequest, error)
MDecodeIncrementRequest deserializes a IncrementRequest using msgpack
type KeyValue ¶
type KeyValue interface { // Increments a numeric value, returning the new value Increment(ctx *actor.Context, arg IncrementRequest) (int32, error) // returns whether the store contains the key Contains(ctx *actor.Context, arg string) (bool, error) // Deletes a key, returning true if the key was deleted Del(ctx *actor.Context, arg string) (bool, error) // Gets a value for a specified key. If the key exists, // the return structure contains exists: true and the value, // otherwise the return structure contains exists == false. Get(ctx *actor.Context, arg string) (*GetResponse, error) // Append a value onto the end of a list. Returns the new list size ListAdd(ctx *actor.Context, arg ListAddRequest) (uint32, error) // Deletes a list and its contents // input: list name // output: true if the list existed and was deleted ListClear(ctx *actor.Context, arg string) (bool, error) // Deletes a value from a list. Returns true if the item was removed. ListDel(ctx *actor.Context, arg ListDelRequest) (bool, error) // Retrieves a range of values from a list using 0-based indices. // Start and end values are inclusive, for example, (0,10) returns // 11 items if the list contains at least 11 items. If the stop value // is beyond the end of the list, it is treated as the end of the list. ListRange(ctx *actor.Context, arg ListRangeRequest) (*StringList, error) // Sets the value of a key. // expires is an optional number of seconds before the value should be automatically deleted, // or 0 for no expiration. Set(ctx *actor.Context, arg SetRequest) error // Add an item into a set. Returns number of items added (1 or 0) SetAdd(ctx *actor.Context, arg SetAddRequest) (uint32, error) // Deletes an item from the set. Returns number of items removed from the set (1 or 0) SetDel(ctx *actor.Context, arg SetDelRequest) (uint32, error) // perform intersection of sets and returns values from the intersection. // input: list of sets for performing intersection (at least two) // output: values SetIntersection(ctx *actor.Context, arg StringList) (*StringList, error) // Retrieves all items from a set // input: String // output: set members SetQuery(ctx *actor.Context, arg string) (*StringList, error) // perform union of sets and returns values from the union // input: list of sets for performing union (at least two) // output: union of values SetUnion(ctx *actor.Context, arg StringList) (*StringList, error) // clears all values from the set and removes it // input: set name // output: true if the set existed and was deleted SetClear(ctx *actor.Context, arg string) (bool, error) }
type KeyValueReceiver ¶
type KeyValueReceiver struct{}
KeyValueReceiver receives messages defined in the KeyValue service interface
func (*KeyValueReceiver) Dispatch ¶
func (r *KeyValueReceiver) Dispatch(ctx *actor.Context, svc interface{}, message *actor.Message) (*actor.Message, error)
type KeyValueSender ¶
type KeyValueSender struct {
// contains filtered or unexported fields
}
KeyValueSender sends messages to a KeyValue service
func NewProviderKeyValue ¶
func NewProviderKeyValue() *KeyValueSender
NewProvider constructs a client for sending to a KeyValue provider implementing the 'wasmcloud:keyvalue' capability contract, with the "default" link
func NewProviderKeyValueLink ¶
func NewProviderKeyValueLink(linkName string) *KeyValueSender
NewProviderKeyValueLink constructs a client for sending to a KeyValue provider implementing the 'wasmcloud:keyvalue' capability contract, with the specified link name
func (*KeyValueSender) Contains ¶
func (s *KeyValueSender) Contains(ctx *actor.Context, arg string) (bool, error)
returns whether the store contains the key
func (*KeyValueSender) Del ¶
func (s *KeyValueSender) Del(ctx *actor.Context, arg string) (bool, error)
Deletes a key, returning true if the key was deleted
func (*KeyValueSender) Get ¶
func (s *KeyValueSender) Get(ctx *actor.Context, arg string) (*GetResponse, error)
Gets a value for a specified key. If the key exists, the return structure contains exists: true and the value, otherwise the return structure contains exists == false.
func (*KeyValueSender) Increment ¶
func (s *KeyValueSender) Increment(ctx *actor.Context, arg IncrementRequest) (int32, error)
Increments a numeric value, returning the new value
func (*KeyValueSender) ListAdd ¶
func (s *KeyValueSender) ListAdd(ctx *actor.Context, arg ListAddRequest) (uint32, error)
Append a value onto the end of a list. Returns the new list size
func (*KeyValueSender) ListClear ¶
func (s *KeyValueSender) ListClear(ctx *actor.Context, arg string) (bool, error)
Deletes a list and its contents input: list name output: true if the list existed and was deleted
func (*KeyValueSender) ListDel ¶
func (s *KeyValueSender) ListDel(ctx *actor.Context, arg ListDelRequest) (bool, error)
Deletes a value from a list. Returns true if the item was removed.
func (*KeyValueSender) ListRange ¶
func (s *KeyValueSender) ListRange(ctx *actor.Context, arg ListRangeRequest) (*StringList, error)
Retrieves a range of values from a list using 0-based indices. Start and end values are inclusive, for example, (0,10) returns 11 items if the list contains at least 11 items. If the stop value is beyond the end of the list, it is treated as the end of the list.
func (*KeyValueSender) Set ¶
func (s *KeyValueSender) Set(ctx *actor.Context, arg SetRequest) error
Sets the value of a key. expires is an optional number of seconds before the value should be automatically deleted, or 0 for no expiration.
func (*KeyValueSender) SetAdd ¶
func (s *KeyValueSender) SetAdd(ctx *actor.Context, arg SetAddRequest) (uint32, error)
Add an item into a set. Returns number of items added (1 or 0)
func (*KeyValueSender) SetClear ¶
func (s *KeyValueSender) SetClear(ctx *actor.Context, arg string) (bool, error)
clears all values from the set and removes it input: set name output: true if the set existed and was deleted
func (*KeyValueSender) SetDel ¶
func (s *KeyValueSender) SetDel(ctx *actor.Context, arg SetDelRequest) (uint32, error)
Deletes an item from the set. Returns number of items removed from the set (1 or 0)
func (*KeyValueSender) SetIntersection ¶
func (s *KeyValueSender) SetIntersection(ctx *actor.Context, arg StringList) (*StringList, error)
perform intersection of sets and returns values from the intersection. input: list of sets for performing intersection (at least two) output: values
func (*KeyValueSender) SetQuery ¶
func (s *KeyValueSender) SetQuery(ctx *actor.Context, arg string) (*StringList, error)
Retrieves all items from a set input: String output: set members
func (*KeyValueSender) SetUnion ¶
func (s *KeyValueSender) SetUnion(ctx *actor.Context, arg StringList) (*StringList, error)
perform union of sets and returns values from the union input: list of sets for performing union (at least two) output: union of values
type ListAddRequest ¶
type ListAddRequest struct { // name of the list to modify ListName string // value to append to the list Value string }
Parameter to ListAdd operation
func CDecodeListAddRequest ¶
func CDecodeListAddRequest(d *cbor.Decoder) (ListAddRequest, error)
CDecodeListAddRequest deserializes a ListAddRequest using cbor
func MDecodeListAddRequest ¶
func MDecodeListAddRequest(d *msgpack.Decoder) (ListAddRequest, error)
MDecodeListAddRequest deserializes a ListAddRequest using msgpack
type ListDelRequest ¶
Removes an item from the list. If the item occurred more than once, removes only the first item. Returns true if the item was found.
func CDecodeListDelRequest ¶
func CDecodeListDelRequest(d *cbor.Decoder) (ListDelRequest, error)
CDecodeListDelRequest deserializes a ListDelRequest using cbor
func MDecodeListDelRequest ¶
func MDecodeListDelRequest(d *msgpack.Decoder) (ListDelRequest, error)
MDecodeListDelRequest deserializes a ListDelRequest using msgpack
type ListRangeRequest ¶
type ListRangeRequest struct { // name of list ListName string // start index of the range, 0-based, inclusive. Start int32 // end index of the range, 0-based, inclusive. Stop int32 }
func CDecodeListRangeRequest ¶
func CDecodeListRangeRequest(d *cbor.Decoder) (ListRangeRequest, error)
CDecodeListRangeRequest deserializes a ListRangeRequest using cbor
func MDecodeListRangeRequest ¶
func MDecodeListRangeRequest(d *msgpack.Decoder) (ListRangeRequest, error)
MDecodeListRangeRequest deserializes a ListRangeRequest using msgpack
type SetAddRequest ¶
type SetAddRequest struct { // name of the set SetName string // value to add to the set Value string }
func CDecodeSetAddRequest ¶
func CDecodeSetAddRequest(d *cbor.Decoder) (SetAddRequest, error)
CDecodeSetAddRequest deserializes a SetAddRequest using cbor
func MDecodeSetAddRequest ¶
func MDecodeSetAddRequest(d *msgpack.Decoder) (SetAddRequest, error)
MDecodeSetAddRequest deserializes a SetAddRequest using msgpack
type SetDelRequest ¶
func CDecodeSetDelRequest ¶
func CDecodeSetDelRequest(d *cbor.Decoder) (SetDelRequest, error)
CDecodeSetDelRequest deserializes a SetDelRequest using cbor
func MDecodeSetDelRequest ¶
func MDecodeSetDelRequest(d *msgpack.Decoder) (SetDelRequest, error)
MDecodeSetDelRequest deserializes a SetDelRequest using msgpack
type SetRequest ¶
type SetRequest struct { // the key name to change (or create) Key string // the new value Value string // expiration time in seconds 0 for no expiration Expires uint32 }
func CDecodeSetRequest ¶
func CDecodeSetRequest(d *cbor.Decoder) (SetRequest, error)
CDecodeSetRequest deserializes a SetRequest using cbor
func MDecodeSetRequest ¶
func MDecodeSetRequest(d *msgpack.Decoder) (SetRequest, error)
MDecodeSetRequest deserializes a SetRequest using msgpack
type StringList ¶
type StringList []string
list of strings
func CDecodeStringList ¶
func CDecodeStringList(d *cbor.Decoder) (StringList, error)
CDecodeStringList deserializes a StringList using cbor
func MDecodeStringList ¶
func MDecodeStringList(d *msgpack.Decoder) (StringList, error)
MDecodeStringList deserializes a StringList using msgpack