Documentation
¶
Overview ¶
Package hubble provides a database/sql driver for Hubble.
The driver should be used via the database/sql package:
import "database/sql"
import _ "gitee.com/beagledata_1/hubble-go-client"
dsn := "http://user@localhost:8080?catalog=default&schema=test"
db, err := sql.Open("hubble", dsn)
Index ¶
- Constants
- Variables
- func Date(year int, month time.Month, day int) hubbleDate
- func DeregisterCustomClient(key string)
- func RegisterCustomClient(key string, client *http.Client) error
- func Serial(v interface{}) (string, error)
- func Time(hour int, minute int, second int, nanosecond int) hubbleTime
- func TimeTz(hour int, minute int, second int, nanosecond int, location *time.Location) hubbleTimeTz
- func Timestamp(year int, month time.Month, day int, hour int, minute int, second int, ...) hubbleTimestamp
- type Config
- type Conn
- type Driver
- type ErrHubble
- type ErrQueryFailed
- type ErrorInfo
- type ErrorLocation
- type FailureInfo
- type NullMap
- type NullSlice2Bool
- type NullSlice2Float64
- type NullSlice2Int64
- type NullSlice2Map
- type NullSlice2String
- type NullSlice2Time
- type NullSlice3Bool
- type NullSlice3Float64
- type NullSlice3Int64
- type NullSlice3Map
- type NullSlice3String
- type NullSlice3Time
- type NullSliceBool
- type NullSliceFloat64
- type NullSliceInt64
- type NullSliceMap
- type NullSliceString
- type NullSliceTime
- type NullTime
- type Numeric
- type ProgressUpdater
- type QueryProgressInfo
- type UnsupportedArgError
Constants ¶
const ( KIND_TYPE = typeKind("TYPE") KIND_NAMED_TYPE = typeKind("NAMED_TYPE") KIND_LONG = typeKind("LONG") KIND_VARIABLE = typeKind("VARIABLE") )
Variables ¶
var ( // DefaultQueryTimeout is the default timeout for queries executed without a context. DefaultQueryTimeout = 60 * time.Second // DefaultCancelQueryTimeout is the timeout for the request to cancel queries in Hubble. DefaultCancelQueryTimeout = 30 * time.Second // ErrOperationNotSupported indicates that a database operation is not supported. ErrOperationNotSupported = errors.New("hubble: operation not supported") // ErrQueryCancelled indicates that a query has been cancelled. ErrQueryCancelled = errors.New("hubble: query cancelled") // ErrUnsupportedHeader indicates that the server response contains an unsupported header. ErrUnsupportedHeader = errors.New("hubble: server response contains an unsupported header") // ErrInvalidResponseType indicates that the server returned an invalid type definition. ErrInvalidResponseType = errors.New("hubble: server response contains an invalid type") // ErrInvalidProgressCallbackHeader indicates that server did not get valid headers for progress callback ErrInvalidProgressCallbackHeader = errors.New("hubble: both " + hubbleProgressCallbackParam + " and " + hubbleProgressCallbackPeriodParam + " must be set when using progress callback") )
Functions ¶
func DeregisterCustomClient ¶
func DeregisterCustomClient(key string)
DeregisterCustomClient removes the client associated to the key.
func RegisterCustomClient ¶
RegisterCustomClient associates a client to a key in the driver's registry.
Register your custom client in the driver, then refer to it by name in the DSN, on the call to sql.Open:
foobarClient := &http.Client{
Transport: &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
DualStack: true,
}).DialContext,
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
TLSClientConfig: &tls.Config{
// your config here...
},
},
}
hubble.RegisterCustomClient("foobar", foobarClient)
db, err := sql.Open("hubble", "https://user@localhost:8080?custom_client=foobar")
func Serial ¶
Serial converts any supported value to its equivalent string for as a Hubble parameter
func Time ¶
Time creates a representation of a Hubble Time type. To represent time with precision higher than nanoseconds, pass the value as a string and use a cast in the query.
Types ¶
type Config ¶
type Config struct {
ServerURI string // URI of the Hubble server, e.g. http://user@localhost:8080
Source string // Source of the connection (optional)
Catalog string // Catalog (optional)
Schema string // Schema (optional)
SessionProperties map[string]string // Session properties (optional)
ExtraCredentials map[string]string // Extra credentials (optional)
CustomClientName string // Custom client name (optional)
KerberosEnabled string // KerberosEnabled (optional, default is false)
KerberosKeytabPath string // Kerberos Keytab Path (optional)
KerberosPrincipal string // Kerberos Principal used to authenticate to KDC (optional)
KerberosRemoteServiceName string // Hubble coordinator Kerberos service name (optional)
KerberosRealm string // The Kerberos Realm (optional)
KerberosConfigPath string // The krb5 config path (optional)
SSLCertPath string // The SSL cert path for TLS verification (optional)
SSLCert string // The SSL cert for TLS verification (optional)
AccessToken string // An access token (JWT) for authentication (optional)
ForwardAuthorizationHeader bool // Allow forwarding the `accessToken` named query parameter in the authorization header, overwriting the `AccessToken` option, if set (optional)
}
Config is a configuration that can be encoded to a DSN string.
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is a Hubble connection.
type ErrHubble ¶
type ErrHubble struct {
Message string `json:"message"`
SqlState string `json:"sqlState"`
ErrorCode int `json:"errorCode"`
ErrorName string `json:"errorName"`
ErrorType string `json:"errorType"`
ErrorLocation ErrorLocation `json:"errorLocation"`
FailureInfo FailureInfo `json:"failureInfo"`
}
type ErrQueryFailed ¶
ErrQueryFailed indicates that a query to Hubble failed.
func (*ErrQueryFailed) Error ¶
func (e *ErrQueryFailed) Error() string
Error implements the error interface.
func (*ErrQueryFailed) Unwrap ¶
func (e *ErrQueryFailed) Unwrap() error
Unwrap implements the unwrap interface.
type ErrorInfo ¶
type ErrorLocation ¶
type FailureInfo ¶
type FailureInfo struct {
Type string `json:"type"`
Message string `json:"message"`
Cause *FailureInfo `json:"cause"`
Suppressed []FailureInfo `json:"suppressed"`
Stack []string `json:"stack"`
ErrorInfo ErrorInfo `json:"errorInfo"`
ErrorLocation ErrorLocation `json:"errorLocation"`
}
type NullSlice2Bool ¶
NullSlice2Bool represents a two-dimensional slice of bool that may be null.
func (*NullSlice2Bool) Scan ¶
func (s *NullSlice2Bool) Scan(value interface{}) error
Scan implements the sql.Scanner interface.
type NullSlice2Float64 ¶
type NullSlice2Float64 struct {
Slice2Float64 [][]sql.NullFloat64
Valid bool
}
NullSlice2Float64 represents a two-dimensional slice of float64 that may be null.
func (*NullSlice2Float64) Scan ¶
func (s *NullSlice2Float64) Scan(value interface{}) error
Scan implements the sql.Scanner interface.
type NullSlice2Int64 ¶
NullSlice2Int64 represents a two-dimensional slice of int64 that may be null.
func (*NullSlice2Int64) Scan ¶
func (s *NullSlice2Int64) Scan(value interface{}) error
Scan implements the sql.Scanner interface.
type NullSlice2Map ¶
NullSlice2Map represents a two-dimensional slice of NullMap that may be null.
func (*NullSlice2Map) Scan ¶
func (s *NullSlice2Map) Scan(value interface{}) error
Scan implements the sql.Scanner interface.
type NullSlice2String ¶
type NullSlice2String struct {
Slice2String [][]sql.NullString
Valid bool
}
NullSlice2String represents a two-dimensional slice of string that may be null.
func (*NullSlice2String) Scan ¶
func (s *NullSlice2String) Scan(value interface{}) error
Scan implements the sql.Scanner interface.
type NullSlice2Time ¶
NullSlice2Time represents a two-dimensional slice of time.Time that may be null.
func (*NullSlice2Time) Scan ¶
func (s *NullSlice2Time) Scan(value interface{}) error
Scan implements the sql.Scanner interface.
type NullSlice3Bool ¶
NullSlice3Bool implements a three-dimensional slice of bool that may be null.
func (*NullSlice3Bool) Scan ¶
func (s *NullSlice3Bool) Scan(value interface{}) error
Scan implements the sql.Scanner interface.
type NullSlice3Float64 ¶
type NullSlice3Float64 struct {
Slice3Float64 [][][]sql.NullFloat64
Valid bool
}
NullSlice3Float64 represents a three-dimensional slice of float64 that may be null.
func (*NullSlice3Float64) Scan ¶
func (s *NullSlice3Float64) Scan(value interface{}) error
Scan implements the sql.Scanner interface.
type NullSlice3Int64 ¶
NullSlice3Int64 implements a three-dimensional slice of int64 that may be null.
func (*NullSlice3Int64) Scan ¶
func (s *NullSlice3Int64) Scan(value interface{}) error
Scan implements the sql.Scanner interface.
type NullSlice3Map ¶
NullSlice3Map represents a three-dimensional slice of NullMap that may be null.
func (*NullSlice3Map) Scan ¶
func (s *NullSlice3Map) Scan(value interface{}) error
Scan implements the sql.Scanner interface.
type NullSlice3String ¶
type NullSlice3String struct {
Slice3String [][][]sql.NullString
Valid bool
}
NullSlice3String implements a three-dimensional slice of string that may be null.
func (*NullSlice3String) Scan ¶
func (s *NullSlice3String) Scan(value interface{}) error
Scan implements the sql.Scanner interface.
type NullSlice3Time ¶
NullSlice3Time represents a three-dimensional slice of time.Time that may be null.
func (*NullSlice3Time) Scan ¶
func (s *NullSlice3Time) Scan(value interface{}) error
Scan implements the sql.Scanner interface.
type NullSliceBool ¶
NullSliceBool represents a slice of bool that may be null.
func (*NullSliceBool) Scan ¶
func (s *NullSliceBool) Scan(value interface{}) error
Scan implements the sql.Scanner interface.
type NullSliceFloat64 ¶
type NullSliceFloat64 struct {
SliceFloat64 []sql.NullFloat64
Valid bool
}
NullSliceFloat64 represents a slice of float64 that may be null.
func (*NullSliceFloat64) Scan ¶
func (s *NullSliceFloat64) Scan(value interface{}) error
Scan implements the sql.Scanner interface.
type NullSliceInt64 ¶
NullSliceInt64 represents a slice of int64 that may be null.
func (*NullSliceInt64) Scan ¶
func (s *NullSliceInt64) Scan(value interface{}) error
Scan implements the sql.Scanner interface.
type NullSliceMap ¶
NullSliceMap represents a slice of NullMap that may be null.
func (*NullSliceMap) Scan ¶
func (s *NullSliceMap) Scan(value interface{}) error
Scan implements the sql.Scanner interface.
type NullSliceString ¶
type NullSliceString struct {
SliceString []sql.NullString
Valid bool
}
NullSliceString represents a slice of string that may be null.
func (*NullSliceString) Scan ¶
func (s *NullSliceString) Scan(value interface{}) error
Scan implements the sql.Scanner interface.
type NullSliceTime ¶
NullSliceTime represents a slice of time.Time that may be null.
func (*NullSliceTime) Scan ¶
func (s *NullSliceTime) Scan(value interface{}) error
Scan implements the sql.Scanner interface.
type NullTime ¶
NullTime represents a time.Time value that can be null. The NullTime supports Hubble's Date, Time and Timestamp data types, with or without time zone.
type Numeric ¶
type Numeric string
Numeric is a string representation of a number, such as "10", "5.5" or in scientific form If another string format is used it will error to serialise
type ProgressUpdater ¶
type ProgressUpdater interface {
// Update the query progress, immediately when the query starts, when receiving data, and once when the query is finished.
Update(QueryProgressInfo)
}
type QueryProgressInfo ¶
type QueryProgressInfo struct {
QueryId string
QueryStats stmtStats
}
type UnsupportedArgError ¶
type UnsupportedArgError struct {
// contains filtered or unexported fields
}
func (UnsupportedArgError) Error ¶
func (e UnsupportedArgError) Error() string