skytable

package module
v0.0.0-...-9395666 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

README

skytable-go

Skytable client driver for Go (WIP)

Introduction

This library is a client for the free and open-source NoSQL database Skytable. First, go ahead and install Skytable by following the instructions here. This version of the library was tested with the latest Skytable release (release 0.7.5).

Installation

go get github.com/satvik007/skytable-go

Features

  • (Will) support skytable 0.7.5 and above
  • Connection pooling
  • Automatic reconnection
  • Automatic retry on error, timeout, and connection loss

Contributing

Open-source, and contributions are always welcome! For ideas and suggestions, create an issue on GitHub and for patches, fork and open those pull requests here!

License

This client library is distributed under the permissive Apache-2.0 License.

Copyrights

Many parts of this codebase comes from the go-redis client. Originally licensed under the BSD-2-Clause license. Copyrights belong to their respective authors.

Documentation

Overview

Package skytable_go implements a client for Skytable.

The client is licensed under the permissive Apache 2 license. You can obtain a copy of the license at http://www.apache.org/licenses/LICENSE-2.0.

This client is a derivative of the go-redis client. See the go-redis license below for more details.

Copyright (c) 2013 The github.com/go-redis/redis Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Index

Constants

View Source
const ActionError = proto.ActionError
View Source
const AuthnRealmError = proto.AuthnRealmError
View Source
const BadCredentials = proto.BadCredentials
View Source
const EncodingError = proto.EncodingError
View Source
const Nil = proto.Nil

Nil reply returned by Skytable when key does not exist.

View Source
const OtherError = proto.OtherError
View Source
const OverwriteError = proto.OverwriteError
View Source
const PacketError = proto.PacketError
View Source
const ServerError = proto.ServerError
View Source
const UnknownDataTypeError = proto.UnknownDataTypeError
View Source
const WrongTypeError = proto.WrongTypeError

Variables

View Source
var ErrClosed = pool.ErrClosed

ErrClosed performs any operation on the closed client will return this error.

Functions

func SetLogger

func SetLogger(logger internal.Logging)

SetLogger set custom log

func Version

func Version() string

Version is the current release version. versions of the client will be released in sync with the version of the db server.

Types

type Client

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

Client is a Skytable client representing a pool of zero or more underlying connections. It's safe for concurrent use by multiple goroutines.

Client creates and frees connections automatically; it also maintains a free pool of idle connections. You can control the pool size with Config.PoolSize option.

func NewClient

func NewClient(opt *Options) *Client

NewClient returns a client to the Skytable Server specified by Options.

func (*Client) AddHook

func (hs *Client) AddHook(hook Hook)

func (Client) AddUser

func (c Client) AddUser(ctx context.Context, username string) *StringCmd

AddUser Attempts to create a new user with the provided username, returning the token.

Time complexity: O(1)

Operation can throw error.

  • 11 Authn realm error The current user is not allowed to perform the action

func (Client) Claim

func (c Client) Claim(ctx context.Context, originKey string) *StringCmd

Claim Attempts to claim the root account using the origin key.

Time complexity: O(1)

Operation can throw error.

  • 10 Bad credentials The authn credentials are invalid

func (Client) Close

func (c Client) Close() error

Close closes the client, releasing any open resources.

It is rare to Close a Client, as the Client is meant to be long-lived and shared between many goroutines.

func (*Client) Conn

func (c *Client) Conn() *Conn

func (Client) CreateKeyspace

func (c Client) CreateKeyspace(ctx context.Context, entity string) *StatusCmd

CreateKeyspace creates a new keyspace.

Transactional: Not yet Time complexity: O(1)

Operation can throw error.

  • string "err-already-exists" if it already existed
  • 5 Server Error An error occurred on the server side

func (Client) CreateTable

func (c Client) CreateTable(ctx context.Context, table, model string, modelArgs []string, properties ...string) *StatusCmd

CreateTable creates a new table.

Transactional: Not yet

Time complexity: O(1)

Currently only keymap model is supported in skytable.

The keymap model A keymap is like an associated array: it maps a key to a value. More importantly, it maps a specific key type to a specific value type.

Warning: Everything after CREATE TABLE is case sensitive!

This is how you create keymap tables:

CREATE TABLE <entity> keymap(<type>,<type>) <properties>

Operation can throw error.

  • string "err-already-exists" if it already existed
  • string "default-container-unset" if the connection level default keyspace has not been set
  • 5 Server error An error occurred on the server side

func (Client) DbSize

func (c Client) DbSize(ctx context.Context, entity string) *IntCmd

DbSize Check the number of entries stored in the current table or in the provided entity.

Time complexity: O(1)

func (Client) Del

func (c Client) Del(ctx context.Context, keys ...string) *IntCmd

Del Delete 'n' keys from the current table. DEL <key1> <key2> ... <keyN> This will return the number of keys that were deleted as an unsigned integer

Time complexity: O(n)

Operation can throw error.

  • 5 Server error An error occurred on the server side

func (Client) DelUser

func (c Client) DelUser(ctx context.Context, username string) *StatusCmd

DelUser Attempts to delete the user with the provided username.

Time complexity: O(1)

Operation can throw error.

  • 10 Bad credentials The authn credentials are invalid
  • 11 Authn realm error The current user is not allowed to perform the action

func (*Client) Do

func (c *Client) Do(ctx context.Context, args ...interface{}) *Cmd

Do creates a Cmd from the args and processes the cmd.

func (Client) DropKeyspace

func (c Client) DropKeyspace(ctx context.Context, keyspace string) *StatusCmd

DropKeyspace removes the specified keyspace from the server.

Operation can throw error.

  • string "container-not-found "if the keyspace wasn't found
  • string "still-in-use" if clients are still connected to the keyspace or the keyspace is not empty
  • 5 Server error An error occurred on the server side

func (Client) DropTable

func (c Client) DropTable(ctx context.Context, table string) *StatusCmd

DropTable removes the specified table from the keyspace.

Operation can throw error.

  • string "container-not-found" if the keyspace wasn't found
  • string "still-in-use" if clients are still connected to the table
  • string "default-container-unset" if the connection level default keyspace has not been set
  • 5 Server error An error occurred on the server side

func (Client) Exists

func (c Client) Exists(ctx context.Context, keys ...string) *IntCmd

Exists Check if 'n' keys exist in the current table. EXISTS <key1> <key2> ... <keyN> This will return the number of keys that exist as an unsigned integer.

Time complexity: O(n)

func (Client) FlushDB

func (c Client) FlushDB(ctx context.Context, entity string) *StatusCmd

FlushDB Removes all entries stored in the current table or in the provided entity. Pass the entity name in FQE i.e.

<keyspace>:<table>

or leave empty to flush the current table. Only passing the table name will flush the table in current active keyspace.

Time complexity: O(n)

Operation can throw error.

  • 5 Server error - An error occurred on the server side

Example:

ctx := context.Background()

sdb := skytable.NewClient(&skytable.Options{
  Addr: "localhost:2003",
})

if err := sdb.FlushDB(ctx, "").Err(); err != nil {
  panic(err)
}

func (Client) Get

func (c Client) Get(ctx context.Context, key string) *StringCmd

Get the value of a key from the current table, if it exists It returns skytable.Nil error when key does not exist.

Time complexity: O(1)

@return the requested value

Operation can throw error.

  • 1 Nil The client asked for a non-existent object

Example:

ctx := context.Background()

