diff --git a/connection.go b/connection.go index aa27953b1..896e5ebe7 100644 --- a/connection.go +++ b/connection.go @@ -293,6 +293,12 @@ type SslOpts struct { Ciphers string } +func (opts Opts) Copy() Opts { + optsCopy := opts + + return optsCopy +} + // Connect creates and configures a new Connection. // // Address could be specified in following ways: @@ -319,7 +325,7 @@ func Connect(addr string, opts Opts) (conn *Connection, err error) { contextRequestId: 1, Greeting: &Greeting{}, control: make(chan struct{}), - opts: opts, + opts: opts.Copy(), dec: newDecoder(&smallBuf{}), } maxprocs := uint32(runtime.GOMAXPROCS(-1)) @@ -344,9 +350,9 @@ func Connect(addr string, opts Opts) (conn *Connection, err error) { } } - if opts.RateLimit > 0 { - conn.rlimit = make(chan struct{}, opts.RateLimit) - if opts.RLimitAction != RLimitDrop && opts.RLimitAction != RLimitWait { + if conn.opts.RateLimit > 0 { + conn.rlimit = make(chan struct{}, conn.opts.RateLimit) + if conn.opts.RLimitAction != RLimitDrop && conn.opts.RLimitAction != RLimitWait { return nil, errors.New("RLimitAction should be specified to RLimitDone nor RLimitWait") } } diff --git a/connection_pool/connection_pool.go b/connection_pool/connection_pool.go index 6597e2dd0..e88e5360c 100644 --- a/connection_pool/connection_pool.go +++ b/connection_pool/connection_pool.go @@ -125,7 +125,7 @@ func ConnectWithOpts(addrs []string, connOpts tarantool.Opts, opts OptsPool) (co connPool = &ConnectionPool{ addrs: make([]string, 0, len(addrs)), - connOpts: connOpts, + connOpts: connOpts.Copy(), opts: opts, state: unknownState, done: make(chan struct{}), diff --git a/multi/multi.go b/multi/multi.go index 67f450c5c..8729b74ae 100644 --- a/multi/multi.go +++ b/multi/multi.go @@ -88,7 +88,7 @@ func ConnectWithOpts(addrs []string, connOpts tarantool.Opts, opts OptsMulti) (c connOpts.Notify = notify connMulti = &ConnectionMulti{ addrs: addrs, - connOpts: connOpts, + connOpts: connOpts.Copy(), opts: opts, notify: notify, control: make(chan struct{}),