storage

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2025 License: MIT Imports: 1 Imported by: 1

Documentation

Index

Constants

View Source
const ConfigJSONSchema = `` /* 735-byte string literal not displayed */

ConfigJSONSchema documents the runtime shape expected by storage providers. It is intentionally minimal; provider-specific options are captured in the nested "options" map.

View Source
const ProfileJSONSchema = `
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "StorageProfile",
  "type": "object",
  "required": ["name", "provider", "config"],
  "properties": {
    "name": {
      "type": "string",
      "pattern": "^[a-z0-9_-]+$",
      "description": "Profile identifier referenced by repositories"
    },
    "description": {
      "type": "string"
    },
    "provider": {
      "type": "string",
      "description": "Registered provider key resolved by the DI container"
    },
    "config": ` + ConfigJSONSchema + `,
    "fallbacks": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Ordered list of fallback profiles to consult when the primary is unavailable"
    },
    "labels": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      }
    },
    "default": {
      "type": "boolean",
      "description": "Marks the profile as the default selection for repositories without explicit configuration"
    }
  },
  "additionalProperties": false
}
`

ProfileJSONSchema describes the payload used to define storage profiles in admin APIs. The container will validate updates against this schema before attempting a hot reload.

Variables

This section is empty.

Functions

This section is empty.

Types

type Capabilities

type Capabilities struct {
	SupportsReload bool
	ReadReplicas   bool
	MultiTenant    bool
	Metadata       map[string]any
}

Capabilities documents optional behaviours supported by a provider.

type CapabilityReporter

type CapabilityReporter interface {
	Capabilities() Capabilities
}

CapabilityReporter exposes optional provider features (e.g., read replicas, sharding) so repositories can make runtime decisions.

type Config

type Config struct {
	Name     string
	Driver   string
	DSN      string
	ReadOnly bool
	Options  map[string]any
}

Config captures the runtime configuration for a storage provider. Detailed schema validation is handled by higher layers (runtimeconfig/admin services).

type Profile

type Profile struct {
	Name        string            `json:"name"`
	Description string            `json:"description,omitempty"`
	Provider    string            `json:"provider"`
	Config      Config            `json:"config"`
	Fallbacks   []string          `json:"fallbacks,omitempty"`
	Labels      map[string]string `json:"labels,omitempty"`
	Default     bool              `json:"default,omitempty"`
}

Profile captures a named storage configuration that can be referenced by repositories at runtime. Future phases will persist these profiles and drive hot-swap mechanics based on admin updates.

type Provider

type Provider interface {
	Query(ctx context.Context, query string, args ...any) (Rows, error)
	Exec(ctx context.Context, query string, args ...any) (Result, error)
	Transaction(ctx context.Context, fn func(tx Transaction) error) error
}

Provider encapsulates the operations required by go-cms repositories. It embeds the legacy StorageProvider contract and adds optional hooks that dynamic implementations can satisfy to support runtime reconfiguration.

type Reloadable

type Reloadable interface {
	Reload(ctx context.Context, cfg Config) error
}

Reloadable providers can apply a new configuration at runtime. Implementations that do not support reloads may omit this interface; the container will keep using the existing provider.

type Result

type Result interface {
	RowsAffected() (int64, error)
	LastInsertId() (int64, error)
}

type Rows

type Rows interface {
	Next() bool
	Scan(dest ...any) error
	Close() error
}

type Transaction

type Transaction interface {
	Provider
	Commit() error
	Rollback() error
}

Jump to

Keyboard shortcuts

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