tarantool / go-tarantool

Tarantool 1.10+ client for Go language
https://pkg.go.dev/github.com/tarantool/go-tarantool/v2
BSD 2-Clause "Simplified" License
180 stars 57 forks source link

v2: improve pool.Connect interface #356

Closed oleg-jukovec closed 7 months ago

oleg-jukovec commented 9 months ago

The current interface:

func Connect(ctx context.Context, dialers map[string]tarantool.Dialer, connOpts tarantool.Opts) (*ConnectionPool, error)

It has two disadvantages:

  1. It does not allow to use different connect options for different connections.
  2. It could be tricky to initialize a map of dialers.

I suggest a small refactoring:

  1. Add the Server type to the pool package, which would describe one server for a pool:
    type Server struct {
    Id     string
    Dialer tarantool.Dialer
    Opts   tarantool.Opts
    }
  2. Update the pool.Connect interface:
    func Connect(ctx context.Context, servers ...Server) (*ConnectionPool, error)
  3. Update pool.ConnectWithOpts:
    func ConnectWithOpts(ctx context.Context, opts Opts, servers ...Server) (*ConnectionPool, error)
  4. Update pool.Add:
    func (p *ConnectionPool) Add(ctx context.Context, server Server) error