kscdb

package module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2022 License: BSD-3-Clause Imports: 14 Imported by: 0

README

Golang AWS Keyspaces make KeyValue Database helper package

The kscdb golang package create connection to AWS Keyspaces and provides functions to use AWS Keyspaces as KeyValue database, create and manage IDs, use Named Queue and call remote functions defined in go plugins.

GoDoc Go Report Card

Run example

The keyvalue packages example connect to AWS Keyspaces, save KeyValue to Keyspaces and than read it. Than save another one KeyValue and read list of keys and list of values. To execute this example you need create kscdb keyspace in your AWS Keyspaces and get your AWS Keyspaces credentials in AWS Users Page.

The -username, -passwd and -host is requered parameters, or you can use environment variables instead:

KEYSPACES_USERNAME - keyspaces user name
KEYSPACES_PASSWD - keyspaces parrword
KEYSPACES_HOST - keyspaces host

Execute next command to run this example:

go run ./cmd/keyvalue

Licence

BSD

Documentation

Overview

kscdb package contains Golang functions to rasy use AWS Keyspaces as KeyValue Database. To use it create next keyspace in your AWS Keyspaces:

kscdb

Index

Constants

View Source
const Version = "0.0.3"

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyList

type KeyList struct {
	// contains filtered or unexported fields
}

KeyList is strings array of keys

func (*KeyList) Append

func (k *KeyList) Append(keys ...string)

Append one key or range of keys to KeyList keys slice

func (*KeyList) Keys

func (k *KeyList) Keys() []string

Keys return keys string slice

func (*KeyList) Len

func (k *KeyList) Len() int

Len return length of keys array

func (*KeyList) MarshalBinary

func (k *KeyList) MarshalBinary() (data []byte, err error)

MarshalBinary marshal Keylist (string slice) to byte slice with \0x00 separator

func (*KeyList) MarshalJSON

func (k *KeyList) MarshalJSON() (data []byte, err error)

MarshalJSON returns the JSON encoding

func (*KeyList) String

func (k *KeyList) String() string

String return keys in string divided by end of line

func (*KeyList) UnmarshalBinary

func (k *KeyList) UnmarshalBinary(data []byte) (err error)

UnmarshalBinary unmarshal byte slice with \0x00 separator to Keylist (string slice)

type Kscdb

type Kscdb struct {
	// contains filtered or unexported fields
}

Kscdb is kscdb packet receiver

func Connect

func Connect(username, passwd string, hosts ...string) (cdb *Kscdb, err error)

Connect to the cql cluster and return kscdb receiver

func (*Kscdb) Close

func (cdb *Kscdb) Close()

Cloase kscdb connection

func (*Kscdb) Delete

func (cdb *Kscdb) Delete(key string) (err error)

Delete record from database by key, returns

func (*Kscdb) DeleteID

func (cdb *Kscdb) DeleteID(key string) (err error)

DeleteID delete counter from database by key

func (*Kscdb) Func

func (cdb *Kscdb) Func(key string, value []byte) (data []byte, err error)

Func execute plugin function and return data

func (*Kscdb) Get

func (cdb *Kscdb) Get(key string) (data []byte, err error)

Get value by key, returns key value or empty data if key not found

func (*Kscdb) GetID

func (cdb *Kscdb) GetID(key string) (data []byte, err error)

GetID returns new diginal ID for key, ID just increments

func (*Kscdb) GetQueue

func (cdb *Kscdb) GetQueue(key string) (data []byte, err error)

GetQueue get first value from named queue by key (name of queue)

func (*Kscdb) List

func (cdb *Kscdb) List(key string) (keyList KeyList, err error)

List read and return array of all keys starts from selected key

func (*Kscdb) ListBody

func (cdb *Kscdb) ListBody(key string) (dataList [][]byte, err error)

ListBody read and return array of all keys data starts from selected key

func (*Kscdb) PluginFunc

func (tcdb *Kscdb) PluginFunc(fff string, value []byte) (data []byte, err error)

PluginFunc process plugin function: plugin_name.func(parameters ...string)

func (*Kscdb) Set

func (cdb *Kscdb) Set(key string, value []byte) (err error)

Set key value

func (*Kscdb) SetID

func (cdb *Kscdb) SetID(key string, value []byte) (err error)

SetID set keys next ID value

func (*Kscdb) SetQueue

func (cdb *Kscdb) SetQueue(key string, value []byte) (err error)

SetQueue add value to named queue by key (name of queue)

type Plugin

type Plugin struct {
	ID            uint32   // Packet id
	Name          string   // Plugin name
	Func          string   // Function name
	Params        []string // Function parameters
	RequestInJSON bool     // Request packet format
}

Plugin is plugins function and parameters used in requests and response teonet commands.

func (*Plugin) Empty

func (p *Plugin) Empty()

Empty clears KeyValue values to it default values.

func (Plugin) MarshalBinary

func (p Plugin) MarshalBinary() (data []byte, err error)

MarshalBinary encodes Plugin receiver data into binary buffer and returns it in byte slice.

func (*Plugin) UnmarshalBinary

func (p *Plugin) UnmarshalBinary(data []byte) (err error)

UnmarshalBinary decode binary buffer into Plugin receiver data.

Directories

Path Synopsis
cmd
keyvalue
The `keyvalue` packages example connect to AWS Keyspaces, save KeyValue to Keyspaces and than read it.
The `keyvalue` packages example connect to AWS Keyspaces, save KeyValue to Keyspaces and than read it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL