backend

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package backend contains the thin runtime boundary around Apache's official IoTDB Go client.

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = errors.New("iotdb: backend is closed")

ErrClosed reports use of a backend after its lifecycle has ended.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	Mode() ModelMode
	Ping(context.Context) error
	Exec(context.Context, string) error
	Query(context.Context, string) (ResultSet, error)
	InsertTablets(context.Context, []*client.Tablet, bool) error
	InspectTreeDevice(context.Context, string) (TreeDeviceSchema, error)
	EnsureTreeSchema(context.Context, string, []Measurement, bool) error
	Close() error
}

Backend is the model-independent runtime used by the GORM adapter.

type Config

type Config struct {
	Mode                   ModelMode
	NodeURLs               []string
	Username               string
	Password               string
	Database               string
	PoolSize               int
	ConnectTimeout         time.Duration
	AcquireTimeout         time.Duration
	QueryTimeout           time.Duration
	FetchSize              int32
	TimeZone               string
	ConnectRetryMax        int
	EnableRPCCompression   bool
	TableInsertConcurrency int
}

Config contains the official-client settings needed by a backend.

type Measurement

type Measurement struct {
	Name        string
	DataType    client.TSDataType
	Encoding    client.TSEncoding
	Compression client.TSCompressionType
}

Measurement describes one TreeModel time series.

type ModelMode

type ModelMode uint8

ModelMode selects the IoTDB data model used by a dialector.

const (
	// TreeModel targets IoTDB's hierarchical time-series model.
	TreeModel ModelMode = iota
	// TableModel targets IoTDB's relational table model.
	TableModel
)

type Official

type Official struct {
	// contains filtered or unexported fields
}

Official implements Backend with official v2 write/Table pools and a v1 TreeModel query pool.

func NewOfficial

func NewOfficial(config Config) (*Official, error)

NewOfficial creates the official pools required by the configured model compatibility boundary.

func (*Official) Close

func (o *Official) Close() error

Close waits for checked-out result sets and then closes all owned official pools.

func (*Official) EnsureTreeSchema

func (o *Official) EnsureTreeSchema(ctx context.Context, device string, measurements []Measurement, aligned bool) error

EnsureTreeSchema creates only missing measurements and rejects incompatible schema.

func (*Official) Exec

func (o *Official) Exec(ctx context.Context, statement string) error

Exec executes one non-query statement through the selected official pool.

func (*Official) InsertTablets

func (o *Official) InsertTablets(ctx context.Context, tablets []*client.Tablet, aligned bool) error

InsertTablets inserts prebuilt official tablets without SQL row fallback.

func (*Official) InspectTreeDevice

func (o *Official) InspectTreeDevice(ctx context.Context, device string) (TreeDeviceSchema, error)

InspectTreeDevice returns existing alignment and measurement type metadata.

func (*Official) Mode

func (o *Official) Mode() ModelMode

Mode reports the configured server model.

func (*Official) Ping

func (o *Official) Ping(ctx context.Context) error

Ping verifies that a session can execute a small server-side query.

func (*Official) Query

func (o *Official) Query(ctx context.Context, statement string) (ResultSet, error)

Query executes one query and keeps its official session checked out until Close.

type ResultSet

type ResultSet interface {
	ColumnNames() []string
	ColumnTypes() []string
	Next() (bool, error)
	Value(index int) (any, error)
	Close() error
}

ResultSet is the minimal result contract consumed by the database/sql bridge.

type TreeDeviceSchema

type TreeDeviceSchema struct {
	Exists       bool
	Aligned      bool
	Measurements map[string]client.TSDataType
}

TreeDeviceSchema is the server-side schema currently visible for a device.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL