connection_pool

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2022 License: BSD-2-Clause Imports: 6 Imported by: 1

Documentation

Overview

Package with methods to work with a Tarantool cluster considering master discovery.

Main features:

- Return available connection from pool according to round-robin strategy.

- Automatic master discovery by mode parameter.

Since: 1.6.0

Index

Examples

Constants

View Source
const (
	ANY = iota
	RW
	RO
	PreferRW
	PreferRO
)

Mode parameter:

- ANY (use any instance) - the request can be executed on any instance (master or replica).

- RW (writeable instance (master)) - the request can only be executed on master.

- RO (read only instance (replica)) - the request can only be executed on replica.

- PREFER_RO (prefer read only instance (replica)) - if there is one, otherwise fallback to a writeable one (master).

- PREFER_RW (prefer write only instance (master)) - if there is one, otherwise fallback to a read only one (replica).

  Request   Default mode
---------- --------------
| call    | no default  |
| eval    | no default  |
| ping    | no default  |
| insert  | RW          |
| delete  | RW          |
| replace | RW          |
| update  | RW          |
| upsert  | RW          |
| select  | ANY         |
| get     | ANY         |

Variables

View Source
var (
	ErrEmptyAddrs        = errors.New("addrs (first argument) should not be empty")
	ErrWrongCheckTimeout = errors.New("wrong check timeout, must be greater than 0")
	ErrNoConnection      = errors.New("no active connections")
	ErrTooManyArgs       = errors.New("too many arguments")
	ErrIncorrectResponse = errors.New("Incorrect response format")
	ErrIncorrectStatus   = errors.New("Incorrect instance status: status should be `running`")
	ErrNoRwInstance      = errors.New("Can't find rw instance in pool")
	ErrNoRoInstance      = errors.New("Can't find ro instance in pool")
	ErrNoHealthyInstance = errors.New("Can't find healthy instance in pool")
)

Functions

This section is empty.

Types

type ConnectionInfo

type ConnectionInfo struct {
	ConnectedNow bool
	ConnRole     Role
}

ConnectionInfo structure for information about connection statuses:

- ConnectedNow reports if connection is established at the moment.

- ConnRole reports master/replica role of instance.

type ConnectionPool

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

Main features:

- Return available connection from pool according to round-robin strategy.

- Automatic master discovery by mode parameter.

func Connect

func Connect(addrs []string, connOpts tarantool.Opts) (connPool *ConnectionPool, err error)

ConnectWithOpts creates pool for instances with addresses addrs.

func ConnectWithOpts

func ConnectWithOpts(addrs []string, connOpts tarantool.Opts, opts OptsPool) (connPool *ConnectionPool, err error)

ConnectWithOpts creates pool for instances with addresses addrs with options opts.

func (*ConnectionPool) Call

func (connPool *ConnectionPool) Call(functionName string, args interface{}, userMode Mode) (resp *tarantool.Response, err error)

Call calls registered Tarantool function. It uses request code for Tarantool 1.6, so result is converted to array of arrays.

func (*ConnectionPool) Call17

func (connPool *ConnectionPool) Call17(functionName string, args interface{}, userMode Mode) (resp *tarantool.Response, err error)

Call17 calls registered Tarantool function. It uses request code for Tarantool 1.7, so result is not converted (though, keep in mind, result is always array).

Example
pool, err := examplePool(testRoles)
if err != nil {
	fmt.Println(err)
}
defer pool.Close()

// Call a function 'simple_incr' with arguments.
resp, err := pool.Call17("simple_incr", []interface{}{1}, connection_pool.PreferRW)
fmt.Println("Call simple_incr()")
fmt.Println("Error", err)
fmt.Println("Code", resp.Code)
fmt.Println("Data", resp.Data)
Output:

Call simple_incr()
Error <nil>
Code 0
Data [2]

func (*ConnectionPool) Call17Async

func (connPool *ConnectionPool) Call17Async(functionName string, args interface{}, userMode Mode) *tarantool.Future

Call17Async sends a call to registered Tarantool function and returns Future. It uses request code for Tarantool 1.7, so future's result will not be converted (though, keep in mind, result is always array).

func (*ConnectionPool) Call17Typed

func (connPool *ConnectionPool) Call17Typed(functionName string, args interface{}, result interface{}, userMode Mode) (err error)

Call17Typed calls registered function. It uses request code for Tarantool 1.7, so result is not converted (though, keep in mind, result is always array).

func (*ConnectionPool) CallAsync

func (connPool *ConnectionPool) CallAsync(functionName string, args interface{}, userMode Mode) *tarantool.Future

CallAsync sends a call to registered Tarantool function and returns Future. It uses request code for Tarantool 1.6, so future's result is always array of arrays.

func (*ConnectionPool) CallTyped

func (connPool *ConnectionPool) CallTyped(functionName string, args interface{}, result interface{}, userMode Mode) (err error)

CallTyped calls registered function. It uses request code for Tarantool 1.6, so result is converted to array of arrays.

func (*ConnectionPool) Close

func (connPool *ConnectionPool) Close() []error

Close closes connections in pool.

func (*ConnectionPool) ConfiguredTimeout

func (connPool *ConnectionPool) ConfiguredTimeout(mode Mode) (time.Duration, error)

ConfiguredTimeout gets timeout of current connection.

func (*ConnectionPool) ConnectedNow

func (connPool *ConnectionPool) ConnectedNow(mode Mode) (bool, error)

ConnectedNow gets connected status of pool.

func (*ConnectionPool) Delete

func (connPool *ConnectionPool) Delete(space, index interface{}, key interface{}, userMode ...Mode) (resp *tarantool.Response, err error)

Delete performs deletion of a tuple by key. Result will contain array with deleted tuple.

Example
pool, err := examplePool(testRoles)
if err != nil {
	fmt.Println(err)
}
defer pool.Close()

// Connect to servers[2] to check if tuple
// was inserted on RW instance
conn, err := tarantool.Connect(servers[2], connOpts)
if err != nil || conn == nil {
	fmt.Printf("failed to connect to %s", servers[2])
	return
}

// Insert a new tuple {"key1", "value1"}.
_, err = conn.Insert(spaceNo, []interface{}{"key1", "value1"})
if err != nil {
	fmt.Printf("Failed to insert: %s", err.Error())
	return
}
// Insert a new tuple {"key2", "value2"}.
_, err = conn.Insert(spaceNo, []interface{}{"key2", "value2"})
if err != nil {
	fmt.Printf("Failed to insert: %s", err.Error())
	return
}

// Delete tuple with primary key {"key1"}.
resp, err := pool.Delete(spaceNo, indexNo, []interface{}{"key1"})
fmt.Println("Delete key1")
fmt.Println("Error", err)
fmt.Println("Code", resp.Code)
fmt.Println("Data", resp.Data)

// Delete tuple with primary key { "key2" }.
resp, err = pool.Delete(spaceName, indexName, []interface{}{"key2"}, connection_pool.PreferRW)
fmt.Println("Delete key2")
fmt.Println("Error", err)
fmt.Println("Code", resp.Code)
fmt.Println("Data", resp.Data)
Output:

Delete key1
Error <nil>
Code 0
Data [[key1 value1]]
Delete key2
Error <nil>
Code 0
Data [[key2 value2]]

func (*ConnectionPool) DeleteAsync

func (connPool *ConnectionPool) DeleteAsync(space, index interface{}, key interface{}, userMode ...Mode) *tarantool.Future

DeleteAsync sends deletion action to Tarantool and returns Future. Future's result will contain array with deleted tuple.

func (*ConnectionPool) DeleteTyped

func (connPool *ConnectionPool) DeleteTyped(space, index interface{}, key interface{}, result interface{}, userMode ...Mode) (err error)

DeleteTyped performs deletion of a tuple by key and fills result with deleted tuple.

func (*ConnectionPool) Eval

func (connPool *ConnectionPool) Eval(expr string, args interface{}, userMode Mode) (resp *tarantool.Response, err error)