sdb := skytable.NewClient(&skytable.Options{
  Addr: "localhost:2003",
})

// setting key: value
if err := sdb.Set(ctx, "key", "value").Err(); err != nil {
  panic(err)
}

// getting key: value
val, err := sdb.Get(ctx, "key").Result()
if err != nil {
  panic(err)
}
fmt.Println("key:", val)

func (Client) Heya

func (c Client) Heya(ctx context.Context, message string) *StringCmd

Heya Either returns a "HEY!" or returns the provided argument as a str

Time complexity: O(1)

Example:

		ctx := context.Background()

   sdb := skytable.NewClient(&skytable.Options{
			Addr: "localhost:2003",
		})

		reply := sdb.Heya(ctx, "").Result()
		fmt.Println(reply)

func (Client) InspectKeyspace

func (c Client) InspectKeyspace(ctx context.Context, keyspace string) *StringSliceCmd

InspectKeyspace This will return a flat array with all the table names passing keyspace as empty string "" will return all the table names in current keyspace

func (Client) InspectKeyspaces

func (c Client) InspectKeyspaces(ctx context.Context) *StringSliceCmd

InspectKeyspaces This will return a flat array with all the keyspace names

func (Client) InspectTable

func (c Client) InspectTable(ctx context.Context, table string) *StringSliceCmd

InspectTable This will return a string with the table's syntactical description. For example, the keymap model can return: Keymap { data: (binstr,binstr), volatile: true }

func (Client) KeyLen

func (c Client) KeyLen(ctx context.Context, key string) *IntCmd

KeyLen Returns the length of the UTF-8 string, if it exists in the current table.

Time complexity: O(1)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object

func (Client) LGet

func (c Client) LGet(ctx context.Context, key string) *StringSliceCmd

LGet Returns all the values contained in the provided list, if it exists in the current table.

Time complexity: O(n)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object

func (Client) LGetFirst

func (c Client) LGetFirst(ctx context.Context, key string) *StringCmd

LGetFirst Returns the first element present in the list, if it exists.

Time complexity: O(1)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object
  • string "list-is-empty"

func (Client) LGetLast

func (c Client) LGetLast(ctx context.Context, key string) *StringCmd

LGetLast Returns the last element present in the list, if it exists.

Time complexity: O(1)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object
  • string "list-is-empty"

func (Client) LGetLen

func (c Client) LGetLen(ctx context.Context, key string) *IntCmd

LGetLen Returns the length of the list

Time complexity: O(1)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object

func (Client) LGetLimit

func (c Client) LGetLimit(ctx context.Context, key string, limit int) *StringSliceCmd

LGetLimit Returns a maximum of limit values from the provided list, if it exists in the current table

Time complexity: O(n)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object

func (Client) LGetRange

func (c Client) LGetRange(ctx context.Context, key string, start int, stop int) *StringSliceCmd

LGetRange Returns items in the given range. If stop is provided as -1, all the elements from that index are returned. If a value for stop is provided, then a subarray is returned array[start:stop] -> [start, stop)

Time complexity: O(n)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object
  • string "bad-list-index" The index is out of range

func (Client) LGetValueAt

func (c Client) LGetValueAt(ctx context.Context, key string, index int) *StringCmd

LGetValueAt Returns the element present at the provided index, if it exists in the given list.

Time complexity: O(1)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object
  • string "bad-list-index" The index is out of range

func (Client) LModClear

func (c Client) LModClear(ctx context.Context, key string) *StatusCmd

LModClear Removes all the elements present in the list.

Time complexity: O(n)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object
  • 5 Server error An error occurred on the server side

func (Client) LModInsert

func (c Client) LModInsert(ctx context.Context, key string, index int, value interface{}) *StatusCmd

LModInsert Inserts the element to the provided index, if it is valid while shifting elements to the right if required.

Time complexity: O(1)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object
  • 5 Server error An error occurred on the server side
  • string "bad-list-index" The index is out of range

func (Client) LModPop

func (c Client) LModPop(ctx context.Context, key string, index int) *StringCmd

LModPop Removes the element from the end of the list if index<0 or from the provided index while shifting elements to the right if required.

Time complexity: O(1)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object
  • 5 Server error An error occurred on the server side
  • string "bad-list-index" The index is out of range

func (Client) LModPush

func (c Client) LModPush(ctx context.Context, key string, elements ...interface{}) *StatusCmd

LModPush Appends the elements to the end of the provided list, if it exists.

Time complexity: O(1)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object
  • 5 Server error An error occurred on the server side

func (Client) LModRemove

func (c Client) LModRemove(ctx context.Context, key string, index int) *StatusCmd

LModRemove Removes the element at the provided index from the list, shifting elements to the right if required.

Time complexity: O(1)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object
  • 5 Server error An error occurred on the server side
  • string "bad-list-index" The index is out of range

func (Client) LSKeys

func (c Client) LSKeys(ctx context.Context, entity string, limit int) *StringSliceCmd

LSKeys Returns a flat string array of keys present in the current table or in the provided entity. If no <limit> is given, then a maximum of 10 keys are returned. If a limit is specified, then a maximum of <limit> keys are returned. The order of keys is meaningless. For current table pass entity as "" For default limit 10, you can pass limit as "0"

Time complexity: O(n)

func (Client) LSet

func (c Client) LSet(ctx context.Context, key string, values ...interface{}) *StatusCmd

LSet Creates a list with the provided values, or simply creates an empty list if it doesn't already exist in the table.

Time complexity: O(n)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object
  • 5 Server error An error occurred on the server side

func (Client) ListUser

func (c Client) ListUser(ctx context.Context) *StringSliceCmd

ListUser Attempts to return a list of users for the current database instance

Time complexity: O(1)

func (Client) MGet

func (c Client) MGet(ctx context.Context, keys ...interface{}) *SliceCmd

MGet Get the value of 'n' keys from the current table, if they exist.

Time complexity: O(n)

func (Client) MKSnap

func (c Client) MKSnap(ctx context.Context, snapName string) *StatusCmd

MKSnap This action can be used to create a snapshot. Do note that this action requires snapshotting to be enabled on the server side, before it can create snapshots. If you want to create snapshots without snapshots being enabled on the server-side, pass a second argument <SNAPNAME> to specify a snapshot name and a snapshot will be created in a folder called rsnap under your data directory. For more information on snapshots, read this document https://docs.skytable.io/snapshots

Time complexity: O(n)

Operation can throw error.

  • string "err-snapshot-disabled" Snapshots have been disabled on the server-side
  • string "err-snapshot-busy" A snapshot operation is already in progress

func (Client) MPop

func (c Client) MPop(ctx context.Context, keys ...interface{}) *StringSliceCmd

MPop Deletes and returns the values of the provided 'n' keys from the current table. If the database is poisoned, this will return a server error

Time complexity: O(n)

Operation can throw error.

  • 5 Server error An error occurred on the server side

func (Client) MSet

func (c Client) MSet(ctx context.Context, keyValuePairs ...interface{}) *IntCmd

MSet Set the value of 'n' keys in the current table, if they don't already exist. This will return the number of keys that were set as an unsigned integer.

Time complexity: O(n)

Operation can throw error.

  • 5 Server error An error occurred on the server side

func (Client) MUpdate

func (c Client) MUpdate(ctx context.Context, keyValuePairs ...interface{}) *IntCmd

MUpdate Update the value of 'n' keys in the current table, if they already exist. This will return the number of keys that were updated as an unsigned integer.

