Documentation ¶
Index ¶
- Constants
- Variables
- func RegisterTlsConfig(key string, config *tls.Config)
- func Sign(signingKey SigningKey, cred *AKCredential) (string, error)
- func WriteUserInfoToEncoder(encoder *ch_encoding.Encoder, info *UserInfo) error
- type AKCredential
- type APITokenAuthentication
- type Authentication
- type ConnConfig
- type DialStrategy
- type ErrBadConnection
- type GatewayConn
- func (g *GatewayConn) AddSetting(key string, value interface{}) error
- func (g *GatewayConn) AddSettingChecked(key string, val interface{})
- func (g *GatewayConn) AddSettingsTemporarily(temp map[string]interface{}) func()
- func (g *GatewayConn) ApplyConnConfigs(configs map[string]interface{})
- func (g *GatewayConn) ApplyConnConfigsTemporarily(configs map[string]interface{}) func()
- func (g *GatewayConn) Cancel()
- func (g *GatewayConn) CheckConnection() (err error)
- func (g *GatewayConn) Clone() *GatewayConn
- func (g *GatewayConn) Close() error
- func (g *GatewayConn) Closed() bool
- func (g *GatewayConn) FlushServerResponses(ctx context.Context) error
- func (g *GatewayConn) GetAllSettings() map[string]interface{}
- func (g *GatewayConn) GetDisplayName() string
- func (g *GatewayConn) GetResponseStream(ctx context.Context) <-chan response.Packet
- func (g *GatewayConn) InAnsiSQLMode() bool
- func (g *GatewayConn) InQueryingState() bool
- func (g *GatewayConn) Log(s string, args ...interface{})
- func (g *GatewayConn) Ping() error
- func (g *GatewayConn) SendClientData(block *data.Block) error
- func (g *GatewayConn) SendQuery(query string) error
- func (g *GatewayConn) SendQueryAssertNoError(ctx context.Context, query string) error
- func (g *GatewayConn) SendQueryFull(query, queryID string, extTables <-chan *data.Block, extTableName string) error
- func (g *GatewayConn) SetCurrentDatabase(database string)
- func (g *GatewayConn) SetLog(logf func(string, ...interface{}))
- type OptionConfig
- func OptionConnTimeout(d uint64) OptionConfig
- func OptionDialStrategy(strategy DialStrategy) OptionConfig
- func OptionHostName(host string) OptionConfig
- func OptionLogf(logf logf) OptionConfig
- func OptionNoDelay(noDelay bool) OptionConfig
- func OptionReceiveTimeout(d uint64) OptionConfig
- func OptionRegion(region string) OptionConfig
- func OptionSecure(secure bool) OptionConfig
- func OptionSendTimeout(d uint64) OptionConfig
- func OptionSkipVerification(skip bool) OptionConfig
- func OptionTlsConfig(tlsConfig *tls.Config) OptionConfig
- func OptionTlsConfigFromRegistry(key string) OptionConfig
- func OptionVolcano(region string) OptionConfig
- type PasswordAuthentication
- type RefreshReader
- type SetReadDeadlineReader
- type SignatureAuthentication
- type SigningKey
- type SystemAuthentication
- type UserInfo
Constants ¶
const ( SignatureAuthService = "bytehouse" // Bytehouse is one of Volcano service SignatureDateFormat = "20060102" )
const ( RegionCnNorth1 = "CN-NORTH-1" RegionApSouthEast1 = "AP-SOUTHEAST-1" )
const (
RegionCnBeijing = "CN-BEIJING"
)
const (
TCP uint64 = 1
)
Variables ¶
var ErrNoHost = errors2.New("conn configs have no hosts")
Functions ¶
func RegisterTlsConfig ¶
func Sign ¶
func Sign(signingKey SigningKey, cred *AKCredential) (string, error)
Sign signs credential (claim) using signing key. It returns the signature string and error if any.
func WriteUserInfoToEncoder ¶
func WriteUserInfoToEncoder(encoder *ch_encoding.Encoder, info *UserInfo) error
Types ¶
type AKCredential ¶
type AKCredential struct { AccessKey string `json:"sub"` Service string `json:"aud"` // default: ByteHouse Date string `json:"date"` // format: yyyymmdd Region string `json:"region"` }
AKCredential contain credential scope. It also implement jwt.Claims and used as a claim.
func (AKCredential) Scope ¶
func (v AKCredential) Scope() string
Scope is credential scope in unix-path like separator.
type APITokenAuthentication ¶
type APITokenAuthentication struct {
// contains filtered or unexported fields
}
func NewAPITokenAuthentication ¶
func NewAPITokenAuthentication(token string) *APITokenAuthentication
func (*APITokenAuthentication) Identity ¶
func (a *APITokenAuthentication) Identity() string
func (*APITokenAuthentication) WriteAuthData ¶
func (a *APITokenAuthentication) WriteAuthData(encoder *ch_encoding.Encoder) error
func (*APITokenAuthentication) WriteAuthProtocol ¶
func (a *APITokenAuthentication) WriteAuthProtocol(encoder *ch_encoding.Encoder) error
type Authentication ¶
type Authentication interface { WriteAuthProtocol(*ch_encoding.Encoder) error WriteAuthData(*ch_encoding.Encoder) error Identity() string }
type ConnConfig ¶
type ConnConfig struct {
// contains filtered or unexported fields
}
func NewConnConfig ¶
func NewConnConfig(opts ...OptionConfig) (*ConnConfig, error)
type DialStrategy ¶
type DialStrategy string
const ( DialRandom DialStrategy = "random" DialInOrder DialStrategy = "in_order" DialTimeRandom DialStrategy = "time_random" )
type ErrBadConnection ¶
type ErrBadConnection struct {
// contains filtered or unexported fields
}
ErrBadConnection is a connection err Returning this err will cause upstream sql driver to return ErrBadConn, causing the connection to be discarded.
func NewErrBadConnection ¶
func NewErrBadConnection(value string) *ErrBadConnection
func (ErrBadConnection) Error ¶
func (e ErrBadConnection) Error() string
func (ErrBadConnection) Is ¶
func (e ErrBadConnection) Is(target error) bool
Is returns true if target is of ErrBadConnection
type GatewayConn ¶
type GatewayConn struct {
// contains filtered or unexported fields
}
func MockConn ¶
func MockConn() *GatewayConn
func NewGatewayConn ¶
func NewGatewayConn( connConfigs *ConnConfig, database string, authentication Authentication, compress bool, querySetting map[string]interface{}, ) *GatewayConn
func (*GatewayConn) AddSetting ¶
func (g *GatewayConn) AddSetting(key string, value interface{}) error
func (*GatewayConn) AddSettingChecked ¶
func (g *GatewayConn) AddSettingChecked(key string, val interface{})
AddSettingChecked assumes that the key and val passed are correct (key exist and val is of correct data type) and will not return error until query reaches the server. callers are expected to handle the checking on their own.
func (*GatewayConn) AddSettingsTemporarily ¶
func (g *GatewayConn) AddSettingsTemporarily(temp map[string]interface{}) func()
func (*GatewayConn) ApplyConnConfigs ¶
func (g *GatewayConn) ApplyConnConfigs(configs map[string]interface{})
func (*GatewayConn) ApplyConnConfigsTemporarily ¶
func (g *GatewayConn) ApplyConnConfigsTemporarily(configs map[string]interface{}) func()
func (*GatewayConn) Cancel ¶
func (g *GatewayConn) Cancel()
Cancel cancels the current query and disconnects. Non-blocking process
func (*GatewayConn) CheckConnection ¶
func (g *GatewayConn) CheckConnection() (err error)
func (*GatewayConn) Clone ¶
func (g *GatewayConn) Clone() *GatewayConn
func (*GatewayConn) Close ¶
func (g *GatewayConn) Close() error
func (*GatewayConn) Closed ¶
func (g *GatewayConn) Closed() bool
Closed returns true iff conn is closed
func (*GatewayConn) FlushServerResponses ¶
func (g *GatewayConn) FlushServerResponses(ctx context.Context) error
FlushServerResponses discards all server response, returning exception if any.
func (*GatewayConn) GetAllSettings ¶
func (g *GatewayConn) GetAllSettings() map[string]interface{}
func (*GatewayConn) GetDisplayName ¶
func (g *GatewayConn) GetDisplayName() string
func (*GatewayConn) GetResponseStream ¶
func (g *GatewayConn) GetResponseStream(ctx context.Context) <-chan response.Packet
GetResponseStream Read Response(s) until EOS or Exception
func (*GatewayConn) InAnsiSQLMode ¶
func (g *GatewayConn) InAnsiSQLMode() bool
func (*GatewayConn) InQueryingState ¶
func (g *GatewayConn) InQueryingState() bool
func (*GatewayConn) Log ¶
func (g *GatewayConn) Log(s string, args ...interface{})
func (*GatewayConn) Ping ¶
func (g *GatewayConn) Ping() error
func (*GatewayConn) SendClientData ¶
func (g *GatewayConn) SendClientData(block *data.Block) error
func (*GatewayConn) SendQuery ¶
func (g *GatewayConn) SendQuery(query string) error
func (*GatewayConn) SendQueryAssertNoError ¶
func (g *GatewayConn) SendQueryAssertNoError(ctx context.Context, query string) error
SendQueryAssertNoError sends query to server, flushes all response from server, returning error if any.
func (*GatewayConn) SendQueryFull ¶
func (*GatewayConn) SetCurrentDatabase ¶
func (g *GatewayConn) SetCurrentDatabase(database string)
func (*GatewayConn) SetLog ¶
func (g *GatewayConn) SetLog(logf func(string, ...interface{}))
type OptionConfig ¶
type OptionConfig func(connConfigs *ConnConfig) error
func OptionConnTimeout ¶
func OptionConnTimeout(d uint64) OptionConfig
func OptionDialStrategy ¶
func OptionDialStrategy(strategy DialStrategy) OptionConfig
func OptionHostName ¶
func OptionHostName(host string) OptionConfig
func OptionLogf ¶
func OptionLogf(logf logf) OptionConfig
func OptionNoDelay ¶
func OptionNoDelay(noDelay bool) OptionConfig
func OptionReceiveTimeout ¶
func OptionReceiveTimeout(d uint64) OptionConfig
func OptionRegion ¶
func OptionRegion(region string) OptionConfig
func OptionSecure ¶
func OptionSecure(secure bool) OptionConfig
func OptionSendTimeout ¶
func OptionSendTimeout(d uint64) OptionConfig
func OptionSkipVerification ¶
func OptionSkipVerification(skip bool) OptionConfig
func OptionTlsConfig ¶
func OptionTlsConfig(tlsConfig *tls.Config) OptionConfig
func OptionTlsConfigFromRegistry ¶
func OptionTlsConfigFromRegistry(key string) OptionConfig
func OptionVolcano ¶
func OptionVolcano(region string) OptionConfig
type PasswordAuthentication ¶
type PasswordAuthentication struct {
// contains filtered or unexported fields
}
func NewPasswordAuthentication ¶
func NewPasswordAuthentication(user, password string) *PasswordAuthentication
func (*PasswordAuthentication) Identity ¶
func (p *PasswordAuthentication) Identity() string
func (*PasswordAuthentication) WriteAuthData ¶
func (p *PasswordAuthentication) WriteAuthData(encoder *ch_encoding.Encoder) error
func (*PasswordAuthentication) WriteAuthProtocol ¶
func (p *PasswordAuthentication) WriteAuthProtocol(encoder *ch_encoding.Encoder) error
type RefreshReader ¶
type RefreshReader struct {
// contains filtered or unexported fields
}
RefreshReader is a Reader that extends the read deadline by a fixed duration each time a read operation was carried out.
func NewRefreshReader ¶
func NewRefreshReader(r SetReadDeadlineReader, reset time.Duration) *RefreshReader
func (*RefreshReader) Close ¶
func (r *RefreshReader) Close() error
type SetReadDeadlineReader ¶
type SignatureAuthentication ¶
type SignatureAuthentication struct {
// contains filtered or unexported fields
}
SignatureAuthentication handler based on ByteHouse AM custom AK/SK Signature Auth.
func NewSignatureAuthentication ¶
func NewSignatureAuthentication(accessKey, secretKey, region string) *SignatureAuthentication
NewSignatureAuthentication creates new Authentication handler based on ByteHouse AM custom AK/SK Signature Auth.
func (*SignatureAuthentication) Identity ¶
func (s *SignatureAuthentication) Identity() string
func (*SignatureAuthentication) WriteAuthData ¶
func (s *SignatureAuthentication) WriteAuthData(encoder *ch_encoding.Encoder) error
func (*SignatureAuthentication) WriteAuthProtocol ¶
func (s *SignatureAuthentication) WriteAuthProtocol(encoder *ch_encoding.Encoder) error
type SigningKey ¶
type SigningKey []byte
SigningKey represent signing key created from secret key + credential.
func NewSigningKey ¶
func NewSigningKey(secret string, cred *AKCredential) SigningKey
NewSigningKey creates new signing key.
func (SigningKey) JWTSecretFunc ¶
func (s SigningKey) JWTSecretFunc(_ *jwt.Token) (interface{}, error)
type SystemAuthentication ¶
type SystemAuthentication struct {
// contains filtered or unexported fields
}
func NewSystemAuthentication ¶
func NewSystemAuthentication(token string) *SystemAuthentication
func (*SystemAuthentication) Identity ¶
func (s *SystemAuthentication) Identity() string
func (*SystemAuthentication) WriteAuthData ¶
func (s *SystemAuthentication) WriteAuthData(encoder *ch_encoding.Encoder) error
func (*SystemAuthentication) WriteAuthProtocol ¶
func (s *SystemAuthentication) WriteAuthProtocol(encoder *ch_encoding.Encoder) error
type UserInfo ¶
type UserInfo struct {
// contains filtered or unexported fields
}
func NewUserInfo ¶
func NewUserInfo() *UserInfo