Documentation ¶
Index ¶
- func DeregisterDialer(name string)
- func GetVTGateProtocol() string
- func RegisterDialer(name string, dialer DialerFunc)
- func SetVTGateProtocol(protocol string)
- type DialerFunc
- type Impl
- type VStreamReader
- type VTGateConn
- func (conn *VTGateConn) Close()
- func (conn *VTGateConn) ResolveTransaction(ctx context.Context, dtid string) error
- func (conn *VTGateConn) Session(targetString string, options *querypb.ExecuteOptions) *VTGateSession
- func (conn *VTGateConn) SessionFromPb(sn *vtgatepb.Session) *VTGateSession
- func (conn *VTGateConn) VStream(ctx context.Context, tabletType topodatapb.TabletType, ...) (VStreamReader, error)
- type VTGateSession
- func (sn *VTGateSession) Execute(ctx context.Context, query string, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)
- func (sn *VTGateSession) ExecuteBatch(ctx context.Context, query []string, ...) ([]sqltypes.QueryResponse, error)
- func (sn *VTGateSession) Prepare(ctx context.Context, query string, bindVars map[string]*querypb.BindVariable) ([]*querypb.Field, error)
- func (sn *VTGateSession) SessionPb() *vtgatepb.Session
- func (sn *VTGateSession) StreamExecute(ctx context.Context, query string, bindVars map[string]*querypb.BindVariable) (sqltypes.ResultStream, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeregisterDialer ¶ added in v0.16.0
func DeregisterDialer(name string)
DeregisterDialer removes the named DialerFunc from the registered list of dialers. If the named DialerFunc does not exist, it is a noop.
This is useful to avoid unbounded memory use if many different dialer implementations are used throughout the lifetime of a program.
func GetVTGateProtocol ¶ added in v0.15.0
func GetVTGateProtocol() string
GetVTGateProtocol returns the protocol used to connect to vtgate as provided in the flag.
func RegisterDialer ¶
func RegisterDialer(name string, dialer DialerFunc)
RegisterDialer is meant to be used by Dialer implementations to self register.
func SetVTGateProtocol ¶ added in v0.15.0
func SetVTGateProtocol(protocol string)
SetVTGateProtocol set the protocol to be used to connect to vtgate.
Types ¶
type DialerFunc ¶
DialerFunc represents a function that will return an Impl object that can communicate with a VTGate.
type Impl ¶
type Impl interface { // Execute executes a non-streaming query on vtgate. This is a V3 function. Execute(ctx context.Context, session *vtgatepb.Session, query string, bindVars map[string]*querypb.BindVariable) (*vtgatepb.Session, *sqltypes.Result, error) // ExecuteBatch executes a non-streaming queries on vtgate. This is a V3 function. ExecuteBatch(ctx context.Context, session *vtgatepb.Session, queryList []string, bindVarsList []map[string]*querypb.BindVariable) (*vtgatepb.Session, []sqltypes.QueryResponse, error) // StreamExecute executes a streaming query on vtgate. This is a V3 function. StreamExecute(ctx context.Context, session *vtgatepb.Session, query string, bindVars map[string]*querypb.BindVariable, processResponse func(*vtgatepb.StreamExecuteResponse)) (sqltypes.ResultStream, error) // Prepare returns the fields information for the query as part of supporting prepare statements. Prepare(ctx context.Context, session *vtgatepb.Session, sql string, bindVariables map[string]*querypb.BindVariable) (*vtgatepb.Session, []*querypb.Field, error) // CloseSession closes the session provided by rolling back any active transaction. CloseSession(ctx context.Context, session *vtgatepb.Session) error // ResolveTransaction resolves the specified 2pc transaction. ResolveTransaction(ctx context.Context, dtid string) error // VStream streams binlogevents VStream(ctx context.Context, tabletType topodatapb.TabletType, vgtid *binlogdatapb.VGtid, filter *binlogdatapb.Filter, flags *vtgatepb.VStreamFlags) (VStreamReader, error) // Close must be called for releasing resources. Close() }
Impl defines the interface for a vtgate client protocol implementation. It can be used concurrently across goroutines.
type VStreamReader ¶
type VStreamReader interface { // Recv returns the next result on the stream. // It will return io.EOF if the stream ended. Recv() ([]*binlogdatapb.VEvent, error) }
VStreamReader is returned by VStream.
type VTGateConn ¶
type VTGateConn struct {
// contains filtered or unexported fields
}
VTGateConn is the client API object to talk to vtgate. It can support concurrent sessions. It is constructed using the Dial method.
func Dial ¶
func Dial(ctx context.Context, address string) (*VTGateConn, error)
Dial dials using the command-line specified protocol, and returns the *VTGateConn.
func DialProtocol ¶
DialProtocol dials a specific protocol, and returns the *VTGateConn
func (*VTGateConn) Close ¶
func (conn *VTGateConn) Close()
Close must be called for releasing resources.
func (*VTGateConn) ResolveTransaction ¶
func (conn *VTGateConn) ResolveTransaction(ctx context.Context, dtid string) error
ResolveTransaction resolves the 2pc transaction.
func (*VTGateConn) Session ¶
func (conn *VTGateConn) Session(targetString string, options *querypb.ExecuteOptions) *VTGateSession
Session returns a VTGateSession that can be used to access V3 functions.
func (*VTGateConn) SessionFromPb ¶ added in v0.13.0
func (conn *VTGateConn) SessionFromPb(sn *vtgatepb.Session) *VTGateSession
SessionFromPb returns a VTGateSession based on the provided proto session.
func (*VTGateConn) VStream ¶
func (conn *VTGateConn) VStream(ctx context.Context, tabletType topodatapb.TabletType, vgtid *binlogdatapb.VGtid, filter *binlogdatapb.Filter, flags *vtgatepb.VStreamFlags) (VStreamReader, error)
VStream streams binlog events.
type VTGateSession ¶
type VTGateSession struct {
// contains filtered or unexported fields
}
VTGateSession exposes the V3 API to the clients. The object maintains client-side state and is comparable to a native MySQL connection. For example, if you enable autocommit on a Session object, all subsequent calls will respect this. Functions within an object must not be called concurrently. You can create as many objects as you want. All of them will share the underlying connection to vtgate ("VTGateConn" object).
func (*VTGateSession) Execute ¶
func (sn *VTGateSession) Execute(ctx context.Context, query string, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error)
Execute performs a VTGate Execute.
func (*VTGateSession) ExecuteBatch ¶
func (sn *VTGateSession) ExecuteBatch(ctx context.Context, query []string, bindVars []map[string]*querypb.BindVariable) ([]sqltypes.QueryResponse, error)
ExecuteBatch executes a list of queries on vtgate within the current transaction.
func (*VTGateSession) Prepare ¶ added in v0.11.0
func (sn *VTGateSession) Prepare(ctx context.Context, query string, bindVars map[string]*querypb.BindVariable) ([]*querypb.Field, error)
Prepare performs a VTGate Prepare.
func (*VTGateSession) SessionPb ¶ added in v0.13.0
func (sn *VTGateSession) SessionPb() *vtgatepb.Session
SessionPb returns the underlying proto session.
func (*VTGateSession) StreamExecute ¶
func (sn *VTGateSession) StreamExecute(ctx context.Context, query string, bindVars map[string]*querypb.BindVariable) (sqltypes.ResultStream, error)
StreamExecute executes a streaming query on vtgate. It returns a ResultStream and an error. First check the error. Then you can pull values from the ResultStream until io.EOF, or another error.