Time complexity: O(n)

Operation can throw error.

  • 5 Server error An error occurred on the server side

func (*Client) Options

func (c *Client) Options() *Options

Options returns read-only Options that were used to create the client.

func (*Client) Pipeline

func (c *Client) Pipeline() Pipeliner

func (*Client) Pipelined

func (c *Client) Pipelined(ctx context.Context, fn func(Pipeliner) error) ([]Cmder, error)

func (*Client) PoolStats

func (c *Client) PoolStats() *PoolStats

PoolStats returns connection pool stats.

func (Client) Pop

func (c Client) Pop(ctx context.Context, key string) *StringCmd

Pop Deletes and return the value of the provided key from the current table. If the database is poisoned, this will return a server error.

Time complexity: O(1)

Operation can throw error.

  • 5 Server error An error occurred on the server side

func (*Client) Process

func (c *Client) Process(ctx context.Context, cmd Cmder) error

func (Client) Restore

func (c Client) Restore(ctx context.Context, originKey, username string) *StringCmd

Restore Attempts to restore the password for the provided user. This will regenerate the token and return the newly issued token. However, if you aren't a root account, that is, you lost your root password, then you'll need to run with username as "root".

Time complexity: O(1)

Operation can throw error.

  • 10 Bad credentials The authn credentials are invalid
  • 11 Authn realm error The current user is not allowed to perform the action

func (Client) SDel

func (c Client) SDel(ctx context.Context, keys ...interface{}) *StatusCmd

SDel Delete all keys if all of the keys exist in the current table. Do note that if a single key doesn't exist, then a Nil code is returned.

Time complexity: O(n)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object
  • 5 Server error An error occurred on the server side

func (Client) SSet

func (c Client) SSet(ctx context.Context, keyValuePairs ...interface{}) *StatusCmd

SSet Set all keys to the given values only if all of them don't exist in the current table

Time complexity: O(n)

Operation can throw error. - 2 Overwrite error The client tried to overwrite data - 5 Server error An error occurred on the server side

func (Client) SUpdate

func (c Client) SUpdate(ctx context.Context, keyValuePairs ...interface{}) *StatusCmd

SUpdate Update all keys if all of the keys exist in the current table. Do note that if a single key doesn't exist, then a Nil code is returned.

Time complexity: O(n)

Operation can throw error. - 1 Nil The client asked for a non-existent object - 5 Server error An error occurred on the server side

func (Client) Set

func (c Client) Set(ctx context.Context, key interface{}, value interface{}) *StatusCmd

Set the value of a key in the current table, if it doesn't already exist Throws overwriting error if the key already exists.

Time complexity: O(1)

Operation can throw error.

  • 2 Overwrite error The client tried to overwrite data
  • 5 Server error An error occurred on the server side

Example:

ctx := context.Background()

sdb := skytable.NewClient(&skytable.Options{
  Addr: "localhost:2003",
})

// setting key: value
if err := sdb.Set(ctx, "key", "value").Err(); err != nil {
  panic(err)
}

func (Client) String

func (c Client) String() string

func (Client) SysInfo

func (c Client) SysInfo(ctx context.Context, property string) *StringCmd

SysInfo Returns static properties of the system, i.e properties that do not change during runtime.

The following properties are available:

  • version: Returns the server version (String)
  • protocol: Returns the protocol version string (String)
  • protover: Returns the protocol version (float)

Time complexity: O(1)

func (Client) SysMetric

func (c Client) SysMetric(ctx context.Context, metric string) *StringCmd

SysMetric Returns dynamic properties of the system, i.e metrics are properties that can change during runtime.

The following metrics are available:

  • health: Returns "good" or "critical" depending on the system state (String)
  • storage: Returns bytes used for on-disk storage (uint64)

func (Client) USet

func (c Client) USet(ctx context.Context, keyValuePairs ...interface{}) *IntCmd

USet SET all keys if they don't exist, or UPDATE them if they do exist. This operation performs USETs in the current table

Time complexity: O(n)

Operation can throw error. - 5 Server error An error occurred on the server side

func (Client) Update

func (c Client) Update(ctx context.Context, key interface{}, value interface{}) *StatusCmd

Update the value of an existing key in the current table

Time complexity: O(1)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object
  • 5 Server error An error occurred on the server side

Example:

ctx := context.Background()

sdb := skytable.NewClient(&skytable.Options{
  Addr: "localhost:2003",
})

// setting key: value
if err := sdb.Set(ctx, "key", "value").Err(); err != nil {
  panic(err)
}

// updating key: value
if err := sdb.Update(ctx, "key", "value2").Err(); err != nil {
  panic(err)
}

func (Client) Use

func (c Client) Use(ctx context.Context, entity string) *StatusCmd

Use the specified entity - table or keyspace Entity is simply a string in FQE i.e. <keyspace>:<table> for a table or <keyspace> for a keyspace. See https://docs.skytable.io/containers for more.

Time complexity: O(1)

The operation can throw error.

  • string "container-not-found" if the keyspace wasn't found
  • string "default-container-unset" if the connection level default keyspace has not been set

Example:

   ctx := context.Background()

   sdb := skytable.NewClient(&skytable.Options{
     Addr: "localhost:2003",
   })

   // creating new keyspace with the name "keyspace"
   if err := sdb.CreateKeyspace(ctx, "keyspace"); err != nil {
			panic(err)
		}

		// creating new table under the keyspace "keyspace" with the name "table"
   if err := sdb.CreateTable(ctx, "keyspace:table", "keymap", []string{"str", "binstr"}).Err(); err != nil {
			panic(err)
		}

		// using the entity "keyspace:table"
  	if err := sdb.Use(ctx, "keyspace:table"); err != nil {
			panic(err)
		}

func (Client) WhereAmI

func (c Client) WhereAmI(ctx context.Context) *StringSliceCmd

WhereAmI Returns an array with either the name of the current keyspace as the first element or if a default table is set, then it returns the keyspace name as the first element and the table name as the second element

func (Client) WhoAmI

func (c Client) WhoAmI(ctx context.Context) *StringCmd

WhoAmI Returns a string with the AuthID of the currently logged-in user or errors if the user is not logged in

Time complexity: O(1)

func (*Client) WithTimeout

func (c *Client) WithTimeout(timeout time.Duration) *Client

type Cmd

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

func NewCmd

func NewCmd(ctx context.Context, args ...interface{}) *Cmd

func (*Cmd) Args

func (cmd *Cmd) Args() []interface{}

func (*Cmd) Bool

func (cmd *Cmd) Bool() (bool, error)

func (*Cmd) BoolSlice

func (cmd *Cmd) BoolSlice() ([]bool, error)

func (*Cmd) Err

func (cmd *Cmd) Err() error

func (*Cmd) Float32

func (cmd *Cmd) Float32() (float32, error)

func (*Cmd) Float32Slice

func (cmd *Cmd) Float32Slice() ([]float32, error)

func (*Cmd) Float64

func (cmd *Cmd) Float64() (float64, error)

func (*Cmd) Float64Slice

func (cmd *Cmd) Float64Slice() ([]float64, error)

func (*Cmd) FullName

func (cmd *Cmd) FullName() string

func (*Cmd) Int

func (cmd *Cmd) Int() (int, error)

func (*Cmd) Int64

func (cmd *Cmd) Int64() (int64, error)

func (*Cmd) Int64Slice

func (cmd *Cmd) Int64Slice() ([]int64, error)

