Documentation ¶
Index ¶
- Variables
- func RegisterDialer(name string, dialer DialerFunc)
- 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) 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) StreamExecute(ctx context.Context, query string, bindVars map[string]*querypb.BindVariable) (sqltypes.ResultStream, error)
Constants ¶
This section is empty.
Variables ¶
var ( // VtgateProtocol defines the RPC implementation used for connecting to vtgate. VtgateProtocol = flag.String("vtgate_protocol", "grpc", "how to talk to vtgate") )
Functions ¶
func RegisterDialer ¶
func RegisterDialer(name string, dialer DialerFunc)
RegisterDialer is meant to be used by Dialer implementations to self register.
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) (sqltypes.ResultStream, 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) 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) 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.