Documentation
¶
Index ¶
- Constants
- type Decimal
- type HttpError
- type InvalidConfigStrError
- type LineSender
- type LineSenderOption
- func WithAddress(addr string) LineSenderOption
- func WithAuth(tokenId, token string) LineSenderOption
- func WithAutoFlushBytes(bytes int) LineSenderOption
- func WithAutoFlushDisabled() LineSenderOption
- func WithAutoFlushInterval(interval time.Duration) LineSenderOption
- func WithAutoFlushRows(rows int) LineSenderOption
- func WithBasicAuth(user, pass string) LineSenderOption
- func WithBearerToken(token string) LineSenderOption
- func WithCloseTimeout(d time.Duration) LineSenderOption
- func WithFileNameLimit(limit int) LineSenderOption
- func WithGorilla(enabled bool) LineSenderOption
- func WithHttp() LineSenderOption
- func WithHttpTransport(t *http.Transport) LineSenderOption
- func WithInFlightWindow(window int) LineSenderOption
- func WithInitBufferSize(sizeInBytes int) LineSenderOption
- func WithMaxBufferSize(sizeInBytes int) LineSenderOption
- func WithMaxSchemasPerConnection(n int) LineSenderOption
- func WithMinThroughput(bytesPerSecond int) LineSenderOption
- func WithProtocolVersion(version protocolVersion) LineSenderOption
- func WithQwp() LineSenderOption
- func WithQwpDumpWriter(w io.Writer) LineSenderOption
- func WithRequestTimeout(timeout time.Duration) LineSenderOption
- func WithRetryTimeout(t time.Duration) LineSenderOption
- func WithTcp() LineSenderOption
- func WithTls() LineSenderOption
- func WithTlsInsecureSkipVerify() LineSenderOption
- type LineSenderPool
- type LineSenderPoolOption
- type NdArray
- func (n *NdArray[T]) Append(val T) (bool, error)
- func (n *NdArray[T]) Data() []T
- func (n *NdArray[T]) Fill(value T)
- func (n *NdArray[T]) Get(positions ...uint) (T, error)
- func (n *NdArray[T]) NDims() int
- func (n *NdArray[T]) ResetAppendIndex()
- func (n *NdArray[T]) Reshape(newShape ...uint) (*NdArray[T], error)
- func (n *NdArray[T]) Set(v T, positions ...uint) error
- func (n *NdArray[T]) Shape() []uint
- func (n *NdArray[T]) Size() int
- type NdArrayElementType
- type QwpError
- type QwpSender
- type RetryTimeoutError
- type ShopspringDecimal
Constants ¶
const ( ProtocolVersion1 protocolVersion = 1 ProtocolVersion2 protocolVersion = 2 ProtocolVersion3 protocolVersion = 3 )
const MaxArrayElements = (1 << 28) - 1
MaxArrayElements defines the maximum total number of elements of Array
const (
// MaxDimensions defines the maximum dims of NdArray
MaxDimensions = 32
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decimal ¶ added in v4.1.0
type Decimal struct {
// contains filtered or unexported fields
}
Decimal represents a decimal value as a two's complement big-endian byte slice and a scale.
func NewDecimal ¶ added in v4.1.0
NewDecimal constructs a decimal from an arbitrary-precision integer and a scale. Providing a nil unscaled value produces a NULL decimal.
func NewDecimalFromInt64 ¶ added in v4.1.0
NewDecimalFromInt64 constructs a decimal from a 64-bit integer and a scale.
type HttpError ¶
type HttpError struct {
Code string `json:"code"`
Message string `json:"message"`
Line int `json:"line,omitempty"`
ErrorId string `json:"errorId"`
// contains filtered or unexported fields
}
HttpError is a server-sent error message.
func (*HttpError) HttpStatus ¶
HttpStatus returns error HTTP status code.
type InvalidConfigStrError ¶
type InvalidConfigStrError struct {
// contains filtered or unexported fields
}
InvalidConfigStrError is error indicating invalid config string.
func NewInvalidConfigStrError ¶
func NewInvalidConfigStrError(msg string, args ...interface{}) *InvalidConfigStrError
NewInvalidConfigStrError creates new InvalidConfigStrError.
func (*InvalidConfigStrError) Error ¶
func (e *InvalidConfigStrError) Error() string
Error returns full error message string.
type LineSender ¶
type LineSender interface {
// Table sets the table name (metric) for a new ILP message. Should be
// called before any Symbol or Column method.
//
// Table name cannot contain any of the following characters:
// '\n', '\r', '?', ',', ”', '"', '\', '/', ':', ')', '(', '+', '*',
// '%', '~', starting '.', trailing '.', or a non-printable char.
Table(name string) LineSender
// Symbol adds a symbol column value to the ILP message. Should be called
// before any Column method.
//
// Symbol name cannot contain any of the following characters:
// '\n', '\r', '?', '.', ',', ”', '"', '\\', '/', ':', ')', '(', '+',
// '-', '*' '%%', '~', or a non-printable char.
Symbol(name, val string) LineSender
// Int64Column adds a 64-bit integer (long) column value to the ILP
// message.
//
// Column name cannot contain any of the following characters:
// '\n', '\r', '?', '.', ',', ”', '"', '\\', '/', ':', ')', '(', '+',
// '-', '*' '%%', '~', or a non-printable char.
Int64Column(name string, val int64) LineSender
// Long256Column adds a 256-bit unsigned integer (long256) column
// value to the ILP message.
//
// Only non-negative numbers that fit into 256-bit unsigned integer are
// supported and any other input value would lead to an error.
//
// Column name cannot contain any of the following characters:
// '\n', '\r', '?', '.', ',', ”', '"', '\\', '/', ':', ')', '(', '+',
// '-', '*' '%%', '~', or a non-printable char.
Long256Column(name string, val *big.Int) LineSender
// TimestampColumn adds a timestamp column value to the ILP
// message.
//
// Should be used only for non-designated timestamp column.
// Designated timestamp column values should be passed to At/AtNow.
//
// Column name cannot contain any of the following characters:
// '\n', '\r', '?', '.', ',', ”', '"', '\\', '/', ':', ')', '(', '+',
// '-', '*' '%%', '~', or a non-printable char.
TimestampColumn(name string, ts time.Time) LineSender
// Float64Column adds a 64-bit float (double) column value to the ILP
// message.
//
// Column name cannot contain any of the following characters:
// '\n', '\r', '?', '.', ',', ”', '"', '\', '/', ':', ')', '(', '+',
// '-', '*' '%%', '~', or a non-printable char.
Float64Column(name string, val float64) LineSender
// DecimalColumnFromString adds a decimal column value to the ILP message.
//
// Serializes the decimal value using the text representation.
//
// Column name cannot contain any of the following characters:
// '\n', '\r', '?', '.', ',', ”', '"', '\', '/', ':', ')', '(', '+',
// '-', '*' '%%', '~', or a non-printable char.
DecimalColumnFromString(name string, val string) LineSender
// DecimalColumn adds a decimal column value to the ILP message.
//
// Serializes the decimal value using the binary representation.
//
// Column name cannot contain any of the following characters:
// '\n', '\r', '?', '.', ',', ”', '"', '\', '/', ':', ')', '(', '+',
// '-', '*' '%%', '~', or a non-printable char.
DecimalColumn(name string, val Decimal) LineSender
// DecimalColumnShopspring adds a decimal column value to the ILP message.
//
// Serializes the decimal value using the binary representation.
//
// Column name cannot contain any of the following characters:
// '\n', '\r', '?', '.', ',', ”', '"', '\', '/', ':', ')', '(', '+',
// '-', '*' '%%', '~', or a non-printable char.
DecimalColumnShopspring(name string, val ShopspringDecimal) LineSender
// StringColumn adds a string column value to the ILP message.
//
// Column name cannot contain any of the following characters:
// '\n', '\r', '?', '.', ',', ”', '"', '\', '/', ':', ')', '(', '+',
// '-', '*' '%%', '~', or a non-printable char.
StringColumn(name, val string) LineSender
// BoolColumn adds a boolean column value to the ILP message.
//
// Column name cannot contain any of the following characters:
// '\n', '\r', '?', '.', ',', ”', '"', '\', '/', ':', ')', '(', '+',
// '-', '*' '%%', '~', or a non-printable char.
BoolColumn(name string, val bool) LineSender
// Float64Array1DColumn adds an array of 64-bit floats (double array) to the ILP message.
//
// Column name cannot contain any of the following characters:
// '\n', '\r', '?', '.', ',', "', '"', '\', '/', ':', ')', '(', '+',
// '-', '*' '%%', '~', or a non-printable char.
Float64Array1DColumn(name string, values []float64) LineSender
// Float64Array2DColumn adds a 2D array of 64-bit floats (double 2D array) to the ILP message.
//
// The values parameter must have a regular (rectangular) shape - all rows must have
// exactly the same length. If the array has irregular shape, this method returns an error.
//
// Example of valid input:
// values := [][]float64{{1.0, 2.0}, {3.0, 4.0}, {5.0, 6.0}} // 3x2 regular shape
//
// Example of invalid input:
// values := [][]float64{{1.0, 2.0}, {3.0}, {4.0, 5.0, 6.0}} // irregular shape - returns error
//
// Column name cannot contain any of the following characters:
// '\n', '\r', '?', '.', ',', "', '"', '\', '/', ':', ')', '(', '+',
// '-', '*' '%%', '~', or a non-printable char.
Float64Array2DColumn(name string, values [][]float64) LineSender
// Float64Array3DColumn adds a 3D array of 64-bit floats (double 3D array) to the ILP message.
//
// The values parameter must have a regular (cuboid) shape - all dimensions must have
// consistent sizes throughout. If the array has irregular shape, this method returns an error.
//
// Example of valid input:
// values := [][][]float64{
// {{1.0, 2.0}, {3.0, 4.0}}, // 2x2 matrix
// {{5.0, 6.0}, {7.0, 8.0}}, // 2x2 matrix (same shape)
// } // 2x2x2 regular shape
//
// Example of invalid input:
// values := [][][]float64{
// {{1.0, 2.0}, {3.0, 4.0}}, // 2x2 matrix
// {{5.0}, {6.0, 7.0, 8.0}}, // irregular matrix - returns error
// }
//
// Column name cannot contain any of the following characters:
// '\n', '\r', '?', '.', ',', "', '"', '\', '/', ':', ')', '(', '+',
// '-', '*' '%%', '~', or a non-printable char.
Float64Array3DColumn(name string, values [][][]float64) LineSender
// Float64ArrayNDColumn adds an n-dimensional array of 64-bit floats (double n-D array) to the ILP message.
//
// Example usage:
// // Create a 2x3x4 array
// arr, _ := questdb.NewNDArray[float64](2, 3, 4)
// arr.Fill(1.5)
// sender.Float64ArrayNDColumn("ndarray_col", arr)
//
// Column name cannot contain any of the following characters:
// '\n', '\r', '?', '.', ',', "', '"', '\', '/', ':', ')', '(', '+',
// '-', '*' '%%', '~', or a non-printable char.
Float64ArrayNDColumn(name string, values *NdArray[float64]) LineSender
// At sets the designated timestamp value and finalizes the ILP
// message.
//
// If the underlying buffer reaches configured capacity or the
// number of buffered messages exceeds the auto-flush trigger, this
// method also sends the accumulated messages.
//
// If ts.IsZero(), no timestamp is sent to the server.
At(ctx context.Context, ts time.Time) error
// AtNow omits designated timestamp value and finalizes the ILP
// message. The server will insert each message using the system
// clock as the row timestamp.
//
// If the underlying buffer reaches configured capacity or the
// number of buffered messages exceeds the auto-flush trigger, this
// method also sends the accumulated messages.
AtNow(ctx context.Context) error
// Flush sends the accumulated messages via the underlying
// connection. Should be called periodically to make sure that
// all messages are sent to the server.
//
// For optimal performance, this method should not be called after
// each ILP message. Instead, the messages should be written in
// batches followed by a Flush call. The optimal batch size may
// vary from one thousand to few thousand messages depending on
// the message size.
Flush(ctx context.Context) error
// Close closes the underlying HTTP client.
//
// If auto-flush is enabled, the client will flush any remaining buffered
// messages before closing itself.
Close(ctx context.Context) error
}
LineSender allows you to insert rows into QuestDB by sending ILP messages over HTTP or TCP protocol.
Each sender corresponds to a single client-server connection. A sender should not be called concurrently by multiple goroutines.
HTTP senders reuse connections from a global pool by default. You can customize the HTTP transport by passing a custom http.Transport to the WithHttpTransport option.
func LineSenderFromConf ¶
func LineSenderFromConf(ctx context.Context, conf string) (LineSender, error)
LineSenderFromConf creates a LineSender using the QuestDB config string format.
Example config string: "http::addr=localhost;username=admin;password=quest;auto_flush_rows=1000;"
QuestDB ILP clients use a common key-value configuration string format across all implementations. We opted for this config over a URL because it reduces the amount of character escaping required for paths and base64-encoded param values.
The config string format is as follows:
schema::key1=value1;key2=value2;key3=value3;
Schemas supported are "http", "https", "tcp", "tcps"
Options: http(s) and tcp(s):
-------------------
addr: hostname/port of QuestDB endpoint
init_buf_size: initial growable ILP buffer size in bytes (defaults to 128KiB)
tls_verify: determines if TLS certificates should be validated (defaults to "on", can be set to "unsafe_off")
http(s)-only
------------
username: for basic authentication
password: for basic authentication
token: bearer token auth (used instead of basic authentication)
auto_flush: determines if auto-flushing is enabled (values "on" or "off", defaults to "on")
auto_flush_rows: auto-flushing is triggered above this row count (defaults to 75000). If set, explicitly implies auto_flush=on. Set to 'off' to disable.
auto_flush_interval: auto-flushing is triggered above this time, in milliseconds (defaults to 1000 milliseconds). If set, explicitly implies auto_flush=on. Set to 'off' to disable.
request_min_throughput: bytes per second, used to calculate each request's timeout (defaults to 100KiB/s)
request_timeout: minimum request timeout in milliseconds (defaults to 10 seconds)
retry_timeout: cumulative maximum millisecond duration spent in retries (defaults to 10 seconds)
max_buf_size: buffer growth limit in bytes. Client errors if breached (default is 100MiB)
tcp(s)-only
-----------
username: KID (key ID) for ECDSA authentication
token: Secret K (D) for ECDSA authentication
func LineSenderFromEnv ¶
func LineSenderFromEnv(ctx context.Context) (LineSender, error)
LineSenderFromEnv creates a LineSender with a config string defined by the QDB_CLIENT_CONF environment variable. See LineSenderFromConf for the config string format.
This is a convenience method suitable for Cloud environments.
func NewLineSender ¶
func NewLineSender(ctx context.Context, opts ...LineSenderOption) (LineSender, error)
NewLineSender creates new InfluxDB Line Protocol (ILP) sender. Each sender corresponds to a single client connection. LineSender should not be called concurrently by multiple goroutines.
type LineSenderOption ¶
type LineSenderOption func(*lineSenderConfig)
LineSenderOption defines line sender config option.
func WithAddress ¶
func WithAddress(addr string) LineSenderOption
WithAddress sets address to connect to. Should be in the "host:port" format. Defaults to "127.0.0.1:9000" in case of HTTP and "127.0.0.1:9009" in case of TCP.
func WithAuth ¶
func WithAuth(tokenId, token string) LineSenderOption
WithAuth sets token (private key) used for ILP authentication.
Only available for the TCP sender.
func WithAutoFlushBytes ¶ added in v4.2.0
func WithAutoFlushBytes(bytes int) LineSenderOption
WithAutoFlushBytes triggers an auto-flush once the cumulative size of all buffered table data exceeds the given byte threshold. A value of 0 disables the byte-based trigger. Defaults to 0.
Only available for the QWP sender. Distinct from WithMaxBufferSize: this is a soft trigger, while WithMaxBufferSize is a hard cap.
func WithAutoFlushDisabled ¶
func WithAutoFlushDisabled() LineSenderOption
WithAutoFlushDisabled turns off auto-flushing behavior. To send ILP messages, the user must call Flush().
Only available for the HTTP sender.
func WithAutoFlushInterval ¶
func WithAutoFlushInterval(interval time.Duration) LineSenderOption
WithAutoFlushInterval the interval at which the Sender automatically flushes its buffer. Defaults to 1 second.
Only available for the HTTP sender.
func WithAutoFlushRows ¶
func WithAutoFlushRows(rows int) LineSenderOption
WithAutoFlushRows sets the number of buffered rows that must be breached in order to trigger an auto-flush. Defaults to 75000.
Only available for the HTTP sender.
func WithBasicAuth ¶
func WithBasicAuth(user, pass string) LineSenderOption
WithBasicAuth sets a Basic authentication header for ILP requests over HTTP.
Only available for the HTTP sender.
func WithBearerToken ¶
func WithBearerToken(token string) LineSenderOption
WithBearerToken sets a Bearer token Authentication header for ILP requests.
Only available for the HTTP sender.
func WithCloseTimeout ¶ added in v4.2.0
func WithCloseTimeout(d time.Duration) LineSenderOption
WithCloseTimeout sets the time Close() waits for the async I/O goroutine to finish before force-cancelling. Defaults to 5 seconds. Calling Flush() before Close() guarantees all data is ACKed regardless of this timeout.
Only relevant for the QWP sender in async mode (in-flight window > 1).
func WithFileNameLimit ¶
func WithFileNameLimit(limit int) LineSenderOption
WithFileNameLimit sets maximum file name length in chars allowed by the server. Affects maximum table and column name lengths accepted by the sender. Should be set to the same value as on the server. Defaults to 127.
func WithGorilla ¶ added in v4.2.0
func WithGorilla(enabled bool) LineSenderOption
WithGorilla enables or disables Gorilla delta-of-delta encoding for timestamp columns. Defaults to enabled. When disabled, FLAG_GORILLA is cleared on every message and timestamp columns are sent as raw int64 little-endian values with no encoding-flag prefix.
Mirrors QwpWebSocketSender.setGorillaEnabled in the Java client (default true there as well). Only available for the QWP sender.
func WithHttpTransport ¶
func WithHttpTransport(t *http.Transport) LineSenderOption
WithHttpTransport sets the client's http transport to the passed pointer instead of the global transport. This can be used for customizing the http transport used by the LineSender. For example to set custom timeouts, TLS settings, etc. WithTlsInsecureSkipVerify is ignored when this option is in use.
Only available for the HTTP sender.
func WithInFlightWindow ¶ added in v4.2.0
func WithInFlightWindow(window int) LineSenderOption
WithInFlightWindow sets the number of concurrent in-flight batches for async QWP mode. A value of 1 forces synchronous mode (each Flush blocks until the ACK arrives). Values > 1 enable async mode with a dedicated I/O goroutine. Defaults to 128.
Only available for the QWP sender.
func WithInitBufferSize ¶
func WithInitBufferSize(sizeInBytes int) LineSenderOption
WithInitBufferSize sets the desired initial buffer capacity in bytes to be used when sending ILP messages. Defaults to 128KB.
This setting is a soft limit, i.e. the underlying buffer may grow larger than the provided value.
func WithMaxBufferSize ¶
func WithMaxBufferSize(sizeInBytes int) LineSenderOption
WithMaxBufferSize sets the maximum buffer capacity in bytes to be used when sending ILP messages. The sender will return an error if the limit is reached. Defaults to 100MB.
Only available for the HTTP sender.
func WithMaxSchemasPerConnection ¶ added in v4.2.0
func WithMaxSchemasPerConnection(n int) LineSenderOption
WithMaxSchemasPerConnection caps the number of schema IDs that may be registered on a single QWP connection before the sender returns an error. Once the cap is hit, the caller should close and re-open the sender to start a new schema ID space. Defaults to 65535.
Only available for the QWP sender.
func WithMinThroughput ¶
func WithMinThroughput(bytesPerSecond int) LineSenderOption
WithMinThroughput is used in combination with request_timeout to set the timeout of an ILP request. Defaults to 100KiB/s.
timeout = (request.len() / request_min_throughput) + request_timeout
Only available for the HTTP sender.
func WithProtocolVersion ¶
func WithProtocolVersion(version protocolVersion) LineSenderOption
WithProtocolVersion sets the ingestion protocol version.
- HTTP transport automatically negotiates the protocol version by default(unset, STRONGLY RECOMMENDED). You can explicitly configure the protocol version to avoid the slight latency cost at connection time.
- TCP transport does not negotiate the protocol version and uses ProtocolVersion1 by default. You must explicitly set ProtocolVersion2 in order to ingest arrays.
- ProtocolVersion3 enables decimal binary encoding (ILP v3).
NOTE: QuestDB server version 9.0.0 or later is required for ProtocolVersion2. For ProtocolVersion3, make sure the server advertises ILP v3 support via /settings.
func WithQwp ¶ added in v4.2.0
func WithQwp() LineSenderOption
WithQwp enables ingestion over the QWP WebSocket protocol.
func WithQwpDumpWriter ¶ added in v4.2.0
func WithQwpDumpWriter(w io.Writer) LineSenderOption
WithQwpDumpWriter returns an option that records all outgoing TCP bytes to w. When no server address is configured, an in-process fake WebSocket acceptor is used so the dump includes the full HTTP upgrade and WebSocket framing — replayable via "cat dump.bin | nc host port".
Only available for the QWP sender.
func WithRequestTimeout ¶
func WithRequestTimeout(timeout time.Duration) LineSenderOption
WithRequestTimeout is used in combination with request_min_throughput to set the timeout of an ILP request. Defaults to 10 seconds.
timeout = (request.len() / request_min_throughput) + request_timeout
Only available for the HTTP sender.
func WithRetryTimeout ¶
func WithRetryTimeout(t time.Duration) LineSenderOption
WithRetryTimeout is the cumulative maximum duration spend in retries. Defaults to 10 seconds. Retries work great when used in combination with server-side data deduplication.
Only network-related errors and certain 5xx response codes are retryable.
Only available for the HTTP sender.
func WithTlsInsecureSkipVerify ¶
func WithTlsInsecureSkipVerify() LineSenderOption
WithTlsInsecureSkipVerify enables TLS connection encryption, but skips server certificate verification. Useful in test environments with self-signed certificates. Do not use in production environments.
type LineSenderPool ¶
type LineSenderPool struct {
// contains filtered or unexported fields
}
LineSenderPool wraps a mutex-protected slice of LineSender. It allows a goroutine to Acquire a sender from the pool and Release it back to the pool when it's done being used.
WARNING: This is an experimental API that is designed to work with HTTP senders ONLY.
func PoolFromConf ¶
func PoolFromConf(conf string, opts ...LineSenderPoolOption) (*LineSenderPool, error)
PoolFromConf instantiates a new LineSenderPool with a QuestDB configuration string. Any sender acquired from this pool will be initialized with the same configuration string that was passed into the conf argument.
The default maximum number of senders is 64, but can be customized by using the WithMaxSenders option.
func PoolFromOptions ¶
func PoolFromOptions(opts ...LineSenderOption) (*LineSenderPool, error)
PoolFromOptions instantiates a new LineSenderPool using programmatic options. Any sender acquired from this pool will be initialized with the same options that were passed into the opts argument.
Unlike PoolFromConf, PoolFromOptions does not have the ability to customize the returned LineSenderPool. In this case, to add options (such as WithMaxSenders), you need manually apply these options after calling this method.
// Create a PoolFromOptions with LineSender options
p, err := PoolFromOptions(
WithHttp(),
WithAutoFlushRows(1000000),
)
if err != nil {
panic(err)
}
// Add Pool-level options manually
WithMaxSenders(32)(p)
func (*LineSenderPool) Close ¶
func (p *LineSenderPool) Close(ctx context.Context) error
Close sets the pool's status to "closed" and closes all cached LineSenders. When LineSenders are released back into a closed pool, they will be closed and discarded.
func (*LineSenderPool) IsClosed ¶
func (p *LineSenderPool) IsClosed() bool
IsClosed will return true if the pool is closed. Once a pool is closed, you will not be able to Acquire any new LineSenders from it. When LineSenders are released back into a closed pool, they will be closed and discarded.
func (*LineSenderPool) Len ¶
func (p *LineSenderPool) Len() int
Len returns the number of LineSenders in the pool.
func (*LineSenderPool) Sender ¶
func (p *LineSenderPool) Sender(ctx context.Context) (LineSender, error)
Sender obtains a LineSender from the pool. If the pool is empty, a new LineSender will be instantiated using the pool's config string. If there is already maximum number of senders obtained from the pool, this call will block until one of the senders is returned back to the pool by calling sender.Close().
type LineSenderPoolOption ¶
type LineSenderPoolOption func(*LineSenderPool)
LineSenderPoolOption defines line sender pool config option.
func WithMaxSenders ¶
func WithMaxSenders(count int) LineSenderPoolOption
WithMaxSenders sets the maximum number of senders in the pool. The default maximum number of senders is 64.
type NdArray ¶
type NdArray[T NdArrayElementType] struct { // contains filtered or unexported fields }
NdArray represents a generic n-dimensional array with shape validation. It's designed to be used with the [LineSender.Float64ArrayNDColumn] method for sending multi-dimensional arrays to QuestDB via the ILP protocol.
NdArray instances are meant to be reused across multiple calls to the sender to avoid memory allocations. Use Append to populate data and ResetAppendIndex to reset the array for reuse after sending data.
By default, all values in the array are initialized to zero.
func NewNDArray ¶
func NewNDArray[T NdArrayElementType](shape ...uint) (*NdArray[T], error)
NewNDArray creates a new NdArray with the specified shape. All elements are initialized to zero by default.
func (*NdArray[T]) Append ¶
Append adds a value to the array sequentially at the current append index. Returns true if there's more space for additional values, false if the array is now full. Use ResetAppendIndex() to reuse the array for multiple ILP messages.
Example:
arr, _ := NewNDArray[float64](2, 3) // 2x3 array (6 elements total) hasMore, _ := arr.Append(1.0) // hasMore = true, index now at 1 hasMore, _ = arr.Append(2.0) // hasMore = true, index now at 2 // ... append 4 more values hasMore, _ = arr.Append(6.0) // hasMore = false, array is full // To reuse the array: arr.ResetAppendIndex() arr.Append(10.0) // overwrites ...
func (*NdArray[T]) Fill ¶
func (n *NdArray[T]) Fill(value T)
Fill fills the entire array with the specified value
func (*NdArray[T]) ResetAppendIndex ¶
func (n *NdArray[T]) ResetAppendIndex()
ResetAppendIndex resets the append index to 0, allowing the NdArray to be reused for multiple append operations. This is useful for reusing arrays across multiple messages/rows ingestion without reallocating memory.
Example:
arr, _ := NewNDArray[float64](2) // 1D array with 3 elements arr.Append(2.0) arr.Append(3.0) // array is now full // sender.Float64ArrayNDColumn(arr) arr.ResetAppendIndex() // reset for reuse arr.Append(4.0) arr.Append(5.0)
type NdArrayElementType ¶
type NdArrayElementType interface {
~float64
}
NdArrayElementType represents the constraint for numeric types that can be used in NdArray
type QwpError ¶ added in v4.2.0
type QwpError struct {
// Status is the status code from the ACK response.
Status qwpStatusCode
// Sequence is the cumulative sequence number from the ACK, used
// to correlate responses with requests in async mode.
Sequence int64
// Message is the server's error description, or empty if
// no error message was included in the response.
Message string
}
QwpError represents an error returned by the QuestDB server in a QWP ACK response. It contains the status code, the sequence number from the response, and an optional error message.
type QwpSender ¶ added in v4.2.0
type QwpSender interface {
LineSender
// ByteColumn adds a BYTE (int8) column value.
ByteColumn(name string, val int8) QwpSender
// ShortColumn adds a SHORT (int16) column value.
ShortColumn(name string, val int16) QwpSender
// Int32Column adds an INT (int32) column value.
Int32Column(name string, val int32) QwpSender
// Float32Column adds a FLOAT (float32) column value.
Float32Column(name string, val float32) QwpSender
// CharColumn adds a CHAR column value stored as a UTF-16 code unit.
CharColumn(name string, val rune) QwpSender
// DateColumn adds a DATE column value (milliseconds since epoch).
DateColumn(name string, val time.Time) QwpSender
// TimestampNanosColumn adds a TIMESTAMP column value (nanoseconds since epoch).
TimestampNanosColumn(name string, val time.Time) QwpSender
// UuidColumn adds a UUID column value from high and low 64-bit parts.
UuidColumn(name string, hi, lo uint64) QwpSender
// GeohashColumn adds a GEOHASH column value with the given bit precision.
GeohashColumn(name string, hash uint64, precision int) QwpSender
// Int64Array1DColumn adds a 1-dimensional LONG array column.
Int64Array1DColumn(name string, values []int64) QwpSender
// Int64Array2DColumn adds a 2-dimensional LONG array column.
Int64Array2DColumn(name string, values [][]int64) QwpSender
// Int64Array3DColumn adds a 3-dimensional LONG array column.
Int64Array3DColumn(name string, values [][][]int64) QwpSender
// Decimal64Column adds a DECIMAL64 column value (8 bytes on the wire,
// 18 digits of precision). Returns an error on the next At/AtNow/Flush
// if the value's unscaled coefficient does not fit in 64 bits.
Decimal64Column(name string, val Decimal) QwpSender
// Decimal128Column adds a DECIMAL128 column value (16 bytes on the wire,
// 38 digits of precision). Returns an error on the next At/AtNow/Flush
// if the value's unscaled coefficient does not fit in 128 bits.
Decimal128Column(name string, val Decimal) QwpSender
// Decimal256Column adds a DECIMAL256 column value (32 bytes on the wire,
// 77 digits of precision). Equivalent to DecimalColumn.
Decimal256Column(name string, val Decimal) QwpSender
// AtNano closes the current row with a nanosecond-resolution
// designated timestamp (TYPE_TIMESTAMP_NANO on the wire). It is
// the nanosecond counterpart of LineSender.At, which uses
// microseconds.
//
// A table's designated timestamp resolution is fixed by its first
// row: mixing At and AtNano on rows of the same table within one
// flush returns a type-conflict error.
AtNano(ctx context.Context, ts time.Time) error
}
QwpSender extends LineSender with column types only available in the QWP binary protocol. These types are not part of ILP and cannot be used with HTTP or TCP senders.
type RetryTimeoutError ¶
RetryTimeoutError is error indicating failed flush retry attempt.
func NewRetryTimeoutError ¶
func NewRetryTimeoutError(timeout time.Duration, lastError error) *RetryTimeoutError
NewRetryTimeoutError returns a new RetryTimeoutError error.
func (*RetryTimeoutError) Error ¶
func (e *RetryTimeoutError) Error() string
Error returns full error message string.
type ShopspringDecimal ¶ added in v4.1.0
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
from-conf
command
|
|
|
http/auth
command
|
|
|
http/auth-and-tls
command
|
|
|
http/basic
command
|
|
|
tcp/auth
command
|
|
|
tcp/auth-and-tls
command
|
|
|
tcp/basic
command
|