Help us shape the future of Go! Take the 2026 Go Developer Survey

projectstore

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package projectstore is the single read surface for a forge project's PROJECT-GLOBAL state. Every consumer outside the config loader reads project metadata and feature flags through a Store rather than touching *config.ProjectConfig directly.

It deliberately does NOT answer "what does this project contain". Servers, workers, crons, operators and binaries are declared by the code that implements them, and the only way to learn about them is to read that code (codegen.DiscoverProjectComponents). A store method returning them would be a cache of the tree that is stale the moment an add verb runs.

Why the indirection: the project + feature state is the part of forge.yaml that a future revision wants to relocate out of the hand-edited file. Routing every consumer through this one type localizes that swap to one implementation; nothing else in the tree assumes the state lives in a *config.ProjectConfig.

Interfaces at the consumer, not here. New returns a concrete *Store (accept interfaces, return structs). Callers that take the store as a dependency declare the narrow interface they actually use next to themselves — e.g. `type featureReader interface { Features() FeatureSet }` for the feature-gate helpers, `type metaReader interface { Meta() ProjectMeta }` for the namespace resolvers. A wide interface declared here that each caller used a slice of was interface bloat: 16 of its 29 methods had zero callers. The store therefore exposes only the accessors that are actually read; add a method when a consumer needs it, not before.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FeatureSet

type FeatureSet = config.FeaturesConfig

FeatureSet is the resolved feature state of a project — the same derived+explicit resolution config.FeaturesConfig performs. It is a thin alias today (yamlStore returns the config block directly) so every existing *Enabled() accessor keeps working; the type exists so the interface advertises features as a first-class surface for Phase 2.

type ProjectMeta

type ProjectMeta struct {
	Name         string
	ModulePath   string
	Kind         string // raw kind: "" | service | cli | library
	Binary       string // raw binary mode: "" | per-service | shared
	ForgeVersion string
}

ProjectMeta is the project-level metadata view: identity, kind, binary mode, and the pinned versions. The Effective*/Is* accessors mirror the config helpers so consumers get the derived forms without re-deriving.

func (ProjectMeta) EffectiveBinary

func (m ProjectMeta) EffectiveBinary() string

EffectiveBinary returns the binary mode, defaulting to "per-service".

func (ProjectMeta) EffectiveForgeVersion

func (m ProjectMeta) EffectiveForgeVersion() string

EffectiveForgeVersion returns the pinned forge version, defaulting to "0.0.0" for projects predating the field.

func (ProjectMeta) EffectiveKind

func (m ProjectMeta) EffectiveKind() string

EffectiveKind returns the project kind, defaulting to "service".

func (ProjectMeta) IsBinaryShared

func (m ProjectMeta) IsBinaryShared() bool

IsBinaryShared reports whether the project uses the shared-binary mode.

func (ProjectMeta) IsCLIKind

func (m ProjectMeta) IsCLIKind() bool

IsCLIKind reports whether the project is a CLI binary.

func (ProjectMeta) IsLibraryKind

func (m ProjectMeta) IsLibraryKind() bool

IsLibraryKind reports whether the project is a pure Go library.

func (ProjectMeta) IsServiceKind

func (m ProjectMeta) IsServiceKind() bool

IsServiceKind reports whether the project is a Connect-RPC service.

type Store

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

Store is the forge.yaml-backed project store. It wraps a *config.ProjectConfig that has already been through the loader (LoadStrict → ApplyDerivedDefaults → path/kind normalization) and projects its read surface into the view types below.

This is the ONLY type that holds a *config.ProjectConfig. Phase 2's source swap replaces (or supplements) this implementation; consumers depend on narrow interfaces they declare themselves (see the package doc), so the swap stays invisible to them.

Accept interfaces, return structs: New returns a concrete *Store rather than a wide interface. Each consumer that takes the store as a dependency declares the one- or two-method interface it actually uses (e.g. `featureReader { Features() FeatureSet }`), so there is no speculative all-methods abstraction for callers to over-depend on.

func New

func New(cfg *config.ProjectConfig) *Store

New wraps an already-loaded, already-derived project config in a *Store. The caller owns loading + normalization (the cli/generator loaders); New takes the resulting config and exposes it through the view accessors. The pointer is retained (not copied) so mutation methods and Config() observe the same underlying config the loader produced.

func (*Store) CI

func (s *Store) CI() config.CIConfig

CI returns the `ci:` section.

func (*Store) Config

func (s *Store) Config() *config.ProjectConfig

Config returns the underlying project config — the write/marshal + whole-config escape hatch, and the one seam Phase 2 must reconcile.

func (*Store) Contracts

func (s *Store) Contracts() config.ContractsConfig

Contracts returns the `contracts:` section.

func (*Store) Database

func (s *Store) Database() config.DatabaseConfig

Database returns the `database:` section.

func (*Store) Features

func (s *Store) Features() FeatureSet

Features returns the resolved (derived + explicit) feature set.

func (*Store) Frontends

func (s *Store) Frontends() []config.FrontendConfig

Frontends returns the declared frontend configs.

func (*Store) K8s

func (s *Store) K8s() config.K8sConfig

K8s returns the `k8s:` section.

func (*Store) Lint

func (s *Store) Lint() config.LintConfig

Lint returns the `lint:` section.

func (*Store) Meta

func (s *Store) Meta() ProjectMeta

Meta returns project-level metadata (name, module, kind, versions).

Jump to

Keyboard shortcuts

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