Eval passes lua expression for evaluation.

Example
pool, err := examplePool(testRoles)
if err != nil {
	fmt.Println(err)
}
defer pool.Close()

// Run raw Lua code.
resp, err := pool.Eval("return 1 + 2", []interface{}{}, connection_pool.PreferRW)
fmt.Println("Eval 'return 1 + 2'")
fmt.Println("Error", err)
fmt.Println("Code", resp.Code)
fmt.Println("Data", resp.Data)
Output:

Eval 'return 1 + 2'
Error <nil>
Code 0
Data [3]

func (*ConnectionPool) EvalAsync

func (connPool *ConnectionPool) EvalAsync(expr string, args interface{}, userMode Mode) *tarantool.Future

EvalAsync sends a lua expression for evaluation and returns Future.

func (*ConnectionPool) EvalTyped

func (connPool *ConnectionPool) EvalTyped(expr string, args interface{}, result interface{}, userMode Mode) (err error)

EvalTyped passes lua expression for evaluation.

func (*ConnectionPool) GetAddrs

func (connPool *ConnectionPool) GetAddrs() []string

GetAddrs gets addresses of connections in pool.

func (*ConnectionPool) GetPoolInfo

func (connPool *ConnectionPool) GetPoolInfo() map[string]*ConnectionInfo

GetPoolInfo gets information of connections (connected status, ro/rw role).

func (*ConnectionPool) GetTyped

func (connPool *ConnectionPool) GetTyped(space, index interface{}, key interface{}, result interface{}, userMode ...Mode) (err error)

GetTyped performs select (with limit = 1 and offset = 0) to box space and fills typed result.

func (*ConnectionPool) Insert

func (connPool *ConnectionPool) Insert(space interface{}, tuple interface{}, userMode ...Mode) (resp *tarantool.Response, err error)

Insert performs insertion to box space. Tarantool will reject Insert when tuple with same primary key exists.

Example
pool, err := examplePool(testRoles)
if err != nil {
	fmt.Println(err)
}
defer pool.Close()

// Insert a new tuple {"key1", "value1"}.
resp, err := pool.Insert(spaceNo, []interface{}{"key1", "value1"})
fmt.Println("Insert key1")
fmt.Println("Error", err)
fmt.Println("Code", resp.Code)
fmt.Println("Data", resp.Data)
// Insert a new tuple {"key2", "value2"}.
resp, err = pool.Insert(spaceName, &Tuple{Key: "key2", Value: "value2"}, connection_pool.PreferRW)
fmt.Println("Insert key2")
fmt.Println("Error", err)
fmt.Println("Code", resp.Code)
fmt.Println("Data", resp.Data)

// Connect to servers[2] to check if tuple
// was inserted on RW instance
conn, err := tarantool.Connect(servers[2], connOpts)
if err != nil || conn == nil {
	fmt.Printf("failed to connect to %s", servers[2])
	return
}

// Delete tuple with primary key "key1".
_, err = conn.Delete(spaceName, indexName, []interface{}{"key1"})
if err != nil {
	fmt.Printf("Failed to delete: %s", err.Error())
}
// Delete tuple with primary key "key2".
_, err = conn.Delete(spaceNo, indexNo, []interface{}{"key2"})
if err != nil {
	fmt.Printf("Failed to delete: %s", err.Error())
}
Output:

Insert key1
Error <nil>
Code 0
Data [[key1 value1]]
Insert key2
Error <nil>
Code 0
Data [[key2 value2]]

func (*ConnectionPool) InsertAsync

func (connPool *ConnectionPool) InsertAsync(space interface{}, tuple interface{}, userMode ...Mode) *tarantool.Future

InsertAsync sends insert action to Tarantool and returns Future. Tarantool will reject Insert when tuple with same primary key exists.

func (*ConnectionPool) InsertTyped

func (connPool *ConnectionPool) InsertTyped(space interface{}, tuple interface{}, result interface{}, userMode ...Mode) (err error)

InsertTyped performs insertion to box space. Tarantool will reject Insert when tuple with same primary key exists.

