Documentation ¶
Index ¶
- Constants
- Variables
- func AuthServerNegotiateClearOrDialog(c *Conn, method string) (string, error)
- func AuthServerReadPacketString(c *Conn) (string, error)
- func GetMysqlVars() *sqltypes.Result
- func IsNum(typ uint8) bool
- func NewSalt() ([]byte, error)
- func ParseErrorPacket(data []byte) error
- func RegisterAuthServerImpl(name string, authServer AuthServer)
- func RowToSQL(row SQLRow) []sqltypes.Value
- func SchemaToFields(s Schema) []*query.Field
- func ScramblePassword(salt, password []byte) []byte
- type AuthServer
- type AuthServerNone
- func (a *AuthServerNone) AuthMethod(user string) (string, error)
- func (a *AuthServerNone) Negotiate(c *Conn, user string, remotAddr net.Addr) (Getter, error)
- func (a *AuthServerNone) Salt() ([]byte, error)
- func (a *AuthServerNone) ValidateHash(salt []byte, user string, authResponse []byte, remoteAddr net.Addr) (Getter, error)
- type AuthServerStatic
- func (a *AuthServerStatic) AuthMethod(user string) (string, error)
- func (a *AuthServerStatic) Negotiate(c *Conn, user string, remoteAddr net.Addr) (Getter, error)
- func (a *AuthServerStatic) Salt() ([]byte, error)
- func (a *AuthServerStatic) ValidateHash(salt []byte, user string, authResponse []byte, remoteAddr net.Addr) (Getter, error)
- type AuthServerStaticEntry
- type Column
- type Conn
- func (c *Conn) Close()
- func (c *Conn) ExecuteFetch(query string, maxrows int, wantfields bool) (result *sqltypes.Result, err error)
- func (c *Conn) ExecuteFetchMulti(query string, maxrows int, wantfields bool) (result *sqltypes.Result, more bool, err error)
- func (c *Conn) ExecuteFetchWithWarningCount(query string, maxrows int, wantfields bool) (result *sqltypes.Result, warnings uint16, err error)
- func (c *Conn) ID() int64
- func (c *Conn) IsClosed() bool
- func (c *Conn) ReadPacket() ([]byte, error)
- func (c *Conn) ReadQueryResult(maxrows int, wantfields bool) (result *sqltypes.Result, more bool, warnings uint16, err error)
- func (c *Conn) RecycleReadPacket()
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) RequestFile(filename string) []byte
- func (c *Conn) String() string
- func (c *Conn) WriteComQuery(query string) error
- func (c *Conn) WriteErrorResponse(error string)
- type ConnParams
- type Getter
- type Handler
- type Listener
- type ListenerConfig
- type NoneGetter
- type SQLError
- type SQLRow
- type Schema
- type StaticUserData
Constants ¶
const ( // MysqlNativePassword uses a salt and transmits a hash on the wire. MysqlNativePassword = "mysql_native_password" // MysqlClearPassword transmits the password in the clear. MysqlClearPassword = "mysql_clear_password" // MysqlDialog uses the dialog plugin on the client side. // It transmits data in the clear. MysqlDialog = "dialog" )
Supported auth forms.
const ( // CapabilityClientLongPassword is CLIENT_LONG_PASSWORD. // New more secure passwords. Assumed to be set since 4.1.1. // We do not check this anywhere. CapabilityClientLongPassword = 1 // CapabilityClientFoundRows is CLIENT_FOUND_ROWS. CapabilityClientFoundRows = 1 << 1 // CapabilityClientLongFlag is CLIENT_LONG_FLAG. // Longer flags in Protocol::ColumnDefinition320. // Set it everywhere, not used, as we use Protocol::ColumnDefinition41. CapabilityClientLongFlag = 1 << 2 // CapabilityClientConnectWithDB is CLIENT_CONNECT_WITH_DB. // One can specify db on connect. CapabilityClientConnectWithDB = 1 << 3 // CLIENT_LOCAL_FILES 1 << 7 // Client can use LOCAL INFILE request of LOAD DATA|XML. // We do not set it. CapabilityClientLoadDataLocal = 1 << 7 // CapabilityClientProtocol41 is CLIENT_PROTOCOL_41. // New 4.1 protocol. Enforced everywhere. CapabilityClientProtocol41 = 1 << 9 // CapabilityClientSSL is CLIENT_SSL. // Switch to SSL after handshake. CapabilityClientSSL = 1 << 11 // CapabilityClientTransactions is CLIENT_TRANSACTIONS. // Can send status flags in EOF_Packet. // This flag is optional in 3.23, but always set by the server since 4.0. // We just do it all the time. CapabilityClientTransactions = 1 << 13 // CapabilityClientSecureConnection is CLIENT_SECURE_CONNECTION. // New 4.1 authentication. Always set, expected, never checked. CapabilityClientSecureConnection = 1 << 15 // CapabilityClientMultiStatements is CLIENT_MULTI_STATEMENTS // Can handle multiple statements per COM_QUERY and COM_STMT_PREPARE. CapabilityClientMultiStatements = 1 << 16 // CapabilityClientMultiResults is CLIENT_MULTI_RESULTS // Can send multiple resultsets for COM_QUERY. CapabilityClientMultiResults = 1 << 17 // CapabilityClientPluginAuth is CLIENT_PLUGIN_AUTH. // Client supports plugin authentication. CapabilityClientPluginAuth = 1 << 19 // CapabilityClientConnAttr is CLIENT_CONNECT_ATTRS // Permits connection attributes in Protocol::HandshakeResponse41. CapabilityClientConnAttr = 1 << 20 // CapabilityClientPluginAuthLenencClientData is CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA CapabilityClientPluginAuthLenencClientData = 1 << 21 // CapabilityClientDeprecateEOF is CLIENT_DEPRECATE_EOF // Expects an OK (instead of EOF) after the resultset rows of a Text Resultset. CapabilityClientDeprecateEOF = 1 << 24 )
Capability flags. Originally found in include/mysql/mysql_com.h
const ( // ComQuit is COM_QUIT. ComQuit = 0x01 // ComInitDB is COM_INIT_DB. ComInitDB = 0x02 // ComQuery is COM_QUERY. ComQuery = 0x03 // ComPing is COM_PING. ComPing = 0x0e // ComSetOption is COM_SET_OPTION ComSetOption = 0x1b // OKPacket is the header of the OK packet. OKPacket = 0x00 // EOFPacket is the header of the EOF packet. EOFPacket = 0xfe // AuthSwitchRequestPacket is used to switch auth method. AuthSwitchRequestPacket = 0xfe // ErrPacket is the header of the error packet. ErrPacket = 0xff // NullValue is the encoded value of NULL. NullValue = 0xfb )
Packet types. Originally found in include/mysql/mysql_com.h
const ( // CRUnknownError is CR_UNKNOWN_ERROR CRUnknownError = 2000 // CRServerGone is CR_SERVER_GONE_ERROR. // This is returned if the client tries to send a command but it fails. CRServerGone = 2006 // CRServerHandshakeErr is CR_SERVER_HANDSHAKE_ERR CRServerHandshakeErr = 2012 // CRServerLost is CR_SERVER_LOST. // Used when: // - the client cannot write an initial auth packet. // - the client cannot read an initial auth packet. // - the client cannot read a response from the server. CRServerLost = 2013 // CRMalformedPacket is CR_MALFORMED_PACKET CRMalformedPacket = 2027 )
Error codes for client-side errors. Originally found in include/mysql/errmsg.h and https://dev.mysql.com/doc/refman/5.7/en/error-messages-client.html
const ( // unknown ERUnknownError = 1105 // unavailable ERServerShutdown = 1053 // permissions ERAccessDeniedError = 1045 // invalid arg ERUnknownComError = 1047 ERParseError = 1064 )
Error codes for server-side errors. Originally found in include/mysql/mysqld_error.h and https://dev.mysql.com/doc/refman/5.7/en/error-messages-server.html The below are in sorted order by value, grouped by vterror code they should be bucketed into. See above reference for more information on each code.
const ( // SSUnknownSqlstate is ER_SIGNAL_EXCEPTION in // include/mysql/sql_state.h, but: // const char *unknown_sqlstate= "HY000" // in client.c. So using that one. SSUnknownSQLState = "HY000" // SSUnknownComError is ER_UNKNOWN_COM_ERROR SSUnknownComError = "08S01" // SSServerShutdown is ER_SERVER_SHUTDOWN SSServerShutdown = "08S01" // SSAccessDeniedError is ER_ACCESS_DENIED_ERROR SSAccessDeniedError = "28000" )
Sql states for errors. Originally found in include/mysql/sql_state.h
const ( // CharacterSetUtf8 is for UTF8. We use this by default. CharacterSetUtf8 = 33 // CharacterSetBinary is for binary. Use by integer fields for instance. CharacterSetBinary = 63 )
A few interesting character set values. See http://dev.mysql.com/doc/internals/en/character-set.html#packet-Protocol::CharacterSet
const (
// ERVitessMaxRowsExceeded is when a user tries to select more rows than the max rows as enforced by vitess.
ERVitessMaxRowsExceeded = 10001
)
Error codes return in SQLErrors generated by vitess. These error codes are in a high range to avoid conflicting with mysql error codes below.
const ( // MaxPacketSize is the maximum payload length of a packet // the server supports. MaxPacketSize = (1 << 24) - 1 )
const (
// ServerMoreResultsExists is SERVER_MORE_RESULTS_EXISTS
ServerMoreResultsExists = 0x0008
)
Status flags. They are returned by the server in a few cases. Originally found in include/mysql/mysql_com.h See http://dev.mysql.com/doc/internals/en/status-flags.html
Variables ¶
var CharacterSetMap = map[string]uint8{ "big5": 1, "dec8": 3, "cp850": 4, "hp8": 6, "koi8r": 7, "latin1": 8, "latin2": 9, "swe7": 10, "ascii": 11, "ujis": 12, "sjis": 13, "hebrew": 16, "tis620": 18, "euckr": 19, "koi8u": 22, "gb2312": 24, "greek": 25, "cp1250": 26, "gbk": 28, "latin5": 30, "armscii8": 32, "utf8": CharacterSetUtf8, "ucs2": 35, "cp866": 36, "keybcs2": 37, "macce": 38, "macroman": 39, "cp852": 40, "latin7": 41, "utf8mb4": 45, "cp1251": 51, "utf16": 54, "utf16le": 56, "cp1256": 57, "cp1257": 59, "utf32": 60, "binary": CharacterSetBinary, "geostd8": 92, "cp932": 95, "eucjpms": 97, }
CharacterSetMap maps the charset name (used in ConnParams) to the integer value. Interesting ones have their own constant above.
Functions ¶
func AuthServerNegotiateClearOrDialog ¶
AuthServerNegotiateClearOrDialog will finish a negotiation based on the method type for the connection. Only supports MysqlClearPassword and MysqlDialog.
func AuthServerReadPacketString ¶
AuthServerReadPacketString is a helper method to read a packet as a null terminated string. It is used by the mysql_clear_password and dialog plugins.
func GetMysqlVars ¶
func IsNum ¶
IsNum returns true if a MySQL type is a numeric value. It is the same as IS_NUM defined in mysql.h.
FIXME(alainjobart) This needs to use the constants in replication/constants.go, so we are using numerical values here.
func ParseErrorPacket ¶
ParseErrorPacket parses the error packet and returns a SQLError.
func RegisterAuthServerImpl ¶
func RegisterAuthServerImpl(name string, authServer AuthServer)
RegisterAuthServerImpl registers an implementations of AuthServer.
func SchemaToFields ¶
func ScramblePassword ¶
ScramblePassword computes the hash of the password using 4.1+ method.
Types ¶
type AuthServer ¶
type AuthServer interface { // AuthMethod returns the authentication method to use for the // given user. If this returns MysqlNativePassword // (mysql_native_password), then ValidateHash() will be // called, and no further roundtrip with the client is // expected. If anything else is returned, Negotiate() // will be called on the connection, and the AuthServer // needs to handle the packets. AuthMethod(user string) (string, error) // Salt returns the salt to use for a connection. // It should be 20 bytes of data. // Most implementations should just use mysql.NewSalt(). // (this is meant to support a plugin that would use an // existing MySQL server as the source of auth, and just forward // the salt generated by that server). // Do not return zero bytes, as a known salt can be the source // of a crypto attack. Salt() ([]byte, error) // ValidateHash validates the data sent by the client matches // what the server computes. It also returns the user data. ValidateHash(salt []byte, user string, authResponse []byte, remoteAddr net.Addr) (Getter, error) // Negotiate is called if AuthMethod returns anything else // than MysqlNativePassword. It is handed the connection after the // AuthSwitchRequest packet is sent. // - If the negotiation fails, it should just return an error // (should be a SQLError if possible). // The framework is responsible for writing the Error packet // and closing the connection in that case. // - If the negotiation works, it should return the Getter, // and no error. The framework is responsible for writing the // OK packet. Negotiate(c *Conn, user string, remoteAddr net.Addr) (Getter, error) }
AuthServer is the interface that servers must implement to validate users and passwords. It has two modes:
1. using salt the way MySQL native auth does it. In that case, the password is not sent in the clear, but the salt is used to hash the password both on the client and server side, and the result is sent and compared.
2. sending the user / password in the clear (using MySQL Cleartext method). The server then gets access to both user and password, and can authenticate using any method. If SSL is not used, it means the password is sent in the clear. That may not be suitable for some use cases.
type AuthServerNone ¶
type AuthServerNone struct{}
AuthServerNone takes all comers. It's meant to be used for testing and prototyping. With this config, you can connect to a local vtgate using the following command line: 'mysql -P port -h ::'. It only uses MysqlNativePassword method.
func (*AuthServerNone) AuthMethod ¶
func (a *AuthServerNone) AuthMethod(user string) (string, error)
AuthMethod is part of the AuthServer interface. We always return MysqlNativePassword.
func (*AuthServerNone) Negotiate ¶
Negotiate is part of the AuthServer interface. It will never be called.
func (*AuthServerNone) ValidateHash ¶
func (a *AuthServerNone) ValidateHash(salt []byte, user string, authResponse []byte, remoteAddr net.Addr) (Getter, error)
ValidateHash validates hash
type AuthServerStatic ¶
type AuthServerStatic struct { // Method can be set to: // - MysqlNativePassword // - MysqlClearPassword // - MysqlDialog // It defaults to MysqlNativePassword. Method string // Entries contains the users, passwords and user data. Entries map[string][]*AuthServerStaticEntry // contains filtered or unexported fields }
AuthServerStatic implements AuthServer using a static configuration.
func (*AuthServerStatic) AuthMethod ¶
func (a *AuthServerStatic) AuthMethod(user string) (string, error)
AuthMethod is part of the AuthServer interface.
func (*AuthServerStatic) Negotiate ¶
Negotiate is part of the AuthServer interface. It will be called if Method is anything else than MysqlNativePassword. We only recognize MysqlClearPassword and MysqlDialog here.
func (*AuthServerStatic) Salt ¶
func (a *AuthServerStatic) Salt() ([]byte, error)
Salt is part of the AuthServer interface.
func (*AuthServerStatic) ValidateHash ¶
func (a *AuthServerStatic) ValidateHash(salt []byte, user string, authResponse []byte, remoteAddr net.Addr) (Getter, error)
ValidateHash is part of the AuthServer interface.
type AuthServerStaticEntry ¶
type AuthServerStaticEntry struct { // MysqlNativePassword is generated by password hashing methods in MySQL. // These changes are illustrated by changes in the result from the PASSWORD() function // that computes password hash values and in the structure of the user table where passwords are stored. // mysql> SELECT PASSWORD('mypass'); // +-------------------------------------------+ // | PASSWORD('mypass') | // +-------------------------------------------+ // | *6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4 | // +-------------------------------------------+ // MysqlNativePassword's format looks like "*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4", it store a hashing value. // Use MysqlNativePassword in auth config, maybe more secure. After all, it is cryptographic storage. MysqlNativePassword string Password string UserData string SourceHost string Groups []string }
AuthServerStaticEntry stores the values for a given user.
type Column ¶
type Column struct { // Name is the name of the column. Name string // Type is the data type of the column. Type query.Type // Default contains the default value of the column or nil if it is NULL. Default interface{} // Nullable is true if the column can contain NULL values, or false // otherwise. Nullable bool // Source is the name of the table this column came from. Source string // PrimaryKey is true if the column is part of the primary key for its table. PrimaryKey bool }
type Conn ¶
type Conn struct { // conn is the underlying network connection. // Calling Close() on the Conn will close this connection. // If there are any ongoing reads or writes, they may get interrupted. Conn net.Conn // ConnectionID is set: // - at Connect() time for clients, with the value returned by // the server. // - at accept time for the server. ConnectionID uint32 // Capabilities is the current set of features this connection // is using. It is the features that are both supported by // the client and the server, and currently in use. // It is set during the initial handshake. // // It is only used for CapabilityClientDeprecateEOF // and CapabilityClientFoundRows. Capabilities uint32 // CharacterSet is the character set used by the other side of the // connection. // It is set during the initial handshake. // See the values in constants.go. CharacterSet uint8 // User is the name used by the client to connect. // It is set during the initial handshake. User string // UserData is custom data returned by the AuthServer module. // It is set during the initial handshake. UserData Getter // SchemaName is the default database name to use. It is set // during handshake, and by ComInitDb packets. Both client and // servers maintain it. SchemaName string // ServerVersion is set during Connect with the server // version. It is not changed afterwards. It is unused for // server-side connections. ServerVersion string // StatusFlags are the status flags we will base our returned flags on. // This is a bit field, with values documented in constants.go. // An interesting value here would be ServerStatusAutocommit. // It is only used by the server. These flags can be changed // by Handler methods. StatusFlags uint16 // ClientData is a place where an application can store any // connection-related data. Mostly used on the server side, to // avoid maps indexed by ConnectionID for instance. ClientData interface{} SupportLoadDataLocal bool IsJdbcClient bool ConnAttrs map[string]string Files map[string][]byte Flag string FlagGroup string Vars map[string]string // contains filtered or unexported fields }
func (*Conn) Close ¶
func (c *Conn) Close()
Close closes the connection. It can be called from a different go routine to interrupt the current connection.
func (*Conn) ExecuteFetch ¶
func (c *Conn) ExecuteFetch(query string, maxrows int, wantfields bool) (result *sqltypes.Result, err error)
ExecuteFetch executes a query and returns the result. Returns a SQLError. Depending on the transport used, the error returned might be different for the same condition:
1. if the server closes the connection when no command is in flight:
1.1 unix: WriteComQuery will fail with a 'broken pipe', and we'll return CRServerGone(2006). 1.2 tcp: WriteComQuery will most likely work, but readComQueryResponse will fail, and we'll return CRServerLost(2013). This is because closing a TCP socket on the server side sends a FIN to the client (telling the client the server is done writing), but on most platforms doesn't send a RST. So the client has no idea it can't write. So it succeeds writing data, which *then* triggers the server to send a RST back, received a bit later. By then, the client has already started waiting for the response, and will just return a CRServerLost(2013). So CRServerGone(2006) will almost never be seen with TCP. 2. if the server closes the connection when a command is in flight, readComQueryResponse will fail, and we'll return CRServerLost(2013).
func (*Conn) ExecuteFetchMulti ¶
func (c *Conn) ExecuteFetchMulti(query string, maxrows int, wantfields bool) (result *sqltypes.Result, more bool, err error)
ExecuteFetchMulti is for fetching multiple results from a multi-statement result. It returns an additional 'more' flag. If it is set, you must fetch the additional results using ReadQueryResult.
func (*Conn) ExecuteFetchWithWarningCount ¶
func (c *Conn) ExecuteFetchWithWarningCount(query string, maxrows int, wantfields bool) (result *sqltypes.Result, warnings uint16, err error)
ExecuteFetchWithWarningCount is for fetching results and a warning count Note: In a future iteration this should be abolished and merged into the ExecuteFetch API.
func (*Conn) IsClosed ¶
IsClosed returns true if this connection was ever closed by the Close() method. Note if the other side closes the connection, but Close() wasn't called, this will return false.
func (*Conn) ReadPacket ¶
ReadPacket reads a packet from the underlying connection. it is the public API version, that returns a SQLError. The memory for the packet is always allocated, and it is owned by the caller after this function returns.
func (*Conn) ReadQueryResult ¶
func (c *Conn) ReadQueryResult(maxrows int, wantfields bool) (result *sqltypes.Result, more bool, warnings uint16, err error)
ReadQueryResult gets the result from the last written query.
func (*Conn) RecycleReadPacket ¶
func (c *Conn) RecycleReadPacket()
RecycleReadPacket recycles the read packet. It needs to be called after readEphemeralPacket was called.
func (*Conn) RemoteAddr ¶
RemoteAddr returns the underlying socket RemoteAddr().
func (*Conn) RequestFile ¶
func (*Conn) WriteComQuery ¶
WriteComQuery writes a query for the server to execute. Client -> Server. Returns SQLError(CRServerGone) if it can't.
func (*Conn) WriteErrorResponse ¶
type ConnParams ¶
type ConnParams struct { Host string `json:"host"` Port int `json:"port"` Uname string `json:"uname"` Pass string `json:"pass"` DbName string `json:"dbname"` UnixSocket string `json:"unix_socket"` Charset string `json:"charset"` Flags uint64 `json:"flags"` // The following SSL flags are only used when flags |= 2048 // is set (CapabilityClientSSL). SslCa string `json:"ssl_ca"` SslCaPath string `json:"ssl_ca_path"` SslCert string `json:"ssl_cert"` SslKey string `json:"ssl_key"` ServerName string `json:"server_name"` // The following is only set when the deprecated "dbname" flags are // supplied and will be removed. DeprecatedDBName string // The following is only set to force the client to connect without // using CapabilityClientDeprecateEOF DisableClientDeprecateEOF bool }
ConnParams contains all the parameters to use to connect to mysql.
func (*ConnParams) EnableClientFoundRows ¶
func (cp *ConnParams) EnableClientFoundRows()
EnableClientFoundRows sets the flag for CLIENT_FOUND_ROWS.
func (*ConnParams) EnableSSL ¶
func (cp *ConnParams) EnableSSL()
EnableSSL will set the right flag on the parameters.
func (*ConnParams) SslEnabled ¶
func (cp *ConnParams) SslEnabled() bool
SslEnabled returns if SSL is enabled.
type Handler ¶
type Handler interface { // NewConnection is called when a connection is created. // It is not established yet. The handler can decide to // set StatusFlags that will be returned by the handshake methods. // In particular, ServerStatusAutocommit might be set. NewConnection(c *Conn) // ConnectionClosed is called when a connection is closed. ConnectionClosed(c *Conn) // ComQuery is called when a connection receives a query. // Note the contents of the query slice may change after // the first call to callback. So the Handler should not // hang on to the byte slice. ComQuery(c *Conn, query string, callback func(*sqltypes.Result) error) error // WarningCount is called at the end of each query to obtain // the value to be returned to the client in the EOF packet. // Note that this will be called either in the context of the // ComQuery callback if the result does not contain any fields, // or after the last ComQuery call completes. WarningCount(c *Conn) uint16 }
A Handler is an interface used by Listener to send queries. The implementation of this interface may store data in the ClientData field of the Connection for its own purposes.
For a given Connection, all these methods are serialized. It means only one of these methods will be called concurrently for a given Connection. So access to the Connection ClientData does not need to be protected by a mutex.
However, each connection is using one go routine, so multiple Connection objects can call these concurrently, for different Connections.
type Listener ¶
type Listener struct { // ServerVersion is the version we will advertise. ServerVersion string // TLSConfig is the server TLS config. If set, we will advertise // that we support SSL. TLSConfig *tls.Config // AllowClearTextWithoutTLS needs to be set for the // mysql_clear_password authentication method to be accepted // by the server when TLS is not in use. AllowClearTextWithoutTLS bool // SlowConnectWarnThreshold if non-zero specifies an amount of time // beyond which a warning is logged to identify the slow connection SlowConnectWarnThreshold time.Duration // RequireSecureTransport configures the server to reject connections from insecure clients RequireSecureTransport bool // contains filtered or unexported fields }
Listener is the MySQL server protocol listener.
func NewFromListener ¶
func NewFromListener(l net.Listener, authServer AuthServer, handler Handler, versionString string, connReadTimeout time.Duration, connWriteTimeout time.Duration) (*Listener, error)
NewFromListener creares a new mysql listener from an existing net.Listener
func NewListener ¶
func NewListener(protocol, address string, authServer AuthServer, handler Handler, versionString string, connReadTimeout time.Duration, connWriteTimeout time.Duration) (*Listener, error)
NewListener creates a new Listener.
func NewListenerWithConfig ¶
func NewListenerWithConfig(cfg ListenerConfig) (*Listener, error)
NewListenerWithConfig creates new listener using provided config. There are no default values for config, so caller should ensure its correctness.
func (*Listener) Accept ¶
func (l *Listener) Accept()
Accept runs an accept loop until the listener is closed.
type ListenerConfig ¶
type ListenerConfig struct { // Protocol-Address pair and Listener are mutually exclusive parameters Protocol string Address string VersionString string Listener net.Listener AuthServer AuthServer Handler Handler ConnReadTimeout time.Duration ConnWriteTimeout time.Duration ConnReadBufferSize int }
ListenerConfig should be used with NewListenerWithConfig to specify listener parameters.
type NoneGetter ¶
type NoneGetter struct{}
NoneGetter holds the empty string
func (*NoneGetter) Get ¶
func (ng *NoneGetter) Get() *querypb.VTGateCallerID
Get returns the empty string
type SQLError ¶
SQLError is the error structure returned from calling a db library function
func NewSQLError ¶
NewSQLError creates a new SQLError. If sqlState is left empty, it will default to "HY000" (general error). TODO: Should be aligned with vterrors, stack traces and wrapping
type StaticUserData ¶
type StaticUserData struct {
// contains filtered or unexported fields
}
StaticUserData holds the username and groups
func (*StaticUserData) Get ¶
func (sud *StaticUserData) Get() *querypb.VTGateCallerID
Get returns the wrapped username and groups