func (*Cmd) Name

func (cmd *Cmd) Name() string

func (*Cmd) Result

func (cmd *Cmd) Result() (interface{}, error)

func (*Cmd) SetErr

func (cmd *Cmd) SetErr(e error)

func (*Cmd) SetFirstKeyPos

func (cmd *Cmd) SetFirstKeyPos(keyPos int8)

func (*Cmd) SetVal

func (cmd *Cmd) SetVal(val interface{})

func (*Cmd) Slice

func (cmd *Cmd) Slice() ([]interface{}, error)

func (*Cmd) String

func (cmd *Cmd) String() string

func (*Cmd) StringSlice

func (cmd *Cmd) StringSlice() ([]string, error)

func (*Cmd) Text

func (cmd *Cmd) Text() (string, error)

func (*Cmd) Uint64

func (cmd *Cmd) Uint64() (uint64, error)

func (*Cmd) Uint64Slice

func (cmd *Cmd) Uint64Slice() ([]uint64, error)

func (*Cmd) Val

func (cmd *Cmd) Val() interface{}

type Cmdable

type Cmdable interface {
	Pipeline() Pipeliner
	Pipelined(ctx context.Context, fn func(Pipeliner) error) ([]Cmder, error)

	AddUser(ctx context.Context, username string) *StringCmd
	Claim(ctx context.Context, originKey string) *StringCmd
	CreateKeyspace(ctx context.Context, entity string) *StatusCmd
	CreateTable(ctx context.Context, table, model string, modelArgs []string, properties ...string) *StatusCmd
	DbSize(ctx context.Context, entity string) *IntCmd
	Del(ctx context.Context, keys ...string) *IntCmd
	DelUser(ctx context.Context, username string) *StatusCmd
	DropKeyspace(ctx context.Context, keyspace string) *StatusCmd
	DropTable(ctx context.Context, table string) *StatusCmd
	Exists(ctx context.Context, keys ...string) *IntCmd
	FlushDB(ctx context.Context, entity string) *StatusCmd
	Get(ctx context.Context, key string) *StringCmd
	Heya(ctx context.Context, message string) *StringCmd
	InspectKeyspace(ctx context.Context, keyspace string) *StringSliceCmd
	InspectKeyspaces(ctx context.Context) *StringSliceCmd
	InspectTable(ctx context.Context, table string) *StringSliceCmd
	KeyLen(ctx context.Context, key string) *IntCmd
	LGet(ctx context.Context, key string) *StringSliceCmd
	LGetLimit(ctx context.Context, key string, limit int) *StringSliceCmd
	LGetLen(ctx context.Context, key string) *IntCmd
	LGetValueAt(ctx context.Context, key string, index int) *StringCmd
	LGetFirst(ctx context.Context, key string) *StringCmd
	LGetLast(ctx context.Context, key string) *StringCmd
	LGetRange(ctx context.Context, key string, start, stop int) *StringSliceCmd
	ListUser(ctx context.Context) *StringSliceCmd
	LModPush(ctx context.Context, key string, elements ...interface{}) *StatusCmd
	LModInsert(ctx context.Context, key string, index int, value interface{}) *StatusCmd
	LModPop(ctx context.Context, key string, index int) *StringCmd
	LModRemove(ctx context.Context, key string, index int) *StatusCmd
	LModClear(ctx context.Context, key string) *StatusCmd
	LSet(ctx context.Context, key string, values ...interface{}) *StatusCmd
	LSKeys(ctx context.Context, entity string, limit int) *StringSliceCmd
	MGet(ctx context.Context, keys ...interface{}) *SliceCmd
	MKSnap(ctx context.Context, snapName string) *StatusCmd
	MPop(ctx context.Context, keys ...interface{}) *StringSliceCmd
	MSet(ctx context.Context, keyValuePairs ...interface{}) *IntCmd
	MUpdate(ctx context.Context, keyValuePairs ...interface{}) *IntCmd
	Pop(ctx context.Context, key string) *StringCmd
	Restore(ctx context.Context, originKey string, username string) *StringCmd
	SDel(ctx context.Context, keys ...interface{}) *StatusCmd
	Set(ctx context.Context, key interface{}, value interface{}) *StatusCmd
	SSet(ctx context.Context, keyValuePairs ...interface{}) *StatusCmd
	SUpdate(ctx context.Context, keyValuePairs ...interface{}) *StatusCmd
	SysInfo(ctx context.Context, property string) *StringCmd
	SysMetric(ctx context.Context, metric string) *StringCmd
	Update(ctx context.Context, key interface{}, value interface{}) *StatusCmd
	Use(ctx context.Context, entity string) *StatusCmd
	USet(ctx context.Context, keyValuePairs ...interface{}) *IntCmd
	WhereAmI(ctx context.Context) *StringSliceCmd
	WhoAmI(ctx context.Context) *StringCmd
}

type Cmder

type Cmder interface {
	Name() string
	FullName() string
	Args() []interface{}
	String() string

	SetFirstKeyPos(int8)

	SetErr(error)
	Err() error
	// contains filtered or unexported methods
}

type Conn

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

Conn represents a single Skytable connection rather than a pool of connections. Prefer running commands from Client unless there is a specific need for a continuous single Skytable connection.

func (*Conn) Pipeline

func (c *Conn) Pipeline() Pipeliner

func (*Conn) Pipelined

func (c *Conn) Pipelined(ctx context.Context, fn func(Pipeliner) error) ([]Cmder, error)

func (*Conn) Process

func (c *Conn) Process(ctx context.Context, cmd Cmder) error

type Error

type Error interface {
	error

	// skytableError is a no-op function but
	// serves to distinguish types that are Skytable
	// errors from ordinary errors: a type is a
	// Skytable error if it has a SkytableError method.
	SkytableError()
}

type Hook

type Hook interface {
	BeforeProcess(ctx context.Context, cmd Cmder) (context.Context, error)
	AfterProcess(ctx context.Context, cmd Cmder) error

	BeforeProcessPipeline(ctx context.Context, cmds []Cmder) (context.Context, error)
	AfterProcessPipeline(ctx context.Context, cmds []Cmder) error
}

type IntCmd

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

func NewIntCmd

func NewIntCmd(ctx context.Context, args ...interface{}) *IntCmd

func (*IntCmd) Args

func (cmd *IntCmd) Args() []interface{}

func (*IntCmd) Err

func (cmd *IntCmd) Err() error

func (*IntCmd) FullName

func (cmd *IntCmd) FullName() string

func (*IntCmd) Name

func (cmd *IntCmd) Name() string

func (*IntCmd) Result

func (cmd *IntCmd) Result() (int64, error)

func (*IntCmd) SetErr

func (cmd *IntCmd) SetErr(e error)

func (*IntCmd) SetFirstKeyPos

func (cmd *IntCmd) SetFirstKeyPos(keyPos int8)

func (*IntCmd) SetVal

func (cmd *IntCmd) SetVal(val int64)

func (*IntCmd) String

func (cmd *IntCmd) String() string

func (*IntCmd) Uint64

func (cmd *IntCmd) Uint64() (uint64, error)

func (*IntCmd) Val

func (cmd *IntCmd) Val() int64

type Limiter

type Limiter interface {
	// Allow returns nil if operation is allowed or an error otherwise.
	// If operation is allowed client must ReportResult of the operation
	// If operation is allowed client must ReportResult of the operation
	// whether it is a success or a failure.
	Allow() error
	// ReportResult reports the result of the previously allowed operation.
	// nil indicates a success, non-nil error usually indicates a failure.
	ReportResult(result error)
}

