portalstore

package
v1.100.4 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package portalstore assembles the asset-portal store layer behind one Handle: the five Postgres stores (asset, share, version, collection, thread), the knowledge-page store, the S3 blob backend, and the save/manage-artifact toolkit built on top of them.

Construction takes explicit inputs — a *sql.DB, the resolved portal.S3Client (or nil for database-only mode), the embedding.Provider that powers ranked artifact search, and the toolkit's Config knobs — so the subsystem is constructible and testable without a Platform. It imports pkg/portal, pkg/portal/knowledgepage, and pkg/toolkits/portal, never pkg/platform. The *sql.DB and embedding.Provider back many other subsystems, so they stay owned by Platform and are passed in rather than owned here.

Toolkit registration stays a Platform/registry concern: New builds the toolkit and exposes it via Toolkit() for Platform to register into the shared toolkit registry. The only resource this package owns for shutdown is the S3 client, closed via Close.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Name is the toolkit instance name (the platform passes its default).
	Name string
	// S3Bucket / S3Prefix address the portal's blob backend; empty in
	// database-only mode (no S3 client).
	S3Bucket string
	S3Prefix string
	// BaseURL is the portal's public base URL used to render share links.
	BaseURL string
	// MaxContentSize caps artifact content size in bytes (0 = no limit).
	MaxContentSize int
}

Config carries the portal-toolkit knobs the owner needs to build the save/manage-artifact toolkit. The stores themselves need only the *sql.DB; these values shape the toolkit's blob addressing and artifact limits.

type Handle

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

Handle owns the assembled portal store layer: the six stores, the S3 blob backend, and the artifact toolkit. The read accessors expose the stores + S3 client that Platform surfaces through its Portal* accessors (the admin REST handler and portal REST wiring) and that the cross-toolkit export wiring and search/enrichment provider assembly consume; Toolkit() exposes the artifact toolkit for registration and as the memory thread linker. Close is the shutdown seam Platform wires into its own lifecycle (only the S3 client needs closing — the stores share Platform's *sql.DB, which Platform closes).

func New

func New(db *sql.DB, s3Client portal.S3Client, embedder embedding.Provider, cfg Config) *Handle

New assembles the six Postgres-backed stores and the artifact toolkit from an explicit *sql.DB, the resolved S3 client (nil for database-only mode), the embedding provider, and the toolkit Config. It returns nil when db is nil: the portal is a no-op without a database, matching the platform precondition.

func NewFromStores

func NewFromStores(s Stores, embedder embedding.Provider, cfg Config) *Handle

NewFromStores assembles the Handle and its artifact toolkit from already-built store implementations. New delegates here after constructing the Postgres stores; it is also the entry point for assembling a Handle over injected store implementations (fakes or alternative backends) without a *sql.DB.

func (*Handle) AssetStore

func (h *Handle) AssetStore() portal.AssetStore

AssetStore returns the portal asset store, or nil on a nil Handle (portal disabled or no database).

func (*Handle) Close

func (h *Handle) Close() error

Close closes the S3 blob backend. No-op on a nil Handle or in database-only mode (no S3 client). The stores share Platform's *sql.DB, which Platform closes, so they are not closed here.

func (*Handle) CollectionStore

func (h *Handle) CollectionStore() portal.CollectionStore

CollectionStore returns the portal collection store, or nil on a nil Handle.

func (*Handle) KnowledgePageStore

func (h *Handle) KnowledgePageStore() knowledgepage.Store

KnowledgePageStore returns the canonical knowledge-page store, or nil on a nil Handle.

func (*Handle) S3Client

func (h *Handle) S3Client() portal.S3Client

S3Client returns the portal S3 blob backend, or nil on a nil Handle or in database-only mode (no s3_connection configured).

func (*Handle) ShareStore

func (h *Handle) ShareStore() portal.ShareStore

ShareStore returns the portal share store, or nil on a nil Handle.

func (*Handle) ThreadStore

func (h *Handle) ThreadStore() portal.ThreadStore

ThreadStore returns the portal feedback-thread store, or nil on a nil Handle.

func (*Handle) Toolkit

func (h *Handle) Toolkit() *portalkit.Toolkit

Toolkit returns the save/manage-artifact toolkit for Platform to register into the shared toolkit registry and to wire as the memory thread linker, or nil on a nil Handle.

func (*Handle) VersionStore

func (h *Handle) VersionStore() portal.VersionStore

VersionStore returns the portal version store, or nil on a nil Handle.

type Stores

type Stores struct {
	Asset         portal.AssetStore
	Share         portal.ShareStore
	Version       portal.VersionStore
	Collection    portal.CollectionStore
	Thread        portal.ThreadStore
	KnowledgePage knowledgepage.Store
	S3Client      portal.S3Client
}

Stores bundles the six store implementations and the S3 blob client the Handle owns. New builds these from a *sql.DB; NewFromStores assembles a Handle from already-built implementations — the path New itself delegates to after constructing the Postgres stores, and the seam that lets callers (and tests) inject their own store implementations without a database.

Jump to

Keyboard shortcuts

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