func (*ConnectionPool) Ping

func (connPool *ConnectionPool) Ping(userMode Mode) (*tarantool.Response, error)

Ping sends empty request to Tarantool to check connection.

Example
pool, err := examplePool(testRoles)
if err != nil {
	fmt.Println(err)
}
defer pool.Close()

// Ping a Tarantool instance to check connection.
resp, err := pool.Ping(connection_pool.ANY)
fmt.Println("Ping Code", resp.Code)
fmt.Println("Ping Data", resp.Data)
fmt.Println("Ping Error", err)
Output:

Ping Code 0
Ping Data []
Ping Error <nil>

func (*ConnectionPool) Replace

func (connPool *ConnectionPool) Replace(space interface{}, tuple interface{}, userMode ...Mode) (resp *tarantool.Response, err error)

Replace performs "insert or replace" action to box space. If tuple with same primary key exists, it will be replaced.

Example
pool, err := examplePool(testRoles)
if err != nil {
	fmt.Println(err)
}
defer pool.Close()

// Connect to servers[2] to check if tuple
// was inserted on RW instance
conn, err := tarantool.Connect(servers[2], connOpts)
if err != nil || conn == nil {
	fmt.Printf("failed to connect to %s", servers[2])
	return
}

// Insert a new tuple {"key1", "value1"}.
_, err = conn.Insert(spaceNo, []interface{}{"key1", "value1"})
if err != nil {
	fmt.Printf("Failed to insert: %s", err.Error())
	return
}

// Replace a tuple with primary key ""key1.
// Note, Tuple is defined within tests, and has EncdodeMsgpack and
// DecodeMsgpack methods.
resp, err := pool.Replace(spaceNo, []interface{}{"key1", "new_value"})
fmt.Println("Replace key1")
fmt.Println("Error", err)
fmt.Println("Code", resp.Code)
fmt.Println("Data", resp.Data)
resp, err = pool.Replace(spaceName, []interface{}{"key1", "another_value"})
fmt.Println("Replace key1")
fmt.Println("Error", err)
fmt.Println("Code", resp.Code)
fmt.Println("Data", resp.Data)
resp, err = pool.Replace(spaceName, &Tuple{Key: "key1", Value: "value2"})
fmt.Println("Replace key1")
fmt.Println("Error", err)
fmt.Println("Code", resp.Code)
fmt.Println("Data", resp.Data)
resp, err = pool.Replace(spaceName, &Tuple{Key: "key1", Value: "new_value2"}, connection_pool.PreferRW)
fmt.Println("Replace key1")
fmt.Println("Error", err)
fmt.Println("Code", resp.Code)
fmt.Println("Data", resp.Data)

// Delete tuple with primary key "key1".
_, err = conn.Delete(spaceName, indexName, []interface{}{"key1"})
if err != nil {
	fmt.Printf("Failed to delete: %s", err.Error())
}
Output:

Replace key1
Error <nil>
Code 0
Data [[key1 new_value]]
Replace key1
Error <nil>
Code 0
Data [[key1 another_value]]
Replace key1
Error <nil>
Code 0
Data [[key1 value2]]
Replace key1
Error <nil>
Code 0
Data [[key1 new_value2]]

func (*ConnectionPool) ReplaceAsync

func (connPool *ConnectionPool) ReplaceAsync(space interface{}, tuple interface{}, userMode ...Mode) *tarantool.Future

ReplaceAsync sends "insert or replace" action to Tarantool and returns Future. If tuple with same primary key exists, it will be replaced.

func (*ConnectionPool) ReplaceTyped

func (connPool *ConnectionPool) ReplaceTyped(space interface{}, tuple interface{}, result interface{}, userMode ...Mode) (err error)

ReplaceTyped performs "insert or replace" action to box space. If tuple with same primary key exists, it will be replaced.

func (*ConnectionPool) Select

func (connPool *ConnectionPool) Select(space, index interface{}, offset, limit, iterator uint32, key interface{}, userMode ...Mode) (resp *tarantool.Response, err error)

