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
- Variables
- func SetLogger(logger internal.Logging)
- func Version() string
- type Client
- func (hs *Client) AddHook(hook Hook)
- func (c Client) AddUser(ctx context.Context, username string) *StringCmd
- func (c Client) Claim(ctx context.Context, originKey string) *StringCmd
- func (c Client) Close() error
- func (c *Client) Conn() *Conn
- func (c Client) CreateKeyspace(ctx context.Context, entity string) *StatusCmd
- func (c Client) CreateTable(ctx context.Context, table, model string, modelArgs []string, ...) *StatusCmd
- func (c Client) DbSize(ctx context.Context, entity string) *IntCmd
- func (c Client) Del(ctx context.Context, keys ...string) *IntCmd
- func (c Client) DelUser(ctx context.Context, username string) *StatusCmd
- func (c *Client) Do(ctx context.Context, args ...interface{}) *Cmd
- func (c Client) DropKeyspace(ctx context.Context, keyspace string) *StatusCmd
- func (c Client) DropTable(ctx context.Context, table string) *StatusCmd
- func (c Client) Exists(ctx context.Context, keys ...string) *IntCmd
- func (c Client) FlushDB(ctx context.Context, entity string) *StatusCmd
- func (c Client) Get(ctx context.Context, key string) *StringCmd
- func (c Client) Heya(ctx context.Context, message string) *StringCmd
- func (c Client) InspectKeyspace(ctx context.Context, keyspace string) *StringSliceCmd
- func (c Client) InspectKeyspaces(ctx context.Context) *StringSliceCmd
- func (c Client) InspectTable(ctx context.Context, table string) *StringSliceCmd
- func (c Client) KeyLen(ctx context.Context, key string) *IntCmd
- func (c Client) LGet(ctx context.Context, key string) *StringSliceCmd
- func (c Client) LGetFirst(ctx context.Context, key string) *StringCmd
- func (c Client) LGetLast(ctx context.Context, key string) *StringCmd
- func (c Client) LGetLen(ctx context.Context, key string) *IntCmd
- func (c Client) LGetLimit(ctx context.Context, key string, limit int) *StringSliceCmd
- func (c Client) LGetRange(ctx context.Context, key string, start int, stop int) *StringSliceCmd
- func (c Client) LGetValueAt(ctx context.Context, key string, index int) *StringCmd
- func (c Client) LModClear(ctx context.Context, key string) *StatusCmd
- func (c Client) LModInsert(ctx context.Context, key string, index int, value interface{}) *StatusCmd
- func (c Client) LModPop(ctx context.Context, key string, index int) *StringCmd
- func (c Client) LModPush(ctx context.Context, key string, elements ...interface{}) *StatusCmd
- func (c Client) LModRemove(ctx context.Context, key string, index int) *StatusCmd
- func (c Client) LSKeys(ctx context.Context, entity string, limit int) *StringSliceCmd
- func (c Client) LSet(ctx context.Context, key string, values ...interface{}) *StatusCmd
- func (c Client) ListUser(ctx context.Context) *StringSliceCmd
- func (c Client) MGet(ctx context.Context, keys ...interface{}) *SliceCmd
- func (c Client) MKSnap(ctx context.Context, snapName string) *StatusCmd
- func (c Client) MPop(ctx context.Context, keys ...interface{}) *StringSliceCmd
- func (c Client) MSet(ctx context.Context, keyValuePairs ...interface{}) *IntCmd
- func (c Client) MUpdate(ctx context.Context, keyValuePairs ...interface{}) *IntCmd
- func (c *Client) Options() *Options
- func (c *Client) Pipeline() Pipeliner
- func (c *Client) Pipelined(ctx context.Context, fn func(Pipeliner) error) ([]Cmder, error)
- func (c *Client) PoolStats() *PoolStats
- func (c Client) Pop(ctx context.Context, key string) *StringCmd
- func (c *Client) Process(ctx context.Context, cmd Cmder) error
- func (c Client) Restore(ctx context.Context, originKey, username string) *StringCmd
- func (c Client) SDel(ctx context.Context, keys ...interface{}) *StatusCmd
- func (c Client) SSet(ctx context.Context, keyValuePairs ...interface{}) *StatusCmd
- func (c Client) SUpdate(ctx context.Context, keyValuePairs ...interface{}) *StatusCmd
- func (c Client) Set(ctx context.Context, key interface{}, value interface{}) *StatusCmd
- func (c Client) String() string
- func (c Client) SysInfo(ctx context.Context, property string) *StringCmd
- func (c Client) SysMetric(ctx context.Context, metric string) *StringCmd
- func (c Client) USet(ctx context.Context, keyValuePairs ...interface{}) *IntCmd
- func (c Client) Update(ctx context.Context, key interface{}, value interface{}) *StatusCmd
- func (c Client) Use(ctx context.Context, entity string) *StatusCmd
- func (c Client) WhereAmI(ctx context.Context) *StringSliceCmd
- func (c Client) WhoAmI(ctx context.Context) *StringCmd
- func (c *Client) WithTimeout(timeout time.Duration) *Client
- type Cmd
- func (cmd *Cmd) Args() []interface{}
- func (cmd *Cmd) Bool() (bool, error)
- func (cmd *Cmd) BoolSlice() ([]bool, error)
- func (cmd *Cmd) Err() error
- func (cmd *Cmd) Float32() (float32, error)
- func (cmd *Cmd) Float32Slice() ([]float32, error)
- func (cmd *Cmd) Float64() (float64, error)
- func (cmd *Cmd) Float64Slice() ([]float64, error)
- func (cmd *Cmd) FullName() string
- func (cmd *Cmd) Int() (int, error)
- func (cmd *Cmd) Int64() (int64, error)
- func (cmd *Cmd) Int64Slice() ([]int64, error)
- func (cmd *Cmd) Name() string
- func (cmd *Cmd) Result() (interface{}, error)
- func (cmd *Cmd) SetErr(e error)
- func (cmd *Cmd) SetFirstKeyPos(keyPos int8)
- func (cmd *Cmd) SetVal(val interface{})
- func (cmd *Cmd) Slice() ([]interface{}, error)
- func (cmd *Cmd) String() string
- func (cmd *Cmd) StringSlice() ([]string, error)
- func (cmd *Cmd) Text() (string, error)
- func (cmd *Cmd) Uint64() (uint64, error)
- func (cmd *Cmd) Uint64Slice() ([]uint64, error)
- func (cmd *Cmd) Val() interface{}
- type Cmdable
- type Cmder
- type Conn
- type Error
- type Hook
- type IntCmd
- func (cmd *IntCmd) Args() []interface{}
- func (cmd *IntCmd) Err() error
- func (cmd *IntCmd) FullName() string
- func (cmd *IntCmd) Name() string
- func (cmd *IntCmd) Result() (int64, error)
- func (cmd *IntCmd) SetErr(e error)
- func (cmd *IntCmd) SetFirstKeyPos(keyPos int8)
- func (cmd *IntCmd) SetVal(val int64)
- func (cmd *IntCmd) String() string
- func (cmd *IntCmd) Uint64() (uint64, error)
- func (cmd *IntCmd) Val() int64
- type Limiter
- type Options
- type Pipeline
- func (c Pipeline) AddUser(ctx context.Context, username string) *StringCmd
- func (c Pipeline) Claim(ctx context.Context, originKey string) *StringCmd
- func (c Pipeline) CreateKeyspace(ctx context.Context, entity string) *StatusCmd
- func (c Pipeline) CreateTable(ctx context.Context, table, model string, modelArgs []string, ...) *StatusCmd
- func (c Pipeline) DbSize(ctx context.Context, entity string) *IntCmd
- func (c Pipeline) Del(ctx context.Context, keys ...string) *IntCmd
- func (c Pipeline) DelUser(ctx context.Context, username string) *StatusCmd
- func (c *Pipeline) Discard()
- func (c *Pipeline) Do(ctx context.Context, args ...interface{}) *Cmd
- func (c Pipeline) DropKeyspace(ctx context.Context, keyspace string) *StatusCmd
- func (c Pipeline) DropTable(ctx context.Context, table string) *StatusCmd
- func (c *Pipeline) Exec(ctx context.Context) ([]Cmder, error)
- func (c Pipeline) Exists(ctx context.Context, keys ...string) *IntCmd
- func (c Pipeline) FlushDB(ctx context.Context, entity string) *StatusCmd
- func (c Pipeline) Get(ctx context.Context, key string) *StringCmd
- func (c Pipeline) Heya(ctx context.Context, message string) *StringCmd
- func (c Pipeline) InspectKeyspace(ctx context.Context, keyspace string) *StringSliceCmd
- func (c Pipeline) InspectKeyspaces(ctx context.Context) *StringSliceCmd
- func (c Pipeline) InspectTable(ctx context.Context, table string) *StringSliceCmd
- func (c Pipeline) KeyLen(ctx context.Context, key string) *IntCmd
- func (c Pipeline) LGet(ctx context.Context, key string) *StringSliceCmd
- func (c Pipeline) LGetFirst(ctx context.Context, key string) *StringCmd
- func (c Pipeline) LGetLast(ctx context.Context, key string) *StringCmd
- func (c Pipeline) LGetLen(ctx context.Context, key string) *IntCmd
- func (c Pipeline) LGetLimit(ctx context.Context, key string, limit int) *StringSliceCmd
- func (c Pipeline) LGetRange(ctx context.Context, key string, start int, stop int) *StringSliceCmd
- func (c Pipeline) LGetValueAt(ctx context.Context, key string, index int) *StringCmd
- func (c Pipeline) LModClear(ctx context.Context, key string) *StatusCmd
- func (c Pipeline) LModInsert(ctx context.Context, key string, index int, value interface{}) *StatusCmd
- func (c Pipeline) LModPop(ctx context.Context, key string, index int) *StringCmd
- func (c Pipeline) LModPush(ctx context.Context, key string, elements ...interface{}) *StatusCmd
- func (c Pipeline) LModRemove(ctx context.Context, key string, index int) *StatusCmd
- func (c Pipeline) LSKeys(ctx context.Context, entity string, limit int) *StringSliceCmd
- func (c Pipeline) LSet(ctx context.Context, key string, values ...interface{}) *StatusCmd
- func (c *Pipeline) Len() int
- func (c Pipeline) ListUser(ctx context.Context) *StringSliceCmd
- func (c Pipeline) Login(ctx context.Context, username, token string) *StatusCmd
- func (c Pipeline) Logout(ctx context.Context) *StatusCmd
- func (c Pipeline) MGet(ctx context.Context, keys ...interface{}) *SliceCmd
- func (c Pipeline) MKSnap(ctx context.Context, snapName string) *StatusCmd
- func (c Pipeline) MPop(ctx context.Context, keys ...interface{}) *StringSliceCmd
- func (c Pipeline) MSet(ctx context.Context, keyValuePairs ...interface{}) *IntCmd
- func (c Pipeline) MUpdate(ctx context.Context, keyValuePairs ...interface{}) *IntCmd
- func (c *Pipeline) Pipeline() Pipeliner
- func (c *Pipeline) Pipelined(ctx context.Context, fn func(Pipeliner) error) ([]Cmder, error)
- func (c Pipeline) Pop(ctx context.Context, key string) *StringCmd
- func (c *Pipeline) Process(ctx context.Context, cmd Cmder) error
- func (c Pipeline) Restore(ctx context.Context, originKey, username string) *StringCmd
- func (c Pipeline) SDel(ctx context.Context, keys ...interface{}) *StatusCmd
- func (c Pipeline) SSet(ctx context.Context, keyValuePairs ...interface{}) *StatusCmd
- func (c Pipeline) SUpdate(ctx context.Context, keyValuePairs ...interface{}) *StatusCmd
- func (c Pipeline) Set(ctx context.Context, key interface{}, value interface{}) *StatusCmd
- func (c Pipeline) SysInfo(ctx context.Context, property string) *StringCmd
- func (c Pipeline) SysMetric(ctx context.Context, metric string) *StringCmd
- func (c Pipeline) USet(ctx context.Context, keyValuePairs ...interface{}) *IntCmd
- func (c Pipeline) Update(ctx context.Context, key interface{}, value interface{}) *StatusCmd
- func (c Pipeline) Use(ctx context.Context, entity string) *StatusCmd
- func (c Pipeline) WhereAmI(ctx context.Context) *StringSliceCmd
- func (c Pipeline) WhoAmI(ctx context.Context) *StringCmd
- type Pipeliner
- type PoolStats
- type SliceCmd
- func (cmd *SliceCmd) Args() []interface{}
- func (cmd *SliceCmd) Err() error
- func (cmd *SliceCmd) FullName() string
- func (cmd *SliceCmd) Name() string
- func (cmd *SliceCmd) Result() ([]interface{}, error)
- func (cmd *SliceCmd) SetErr(e error)
- func (cmd *SliceCmd) SetFirstKeyPos(keyPos int8)
- func (cmd *SliceCmd) SetVal(val []interface{})
- func (cmd *SliceCmd) String() string
- func (cmd *SliceCmd) Val() []interface{}
- type StatefulCmdable
- type StatusCmd
- func (cmd *StatusCmd) Args() []interface{}
- func (cmd *StatusCmd) Err() error
- func (cmd *StatusCmd) FullName() string
- func (cmd *StatusCmd) Name() string
- func (cmd *StatusCmd) Result() (int64, error)
- func (cmd *StatusCmd) SetErr(e error)
- func (cmd *StatusCmd) SetFirstKeyPos(keyPos int8)
- func (cmd *StatusCmd) SetVal(val int64)
- func (cmd *StatusCmd) String() string
- func (cmd *StatusCmd) Val() int64
- type StringCmd
- func (cmd *StringCmd) Args() []interface{}
- func (cmd *StringCmd) Bool() (bool, error)
- func (cmd *StringCmd) Bytes() ([]byte, error)
- func (cmd *StringCmd) Err() error
- func (cmd *StringCmd) Float32() (float32, error)
- func (cmd *StringCmd) Float64() (float64, error)
- func (cmd *StringCmd) FullName() string
- func (cmd *StringCmd) Int() (int, error)
- func (cmd *StringCmd) Int64() (int64, error)
- func (cmd *StringCmd) Name() string
- func (cmd *StringCmd) Result() (string, error)
- func (cmd *StringCmd) SetErr(e error)
- func (cmd *StringCmd) SetFirstKeyPos(keyPos int8)
- func (cmd *StringCmd) SetVal(val string)
- func (cmd *StringCmd) String() string
- func (cmd *StringCmd) Time() (time.Time, error)
- func (cmd *StringCmd) Uint64() (uint64, error)
- func (cmd *StringCmd) Val() string
- type StringSliceCmd
- func (cmd *StringSliceCmd) Args() []interface{}
- func (cmd *StringSliceCmd) Err() error
- func (cmd *StringSliceCmd) FullName() string
- func (cmd *StringSliceCmd) Name() string
- func (cmd *StringSliceCmd) Result() ([]string, error)
- func (cmd *StringSliceCmd) SetErr(e error)
- func (cmd *StringSliceCmd) SetFirstKeyPos(keyPos int8)
- func (cmd *StringSliceCmd) SetVal(val []string)
- func (cmd *StringSliceCmd) String() string
- func (cmd *StringSliceCmd) Val() []string
Constants ¶
const ActionError = proto.ActionError
const AuthnRealmError = proto.AuthnRealmError
const BadCredentials = proto.BadCredentials
const EncodingError = proto.EncodingError
const Nil = proto.Nil
Nil reply returned by Skytable when key does not exist.
const OtherError = proto.OtherError
const OverwriteError = proto.OverwriteError
const PacketError = proto.PacketError
const ServerError = proto.ServerError
const UnknownDataTypeError = proto.UnknownDataTypeError
const WrongTypeError = proto.WrongTypeError
Variables ¶
var ErrClosed = pool.ErrClosed
ErrClosed performs any operation on the closed client will return this error.
Functions ¶
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 (Client) AddUser ¶
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 ¶
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) CreateKeyspace ¶
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 ¶
DbSize Check the number of entries stored in the current table or in the provided entity.
Time complexity: O(1)
func (Client) Del ¶
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 ¶
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) DropKeyspace ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
MGet Get the value of 'n' keys from the current table, if they exist.
Time complexity: O(n)
func (Client) MKSnap ¶
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 ¶
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 ¶
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) Pop ¶
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) Restore ¶
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 ¶
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 ¶
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 ¶
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 ¶
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) SysInfo ¶
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 ¶
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 ¶
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 ¶
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 ¶
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
type Cmd ¶
type Cmd struct {
// contains filtered or unexported fields
}
func (*Cmd) Float32Slice ¶
func (*Cmd) Float64Slice ¶
func (*Cmd) Int64Slice ¶
func (*Cmd) SetFirstKeyPos ¶
func (cmd *Cmd) SetFirstKeyPos(keyPos int8)
func (*Cmd) StringSlice ¶
func (*Cmd) Uint64Slice ¶
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 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.
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 IntCmd ¶
type IntCmd struct {
// contains filtered or unexported fields
}
func (*IntCmd) SetFirstKeyPos ¶
func (cmd *IntCmd) SetFirstKeyPos(keyPos int8)
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 ¶
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 ¶
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 ¶
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 ¶
DbSize Check the number of entries stored in the current table or in the provided entity.
Time complexity: O(1)
func (Pipeline) Del ¶
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 ¶
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) DropKeyspace ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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) 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 ¶
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 ¶
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 ¶
MGet Get the value of 'n' keys from the current table, if they exist.
Time complexity: O(n)
func (Pipeline) MKSnap ¶
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 ¶
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 ¶
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) Pop ¶
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) Restore ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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
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 SliceCmd ¶
type SliceCmd struct {
// contains filtered or unexported fields
}
func NewSliceCmd ¶
func (*SliceCmd) SetFirstKeyPos ¶
func (cmd *SliceCmd) SetFirstKeyPos(keyPos int8)
type StatefulCmdable ¶
type StatusCmd ¶
type StatusCmd struct {
// contains filtered or unexported fields
}
func NewStatusCmd ¶
func (*StatusCmd) SetFirstKeyPos ¶
func (cmd *StatusCmd) SetFirstKeyPos(keyPos int8)
type StringCmd ¶
type StringCmd struct {
// contains filtered or unexported fields
}
func NewStringCmd ¶
func (*StringCmd) SetFirstKeyPos ¶
func (cmd *StringCmd) SetFirstKeyPos(keyPos int8)
type StringSliceCmd ¶
type StringSliceCmd struct {
// contains filtered or unexported fields
}
func NewStringSliceCmd ¶
func NewStringSliceCmd(ctx context.Context, args ...interface{}) *StringSliceCmd
func (*StringSliceCmd) Result ¶
func (cmd *StringSliceCmd) Result() ([]string, 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