Limiter is the interface of a rate limiter or a circuit breaker.

type Options

type Options struct {
	// The network type, currently only tcp is supported.
	// Default is tcp.
	Network string
	// host:port address.
	Addr string

	// Dialer creates new network connection and has priority over
	// Network and Addr options.
	Dialer func(ctx context.Context, network, addr string) (net.Conn, error)

	// Hook that is called when new connection is established.
	OnConnect func(ctx context.Context, cn *Conn) error

	// Optional Username. Required only when authn is enabled in the configuration.
	// Use the specified Username to authenticate the current connection.
	// Authn is not enabled by default. Check the docs. https://docs.skytable.io/auth
	Username string
	// Optional Token. Required only when authn is enabled in the configuration.
	// Use the specified Token to authenticate the current connection.
	// Authn is not enabled by default. Check the docs. https://docs.skytable.io/auth
	Token string
	// CredentialsProvider allows the username and token to be updated
	// before reconnecting. It should return the current username and token.
	CredentialsProvider func() (username string, token string)

	// Table to be selected after connecting to the server.
	// FQE syntax is used to describe the full path to a table.
	// For example, if you have a keyspace supercyan and you have a table cyan within it, then the FQE syntax will be:
	//  supercyan:cyan
	//
	// !IMPORTANT NOTE
	// When you connect to Skytable, you are connected to the default keyspace which has a default table.
	Table string

	// Maximum number of retries before giving up.
	// Default is 3 retries; -1 (not 0) disables retries.
	MaxRetries int
	// Minimum backoff between each retry.
	// Default is 8 milliseconds; -1 disables backoff.
	MinRetryBackoff time.Duration
	// Maximum backoff between each retry.
	// Default is 512 milliseconds; -1 disables backoff.
	MaxRetryBackoff time.Duration

	// Dial timeout for establishing new connections.
	// Default is 5 seconds.
	DialTimeout time.Duration
	// Timeout for socket reads. If reached, commands will fail
	// with a timeout instead of blocking. Use value -1 for no timeout and 0 for default.
	// Default is 3 seconds.
	ReadTimeout time.Duration
	// Timeout for socket writes. If reached, commands will fail
	// with a timeout instead of blocking.
	// Default is ReadTimeout.
	WriteTimeout time.Duration

	// Type of connection pool.
	// true for FIFO pool, false for LIFO pool.
	// Note that fifo has higher overhead compared to lifo.
	PoolFIFO bool
	// Maximum number of socket connections.
	// Default is 10 connections per every available CPU as reported by runtime.GOMAXPROCS.
	PoolSize int
	// Minimum number of idle connections which is useful when establishing
	// new connection is slow.
	MinIdleConns int
	// Connection age at which client retires (closes) the connection.
	// Default is to not close aged connections.
	MaxConnAge time.Duration
	// Amount of time client waits for connection if all connections
	// are busy before returning an error.
	// Default is ReadTimeout + 1 second.
	PoolTimeout time.Duration
	// Amount of time after which client closes idle connections.
	// Should be less than server's timeout.
	// Default is 5 minutes. -1 disables idle timeout check.
	IdleTimeout time.Duration
	// Frequency of idle checks made by idle connections reaper.
	// Default is 1 minute. -1 disables idle connections reaper,
	// but idle connections are still discarded by the client
	// if IdleTimeout is set.
	IdleCheckFrequency time.Duration

	// TLS Config to use. When set TLS will be negotiated.
	TLSConfig *tls.Config

	// Limiter interface used to implemented circuit breaker or rate limiter.
	Limiter Limiter
}

Options keeps the settings to setup skytable connection.

type Pipeline

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

Pipeline implements pipelining as described in https://docs.skytable.io/protocol/skyhash#a-full-example-a-pipelined-query. It's safe for concurrent use by multiple goroutines.

func (Pipeline) AddUser

func (c Pipeline) AddUser(ctx context.Context, username string) *StringCmd

AddUser Attempts to create a new user with the provided username, returning the token.

Time complexity: O(1)

Operation can throw error.

  • 11 Authn realm error The current user is not allowed to perform the action

func (Pipeline) Claim

func (c Pipeline) Claim(ctx context.Context, originKey string) *StringCmd

Claim Attempts to claim the root account using the origin key.

Time complexity: O(1)

Operation can throw error.

  • 10 Bad credentials The authn credentials are invalid

func (Pipeline) CreateKeyspace

func (c Pipeline) CreateKeyspace(ctx context.Context, entity string) *StatusCmd

CreateKeyspace creates a new keyspace.

Transactional: Not yet Time complexity: O(1)

Operation can throw error.

  • string "err-already-exists" if it already existed
  • 5 Server Error An error occurred on the server side

func (Pipeline) CreateTable

func (c Pipeline) CreateTable(ctx context.Context, table, model string, modelArgs []string, properties ...string) *StatusCmd

CreateTable creates a new table.

Transactional: Not yet

Time complexity: O(1)

Currently only keymap model is supported in skytable.

The keymap model A keymap is like an associated array: it maps a key to a value. More importantly, it maps a specific key type to a specific value type.

Warning: Everything after CREATE TABLE is case sensitive!

This is how you create keymap tables:

CREATE TABLE <entity> keymap(<type>,<type>) <properties>

Operation can throw error.

  • string "err-already-exists" if it already existed
  • string "default-container-unset" if the connection level default keyspace has not been set
  • 5 Server error An error occurred on the server side

func (Pipeline) DbSize

func (c Pipeline) DbSize(ctx context.Context, entity string) *IntCmd

DbSize Check the number of entries stored in the current table or in the provided entity.

Time complexity: O(1)

func (Pipeline) Del

func (c Pipeline) Del(ctx context.Context, keys ...string) *IntCmd

Del Delete 'n' keys from the current table. DEL <key1> <key2> ... <keyN> This will return the number of keys that were deleted as an unsigned integer

Time complexity: O(n)

Operation can throw error.

  • 5 Server error An error occurred on the server side

func (Pipeline) DelUser

func (c Pipeline) DelUser(ctx context.Context, username string) *StatusCmd

DelUser Attempts to delete the user with the provided username.

Time complexity: O(1)

Operation can throw error.

  • 10 Bad credentials The authn credentials are invalid
  • 11 Authn realm error The current user is not allowed to perform the action

func (*Pipeline) Discard

func (c *Pipeline) Discard()

Discard resets the pipeline and discards queued commands.

func (*Pipeline) Do

func (c *Pipeline) Do(ctx context.Context, args ...interface{}) *Cmd

Do queues the custom command for later execution.

func (Pipeline) DropKeyspace

func (c Pipeline) DropKeyspace(ctx context.Context, keyspace string) *StatusCmd

DropKeyspace removes the specified keyspace from the server.

Operation can throw error.

  • string "container-not-found "if the keyspace wasn't found
  • string "still-in-use" if clients are still connected to the keyspace or the keyspace is not empty
  • 5 Server error An error occurred on the server side

func (Pipeline) DropTable

func (c Pipeline) DropTable(ctx context.Context, table string) *StatusCmd

DropTable removes the specified table from the keyspace.

Operation can throw error.

  • string "container-not-found" if the keyspace wasn't found
  • string "still-in-use" if clients are still connected to the table
  • string "default-container-unset" if the connection level default keyspace has not been set
  • 5 Server error An error occurred on the server side