Select performs select to box space.

Example
pool, err := examplePool(testRoles)
if err != nil {
	fmt.Println(err)
}
defer pool.Close()

// Connect to servers[2] to check if tuple
// was inserted on RW instance
conn, err := tarantool.Connect(servers[2], connOpts)
if err != nil || conn == nil {
	fmt.Printf("failed to connect to %s", servers[2])
	return
}

// Insert a new tuple {"key1", "value1"}.
_, err = conn.Insert(spaceNo, []interface{}{"key1", "value1"})
if err != nil {
	fmt.Printf("Failed to insert: %s", err.Error())
	return
}
// Insert a new tuple {"key2", "value2"}.
_, err = conn.Insert(spaceName, &Tuple{Key: "key2", Value: "value2"})
if err != nil {
	fmt.Printf("Failed to insert: %s", err.Error())
	return
}

resp, err := pool.Select(
	spaceNo, indexNo, 0, 100, tarantool.IterEq,
	[]interface{}{"key1"}, connection_pool.PreferRW)
if err != nil {
	fmt.Printf("error in select is %v", err)
	return
}
fmt.Printf("response is %#v\n", resp.Data)
resp, err = pool.Select(
	spaceNo, indexNo, 0, 100, tarantool.IterEq,
	[]interface{}{"key2"}, connection_pool.PreferRW)
if err != nil {
	fmt.Printf("error in select is %v", err)
	return
}
fmt.Printf("response is %#v\n", resp.Data)

// Delete tuple with primary key "key1".
_, err = conn.Delete(spaceName, indexName, []interface{}{"key1"})
if err != nil {
	fmt.Printf("Failed to delete: %s", err.Error())
}
// Delete tuple with primary key "key2".
_, err = conn.Delete(spaceNo, indexNo, []interface{}{"key2"})
if err != nil {
	fmt.Printf("Failed to delete: %s", err.Error())
}
Output:

response is []interface {}{[]interface {}{"key1", "value1"}}
response is []interface {}{[]interface {}{"key2", "value2"}}

func (*ConnectionPool) SelectAsync

func (connPool *ConnectionPool) SelectAsync(space, index interface{}, offset, limit, iterator uint32, key interface{}, userMode ...Mode) *tarantool.Future

SelectAsync sends select request to Tarantool and returns Future.

Example
pool, err := examplePool(testRoles)
if err != nil {
	fmt.Println(err)
}
defer pool.Close()

// Connect to servers[2] to check if tuple
// was inserted on RW instance
conn, err := tarantool.Connect(servers[2], connOpts)
if err != nil || conn == nil {
	fmt.Printf("failed to connect to %s", servers[2])
	return
}

// Insert a new tuple {"key1", "value1"}.
_, err = conn.Insert(spaceNo, []interface{}{"key1", "value1"})
if err != nil {
	fmt.Printf("Failed to insert: %s", err.Error())
	return
}
// Insert a new tuple {"key2", "value2"}.
_, err = conn.Insert(spaceName, &Tuple{Key: "key2", Value: "value2"})
if err != nil {
	fmt.Printf("Failed to insert: %s", err.Error())
	return
}
// Insert a new tuple {"key3", "value3"}.
_, err = conn.Insert(spaceNo, []interface{}{"key3", "value3"})
if err != nil {
	fmt.Printf("Failed to insert: %s", err.Error())
	return
}

var futs [3]*tarantool.Future
futs[0] = pool.SelectAsync(
	spaceName, indexName, 0, 2, tarantool.IterEq,
	[]interface{}{"key1"}, connection_pool.PreferRW)
futs[1] = pool.SelectAsync(
	spaceName, indexName, 0, 1, tarantool.IterEq,
	[]interface{}{"key2"}, connection_pool.RW)
futs[2] = pool.SelectAsync(
	spaceName, indexName, 0, 1, tarantool.IterEq,
	[]interface{}{"key3"}, connection_pool.RW)
var t []Tuple
err = futs[0].GetTyped(&t)
fmt.Println("Future", 0, "Error", err)
fmt.Println("Future", 0, "Data", t)

