Documentation
¶
Overview ¶
Package scio provides a URI-based data catalog with atomic operations. It serves as the authoritative map of data sources, providing topology intelligence and type-agnostic access via atoms.
Index ¶
- Variables
- type Catalog
- type Metadata
- type Operations
- type RegistrationOption
- type Registry
- type Resource
- type Scio
- func (s *Scio) Buckets() []Resource
- func (s *Scio) Databases() []Resource
- func (s *Scio) Delete(ctx context.Context, uri string) error
- func (s *Scio) Exists(ctx context.Context, uri string) (bool, error)
- func (s *Scio) FindByField(field string) []Resource
- func (s *Scio) FindBySpec(spec atom.Spec) []Resource
- func (s *Scio) Get(ctx context.Context, uri string) (*atom.Atom, error)
- func (s *Scio) Put(ctx context.Context, uri string, obj *grub.AtomicObject) error
- func (s *Scio) Query(ctx context.Context, uri string, stmt edamame.QueryStatement, ...) ([]*atom.Atom, error)
- func (s *Scio) RegisterBucket(uri string, bucket grub.AtomicBucket, opts ...RegistrationOption) error
- func (s *Scio) RegisterDatabase(uri string, db grub.AtomicDatabase, opts ...RegistrationOption) error
- func (s *Scio) RegisterStore(uri string, store grub.AtomicStore, opts ...RegistrationOption) error
- func (s *Scio) Related(uri string) []Resource
- func (s *Scio) Resource(uri string) *Resource
- func (s *Scio) Select(ctx context.Context, uri string, stmt edamame.SelectStatement, ...) (*atom.Atom, error)
- func (s *Scio) Set(ctx context.Context, uri string, data *atom.Atom) error
- func (s *Scio) SetWithTTL(ctx context.Context, uri string, data *atom.Atom, ttl time.Duration) error
- func (s *Scio) Sources() []Resource
- func (s *Scio) Spec(uri string) (atom.Spec, error)
- func (s *Scio) Stores() []Resource
- type URI
- type Variant
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidURI indicates the URI could not be parsed. ErrInvalidURI = errors.New("invalid URI") // ErrUnknownVariant indicates an unrecognized URI scheme. ErrUnknownVariant = errors.New("unknown variant") // ErrResourceNotFound indicates the requested resource is not registered. ErrResourceNotFound = errors.New("resource not found") // ErrResourceExists indicates a resource is already registered at the URI. ErrResourceExists = errors.New("resource already exists") // ErrVariantMismatch indicates an operation was attempted on the wrong variant. ErrVariantMismatch = errors.New("variant mismatch") // ErrKeyRequired indicates a key is required but was not provided. ErrKeyRequired = errors.New("key required") // ErrKeyNotExpected indicates a key was provided but is not used by the operation. ErrKeyNotExpected = errors.New("key not expected") )
Semantic errors for scio operations.
var ( ErrNotFound = grub.ErrNotFound ErrDuplicate = grub.ErrDuplicate ErrConflict = grub.ErrConflict ErrConstraint = grub.ErrConstraint ErrInvalidKey = grub.ErrInvalidKey ErrReadOnly = grub.ErrReadOnly ErrTTLNotSupported = grub.ErrTTLNotSupported )
Re-export grub errors for convenience.
Functions ¶
This section is empty.
Types ¶
type Catalog ¶
type Catalog interface {
// Sources returns all registered resources.
Sources() []Resource
// Databases returns all db:// resources.
Databases() []Resource
// Stores returns all kv:// resources.
Stores() []Resource
// Buckets returns all bcs:// resources.
Buckets() []Resource
// Spec returns the atom spec for a specific resource.
Spec(uri string) (atom.Spec, error)
// FindBySpec returns all resources sharing the given spec (by FQDN).
FindBySpec(spec atom.Spec) []Resource
// FindByField returns all resources containing the given field.
FindByField(field string) []Resource
// Related returns other resources with the same spec as the given URI.
Related(uri string) []Resource
}
Catalog defines topology introspection operations.
type Operations ¶
type Operations interface {
// Get retrieves an atom at the given URI.
// Returns ErrNotFound if the key does not exist.
Get(ctx context.Context, uri string) (*atom.Atom, error)
// Set stores an atom at the given URI.
Set(ctx context.Context, uri string, data *atom.Atom) error
// Delete removes the record at the given URI.
// Returns ErrNotFound if the key does not exist.
Delete(ctx context.Context, uri string) error
// Exists checks whether a record exists at the given URI.
Exists(ctx context.Context, uri string) (bool, error)
// Query executes a query statement against a database resource.
// The URI should reference a db:// resource without a key.
Query(ctx context.Context, uri string, stmt edamame.QueryStatement, params map[string]any) ([]*atom.Atom, error)
// Select executes a select statement against a database resource.
// The URI should reference a db:// resource without a key.
Select(ctx context.Context, uri string, stmt edamame.SelectStatement, params map[string]any) (*atom.Atom, error)
// SetWithTTL stores an atom at the given kv:// URI with a TTL.
// TTL of 0 means no expiration.
SetWithTTL(ctx context.Context, uri string, data *atom.Atom, ttl time.Duration) error
// Put stores a blob object at the given bcs:// URI.
Put(ctx context.Context, uri string, obj *grub.AtomicObject) error
}
Operations defines data access operations.
type RegistrationOption ¶
type RegistrationOption func(*registrationConfig)
RegistrationOption configures resource registration.
func WithDescription ¶
func WithDescription(desc string) RegistrationOption
WithDescription sets the resource description.
func WithTag ¶
func WithTag(key, value string) RegistrationOption
WithTag adds a tag to the resource metadata.
func WithVersion ¶
func WithVersion(ver string) RegistrationOption
WithVersion sets the resource version.
type Registry ¶
type Registry interface {
// RegisterDatabase registers an atomic database at the given URI.
// The URI should be in the form db://table.
RegisterDatabase(uri string, db grub.AtomicDatabase, opts ...RegistrationOption) error
// RegisterStore registers an atomic store at the given URI.
// The URI should be in the form kv://store.
RegisterStore(uri string, store grub.AtomicStore, opts ...RegistrationOption) error
// RegisterBucket registers an atomic bucket at the given URI.
// The URI should be in the form bcs://bucket.
RegisterBucket(uri string, bucket grub.AtomicBucket, opts ...RegistrationOption) error
}
Registry defines resource registration operations.
type Scio ¶
type Scio struct {
// contains filtered or unexported fields
}
Scio is the central data catalog and access point.
func (*Scio) Delete ¶
Delete removes the record at the given URI. Returns ErrNotFound if the key does not exist. Returns ErrResourceNotFound if the resource is not registered.
func (*Scio) Exists ¶
Exists checks whether a record exists at the given URI. Returns ErrResourceNotFound if the resource is not registered.
func (*Scio) FindByField ¶
FindByField returns all resources containing the given field.
func (*Scio) FindBySpec ¶
FindBySpec returns all resources sharing the given spec (by FQDN).
func (*Scio) Get ¶
Get retrieves an atom at the given URI. Returns ErrNotFound if the key does not exist. Returns ErrResourceNotFound if the resource is not registered. Returns ErrKeyRequired if no key is provided.
func (*Scio) Put ¶
Put stores a blob object at the given bcs:// URI. Returns ErrVariantMismatch if the URI is not a bcs:// resource.
func (*Scio) Query ¶
func (s *Scio) Query(ctx context.Context, uri string, stmt edamame.QueryStatement, params map[string]any) ([]*atom.Atom, error)
Query executes a query statement against a database resource. The URI should reference a db:// resource without a key component. Returns ErrVariantMismatch if the URI is not a db:// resource. Returns ErrKeyNotExpected if a key component is provided.
func (*Scio) RegisterBucket ¶
func (s *Scio) RegisterBucket(uri string, bucket grub.AtomicBucket, opts ...RegistrationOption) error
RegisterBucket registers an atomic bucket at the given URI. The URI should be in the form bcs://bucket.
func (*Scio) RegisterDatabase ¶
func (s *Scio) RegisterDatabase(uri string, db grub.AtomicDatabase, opts ...RegistrationOption) error
RegisterDatabase registers an atomic database at the given URI. The URI should be in the form db://table.
func (*Scio) RegisterStore ¶
func (s *Scio) RegisterStore(uri string, store grub.AtomicStore, opts ...RegistrationOption) error
RegisterStore registers an atomic store at the given URI. The URI should be in the form kv://store.
func (*Scio) Related ¶
Related returns other resources with the same spec as the given URI. The resource at the given URI is excluded from the results.
func (*Scio) Resource ¶
Resource returns the resource metadata for a specific URI. Returns nil if the resource is not registered.
func (*Scio) Select ¶
func (s *Scio) Select(ctx context.Context, uri string, stmt edamame.SelectStatement, params map[string]any) (*atom.Atom, error)
Select executes a select statement against a database resource. The URI should reference a db:// resource without a key component. Returns ErrVariantMismatch if the URI is not a db:// resource. Returns ErrKeyNotExpected if a key component is provided.
func (*Scio) Set ¶
Set stores an atom at the given URI. Returns ErrResourceNotFound if the resource is not registered. Returns ErrKeyRequired if no key is provided. For kv:// resources, use SetWithTTL to specify expiration.
func (*Scio) SetWithTTL ¶
func (s *Scio) SetWithTTL(ctx context.Context, uri string, data *atom.Atom, ttl time.Duration) error
SetWithTTL stores an atom at the given kv:// URI with a TTL. TTL of 0 means no expiration. Returns ErrVariantMismatch if the URI is not a kv:// resource.
type URI ¶
type URI struct {
Variant Variant
Resource string // table, store, or bucket name
Key string // record key or blob path (may be empty for queries)
}
URI represents a parsed data address.
func ParseURI ¶
ParseURI parses a raw URI string into its components. Supported formats:
- db://table/key -> Variant: db, Resource: table, Key: key
- kv://store/key -> Variant: kv, Resource: store, Key: key
- bcs://bucket/path -> Variant: bcs, Resource: bucket, Key: path (full remainder)
func (*URI) ResourceURI ¶
ResourceURI returns the URI without the key component.