Documentation
¶
Index ¶
- type ConnectionBinding
- func (b *ConnectionBinding) Database() *storage.Database
- func (b *ConnectionBinding) Finalize(username string) (*storage.Database, error)
- func (b *ConnectionBinding) RequestedDB() string
- func (b *ConnectionBinding) SetCandidate(db *storage.Database)
- func (b *ConnectionBinding) SetRequestedDB(name string) error
- type CredentialProvider
- type HandlerFactory
- type Session
- func (s *Session) BeginTransaction(tx *sql.Tx)
- func (s *Session) Bind(db *storage.Database) error
- func (s *Session) Close() error
- func (s *Session) CommitTransaction() error
- func (s *Session) GetBoundDB() *storage.Database
- func (s *Session) GetConnection() *sql.Conn
- func (s *Session) GetDatabase() string
- func (s *Session) GetTransaction() *sql.Tx
- func (s *Session) GetVariable(key string) (string, bool)
- func (s *Session) IsInTransaction() bool
- func (s *Session) RollbackTransaction() error
- func (s *Session) SetConnection(conn *sql.Conn)
- func (s *Session) SetDatabase(db string)
- func (s *Session) SetVariable(key, value string)
- type SessionHandler
- func (h *SessionHandler) Finalize(username string) error
- func (h *SessionHandler) HandleFieldList(table string, fieldWildcard string) ([]*mysql.Field, error)
- func (h *SessionHandler) HandleOtherCommand(cmd byte, data []byte) error
- func (h *SessionHandler) HandleQuery(query string) (*mysql.Result, error)
- func (h *SessionHandler) HandleStmtClose(context interface{}) error
- func (h *SessionHandler) HandleStmtExecute(context interface{}, query string, args []interface{}) (*mysql.Result, error)
- func (h *SessionHandler) HandleStmtPrepare(query string) (int, int, interface{}, error)
- func (h *SessionHandler) UseDB(dbName string) error
- type SessionManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectionBinding ¶
type ConnectionBinding struct {
// contains filtered or unexported fields
}
ConnectionBinding tracks handshake state for one MySQL connection. go-mysql may call UseDB before authentication completes, so binding is finalized only after a successful handshake.
func (*ConnectionBinding) Database ¶
func (b *ConnectionBinding) Database() *storage.Database
Database returns the finalized database, if any.
func (*ConnectionBinding) Finalize ¶
func (b *ConnectionBinding) Finalize(username string) (*storage.Database, error)
Finalize permanently binds the connection to the authenticated database.
func (*ConnectionBinding) RequestedDB ¶
func (b *ConnectionBinding) RequestedDB() string
RequestedDB returns the database name requested during handshake, if any.
func (*ConnectionBinding) SetCandidate ¶
func (b *ConnectionBinding) SetCandidate(db *storage.Database)
SetCandidate stores the authenticated database for later finalization.
func (*ConnectionBinding) SetRequestedDB ¶
func (b *ConnectionBinding) SetRequestedDB(name string) error
SetRequestedDB records the database name from the handshake or COM_INIT_DB. Before finalization this only stores a request; after finalization it enforces immutable binding.
type CredentialProvider ¶
type CredentialProvider struct {
// contains filtered or unexported fields
}
CredentialProvider implements server.CredentialProvider using the storage registry.
func NewCredentialProvider ¶
func NewCredentialProvider(store *storage.Store, binding *ConnectionBinding) *CredentialProvider
NewCredentialProvider creates a per-connection credential provider.
func (*CredentialProvider) CheckUsername ¶
func (p *CredentialProvider) CheckUsername(username string) (bool, error)
CheckUsername reports whether the username exists.
func (*CredentialProvider) GetCredential ¶
func (p *CredentialProvider) GetCredential(username string) (password string, found bool, err error)
GetCredential returns the password for username and stages the database candidate. Username/database mismatches intentionally look like authentication failures.
type HandlerFactory ¶
type HandlerFactory struct {
// contains filtered or unexported fields
}
HandlerFactory creates per-session MySQL protocol handlers.
func NewHandlerFactory ¶
func NewHandlerFactory() *HandlerFactory
NewHandlerFactory creates a factory for session-scoped handlers.
func (*HandlerFactory) NewSessionHandler ¶
func (f *HandlerFactory) NewSessionHandler(session *Session, binding *ConnectionBinding) *SessionHandler
NewSessionHandler returns a handler bound to a client session and connection binding.
type Session ¶
type Session struct {
ID string
Username string
Database string
ConnectedAt time.Time
LastActiveAt time.Time
Variables map[string]string
// Bound tenant database (immutable after auth)
BoundDB *storage.Database
// Transaction state
InTransaction bool
Tx *sql.Tx
// Per-session database connection for coherency
DB *sql.Conn
// contains filtered or unexported fields
}
Session represents a client connection session
func (*Session) BeginTransaction ¶
BeginTransaction starts a transaction on this session
func (*Session) CommitTransaction ¶
CommitTransaction commits the current transaction
func (*Session) GetBoundDB ¶
GetBoundDB returns the authenticated tenant database.
func (*Session) GetConnection ¶
GetConnection returns the per-session database connection
func (*Session) GetDatabase ¶
GetDatabase returns the current database
func (*Session) GetTransaction ¶
GetTransaction returns the current transaction
func (*Session) GetVariable ¶
GetVariable gets a session variable
func (*Session) IsInTransaction ¶
IsInTransaction returns whether the session is in a transaction
func (*Session) RollbackTransaction ¶
RollbackTransaction rolls back the current transaction
func (*Session) SetConnection ¶
SetConnection sets the per-session database connection
func (*Session) SetDatabase ¶
SetDatabase sets the current database name label (must match bound DB).
func (*Session) SetVariable ¶
SetVariable sets a session variable
type SessionHandler ¶
type SessionHandler struct {
// contains filtered or unexported fields
}
SessionHandler implements server.Handler for a single client connection.
func (*SessionHandler) Finalize ¶
func (h *SessionHandler) Finalize(username string) error
Finalize binds the handler to the authenticated database after handshake.
func (*SessionHandler) HandleFieldList ¶
func (h *SessionHandler) HandleFieldList(table string, fieldWildcard string) ([]*mysql.Field, error)
HandleFieldList handles COM_FIELD_LIST command.
func (*SessionHandler) HandleOtherCommand ¶
func (h *SessionHandler) HandleOtherCommand(cmd byte, data []byte) error
HandleOtherCommand handles other MySQL commands.
func (*SessionHandler) HandleQuery ¶
func (h *SessionHandler) HandleQuery(query string) (*mysql.Result, error)
HandleQuery handles COM_QUERY commands (text protocol).
func (*SessionHandler) HandleStmtClose ¶
func (h *SessionHandler) HandleStmtClose(context interface{}) error
HandleStmtClose handles COM_STMT_CLOSE.
func (*SessionHandler) HandleStmtExecute ¶
func (h *SessionHandler) HandleStmtExecute(context interface{}, query string, args []interface{}) (*mysql.Result, error)
HandleStmtExecute handles COM_STMT_EXECUTE.
func (*SessionHandler) HandleStmtPrepare ¶
func (h *SessionHandler) HandleStmtPrepare(query string) (int, int, interface{}, error)
HandleStmtPrepare handles COM_STMT_PREPARE.
func (*SessionHandler) UseDB ¶
func (h *SessionHandler) UseDB(dbName string) error
UseDB handles COM_INIT_DB command (database selection).
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
SessionManager manages active sessions
func NewSessionManager ¶
func NewSessionManager() *SessionManager
NewSessionManager creates a new session manager
func (*SessionManager) Cleanup ¶
func (sm *SessionManager) Cleanup(maxInactive time.Duration) int
Cleanup removes inactive sessions
func (*SessionManager) Count ¶
func (sm *SessionManager) Count() int
Count returns the number of active sessions
func (*SessionManager) Create ¶
func (sm *SessionManager) Create(id string) *Session
Create creates a new unbound session
func (*SessionManager) Get ¶
func (sm *SessionManager) Get(id string) (*Session, bool)
Get returns a session by ID
func (*SessionManager) Remove ¶
func (sm *SessionManager) Remove(id string)
Remove removes a session