resp, err := futs[1].Get()
fmt.Println("Future", 1, "Error", err)
fmt.Println("Future", 1, "Data", resp.Data)

resp, err = futs[2].Get()
fmt.Println("Future", 2, "Error", err)
fmt.Println("Future", 2, "Data", resp.Data)

// Delete tuple with primary key "key1".
_, err = conn.Delete(spaceName, indexName, []interface{}{"key1"})
if err != nil {
	fmt.Printf("Failed to delete: %s", err.Error())
}
// Delete tuple with primary key "key2".
_, err = conn.Delete(spaceNo, indexNo, []interface{}{"key2"})
if err != nil {
	fmt.Printf("Failed to delete: %s", err.Error())
}
// Delete tuple with primary key "key3".
_, err = conn.Delete(spaceNo, indexNo, []interface{}{"key3"})
if err != nil {
	fmt.Printf("Failed to delete: %s", err.Error())
}
Output:

Future 0 Error <nil>
Future 0 Data [{{} key1 value1}]
Future 1 Error <nil>
Future 1 Data [[key2 value2]]
Future 2 Error <nil>
Future 2 Data [[key3 value3]]
Example (Err)
roles := []bool{true, true, true, true, true}
pool, err := examplePool(roles)
if err != nil {
	fmt.Println(err)
}
defer pool.Close()

var futs [3]*tarantool.Future
futs[0] = pool.SelectAsync(
	spaceName, indexName, 0, 2, tarantool.IterEq,
	[]interface{}{"key1"}, connection_pool.RW)

err = futs[0].Err()
fmt.Println("Future", 0, "Error", err)
Output:

Future 0 Error Can't find rw instance in pool

func (*ConnectionPool) SelectTyped

func (connPool *ConnectionPool) SelectTyped(space, index interface{}, offset, limit, iterator uint32, key interface{}, result interface{}, userMode ...Mode) (err error)

SelectTyped performs select to box space and fills typed result.

Example
pool, err := examplePool(testRoles)
if err != nil {
	fmt.Println(err)
}
defer pool.Close()

// Connect to servers[2] to check if tuple
// was inserted on RW instance
conn, err := tarantool.Connect(servers[2], connOpts)
if err != nil || conn == nil {
	fmt.Printf("failed to connect to %s", servers[2])
	return
}

// Insert a new tuple {"key1", "value1"}.
_, err = conn.Insert(spaceNo, []interface{}{"key1", "value1"})
if err != nil {
	fmt.Printf("Failed to insert: %s", err.Error())
	return
}
// Insert a new tuple {"key2", "value2"}.
_, err = conn.Insert(spaceName, &Tuple{Key: "key2", Value: "value2"})
if err != nil {
	fmt.Printf("Failed to insert: %s", err.Error())
	return
}

var res []Tuple
err = pool.SelectTyped(
	spaceNo, indexNo, 0, 100, tarantool.IterEq,
	[]interface{}{"key1"}, &res, connection_pool.PreferRW)
if err != nil {
	fmt.Printf("error in select is %v", err)
	return
}
fmt.Printf("response is %v\n", res)
err = pool.SelectTyped(
	spaceName, indexName, 0, 100, tarantool.IterEq,
	[]interface{}{"key2"}, &res, connection_pool.PreferRW)
if err != nil {
	fmt.Printf("error in select is %v", err)
	return
}
fmt.Printf("response is %v\n", res)

// Delete tuple with primary key "key1".
_, err = conn.Delete(spaceName, indexName, []interface{}{"key1"})
if err != nil {
	fmt.Printf("Failed to delete: %s", err.Error())
}
// Delete tuple with primary key "key2".
_, err = conn.Delete(spaceNo, indexNo, []interface{}{"key2"})
if err != nil {
	fmt.Printf("Failed to delete: %s", err.Error())
}
Output:

response is [{{} key1 value1}]
response is [{{} key2 value2}]

func (*ConnectionPool) Update

