func (db *DB) Master() *DB {
	if db.master == nil {
		panic(ErrNoMaster)
	}
	return db.master
}
Master return *DB instance direct use master conn
use this *DB instance only when you have some reason need to get result without any delay.
package sql
import (
	"context"
	"database/sql"
	"sync/atomic"
	"github.com/pkg/errors"
	"github.com/go-eagle/eagle/pkg/errcode"
)
type DB struct {
	write  *conn
	read   []*conn
	idx    int64
	master *DB
}
func (db *DB) Begin(ctx context.Context) (tx *Tx, err error) {
	return db.write.begin(ctx)
}
func (db *DB) Exec(ctx context.Context, query string, args ...interface{}) (res sql.Result, err error) {
	return db.write.exec(ctx, query, args...)
}
func (db *DB) Prepare(query string) (*Stmt, error) {
	return db.write.prepare(query)
}
func (db *DB) Prepared(query string) (stmt *Stmt) {
	return db.write.prepared(query)
}
func (db *DB) Query(ctx context.Context, query string, args ...interface{}) (rows *Rows, err error) {
	idx := db.readIndex()
	for i := range db.read {
		if rows, err = db.read[(idx+i)%len(db.read)].query(ctx, query, args...); !errors.Is(errcode.ErrServiceUnavailable, err) {
			return
		}
	}
	return db.write.query(ctx, query, args...)
}
func (db *DB) QueryRow(ctx context.Context, query string, args ...interface{}) *Row {
	idx := db.readIndex()
	for i := range db.read {
		if row := db.read[(idx+i)%len(db.read)].queryRow(ctx, query, args...); !errors.Is(errcode.ErrServiceUnavailable, row.err) {
			return row
		}
	}
	return db.write.queryRow(ctx, query, args...)
}
func (db *DB) readIndex() int {
	if len(db.read) == 0 {
		return 0
	}
	v := atomic.AddInt64(&db.idx, 1)
	return int(v) % len(db.read)
}
func (db *DB) Close() (err error) {
	if e := db.write.Close(); e != nil {
		err = errors.WithStack(e)
	}
	for _, rd := range db.read {
		if e := rd.Close(); e != nil {
			err = errors.WithStack(e)
		}
	}
	return
}
func (db *DB) Ping(ctx context.Context) (err error) {
	if err = db.write.ping(ctx); err != nil {
		return
	}
	for _, rd := range db.read {
		if err = rd.ping(ctx); err != nil {
			return
		}
	}
	return
}