db

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

func NewDB

func NewDB(dbPath string) (*DB, error)

NewDB initializes the DuckDB connection without any write queues.

func (*DB) Close

func (db *DB) Close()

Close shuts down all write queues and DB connection.

func (*DB) CreateTable

func (db *DB) CreateTable(tableName string, schema string) error

CreateTable creates a table if it doesn't exist.

func (*DB) DropTable

func (db *DB) DropTable(tableName string) error

DropTable removes a table if it exists.

func (*DB) Exec

func (db *DB) Exec(query string, params ...any) (sql.Result, error)

Exec runs a direct write query and returns the result

func (*DB) ForceFlushTable

func (db *DB) ForceFlushTable(tableName string)

ForceFlushTable forces a flush of the write queue for a specific table

func (*DB) GetWriteQueue

func (db *DB) GetWriteQueue(table string) typesdb.WriteQueueInterface

GetWriteQueue returns the write queue for a given table.

func (*DB) InitWriteQueue

func (db *DB) InitWriteQueue(table string, queueType typesdb.WriteQueueType, batchSize int, flushInterval time.Duration)

InitWriteQueue initializes a write queue for a specific table.

func (*DB) Query

func (db *DB) Query(table string, query string, params ...any) (*sql.Rows, error)

Query runs a read query after flushing pending writes for the given table.

func (*DB) QueryRow

func (db *DB) QueryRow(query string, params ...any) *sql.Row

QueryRow runs a single row query and returns a *sql.Row

func (*DB) QueueWrite

func (db *DB) QueueWrite(tableName, query string, params ...any)

QueueWrite always treats ops here as inserts

func (*DB) QueueWriteWithPath

func (db *DB) QueueWriteWithPath(tableName, path, query string, params ...any)

QueueWriteWithPath is for update‐style ops

func (*DB) Write

func (db *DB) Write(query string, params ...any) error

Write runs a direct write query (e.g. schema setup).

func (*DB) WriteBatch

func (db *DB) WriteBatch(tableQueries map[string][]string, tableParams map[string][][]any) error

WriteBatch exposes batchExecute for use by external modules (e.g., logger).

type WriteQueue

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

WriteQueue manages write operations for a single table

func NewWriteQueue

func NewWriteQueue(tableName string, queueType typesdb.WriteQueueType, batchSize int, flushTimer time.Duration) *WriteQueue

NewWriteQueue creates a new write queue for a specific table

func (*WriteQueue) Add

func (wq *WriteQueue) Add(path string, op typesdb.WriteOp)

Add queues a new operation

func (*WriteQueue) Flush

func (wq *WriteQueue) Flush(force ...bool) []typesdb.Batch

Flush processes all queued operations and returns the batches

func (*WriteQueue) GetFlushInterval

func (wq *WriteQueue) GetFlushInterval() time.Duration

GetFlushInterval returns the current flush interval

func (*WriteQueue) IsReadyToWrite

func (wq *WriteQueue) IsReadyToWrite() bool

IsReadyToWrite returns whether the queue is ready to be flushed

func (*WriteQueue) SetFlushInterval

func (wq *WriteQueue) SetFlushInterval(interval time.Duration)

SetFlushInterval allows changing the flush interval

func (*WriteQueue) ShouldFlush

func (wq *WriteQueue) ShouldFlush(force ...bool) bool

ShouldFlush determines if a flush should occur and sets up the writing state Returns (ShouldFlush bool)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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