func (*Pipeline) Exec

func (c *Pipeline) Exec(ctx context.Context) ([]Cmder, error)

Exec executes all previously queued commands using one client-server roundtrip.

Exec always returns list of commands and error of the first failed command if any.

func (Pipeline) Exists

func (c Pipeline) Exists(ctx context.Context, keys ...string) *IntCmd

Exists Check if 'n' keys exist in the current table. EXISTS <key1> <key2> ... <keyN> This will return the number of keys that exist as an unsigned integer.

Time complexity: O(n)

func (Pipeline) FlushDB

func (c Pipeline) FlushDB(ctx context.Context, entity string) *StatusCmd

FlushDB Removes all entries stored in the current table or in the provided entity. Pass the entity name in FQE i.e.

<keyspace>:<table>

or leave empty to flush the current table. Only passing the table name will flush the table in current active keyspace.

Time complexity: O(n)

Operation can throw error.

  • 5 Server error - An error occurred on the server side

Example:

ctx := context.Background()

sdb := skytable.NewClient(&skytable.Options{
  Addr: "localhost:2003",
})

if err := sdb.FlushDB(ctx, "").Err(); err != nil {
  panic(err)
}

func (Pipeline) Get

func (c Pipeline) Get(ctx context.Context, key string) *StringCmd

Get the value of a key from the current table, if it exists It returns skytable.Nil error when key does not exist.

Time complexity: O(1)

@return the requested value

Operation can throw error.

  • 1 Nil The client asked for a non-existent object

Example:

ctx := context.Background()

sdb := skytable.NewClient(&skytable.Options{
  Addr: "localhost:2003",
})

// setting key: value
if err := sdb.Set(ctx, "key", "value").Err(); err != nil {
  panic(err)
}

// getting key: value
val, err := sdb.Get(ctx, "key").Result()
if err != nil {
  panic(err)
}
fmt.Println("key:", val)

func (Pipeline) Heya

func (c Pipeline) Heya(ctx context.Context, message string) *StringCmd

Heya Either returns a "HEY!" or returns the provided argument as a str

Time complexity: O(1)

Example:

		ctx := context.Background()

   sdb := skytable.NewClient(&skytable.Options{
			Addr: "localhost:2003",
		})

		reply := sdb.Heya(ctx, "").Result()
		fmt.Println(reply)

func (Pipeline) InspectKeyspace

func (c Pipeline) InspectKeyspace(ctx context.Context, keyspace string) *StringSliceCmd

InspectKeyspace This will return a flat array with all the table names passing keyspace as empty string "" will return all the table names in current keyspace

func (Pipeline) InspectKeyspaces

func (c Pipeline) InspectKeyspaces(ctx context.Context) *StringSliceCmd

InspectKeyspaces This will return a flat array with all the keyspace names

func (Pipeline) InspectTable

func (c Pipeline) InspectTable(ctx context.Context, table string) *StringSliceCmd

InspectTable This will return a string with the table's syntactical description. For example, the keymap model can return: Keymap { data: (binstr,binstr), volatile: true }

func (Pipeline) KeyLen

func (c Pipeline) KeyLen(ctx context.Context, key string) *IntCmd

KeyLen Returns the length of the UTF-8 string, if it exists in the current table.

Time complexity: O(1)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object

func (Pipeline) LGet

func (c Pipeline) LGet(ctx context.Context, key string) *StringSliceCmd

LGet Returns all the values contained in the provided list, if it exists in the current table.

Time complexity: O(n)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object

func (Pipeline) LGetFirst

func (c Pipeline) LGetFirst(ctx context.Context, key string) *StringCmd

LGetFirst Returns the first element present in the list, if it exists.

Time complexity: O(1)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object
  • string "list-is-empty"

func (Pipeline) LGetLast

func (c Pipeline) LGetLast(ctx context.Context, key string) *StringCmd

LGetLast Returns the last element present in the list, if it exists.

Time complexity: O(1)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object
  • string "list-is-empty"

func (Pipeline) LGetLen

func (c Pipeline) LGetLen(ctx context.Context, key string) *IntCmd

LGetLen Returns the length of the list

Time complexity: O(1)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object

func (Pipeline) LGetLimit

func (c Pipeline) LGetLimit(ctx context.Context, key string, limit int) *StringSliceCmd

LGetLimit Returns a maximum of limit values from the provided list, if it exists in the current table

Time complexity: O(n)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object

func (Pipeline) LGetRange

func (c Pipeline) LGetRange(ctx context.Context, key string, start int, stop int) *StringSliceCmd

LGetRange Returns items in the given range. If stop is provided as -1, all the elements from that index are returned. If a value for stop is provided, then a subarray is returned array[start:stop] -> [start, stop)

Time complexity: O(n)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object
  • string "bad-list-index" The index is out of range

func (Pipeline) LGetValueAt

func (c Pipeline) LGetValueAt(ctx context.Context, key string, index int) *StringCmd

LGetValueAt Returns the element present at the provided index, if it exists in the given list.

Time complexity: O(1)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object
  • string "bad-list-index" The index is out of range

func (Pipeline) LModClear

func (c Pipeline) LModClear(ctx context.Context, key string) *StatusCmd

LModClear Removes all the elements present in the list.

Time complexity: O(n)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object
  • 5 Server error An error occurred on the server side

func (Pipeline) LModInsert

func (c Pipeline) LModInsert(ctx context.Context, key string, index int, value interface{}) *StatusCmd

LModInsert Inserts the element to the provided index, if it is valid while shifting elements to the right if required.

Time complexity: O(1)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object
  • 5 Server error An error occurred on the server side
  • string "bad-list-index" The index is out of range

func (Pipeline) LModPop

func (c Pipeline) LModPop(ctx context.Context, key string, index int) *StringCmd

LModPop Removes the element from the end of the list if index<0 or from the provided index while shifting elements to the right if required.

Time complexity: O(1)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object
  • 5 Server error An error occurred on the server side
  • string "bad-list-index" The index is out of range

func (Pipeline) LModPush

func (c Pipeline) LModPush(ctx context.Context, key string, elements ...interface{}) *StatusCmd

LModPush Appends the elements to the end of the provided list, if it exists.

Time complexity: O(1)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object
  • 5 Server error An error occurred on the server side

func (Pipeline) LModRemove

func (c Pipeline) LModRemove(ctx context.Context, key string, index int) *StatusCmd

LModRemove Removes the element at the provided index from the list, shifting elements to the right if required.

Time complexity: O(1)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object
  • 5 Server error An error occurred on the server side
  • string "bad-list-index" The index is out of range

func (Pipeline) LSKeys

func (c Pipeline) LSKeys(ctx context.Context, entity string, limit int) *StringSliceCmd

LSKeys Returns a flat string array of keys present in the current table or in the provided entity. If no <limit> is given, then a maximum of 10 keys are returned. If a limit is specified, then a maximum of <limit> keys are returned. The order of keys is meaningless. For current table pass entity as "" For default limit 10, you can pass limit as "0"

Time complexity: O(n)

func (Pipeline) LSet

func (c Pipeline) LSet(ctx context.Context, key string, values ...interface{}) *StatusCmd

LSet Creates a list with the provided values, or simply creates an empty list if it doesn't already exist in the table.

Time complexity: O(n)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object
  • 5 Server error An error occurred on the server side

func (*Pipeline) Len

