Help us shape the future of Go! Take the 2026 Go Developer Survey

volume_idb

package
v0.57.21 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Rendered for js/wasm

Overview

Package volume_idb implements the browser volume engines' storage primitives on IndexedDB: a chunked device.Device and a records.Store.

Every call is one IndexedDB transaction. A call issues all of its requests in one JavaScript task and returns on the transaction's complete event, so the Go code blocks only once per call.

Index

Constants

View Source
const ChunkSize = 64 << 10

ChunkSize is the length of a full chunk.

Variables

This section is empty.

Functions

func DeleteDatabase

func DeleteDatabase(name string) error

DeleteDatabase deletes the database name. A missing database is not an error.

Types

type Device

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

Device is a device.Device on one IndexedDB database. It is the database's only writer, enforced by an exclusive Web Lock held from OpenDevice until Close: it holds the file lengths and the last chunk written to each file, so appends need no read.

func OpenDevice

func OpenDevice(ctx context.Context, name string) (*Device, error)

OpenDevice opens the device database name, creating it when absent. It returns device.ErrHeld while another Device in the origin has name open.

func (*Device) Close

func (d *Device) Close() error

Close closes the database connection and releases the Web Lock.

func (*Device) List

func (d *Device) List(ctx context.Context) ([]device.File, error)

List returns every file from the lengths the device holds.

func (*Device) Read

func (d *Device) Read(ctx context.Context, reads []device.Read) error

Read fills every read, reading the chunks in one transaction.

func (*Device) Remove

func (d *Device) Remove(ctx context.Context, names []string) error

Remove deletes files and their chunks in one transaction.

func (*Device) Truncate

func (d *Device) Truncate(ctx context.Context, name string, size int64) error

Truncate sets a file's length. Shrinking deletes the chunks past the end and cuts the new last chunk, so growing again reads zeros.

func (*Device) Write

func (d *Device) Write(ctx context.Context, writes []device.Write, flush bool) error

Write applies writes in one transaction, strict when flush is set. A chunk the batch overwrites only in part is read first in one read transaction, unless it is a file's last written chunk.

type Store

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

Store is a records.Store on one IndexedDB database.

func OpenStore

func OpenStore(ctx context.Context, name string) (*Store, error)

OpenStore opens the record store database name, creating it when absent.

func (*Store) Close

func (s *Store) Close() error

Close closes the database connection.

func (*Store) Commit

func (s *Store) Commit(ctx context.Context, ops []records.Op, durable bool) error

Commit applies ops in one transaction, strict when durable is set.

func (*Store) Get

func (s *Store) Get(ctx context.Context, keys [][]byte) ([][]byte, error)

Get reads the records of keys in one transaction.

func (*Store) Has

func (s *Store) Has(ctx context.Context, keys [][]byte) ([]bool, error)

Has reports which keys have records in one transaction.

func (*Store) Scan

func (s *Store) Scan(ctx context.Context, prefix []byte, fn func(key, value []byte) error) error

Scan reads every record under prefix in one transaction, then calls fn with each in key order.

Jump to

Keyboard shortcuts

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