teocdb

package
v0.0.0-...-2e4d9bc Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2021 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package teocdb (teo-cdb) is the Teonet key-value database service package

Install this go package:

go get github.com/kirill-scherba/teonet-go/services/teocdb

Data base organisation

This service uses ScyllaDB. If you install this service manually you need install ScyllaDB. Run Scylla in Docker:

https://www.scylladb.com/download/open-source/#docker

You may check version of your existing running scylla docker container with command:

docker exec -it scylla scylla --version

Before you execute application which used this package you need install database schemas. Launch `cqlsh`:

docker exec -it scylla cqlsh

and execute next commands:

create keyspace teocdb with replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 };
create table teocdb.map(key text, data blob, PRIMARY KEY(key));
create table teocdb.ids(id_name text, next_id int, PRIMARY KEY(id_name));
create table teocdb.queue(key text, time timestamp, random UUID, lock text, data blob, PRIMARY KEY(key, time, random));

Index

Constants

This section is empty.

Variables

View Source
var HostsDefault = []string{
	"172.17.0.2", "172.17.0.3", "172.17.0.4",
	"172.18.0.2", "172.18.0.3", "172.18.0.4",
}

HostsDefault is default hosts IPs

View Source
var KeyspaceDefault = "teocdb"

KeyspaceDefault is default keyspace bane

Functions

This section is empty.

Types

type Process

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

Process receiver to process teocdb commands

func (*Process) CmdBinary

func (p *Process) CmdBinary(pac teoapi.Packet) (err error)

CmdBinary process CmdBinary command

func (*Process) CmdDelete

func (p *Process) CmdDelete(pac teoapi.Packet) (err error)

CmdDelete process CmdDelete command

func (*Process) CmdDeleteID

func (p *Process) CmdDeleteID(pac teoapi.Packet) (err error)

CmdDeleteID process CmdDeleteID command

func (*Process) CmdFunc

func (p *Process) CmdFunc(pac teoapi.Packet) (err error)

CmdFunc process CmdFunc command

func (*Process) CmdGet

func (p *Process) CmdGet(pac teoapi.Packet) (err error)

CmdGet process CmdGet command

func (*Process) CmdGetID

func (p *Process) CmdGetID(pac teoapi.Packet) (err error)

CmdGetID process CmdGetID command; next id number created for

func (*Process) CmdGetQueue

func (p *Process) CmdGetQueue(pac teoapi.Packet) (err error)

CmdGetQueue process CmdGetUeue command; get value from queue

func (*Process) CmdList

func (p *Process) CmdList(pac teoapi.Packet) (err error)

CmdList process CmdList command

func (*Process) CmdListBody

func (p *Process) CmdListBody(pac teoapi.Packet) (err error)

CmdListBody process CmdListBody command

func (*Process) CmdSet

func (p *Process) CmdSet(pac teoapi.Packet) (err error)

CmdSet process CmdSet command

func (*Process) CmdSetID

func (p *Process) CmdSetID(pac teoapi.Packet) (err error)

CmdSetID process CmdSetID command; next id number created for

func (*Process) CmdSetQueue

func (p *Process) CmdSetQueue(pac teoapi.Packet) (err error)

CmdSetQueue process CmdSetQueue command; set value to queue

type Teocdb

type Teocdb struct {
	*Process
	// contains filtered or unexported fields
}

Teocdb is teocdb packet receiver

func Connect

func Connect(con cdb.TeoConnector, keyAndHosts ...string) (tcdb *Teocdb, err error)

Connect to the cql cluster and return teocdb receiver

func (*Teocdb) Close

func (tcdb *Teocdb) Close()

Close teocdb connection

func (*Teocdb) Delete

func (tcdb *Teocdb) Delete(key string) (err error)

Delete record from database by key, returns

func (*Teocdb) DeleteID

func (tcdb *Teocdb) DeleteID(key string) (err error)

DeleteID delete counter from database by key

func (*Teocdb) Func

func (tcdb *Teocdb) Func(key string, value []byte) (data []byte, err error)

Func execute plugin function and return data

func (*Teocdb) Get

func (tcdb *Teocdb) Get(key string) (data []byte, err error)

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

func (*Teocdb) GetID

func (tcdb *Teocdb) GetID(key string) (data []byte, err error)

GetID returns new diginal ID for key, ID just increments

func (*Teocdb) GetQueue

func (tcdb *Teocdb) GetQueue(key string) (data []byte, err error)

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

func (*Teocdb) List

func (tcdb *Teocdb) List(key string) (keyList cdb.KeyList, err error)

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

func (*Teocdb) ListBody

func (tcdb *Teocdb) ListBody(key string) (dataList []string, err error)

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

func (*Teocdb) PluginFunc

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

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

func (*Teocdb) Set

func (tcdb *Teocdb) Set(key string, value []byte) (err error)

Set key value

func (*Teocdb) SetID

func (tcdb *Teocdb) SetID(key string, value []byte) (err error)

SetID set keys next ID value

func (*Teocdb) SetQueue

func (tcdb *Teocdb) SetQueue(key string, value []byte) (err error)

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

Jump to

Keyboard shortcuts

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