Documentation
¶
Overview ¶
Package with methods to work with a Tarantool cluster.
Main features:
- Check the active connection with a configurable time interval and switch to the next connection in the pool if there is a connection failure.
- Get the address list from the server and reconfigure it for use in MultiConnection.
Since: 1.5
Index ¶
- Variables
- type ConnectionMulti
- func (connMulti *ConnectionMulti) Call(functionName string, args interface{}) (resp *tarantool.Response, err error)
- func (connMulti *ConnectionMulti) Call16(functionName string, args interface{}) (resp *tarantool.Response, err error)
- func (connMulti *ConnectionMulti) Call16Async(functionName string, args interface{}) *tarantool.Future
- func (connMulti *ConnectionMulti) Call16Typed(functionName string, args interface{}, result interface{}) (err error)
- func (connMulti *ConnectionMulti) Call17(functionName string, args interface{}) (resp *tarantool.Response, err error)
- func (connMulti *ConnectionMulti) Call17Async(functionName string, args interface{}) *tarantool.Future
- func (connMulti *ConnectionMulti) Call17Typed(functionName string, args interface{}, result interface{}) (err error)
- func (connMulti *ConnectionMulti) CallAsync(functionName string, args interface{}) *tarantool.Future
- func (connMulti *ConnectionMulti) CallTyped(functionName string, args interface{}, result interface{}) (err error)
- func (connMulti *ConnectionMulti) Close() (err error)
- func (connMulti *ConnectionMulti) ConfiguredTimeout() time.Duration
- func (connMulti *ConnectionMulti) ConnectedNow() bool
- func (connMulti *ConnectionMulti) Delete(space, index interface{}, key interface{}) (resp *tarantool.Response, err error)
- func (connMulti *ConnectionMulti) DeleteAsync(space, index interface{}, key interface{}) *tarantool.Future
- func (connMulti *ConnectionMulti) DeleteTyped(space, index interface{}, key interface{}, result interface{}) (err error)
- func (connMulti *ConnectionMulti) Do(req tarantool.Request) *tarantool.Future
- func (connMulti *ConnectionMulti) Eval(expr string, args interface{}) (resp *tarantool.Response, err error)
- func (connMulti *ConnectionMulti) EvalAsync(expr string, args interface{}) *tarantool.Future
- func (connMulti *ConnectionMulti) EvalTyped(expr string, args interface{}, result interface{}) (err error)
- func (connMulti *ConnectionMulti) Execute(expr string, args interface{}) (resp *tarantool.Response, err error)
- func (connMulti *ConnectionMulti) ExecuteAsync(expr string, args interface{}) *tarantool.Future
- func (connMulti *ConnectionMulti) ExecuteTyped(expr string, args interface{}, result interface{}) (tarantool.SQLInfo, []tarantool.ColumnMetaData, error)
- func (connMulti *ConnectionMulti) GetTyped(space, index interface{}, key interface{}, result interface{}) (err error)
- func (connMulti *ConnectionMulti) Insert(space interface{}, tuple interface{}) (resp *tarantool.Response, err error)
- func (connMulti *ConnectionMulti) InsertAsync(space interface{}, tuple interface{}) *tarantool.Future
- func (connMulti *ConnectionMulti) InsertTyped(space interface{}, tuple interface{}, result interface{}) (err error)
- func (connMulti *ConnectionMulti) NewPrepared(expr string) (*tarantool.Prepared, error)
- func (connMulti *ConnectionMulti) NewStream() (*tarantool.Stream, error)
- func (connMulti *ConnectionMulti) NewWatcher(key string, callback tarantool.WatchCallback) (tarantool.Watcher, error)
- func (connMulti *ConnectionMulti) Ping() (resp *tarantool.Response, err error)
- func (connMulti *ConnectionMulti) Replace(space interface{}, tuple interface{}) (resp *tarantool.Response, err error)
- func (connMulti *ConnectionMulti) ReplaceAsync(space interface{}, tuple interface{}) *tarantool.Future
- func (connMulti *ConnectionMulti) ReplaceTyped(space interface{}, tuple interface{}, result interface{}) (err error)
- func (connMulti *ConnectionMulti) Select(space, index interface{}, offset, limit, iterator uint32, key interface{}) (resp *tarantool.Response, err error)
- func (connMulti *ConnectionMulti) SelectAsync(space, index interface{}, offset, limit, iterator uint32, key interface{}) *tarantool.Future
- func (connMulti *ConnectionMulti) SelectTyped(space, index interface{}, offset, limit, iterator uint32, key interface{}, ...) (err error)
- func (connMulti *ConnectionMulti) Update(space, index interface{}, key, ops interface{}) (resp *tarantool.Response, err error)
- func (connMulti *ConnectionMulti) UpdateAsync(space, index interface{}, key, ops interface{}) *tarantool.Future
- func (connMulti *ConnectionMulti) UpdateTyped(space, index interface{}, key, ops interface{}, result interface{}) (err error)
- func (connMulti *ConnectionMulti) Upsert(space interface{}, tuple, ops interface{}) (resp *tarantool.Response, err error)
- func (connMulti *ConnectionMulti) UpsertAsync(space interface{}, tuple interface{}, ops interface{}) *tarantool.Future
- type OptsMulti
Examples ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type ConnectionMulti ¶
type ConnectionMulti struct {
// contains filtered or unexported fields
}
ConnectionMulti is a handle with connections to a number of Tarantool instances.
It is created and configured with Connect function, and could not be reconfigured later.
func Connect ¶
func Connect(addrs []string, connOpts tarantool.Opts) (connMulti *ConnectionMulti, err error)
Connect creates and configures new ConnectionMulti.
Example ¶
multiConn, err := Connect([]string{"127.0.0.1:3031", "127.0.0.1:3032"}, tarantool.Opts{ Timeout: 5 * time.Second, User: "test", Pass: "test", }) if err != nil { fmt.Printf("error in connect is %v", err) } fmt.Println(multiConn)
Output:
func ConnectWithOpts ¶
func ConnectWithOpts(addrs []string, connOpts tarantool.Opts, opts OptsMulti) (connMulti *ConnectionMulti, err error)
Connect creates and configures new ConnectionMulti with multiconnection options.
Example ¶
multiConn, err := ConnectWithOpts([]string{"127.0.0.1:3301", "127.0.0.1:3302"}, tarantool.Opts{ Timeout: 5 * time.Second, User: "test", Pass: "test", }, OptsMulti{ // Check for connection timeout every 1 second. CheckTimeout: 1 * time.Second, // Lua function name for getting address list. NodesGetFunctionName: "get_cluster_nodes", // Ask server for updated address list every 3 seconds. ClusterDiscoveryTime: 3 * time.Second, }) if err != nil { fmt.Printf("error in connect is %v", err) } fmt.Println(multiConn)
Output:
func (*ConnectionMulti) Call ¶
func (connMulti *ConnectionMulti) Call(functionName string, args interface{}) (resp *tarantool.Response, err error)
Call calls registered Tarantool function. It uses request code for Tarantool >= 1.7 if go-tarantool was build with go_tarantool_call_17 tag. Otherwise, uses request code for Tarantool 1.6.
func (*ConnectionMulti) Call16 ¶ added in v1.7.0
func (connMulti *ConnectionMulti) Call16(functionName string, args interface{}) (resp *tarantool.Response, err error)
Call16 calls registered Tarantool function. It uses request code for Tarantool 1.6, so result is converted to array of arrays. Deprecated since Tarantool 1.7.2.
func (*ConnectionMulti) Call16Async ¶ added in v1.7.0
func (connMulti *ConnectionMulti) Call16Async(functionName string, args interface{}) *tarantool.Future
Call16Async 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. Deprecated since Tarantool 1.7.2.
func (*ConnectionMulti) Call16Typed ¶ added in v1.7.0
func (connMulti *ConnectionMulti) Call16Typed(functionName string, args interface{}, result interface{}) (err error)
Call16Typed calls registered function. It uses request code for Tarantool 1.6, so result is converted to array of arrays. Deprecated since Tarantool 1.7.2.
func (*ConnectionMulti) Call17 ¶
func (connMulti *ConnectionMulti) Call17(functionName string, args interface{}) (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).
func (*ConnectionMulti) Call17Async ¶
func (connMulti *ConnectionMulti) Call17Async(functionName string, args interface{}) *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 (*ConnectionMulti) Call17Typed ¶
func (connMulti *ConnectionMulti) Call17Typed(functionName string, args interface{}, result interface{}) (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 (*ConnectionMulti) CallAsync ¶
func (connMulti *ConnectionMulti) CallAsync(functionName string, args interface{}) *tarantool.Future
CallAsync sends a call to registered Tarantool function and returns Future. It uses request code for Tarantool >= 1.7 if go-tarantool was build with go_tarantool_call_17 tag. Otherwise, uses request code for Tarantool 1.6.
func (*ConnectionMulti) CallTyped ¶
func (connMulti *ConnectionMulti) CallTyped(functionName string, args interface{}, result interface{}) (err error)
CallTyped calls registered function. It uses request code for Tarantool >= 1.7 if go-tarantool was build with go_tarantool_call_17 tag. Otherwise, uses request code for Tarantool 1.6.
func (*ConnectionMulti) Close ¶
func (connMulti *ConnectionMulti) Close() (err error)
Close closes Connection. After this method called, there is no way to reopen this Connection.
func (*ConnectionMulti) ConfiguredTimeout ¶
func (connMulti *ConnectionMulti) ConfiguredTimeout() time.Duration
ConfiguredTimeout returns a timeout from connection config.
func (*ConnectionMulti) ConnectedNow ¶
func (connMulti *ConnectionMulti) ConnectedNow() bool
ConnectedNow reports if connection is established at the moment.
func (*ConnectionMulti) Delete ¶
func (connMulti *ConnectionMulti) Delete(space, index interface{}, key interface{}) (resp *tarantool.Response, err error)
Delete performs deletion of a tuple by key. Result will contain array with deleted tuple.
func (*ConnectionMulti) DeleteAsync ¶
func (connMulti *ConnectionMulti) DeleteAsync(space, index interface{}, key interface{}) *tarantool.Future
DeleteAsync sends deletion action to Tarantool and returns Future. Future's result will contain array with deleted tuple.
func (*ConnectionMulti) DeleteTyped ¶
func (connMulti *ConnectionMulti) DeleteTyped(space, index interface{}, key interface{}, result interface{}) (err error)
DeleteTyped performs deletion of a tuple by key and fills result with deleted tuple.
func (*ConnectionMulti) Do ¶ added in v1.7.0
func (connMulti *ConnectionMulti) Do(req tarantool.Request) *tarantool.Future
Do sends the request and returns a future.
func (*ConnectionMulti) Eval ¶
func (connMulti *ConnectionMulti) Eval(expr string, args interface{}) (resp *tarantool.Response, err error)
Eval passes Lua expression for evaluation.
func (*ConnectionMulti) EvalAsync ¶
func (connMulti *ConnectionMulti) EvalAsync(expr string, args interface{}) *tarantool.Future
EvalAsync passes Lua expression for evaluation.
func (*ConnectionMulti) EvalTyped ¶
func (connMulti *ConnectionMulti) EvalTyped(expr string, args interface{}, result interface{}) (err error)
EvalTyped passes Lua expression for evaluation.
func (*ConnectionMulti) Execute ¶
func (connMulti *ConnectionMulti) Execute(expr string, args interface{}) (resp *tarantool.Response, err error)
Execute passes sql expression to Tarantool for execution.
Since 1.6.0
func (*ConnectionMulti) ExecuteAsync ¶ added in v1.7.0
func (connMulti *ConnectionMulti) ExecuteAsync(expr string, args interface{}) *tarantool.Future
ExecuteAsync passes sql expression to Tarantool for execution.
func (*ConnectionMulti) ExecuteTyped ¶ added in v1.7.0
func (connMulti *ConnectionMulti) ExecuteTyped(expr string, args interface{}, result interface{}) (tarantool.SQLInfo, []tarantool.ColumnMetaData, error)
ExecuteTyped passes sql expression to Tarantool for execution.
func (*ConnectionMulti) GetTyped ¶
func (connMulti *ConnectionMulti) GetTyped(space, index interface{}, key interface{}, result interface{}) (err error)
GetTyped performs select (with limit = 1 and offset = 0) to box space and fills typed result.
func (*ConnectionMulti) Insert ¶
func (connMulti *ConnectionMulti) Insert(space interface{}, tuple interface{}) (resp *tarantool.Response, err error)
Insert performs insertion to box space. Tarantool will reject Insert when tuple with same primary key exists.
func (*ConnectionMulti) InsertAsync ¶
func (connMulti *ConnectionMulti) InsertAsync(space interface{}, tuple interface{}) *tarantool.Future
InsertAsync sends insert action to Tarantool and returns Future. Tarantool will reject Insert when tuple with same primary key exists.
func (*ConnectionMulti) InsertTyped ¶
func (connMulti *ConnectionMulti) InsertTyped(space interface{}, tuple interface{}, result interface{}) (err error)
InsertTyped performs insertion to box space. Tarantool will reject Insert when tuple with same primary key exists.
func (*ConnectionMulti) NewPrepared ¶ added in v1.7.0
func (connMulti *ConnectionMulti) NewPrepared(expr string) (*tarantool.Prepared, error)
NewPrepared passes a sql statement to Tarantool for preparation synchronously.
func (*ConnectionMulti) NewStream ¶ added in v1.7.0
func (connMulti *ConnectionMulti) NewStream() (*tarantool.Stream, error)
NewStream creates new Stream object for connection.
Since v. 2.10.0, Tarantool supports streams and interactive transactions over them. To use interactive transactions, memtx_use_mvcc_engine box option should be set to true. Since 1.7.0
func (*ConnectionMulti) NewWatcher ¶ added in v1.10.0
func (connMulti *ConnectionMulti) NewWatcher(key string, callback tarantool.WatchCallback) (tarantool.Watcher, error)
NewWatcher does not supported by the ConnectionMulti. The ConnectionMulti is deprecated: use ConnectionPool instead.
Since 1.10.0
func (*ConnectionMulti) Ping ¶
func (connMulti *ConnectionMulti) Ping() (resp *tarantool.Response, err error)
Ping sends empty request to Tarantool to check connection.
func (*ConnectionMulti) Replace ¶
func (connMulti *ConnectionMulti) Replace(space interface{}, tuple interface{}) (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.
func (*ConnectionMulti) ReplaceAsync ¶
func (connMulti *ConnectionMulti) ReplaceAsync(space interface{}, tuple interface{}) *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 (*ConnectionMulti) ReplaceTyped ¶
func (connMulti *ConnectionMulti) ReplaceTyped(space interface{}, tuple interface{}, result interface{}) (err error)
ReplaceTyped performs "insert or replace" action to box space. If tuple with same primary key exists, it will be replaced.
func (*ConnectionMulti) Select ¶
func (connMulti *ConnectionMulti) Select(space, index interface{}, offset, limit, iterator uint32, key interface{}) (resp *tarantool.Response, err error)
Select performs select to box space.
func (*ConnectionMulti) SelectAsync ¶
func (connMulti *ConnectionMulti) SelectAsync(space, index interface{}, offset, limit, iterator uint32, key interface{}) *tarantool.Future
SelectAsync sends select request to Tarantool and returns Future.
func (*ConnectionMulti) SelectTyped ¶
func (connMulti *ConnectionMulti) SelectTyped(space, index interface{}, offset, limit, iterator uint32, key interface{}, result interface{}) (err error)
SelectTyped performs select to box space and fills typed result.
func (*ConnectionMulti) Update ¶
func (connMulti *ConnectionMulti) Update(space, index interface{}, key, ops interface{}) (resp *tarantool.Response, err error)
Update performs update of a tuple by key. Result will contain array with updated tuple.
func (*ConnectionMulti) UpdateAsync ¶
func (connMulti *ConnectionMulti) UpdateAsync(space, index interface{}, key, ops interface{}) *tarantool.Future
Update sends deletion of a tuple by key and returns Future. Future's result will contain array with updated tuple.
func (*ConnectionMulti) UpdateTyped ¶
func (connMulti *ConnectionMulti) UpdateTyped(space, index interface{}, key, ops interface{}, result interface{}) (err error)
UpdateTyped performs update of a tuple by key and fills result with updated tuple.
func (*ConnectionMulti) Upsert ¶
func (connMulti *ConnectionMulti) Upsert(space interface{}, tuple, ops interface{}) (resp *tarantool.Response, err error)
Upsert performs "update or insert" action of a tuple by key. Result will not contain any tuple.
func (*ConnectionMulti) UpsertAsync ¶
func (connMulti *ConnectionMulti) UpsertAsync(space interface{}, tuple interface{}, ops interface{}) *tarantool.Future
UpsertAsync sends "update or insert" action to Tarantool and returns Future. Future's sesult will not contain any tuple.
type OptsMulti ¶
type OptsMulti struct { // CheckTimeout is a time interval to check for connection timeout and try to // switch connection. CheckTimeout time.Duration // Lua function name of the server called to retrieve the address list. NodesGetFunctionName string // Time interval to ask the server for an updated address list (works // if NodesGetFunctionName is set). ClusterDiscoveryTime time.Duration }
OptsMulti is a way to configure Connection with multiconnect-specific options.