func (c *Pipeline) Len() int

Len returns the number of queued commands.

func (Pipeline) ListUser

func (c Pipeline) ListUser(ctx context.Context) *StringSliceCmd

ListUser Attempts to return a list of users for the current database instance

Time complexity: O(1)

func (Pipeline) Login

func (c Pipeline) Login(ctx context.Context, username, token string) *StatusCmd

Login Attempts to log in using the provided credentials

Time complexity: O(1)

Operation can throw error.

  • 10 Bad credentials The authn credentials are invalid

func (Pipeline) Logout

func (c Pipeline) Logout(ctx context.Context) *StatusCmd

Logout Attempts to log out the currently logged-in user

Time complexity: O(1)

Operation can throw error.

  • 10 Bad credentials The authn credentials are invalid

func (Pipeline) MGet

func (c Pipeline) MGet(ctx context.Context, keys ...interface{}) *SliceCmd

MGet Get the value of 'n' keys from the current table, if they exist.

Time complexity: O(n)

func (Pipeline) MKSnap

func (c Pipeline) MKSnap(ctx context.Context, snapName string) *StatusCmd

MKSnap This action can be used to create a snapshot. Do note that this action requires snapshotting to be enabled on the server side, before it can create snapshots. If you want to create snapshots without snapshots being enabled on the server-side, pass a second argument <SNAPNAME> to specify a snapshot name and a snapshot will be created in a folder called rsnap under your data directory. For more information on snapshots, read this document https://docs.skytable.io/snapshots

Time complexity: O(n)

Operation can throw error.

  • string "err-snapshot-disabled" Snapshots have been disabled on the server-side
  • string "err-snapshot-busy" A snapshot operation is already in progress

func (Pipeline) MPop

func (c Pipeline) MPop(ctx context.Context, keys ...interface{}) *StringSliceCmd

MPop Deletes and returns the values of the provided 'n' keys from the current table. If the database is poisoned, this will return a server error

Time complexity: O(n)

Operation can throw error.

  • 5 Server error An error occurred on the server side

func (Pipeline) MSet

func (c Pipeline) MSet(ctx context.Context, keyValuePairs ...interface{}) *IntCmd

MSet Set the value of 'n' keys in the current table, if they don't already exist. This will return the number of keys that were set as an unsigned integer.

Time complexity: O(n)

Operation can throw error.

  • 5 Server error An error occurred on the server side

func (Pipeline) MUpdate

func (c Pipeline) MUpdate(ctx context.Context, keyValuePairs ...interface{}) *IntCmd

MUpdate Update the value of 'n' keys in the current table, if they already exist. This will return the number of keys that were updated as an unsigned integer.

Time complexity: O(n)

Operation can throw error.

  • 5 Server error An error occurred on the server side

func (*Pipeline) Pipeline

func (c *Pipeline) Pipeline() Pipeliner

func (*Pipeline) Pipelined

func (c *Pipeline) Pipelined(ctx context.Context, fn func(Pipeliner) error) ([]Cmder, error)

func (Pipeline) Pop

func (c Pipeline) Pop(ctx context.Context, key string) *StringCmd

Pop Deletes and return the value of the provided key from the current table. If the database is poisoned, this will return a server error.

Time complexity: O(1)

Operation can throw error.

  • 5 Server error An error occurred on the server side

func (*Pipeline) Process

func (c *Pipeline) Process(ctx context.Context, cmd Cmder) error

Process queues the cmd for later execution.

func (Pipeline) Restore

func (c Pipeline) Restore(ctx context.Context, originKey, username string) *StringCmd

Restore Attempts to restore the password for the provided user. This will regenerate the token and return the newly issued token. However, if you aren't a root account, that is, you lost your root password, then you'll need to run with username as "root".

Time complexity: O(1)

Operation can throw error.

  • 10 Bad credentials The authn credentials are invalid
  • 11 Authn realm error The current user is not allowed to perform the action

func (Pipeline) SDel

func (c Pipeline) SDel(ctx context.Context, keys ...interface{}) *StatusCmd

SDel Delete all keys if all of the keys exist in the current table. Do note that if a single key doesn't exist, then a Nil code is returned.

Time complexity: O(n)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object
  • 5 Server error An error occurred on the server side

func (Pipeline) SSet

func (c Pipeline) SSet(ctx context.Context, keyValuePairs ...interface{}) *StatusCmd

SSet Set all keys to the given values only if all of them don't exist in the current table

Time complexity: O(n)

Operation can throw error. - 2 Overwrite error The client tried to overwrite data - 5 Server error An error occurred on the server side

func (Pipeline) SUpdate

func (c Pipeline) SUpdate(ctx context.Context, keyValuePairs ...interface{}) *StatusCmd

SUpdate Update all keys if all of the keys exist in the current table. Do note that if a single key doesn't exist, then a Nil code is returned.

Time complexity: O(n)

Operation can throw error. - 1 Nil The client asked for a non-existent object - 5 Server error An error occurred on the server side

func (Pipeline) Set

func (c Pipeline) Set(ctx context.Context, key interface{}, value interface{}) *StatusCmd

Set the value of a key in the current table, if it doesn't already exist Throws overwriting error if the key already exists.

Time complexity: O(1)

Operation can throw error.

  • 2 Overwrite error The client tried to overwrite data
  • 5 Server error An error occurred on the server side

Example:

ctx := context.Background()

sdb := skytable.NewClient(&skytable.Options{
  Addr: "localhost:2003",
})

// setting key: value
if err := sdb.Set(ctx, "key", "value").Err(); err != nil {
  panic(err)
}

func (Pipeline) SysInfo

func (c Pipeline) SysInfo(ctx context.Context, property string) *StringCmd

SysInfo Returns static properties of the system, i.e properties that do not change during runtime.

The following properties are available:

  • version: Returns the server version (String)
  • protocol: Returns the protocol version string (String)
  • protover: Returns the protocol version (float)

Time complexity: O(1)

func (Pipeline) SysMetric

func (c Pipeline) SysMetric(ctx context.Context, metric string) *StringCmd

SysMetric Returns dynamic properties of the system, i.e metrics are properties that can change during runtime.

The following metrics are available:

  • health: Returns "good" or "critical" depending on the system state (String)
  • storage: Returns bytes used for on-disk storage (uint64)

func (Pipeline) USet

func (c Pipeline) USet(ctx context.Context, keyValuePairs ...interface{}) *IntCmd

USet SET all keys if they don't exist, or UPDATE them if they do exist. This operation performs USETs in the current table

Time complexity: O(n)

Operation can throw error. - 5 Server error An error occurred on the server side

func (Pipeline) Update

func (c Pipeline) Update(ctx context.Context, key interface{}, value interface{}) *StatusCmd

Update the value of an existing key in the current table

Time complexity: O(1)

Operation can throw error.

  • 1 Nil The client asked for a non-existent object
  • 5 Server error An error occurred on the server side

Example:

ctx := context.Background()

sdb := skytable.NewClient(&skytable.Options{
  Addr: "localhost:2003",
})

// setting key: value
if err := sdb.Set(ctx, "key", "value").Err(); err != nil {
  panic(err)
}

// updating key: value
if err := sdb.Update(ctx, "key", "value2").Err(); err != nil {
  panic(err)
}

func (Pipeline) Use

func (c Pipeline) Use(ctx context.Context, entity string) *StatusCmd

