Documentation
¶
Index ¶
- type DB
- func (db *DB) Close()
- func (db *DB) CreateTable(tableName string, schema string) error
- func (db *DB) DropTable(tableName string) error
- func (db *DB) Exec(query string, params ...any) (sql.Result, error)
- func (db *DB) ForceFlushTable(tableName string)
- func (db *DB) GetWriteQueue(table string) typesdb.WriteQueueInterface
- func (db *DB) GetWriteQueueConfig(tableName string) (batchSize int, flushInterval time.Duration, err error)
- func (db *DB) InitWriteQueue(table string, queueType typesdb.WriteQueueType, batchSize int, ...)
- func (db *DB) Query(table string, query string, params ...any) (*sql.Rows, error)
- func (db *DB) QueryRow(query string, params ...any) *sql.Row
- func (db *DB) QueueWrite(tableName, query string, params ...any)
- func (db *DB) QueueWriteWithPath(tableName, path, query string, params ...any)
- func (db *DB) SetWriteQueueBatchSize(tableName string, batchSize int) error
- func (db *DB) SetWriteQueueConfig(tableName string, batchSize int, flushInterval time.Duration) error
- func (db *DB) SetWriteQueueFlushInterval(tableName string, flushInterval time.Duration) error
- func (db *DB) Write(query string, params ...any) error
- func (db *DB) WriteBatch(tableQueries map[string][]string, tableParams map[string][][]any) error
- type WriteQueue
- func (wq *WriteQueue) Add(path string, op typesdb.WriteOp)
- func (wq *WriteQueue) Flush(force ...bool) []typesdb.Batch
- func (wq *WriteQueue) GetBatchSize() int
- func (wq *WriteQueue) GetFlushInterval() time.Duration
- func (wq *WriteQueue) IsReadyToWrite() bool
- func (wq *WriteQueue) SetBatchSize(batchSize int)
- func (wq *WriteQueue) SetConfig(batchSize int, flushInterval time.Duration)
- func (wq *WriteQueue) SetFlushInterval(interval time.Duration)
- func (wq *WriteQueue) ShouldFlush(force ...bool) bool
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 (*DB) CreateTable ¶
CreateTable creates a table if it doesn't exist.
func (*DB) ForceFlushTable ¶
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) GetWriteQueueConfig ¶ added in v0.1.6
func (db *DB) GetWriteQueueConfig(tableName string) (batchSize int, flushInterval time.Duration, err error)
GetWriteQueueConfig returns the current batch size and flush interval for a specific table's write queue
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) QueueWrite ¶
QueueWrite always treats ops here as inserts
func (*DB) QueueWriteWithPath ¶
QueueWriteWithPath is for update‐style ops
func (*DB) SetWriteQueueBatchSize ¶ added in v0.1.6
SetWriteQueueBatchSize updates the batch size for a specific table's write queue
func (*DB) SetWriteQueueConfig ¶ added in v0.1.6
func (db *DB) SetWriteQueueConfig(tableName string, batchSize int, flushInterval time.Duration) error
SetWriteQueueConfig updates both batch size and flush interval for a specific table's write queue
func (*DB) SetWriteQueueFlushInterval ¶ added in v0.1.6
SetWriteQueueFlushInterval updates the flush interval for a specific table's write queue
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) GetBatchSize ¶ added in v0.1.6
func (wq *WriteQueue) GetBatchSize() int
GetBatchSize returns the current batch size
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) SetBatchSize ¶ added in v0.1.6
func (wq *WriteQueue) SetBatchSize(batchSize int)
SetBatchSize allows changing the batch size at runtime
func (*WriteQueue) SetConfig ¶ added in v0.1.6
func (wq *WriteQueue) SetConfig(batchSize int, flushInterval time.Duration)
SetConfig allows updating both batch size and flush interval at once
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)