Documentation
¶
Overview ¶
Package dalgo2openvaultdb provides a DALgo driver for OpenVaultDB.
Use NewDB to create a dal.DB that talks to an OpenVaultDB server over HTTP. Reads (Get, Exists, GetMulti, queries) are available directly on the DB. Writes must happen inside a RunReadwriteTransaction callback.
Package dalgo2openvaultdb implements the DALgo driver for OpenVaultDB.
Index ¶
- Constants
- func NewDB(baseURL, databaseID string, opts ...Option) (dal.DB, error)
- func ReadProviderReads(reader dal.Reader) (providerreads.Envelope, bool)
- func RequireProviderReads(ctx context.Context, plan providerreads.Plan, usedSourceIDs []string) (context.Context, error)
- type AuthorizationError
- type Option
Constants ¶
const ( GuardedMaxRequestBytes = 1 << 20 GuardedMaxResponseBytes = 8 << 20 GuardedQueryTimeout = 10 * time.Second )
Bounds of the guarded read profile (see WithGuardedReads).
Variables ¶
This section is empty.
Functions ¶
func NewDB ¶
NewDB creates a new DALgo DB backed by OpenVaultDB. The returned dal.DB is sealed by dal.NewDB: every read-write transaction it starts hands the worker a transaction whose writes run the framework's BeforeSave validation and hooks before reaching this adapter's code.
db, err := dalgo2openvaultdb.NewDB("http://127.0.0.1:6832", "sneat-dev")
func ReadProviderReads ¶ added in v0.4.0
func ReadProviderReads(reader dal.Reader) (providerreads.Envelope, bool)
ReadProviderReads returns detached executor-observed evidence when supplied. Without RequireProviderReads, this is a decoded provider claim, not evidence checked against independent admission. DALgo's generic metadata carries rights; this adapter-local capability carries the additional live-read envelope.
func RequireProviderReads ¶ added in v0.4.0
func RequireProviderReads(ctx context.Context, plan providerreads.Plan, usedSourceIDs []string) (context.Context, error)
RequireProviderReads freezes independently admitted evidence for one query execution. Never construct plan or usedSourceIDs from the query response. The returned context requires proxy evidence and no-store before any reader is returned. Give each execution a fresh 32-character lowercase hex ID. This capability does not grant source rights or activate a live source.
Types ¶
type AuthorizationError ¶ added in v0.4.0
AuthorizationError carries the server's validated structured denial. Its Error string is deliberately generic so it is safe to show to callers.
func (*AuthorizationError) Error ¶ added in v0.4.0
func (*AuthorizationError) Error() string
func (*AuthorizationError) Unwrap ¶ added in v0.4.0
func (*AuthorizationError) Unwrap() error
type Option ¶
type Option func(*database)
Option configures a DB created by NewDB.
func WithBearerToken ¶ added in v0.2.0
WithBearerToken sends the token as an Authorization: Bearer header on every request — required when the server runs `ovdb serve --auth` (either the owner token or an app token from the connect flow).
func WithGuardedReads ¶ added in v0.4.0
WithGuardedReads turns the DB into a read-only, query-only source for a credential bound to one principal — the profile a host uses when an operator, not the caller, configures where a bearer token may be sent.
Every query must run in a context whose access.Principal has no Subject and the legacy ID principalID; any other caller is refused with access.ErrAccessDenied before a request is made. Queries are serialized as TugQL and sent to the ACL-evaluated /tugql route. A 401/403 decision the server explains is returned as *AuthorizationError. Requests are capped at GuardedMaxRequestBytes, responses at GuardedMaxResponseBytes, each query at GuardedQueryTimeout; redirects are refused, the response must be a JSON object without duplicate keys, and no error carries response text, the URL or the token. Get, Exists, GetMulti, transactions and recordset readers return dal.ErrNotSupported.
NewDB validates the target when this option is set: an http(s) base URL without user info, query or fragment, a database ID without path characters or padding, and a non-empty bearer token.
func WithHTTPClient ¶
WithHTTPClient sets a custom *http.Client. If not provided, http.DefaultClient is used.