teoregistry

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: 6 Imported by: 0

Documentation

Overview

Package teoregistry (teo-registry) is the Teonet registry service package

Teoregistry store teonet applications(services) and its commands api description in teonet database. This package contain teonet registry database schemas, services and clients functions.

Install this go package:

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

Data base organisation

To store database we use ScyllaDB. Run Scylla in Docker:

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

Install database schemas. Before you execute application which used this service, launch `cqlsh`:

docker exec -it scylla cqlsh

and execute next commands:

// Keyspace 'teoregistry'
CREATE KEYSPACE teoregistry WITH replication = { 'class': 'SimpleStrategy', 'replication_factor' : 3 };
USE teoregistry;

// Table 'applications': Teonet applications (services) description
CREATE TABLE IF NOT EXISTS applications(
uuid        TIMEUUID,
name        TEXT,
version     TEXT,
descr       TEXT,
author      TEXT,
license     TEXT,
goget       TEXT,
git         TEXT,
PRIMARY KEY(uuid)
);
CREATE INDEX IF NOT EXISTS ON applications (name);

// Table 'commands': Teonet applications commands description
// - cmdType values:  0 - input; 1 - input/output (same parameters); 2 - output
CREATE TABLE IF NOT EXISTS commands(
app_id       TIMEUUID,
cmd          INT,
type         TINYINT,
descr        TEXT,
txt_f        BOOLEAN,
txt_num      TINYINT,
txt_descr    TEXT,
jsonf        BOOLEAN,
json         TEXT,
binary_f     BOOLEAN,
binary_descr TEXT,
PRIMARY KEY(app_id, cmd, type)
);

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

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

App is application functions receiver

func (*App) Get

func (app *App) Get(uuid gocql.UUID) (a *teoapi.Application, err error)

Get gets application info

func (*App) List

func (app *App) List() (listApp []Applist, err error)

List gets list of applications. Returns list of applications which contain apllication uuid and name

func (*App) Num

func (app *App) Num() (numApp int, err error)

Num gets number of applications

func (*App) Remove

func (app *App) Remove(uuid gocql.UUID) (err error)

Remove removes application info and all its commands

func (*App) Set

func (app *App) Set(a *teoapi.Application) (uuid gocql.UUID, err error)

Set inserts or updates application info

type Applist

type Applist struct {
	UUID gocql.UUID
	Name string
}

Applist is short application representation used in list function and commands

type Com

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

Com is command functions receiver

func (*Com) List

func (com *Com) List(appid gocql.UUID) (listCom []teoapi.Command, err error)

List gets list of commands

func (*Com) Remove

func (com *Com) Remove(appid gocql.UUID, cmd int, cmdtype int) (err error)

Remove removes command

func (*Com) RemoveAll

func (com *Com) RemoveAll(appid gocql.UUID) (err error)

RemoveAll removes all application commands

func (*Com) Set

func (com *Com) Set(c *teoapi.Command) (err error)

Set inserts or updates command info

type Teoregistry

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

Teoregistry is the teoregistry packet receiver

func Connect

func Connect(hosts ...string) (tre *Teoregistry, err error)

Connect to the cql cluster and create teoregistry receiver. First parameter is keyspace, next parameters is hosts name (usualy it should be 3 hosts - 3 ScyllaDB nodes)

func (*Teoregistry) Close

func (tre *Teoregistry) Close()

Close closes cql connection and destroy teoregistry receiver

Jump to

Keyboard shortcuts

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