Documentation
¶
Index ¶
- Constants
- Variables
- func Connector(opt *Options) driver.Connector
- func Context(parent context.Context, options ...QueryOption) context.Context
- func DateNamed(name string, value time.Time, scale TimeUnit) driver.NamedDateValue
- func ExtractJSONPathAs[T any](o *JSON, path string) (valueAs T, ok bool)
- func Named(name string, value any) driver.NamedValue
- func Open(opt *Options) (driver.Conn, error)
- func OpenDB(opt *Options) *sql.DB
- type ArraySet
- type AsyncOptions
- type Auth
- type ClientInfo
- type ColumnNameAndType
- type Compression
- type CompressionMethod
- type Conn
- type ConnOpenStrategy
- type CustomSetting
- type Dial
- type DialResult
- type Dynamic
- type Exception
- type GetJWTFunc
- type GroupSet
- type HTTPProxy
- type HTTPReaderWriter
- type JSON
- type JSONDeserializer
- type JSONSerializer
- type Log
- type OpError
- type Options
- type Parameters
- type Pool
- type ProfileEvent
- type ProfileInfo
- type Progress
- type Protocol
- type QueryOption
- func WithAsync(wait bool) QueryOption
- func WithBlockBufferSize(size uint8) QueryOption
- func WithClientInfo(ci ClientInfo) QueryOption
- func WithColumnNamesAndTypes(columnNamesAndTypes []ColumnNameAndType) QueryOption
- func WithExternalTable(t ...*ext.Table) QueryOption
- func WithJWT(jwt string) QueryOption
- func WithLogs(fn func(*Log)) QueryOption
- func WithParameters(params Parameters) QueryOption
- func WithProfileEvents(fn func([]ProfileEvent)) QueryOption
- func WithProfileInfo(fn func(*ProfileInfo)) QueryOption
- func WithProgress(fn func(*Progress)) QueryOption
- func WithQueryID(queryID string) QueryOption
- func WithQuotaKey(quotaKey string) QueryOption
- func WithSettings(settings Settings) QueryOption
- func WithSpan(span trace.SpanContext) QueryOption
- func WithStdAsync(wait bool) QueryOptiondeprecated
- func WithUserLocation(location *time.Location) QueryOption
- func WithoutProfileEvents() QueryOption
- type QueryOptions
- type ServerVersion
- type Settings
- type TimeUnit
- type Variant
Constants ¶
const ( ClientVersionMajor = 2 ClientVersionMinor = 44 ClientVersionPatch = 0 ClientTCPProtocolVersion = proto.DBMS_TCP_PROTOCOL_VERSION )
const ( CompressionNone = CompressionMethod(compress.None) CompressionLZ4 = CompressionMethod(compress.LZ4) CompressionLZ4HC = CompressionMethod(compress.LZ4HC) CompressionZSTD = CompressionMethod(compress.ZSTD) CompressionGZIP = CompressionMethod(0x95) CompressionDeflate = CompressionMethod(0x96) CompressionBrotli = CompressionMethod(0x97) )
const ( // HeaderUser carries the username on the HTTP interface. HeaderUser = "X-Datastore-User" // HeaderKey carries the password on the HTTP interface. HeaderKey = "X-Datastore-Key" // HeaderSSLCertificateAuth selects certificate authentication ("on") over // password authentication ("off"). HeaderSSLCertificateAuth = "X-Datastore-SSL-Certificate-Auth" )
Wire header names understood by the Datastore HTTP interface.
The server reads these verbatim and provides no aliases, so a client that sends any other spelling cannot authenticate over HTTP. They are declared here once so the wire contract has a single definition.
const ClientName = "datastore-go"
Variables ¶
var ( ErrBatchInvalid = errors.New("datastore: batch is invalid. check appended data is correct") ErrBatchAlreadySent = errors.New("datastore: batch has already been sent") ErrBatchNotSent = errors.New("datastore: invalid retry, batch not sent yet") ErrAcquireConnTimeout = errors.New("datastore: acquire conn timeout. you can increase the number of max open conn or the dial timeout") ErrUnsupportedServerRevision = errors.New("datastore: unsupported server revision") ErrBindMixedParamsFormats = errors.New("datastore [bind]: mixed named, numeric or positional parameters") ErrAcquireConnNoAddress = errors.New("datastore: no valid address supplied") ErrServerUnexpectedData = errors.New("code: 101, message: Unexpected packet Data received from client") ErrConnectionClosed = errors.New("datastore: connection is closed") )
var ( ErrInvalidValueInNamedDateValue = errors.New("invalid value in NamedDateValue for query parameter") ErrUnsupportedQueryParameter = errors.New("unsupported query parameter type") )
var (
ErrInvalidTimezone = errors.New("invalid timezone value")
)
Functions ¶
func Context ¶
func Context(parent context.Context, options ...QueryOption) context.Context
Context returns a derived context with the given Datastore QueryOptions. Existing QueryOptions will be overwritten per option if present. The QueryOptions Settings map will be initialized if nil.
func ExtractJSONPathAs ¶
ExtractJSONPathAs is a convenience function for asserting a path to a specific type. The underlying value is also extracted from its Dynamic wrapper if present. T cannot be a Dynamic, if you want a Dynamic simply use ExtractJSONPathAsDynamic.
Types ¶
type AsyncOptions ¶
type AsyncOptions struct {
// contains filtered or unexported fields
}
type ClientInfo ¶
func (ClientInfo) Append ¶
func (a ClientInfo) Append(b ClientInfo) ClientInfo
Append returns a new copy of the combined ClientInfo structs
func (ClientInfo) String ¶
func (o ClientInfo) String() string
type ColumnNameAndType ¶
ColumnNameAndType represents a column name and type
type Compression ¶
type Compression struct {
Method CompressionMethod
// this only applies to lz4, lz4hc, zlib, and brotli compression algorithms
Level int
}
type CompressionMethod ¶
type CompressionMethod byte
func (CompressionMethod) String ¶
func (c CompressionMethod) String() string
type ConnOpenStrategy ¶
type ConnOpenStrategy uint8
const ( ConnOpenInOrder ConnOpenStrategy = iota ConnOpenRoundRobin ConnOpenRandom )
type CustomSetting ¶
type CustomSetting struct {
Value string
}
CustomSetting is a helper struct to distinguish custom settings from important ones. For the native protocol, the is_important flag is set to 0x02 (see the server's src/Core/BaseSettings.h). Only string values are supported, until the field formatting logic the server implements in src/Core/Field.cpp is implemented in this driver.
type DialResult ¶
type DialResult struct {
// contains filtered or unexported fields
}
func DefaultDialStrategy ¶
type Dynamic ¶
Dynamic is an alias for the Variant type
func ExtractJSONPathAsDynamic ¶
ExtractJSONPathAsDynamic is a convenience function for asserting a path to a Dynamic. If the value is not a Dynamic, the value is wrapped in an untyped Dynamic with false returned.
func NewDynamic ¶
NewDynamic creates a new Dynamic with the given value
func NewDynamicWithType ¶
NewDynamicWithType creates a new Dynamic with the given value and Datastore type
type HTTPReaderWriter ¶
type HTTPReaderWriter struct {
// contains filtered or unexported fields
}
type JSONDeserializer ¶
type JSONDeserializer = col.JSONDeserializer
JSONDeserializer interface allows a struct to load its data from an optimized JSON structure instead of relying on recursive reflection to set its fields.
type JSONSerializer ¶
type JSONSerializer = col.JSONSerializer
JSONSerializer interface allows a struct to be manually converted to an optimized JSON structure instead of relying on recursive reflection. Note that the struct must be a pointer in order for the interface to be matched, reflection will be used otherwise.
type Options ¶
type Options struct {
Protocol Protocol
ClientInfo ClientInfo
TLS *tls.Config
Addr []string
Auth Auth
DialContext func(ctx context.Context, addr string) (net.Conn, error)
DialStrategy func(ctx context.Context, connID int, options *Options, dial Dial) (DialResult, error)
// Deprecated: Use Logger instead. Debug enables legacy debug logging to stdout.
// For structured logging with levels, use the Logger field.
Debug bool
// Deprecated: Use Logger instead. Debugf provides a custom debug logging function.
// For structured logging with levels and custom handlers, use the Logger field with
// a custom slog.Handler.
Debugf func(format string, v ...any)
// Logger provides structured logging using Go's standard log/slog package.
// If nil, no logging occurs (default). To enable logging, provide a configured
// slog.Logger:
//
// logger := slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{
// Level: slog.LevelDebug,
// }))
// opts := &datastore.Options{
// Logger: logger,
// }
//
// For backward compatibility, if Debug=true and Debugf is set, those will be used
// instead of Logger.
Logger *slog.Logger
Settings Settings
Compression *Compression
DialTimeout time.Duration // default 30 second
MaxOpenConns int // default MaxIdleConns + 5
MaxIdleConns int // default 5
ConnMaxLifetime time.Duration // default 1 hour
ConnOpenStrategy ConnOpenStrategy
FreeBufOnConnRelease bool // drop preserved memory buffer after each query
HttpHeaders map[string]string // set additional headers on HTTP requests
HttpUrlPath string // set additional URL path for HTTP requests
HttpMaxConnsPerHost int // MaxConnsPerHost for http.Transport
BlockBufferSize uint8 // default 2 - can be overwritten on query
MaxCompressionBuffer int // default 10485760 - measured in bytes i.e.
// HTTPProxy specifies an HTTP proxy URL to use for requests made by the client.
HTTPProxyURL *url.URL
// GetJWT should return a JWT for authentication with Datastore Cloud.
// This is called per connection/request, so you may cache the token in your app if needed.
// Use this instead of Auth.Username and Auth.Password if you're using JWT auth.
GetJWT GetJWTFunc
// ReadTimeout is the maximum duration the client will wait for Datastore
// to respond to a single Read call for bytes over the connection.
// Can be overridden with context.WithDeadline.
ReadTimeout time.Duration
// Set a custom transport for the http client.
// The default transport configured by the library is passed in as an argument.
TransportFunc func(*http.Transport) (http.RoundTripper, error)
// contains filtered or unexported fields
}
type Parameters ¶
type ProfileEvent ¶
type ProfileInfo ¶
type ProfileInfo = proto.ProfileInfo
type QueryOption ¶
type QueryOption func(*QueryOptions) error
func WithAsync ¶
func WithAsync(wait bool) QueryOption
func WithBlockBufferSize ¶
func WithBlockBufferSize(size uint8) QueryOption
func WithClientInfo ¶
func WithClientInfo(ci ClientInfo) QueryOption
WithClientInfo appends client info data to the query, visible in the system.query_log table. This does not replace the client info provided in the connection options, it appends to it. Can be called multiple times to append more info.
func WithColumnNamesAndTypes ¶
func WithColumnNamesAndTypes(columnNamesAndTypes []ColumnNameAndType) QueryOption
WithColumnNamesAndTypes is used to provide a predetermined list of column names and types for HTTP inserts. Without this, the HTTP implementation will parse the query and run a DESCRIBE TABLE request to fetch and validate column names.
func WithExternalTable ¶
func WithExternalTable(t ...*ext.Table) QueryOption
func WithJWT ¶
func WithJWT(jwt string) QueryOption
WithJWT overrides the existing authentication with the given JWT. This only applies for clients connected with HTTPS to Datastore Cloud.
func WithLogs ¶
func WithLogs(fn func(*Log)) QueryOption
func WithParameters ¶
func WithParameters(params Parameters) QueryOption
func WithProfileEvents ¶
func WithProfileEvents(fn func([]ProfileEvent)) QueryOption
func WithProfileInfo ¶
func WithProfileInfo(fn func(*ProfileInfo)) QueryOption
func WithProgress ¶
func WithProgress(fn func(*Progress)) QueryOption
func WithQueryID ¶
func WithQueryID(queryID string) QueryOption
func WithQuotaKey ¶
func WithQuotaKey(quotaKey string) QueryOption
func WithSettings ¶
func WithSettings(settings Settings) QueryOption
func WithSpan ¶
func WithSpan(span trace.SpanContext) QueryOption
func WithStdAsync
deprecated
func WithStdAsync(wait bool) QueryOption
Deprecated: use `WithAsync` instead.
func WithUserLocation ¶
func WithUserLocation(location *time.Location) QueryOption
func WithoutProfileEvents ¶
func WithoutProfileEvents() QueryOption
WithoutProfileEvents instructs the server not to send profile events for this query. This is a performance optimization for servers >= 25.11 that support the send_profile_events setting. On older servers, the setting is unknown and the server will return an error.
type QueryOptions ¶
type QueryOptions struct {
// contains filtered or unexported fields
}
type ServerVersion ¶
type ServerVersion = proto.ServerHandshake
type Variant ¶
Variant represents a Datastore Variant type that can hold multiple possible types
func NewVariant ¶
NewVariant creates a new Variant with the given value
func NewVariantWithType ¶
NewVariantWithType creates a new Variant with the given value and Datastore type
Source Files
¶
- batch.go
- bind.go
- client_info.go
- col.go
- conn.go
- conn_async_insert.go
- conn_batch.go
- conn_check.go
- conn_exec.go
- conn_handshake.go
- conn_http.go
- conn_http_async_insert.go
- conn_http_batch.go
- conn_http_exec.go
- conn_http_query.go
- conn_logs.go
- conn_ping.go
- conn_pool.go
- conn_process.go
- conn_profile_events.go
- conn_query.go
- conn_send_query.go
- context.go
- context_watchdog.go
- datastore.go
- datastore_options.go
- datastore_rows.go
- datastore_rows_column_type.go
- datastore_std.go
- headers.go
- jwt.go
- logger.go
- query_parameters.go
- scan.go
- struct_map.go
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
cmd/release
command
|
|
|
lib
|
|
|
cityhash102
* COPY from https://github.com/zentures/cityhash/
|
* COPY from https://github.com/zentures/cityhash/ |
|
column/codegen
command
|
|