Documentation
¶
Overview ¶
Package blobstore provides content-addressed blob storage with metadata queries, tenant isolation, and TTL-based expiry. It demonstrates all plugin API patterns: host functions, HTTP routes, database migrations, and background workers.
Blobs are stored via a pluggable Backend interface. The memory backend stores bytes in the blob_content.data BYTEA column (dev/testing). The S3 backend stores bytes in S3-compatible object storage; only metadata is kept in PostgreSQL. Switch backends via the "backend" config option.
Index ¶
- func New() plugin.Plugin
- type Backend
- type Config
- type Plugin
- func (p *Plugin) Info() plugin.PluginInfo
- func (p *Plugin) Init(ctx context.Context, env *plugin.Environment) error
- func (p *Plugin) Migrations() []plugin.Migration
- func (p *Plugin) RegisterHostFunctions(scope plugin.FuncRegistry) error
- func (p *Plugin) RegisterRoutes(mux *http.ServeMux) error
- func (p *Plugin) Run(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Backend ¶
type Backend interface {
// Put stores blob bytes addressed by the hex-encoded SHA-256 hash.
Put(ctx context.Context, sha256 string, data []byte, contentType string) error
// Get retrieves blob bytes by hex-encoded SHA-256 hash.
Get(ctx context.Context, sha256 string) ([]byte, error)
// Delete removes blob bytes by hex-encoded SHA-256 hash.
Delete(ctx context.Context, sha256 string) error
}
Backend stores and retrieves blob bytes. Implementations must be safe for concurrent use.
type Config ¶
type Config struct {
Backend string `json:"backend"` // "s3" or "memory"; defaults to "memory"
Bucket string `json:"bucket"` // S3 bucket name (for s3 backend)
Region string `json:"region"` // AWS region (for s3 backend)
Endpoint string `json:"endpoint,omitempty"` // custom S3 endpoint (for MinIO/GCS)
AccessKeyID string `json:"access_key_id,omitempty"` // S3 access key; falls back to env/instance profile
SecretAccessKey string `json:"secret_access_key,omitempty"` // S3 secret key
Secure bool `json:"secure"` // use HTTPS (default true, set false for local MinIO)
MaxBlobSize int64 `json:"max_blob_size"` // max blob bytes; default 10 MB
}
Config controls blobstore backend selection and S3 parameters.
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
Plugin implements content-addressed blob storage with tenant isolation.
func (*Plugin) Info ¶
func (p *Plugin) Info() plugin.PluginInfo
Info returns plugin metadata for discovery and documentation.
func (*Plugin) Init ¶
Init initializes the plugin with the given environment. It parses optional configuration and sets safe defaults for dev/testing.
func (*Plugin) Migrations ¶
Migrations returns the database schema for blob storage. Tables are idempotent (IF NOT EXISTS) and safe to run multiple times.
func (*Plugin) RegisterHostFunctions ¶
func (p *Plugin) RegisterHostFunctions(scope plugin.FuncRegistry) error
RegisterHostFunctions registers workflow-callable functions on the scoped function registry. The plugin name is implicit -- each plugin gets its own scope, so function names need not be globally unique.