Use the specified entity - table or keyspace Entity is simply a string in FQE i.e. <keyspace>:<table> for a table or <keyspace> for a keyspace. See https://docs.skytable.io/containers for more.

Time complexity: O(1)

The operation can throw error.

  • string "container-not-found" if the keyspace wasn't found
  • string "default-container-unset" if the connection level default keyspace has not been set

Example:

   ctx := context.Background()

   sdb := skytable.NewClient(&skytable.Options{
     Addr: "localhost:2003",
   })

   // creating new keyspace with the name "keyspace"
   if err := sdb.CreateKeyspace(ctx, "keyspace"); err != nil {
			panic(err)
		}

		// creating new table under the keyspace "keyspace" with the name "table"
   if err := sdb.CreateTable(ctx, "keyspace:table", "keymap", []string{"str", "binstr"}).Err(); err != nil {
			panic(err)
		}

		// using the entity "keyspace:table"
  	if err := sdb.Use(ctx, "keyspace:table"); err != nil {
			panic(err)
		}

func (Pipeline) WhereAmI

func (c Pipeline) WhereAmI(ctx context.Context) *StringSliceCmd

WhereAmI Returns an array with either the name of the current keyspace as the first element or if a default table is set, then it returns the keyspace name as the first element and the table name as the second element

func (Pipeline) WhoAmI

func (c Pipeline) WhoAmI(ctx context.Context) *StringCmd

WhoAmI Returns a string with the AuthID of the currently logged-in user or errors if the user is not logged in

Time complexity: O(1)

type Pipeliner

type Pipeliner interface {
	StatefulCmdable
	Len() int
	Do(ctx context.Context, args ...interface{}) *Cmd
	Process(ctx context.Context, cmd Cmder) error
	Discard()
	Exec(ctx context.Context) ([]Cmder, error)
}

Pipeliner is a mechanism to realise Skytable Pipeline technique.

Pipelining is a technique to extremely speed up processing by packing operations to batches, send them at once to Skytable and read a replies in a singe step. See https://docs.skytable.io/actions-overview/#pipelined-queries

Pay attention, that Pipeline is not a transaction, so you can get unexpected results in case of big pipelines and small read/write timeouts. Skytable client has retransmission logic in case of timeouts, pipeline can be retransmitted and commands can be executed more then once. To avoid this: it is good idea to use reasonable bigger read/write timeouts depends of your batch size

type PoolStats

type PoolStats pool.Stats

type SliceCmd

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

func NewSliceCmd

func NewSliceCmd(ctx context.Context, args ...interface{}) *SliceCmd

func (*SliceCmd) Args

func (cmd *SliceCmd) Args() []interface{}

func (*SliceCmd) Err

func (cmd *SliceCmd) Err() error

func (*SliceCmd) FullName

func (cmd *SliceCmd) FullName() string

func (*SliceCmd) Name

func (cmd *SliceCmd) Name() string

func (*SliceCmd) Result

func (cmd *SliceCmd) Result() ([]interface{}, error)

func (*SliceCmd) SetErr

func (cmd *SliceCmd) SetErr(e error)

func (*SliceCmd) SetFirstKeyPos

func (cmd *SliceCmd) SetFirstKeyPos(keyPos int8)

func (*SliceCmd) SetVal

func (cmd *SliceCmd) SetVal(val []interface{})

func (*SliceCmd) String

func (cmd *SliceCmd) String() string

func (*SliceCmd) Val

func (cmd *SliceCmd) Val() []interface{}

type StatefulCmdable

type StatefulCmdable interface {
	Cmdable
	Login(ctx context.Context, username, token string) *StatusCmd
	Logout(ctx context.Context) *StatusCmd
}

type StatusCmd

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

func NewStatusCmd

func NewStatusCmd(ctx context.Context, args ...interface{}) *StatusCmd

func (*StatusCmd) Args

func (cmd *StatusCmd) Args() []interface{}

func (*StatusCmd) Err

func (cmd *StatusCmd) Err() error

func (*StatusCmd) FullName

func (cmd *StatusCmd) FullName() string

func (*StatusCmd) Name

func (cmd *StatusCmd) Name() string

func (*StatusCmd) Result

func (cmd *StatusCmd) Result() (int64, error)

func (*StatusCmd) SetErr

func (cmd *StatusCmd) SetErr(e error)

func (*StatusCmd) SetFirstKeyPos

func (cmd *StatusCmd) SetFirstKeyPos(keyPos int8)

func (*StatusCmd) SetVal

func (cmd *StatusCmd) SetVal(val int64)

func (*StatusCmd) String

func (cmd *StatusCmd) String() string

func (*StatusCmd) Val

func (cmd *StatusCmd) Val() int64

type StringCmd

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

func NewStringCmd

func NewStringCmd(ctx context.Context, args ...interface{}) *StringCmd

func (*StringCmd) Args

func (cmd *StringCmd) Args() []interface{}

func (*StringCmd) Bool

func (cmd *StringCmd) Bool() (bool, error)

func (*StringCmd) Bytes

func (cmd *StringCmd) Bytes() ([]byte, error)

func (*StringCmd) Err

func (cmd *StringCmd) Err() error

func (*StringCmd) Float32

func (cmd *StringCmd) Float32() (float32, error)

func (*StringCmd) Float64

func (cmd *StringCmd) Float64() (float64, error)

func (*StringCmd) FullName

func (cmd *StringCmd) FullName() string

func (*StringCmd) Int

func (cmd *StringCmd) Int() (int, error)

func (*StringCmd) Int64

func (cmd *StringCmd) Int64() (int64, error)

func (*StringCmd) Name

func (cmd *StringCmd) Name() string

func (*StringCmd) Result

func (cmd *StringCmd) Result() (string, error)

func (*StringCmd) SetErr

func (cmd *StringCmd) SetErr(e error)

func (*StringCmd) SetFirstKeyPos

func (cmd *StringCmd) SetFirstKeyPos(keyPos int8)

func (*StringCmd) SetVal

func (cmd *StringCmd) SetVal(val string)

func (*StringCmd) String

func (cmd *StringCmd) String() string

func (*StringCmd) Time

func (cmd *StringCmd) Time() (time.Time, error)

func (*StringCmd) Uint64

func (cmd *StringCmd) Uint64() (uint64, error)

func (*StringCmd) Val

func (cmd *StringCmd) Val() string

type StringSliceCmd

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

func NewStringSliceCmd

func NewStringSliceCmd(ctx context.Context, args ...interface{}) *StringSliceCmd

func (*StringSliceCmd) Args

func (cmd *StringSliceCmd) Args() []interface{}

func (*StringSliceCmd) Err

func (cmd *StringSliceCmd) Err() error

func (*StringSliceCmd) FullName

func (cmd *StringSliceCmd) FullName() string

func (*StringSliceCmd) Name

func (cmd *StringSliceCmd) Name() string

func (*StringSliceCmd) Result

func (cmd *StringSliceCmd) Result() ([]string, error)

func (*StringSliceCmd) SetErr

func (cmd *StringSliceCmd) SetErr(e error)

func (*StringSliceCmd) SetFirstKeyPos

func (cmd *StringSliceCmd) SetFirstKeyPos(keyPos int8)

func (*StringSliceCmd) SetVal

func (cmd *StringSliceCmd) SetVal(val []string)

func (*StringSliceCmd) String

func (cmd *StringSliceCmd) String() string

func (*StringSliceCmd) Val

func (cmd *StringSliceCmd) Val() []string

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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