storage

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package storage provides SQLite-based fingerprint storage for element tracking. It stores element fingerprints keyed by URL + selector identifier, enabling adaptive element relocation when website structures change.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ElementDict

type ElementDict struct {
	Tag        string            `json:"tag"`
	Text       string            `json:"text"`
	Attributes map[string]string `json:"attributes"`
	Path       []string          `json:"path"`
	Parent     *ParentDict       `json:"parent,omitempty"`
	Siblings   []string          `json:"siblings"`
	Children   []string          `json:"children"`
}

ElementDict represents a serialized element fingerprint.

type ParentDict

type ParentDict struct {
	Tag        string            `json:"tag"`
	Attributes map[string]string `json:"attributes"`
	Text       string            `json:"text"`
}

ParentDict represents parent element metadata for fingerprinting.

type Store

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

Store is a thread-safe SQLite storage for element fingerprints.

func New

func New(dbPath string) (*Store, error)

New creates a new Store with the given database file path. Pass ":memory:" for an in-memory database.

func (*Store) Clear

func (s *Store) Clear() error

Clear removes all stored fingerprints.

func (*Store) Close

func (s *Store) Close() error

Close closes the database connection.

func (*Store) Count

func (s *Store) Count() (int, error)

Count returns the total number of stored fingerprints.

func (*Store) Delete

func (s *Store) Delete(rawURL, identifier string) error

Delete removes a stored fingerprint.

func (*Store) List

func (s *Store) List(rawURL string) ([]string, error)

List returns all identifiers stored for a given URL.

func (*Store) Load

func (s *Store) Load(rawURL, identifier string) (*ElementDict, error)

Load retrieves an element fingerprint for the given URL and identifier. Returns nil if not found.

func (*Store) Save

func (s *Store) Save(rawURL, identifier string, elem *ElementDict) error

Save stores an element fingerprint for the given URL and identifier.

Jump to

Keyboard shortcuts

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