func (connPool *ConnectionPool) Update(space, index interface{}, key, ops interface{}, userMode ...Mode) (resp *tarantool.Response, err error)

Update performs update of a tuple by key. Result will contain array with updated tuple.

Example
pool, err := examplePool(testRoles)
if err != nil {
	fmt.Println(err)
}
defer pool.Close()

// Connect to servers[2] to check if tuple
// was inserted on RW instance
conn, err := tarantool.Connect(servers[2], connOpts)
if err != nil || conn == nil {
	fmt.Printf("failed to connect to %s", servers[2])
	return
}

// Insert a new tuple {"key1", "value1"}.
_, err = conn.Insert(spaceNo, []interface{}{"key1", "value1"})
if err != nil {
	fmt.Printf("Failed to insert: %s", err.Error())
	return
}

// Update tuple with primary key { "key1" }.
resp, err := pool.Update(
	spaceName, indexName, []interface{}{"key1"},
	[]interface{}{[]interface{}{"=", 1, "new_value"}}, connection_pool.PreferRW)
fmt.Println("Update key1")
fmt.Println("Error", err)
fmt.Println("Code", resp.Code)
fmt.Println("Data", resp.Data)

// Delete tuple with primary key "key1".
_, err = conn.Delete(spaceName, indexName, []interface{}{"key1"})
if err != nil {
	fmt.Printf("Failed to delete: %s", err.Error())
}
Output:

Update key1
Error <nil>
Code 0
Data [[key1 new_value]]

func (*ConnectionPool) UpdateAsync

func (connPool *ConnectionPool) UpdateAsync(space, index interface{}, key, ops interface{}, userMode ...Mode) *tarantool.Future

UpdateAsync sends deletion of a tuple by key and returns Future. Future's result will contain array with updated tuple.

func (*ConnectionPool) UpdateTyped

func (connPool *ConnectionPool) UpdateTyped(space, index interface{}, key, ops interface{}, result interface{}, userMode ...Mode) (err error)

UpdateTyped performs update of a tuple by key and fills result with updated tuple.

func (*ConnectionPool) Upsert

func (connPool *ConnectionPool) Upsert(space interface{}, tuple, ops interface{}, userMode ...Mode) (resp *tarantool.Response, err error)

Upsert performs "update or insert" action of a tuple by key. Result will not contain any tuple.

func (*ConnectionPool) UpsertAsync

func (connPool *ConnectionPool) UpsertAsync(space interface{}, tuple interface{}, ops interface{}, userMode ...Mode) *tarantool.Future

UpsertAsync sends "update or insert" action to Tarantool and returns Future. Future's sesult will not contain any tuple.

type Mode

type Mode uint32

type OptsPool

type OptsPool struct {
	// timeout for timer to reopen connections
	// that have been closed by some events and
	// to relocate connection between subpools
	// if ro/rw role has been updated
	CheckTimeout time.Duration
}

Additional options (configurable via ConnectWithOpts):

- CheckTimeout - time interval to check for connection timeout and try to switch connection.

type Role

type Role uint32

type RoundRobinStrategy

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

func NewEmptyRoundRobin

func NewEmptyRoundRobin(size int) *RoundRobinStrategy

func (*RoundRobinStrategy) AddConn

func (r *RoundRobinStrategy) AddConn(addr string, conn *tarantool.Connection)

func (*RoundRobinStrategy) CloseConns

func (r *RoundRobinStrategy) CloseConns() []error

func (*RoundRobinStrategy) DeleteConnByAddr

func (r *RoundRobinStrategy) DeleteConnByAddr(addr string) *tarantool.Connection

func (*RoundRobinStrategy) GetConnByAddr

func (r *RoundRobinStrategy) GetConnByAddr(addr string) *tarantool.Connection

func (*RoundRobinStrategy) GetNextConnection

func (r *RoundRobinStrategy) GetNextConnection() *tarantool.Connection

func (*RoundRobinStrategy) IsEmpty

func (r *RoundRobinStrategy) IsEmpty() bool

type State

type State uint32

Jump to

Keyboard shortcuts

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