Documentation
¶
Index ¶
- Variables
- type Backend
- func (backend *Backend) CloseClient() error
- func (backend *Backend) Conn() driver.Conn
- func (backend *Backend) Debug() *Backend
- func (backend *Backend) InitClient() error
- func (backend *Backend) Retrieve(id string, _ *storage.RetrieveOptions) (*sbom.Document, error)
- func (backend *Backend) Store(doc *sbom.Document, opts *storage.StoreOptions) error
- func (backend *Backend) WithAddr(addr ...string) *Backend
- func (backend *Backend) WithBackendOptions(opts *BackendOptions) *Backend
- func (backend *Backend) WithCredentials(username, password string) *Backend
- func (backend *Backend) WithDatabase(database string) *Backend
- type BackendOptions
- type Option
Constants ¶
This section is empty.
Variables ¶
var ErrMissingDocument = errors.New("document not found")
ErrMissingDocument is returned by Retrieve when no document matches the id.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend struct {
// Options is the set of options for the clickhouse Backend.
Options *BackendOptions
// contains filtered or unexported fields
}
Backend implements the protobom/storage.Backend interface backed by ClickHouse.
func NewBackend ¶
NewBackend creates a new clickhouse Backend, applying the given options on top of the defaults.
func (*Backend) CloseClient ¶
CloseClient closes the underlying ClickHouse connection.
func (*Backend) InitClient ¶
InitClient connects to ClickHouse, ensures the target database exists and applies the backend's schema.
func (*Backend) Retrieve ¶
Retrieve implements the storage.Retriever interface. It reads the serialized document blob stored by Store and unmarshals it, so the returned document is a lossless copy of the one originally stored.
FINAL collapses any not-yet-merged ReplacingMergeTree duplicates so the latest stored version of the document is returned.
func (*Backend) Store ¶
Store implements the storage.Storer interface. It keeps the full serialized document as a blob for lossless retrieval and, in parallel, decomposes the node list into the wide nodes and edges tables for querying.
ClickHouse has no cross-table transactions; correctness on re-store comes from idempotency: the tables are ReplacingMergeTree engines keyed by content, so storing the same document twice converges rather than duplicating rows.
func (*Backend) WithBackendOptions ¶
func (backend *Backend) WithBackendOptions(opts *BackendOptions) *Backend
WithBackendOptions replaces the backend's options with opts.
func (*Backend) WithCredentials ¶
WithCredentials sets the username and password used to authenticate.
func (*Backend) WithDatabase ¶
WithDatabase sets the ClickHouse database that holds the protobom tables.
type BackendOptions ¶
type BackendOptions struct {
// Database is the ClickHouse database that holds the protobom tables.
Database string
// Username and Password are the credentials used to authenticate.
Username string
Password string
// Settings are additional ClickHouse settings passed through on connect.
Settings map[string]any
// TLS, when set, enables a secure connection to the server.
TLS *tls.Config
// Addr is the list of ClickHouse node addresses (host:port) to connect to.
Addr []string
// Debug configures the client to output debug information.
Debug bool
}
BackendOptions contains options specific to the protobom clickhouse backend. Field order is chosen to satisfy the fieldalignment linter.
func NewBackendOptions ¶
func NewBackendOptions() *BackendOptions
NewBackendOptions creates a new BackendOptions with sensible defaults for a local single-node ClickHouse server.
type Option ¶
type Option func(*Backend)
Option represents a single configuration option for the clickhouse backend.
func WithBackendOptions ¶
func WithBackendOptions(opts *BackendOptions) Option