storeresync

package
v1.137.1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package storeresync makes a replica's live connections and personas match what the database stores. It is how the platform loads its database personas at startup, and how a replica catches up when its reload channel's LISTEN connection comes back: a notification sent while that connection was down is lost and never repeated, so the replica re-reads what the channel carries, as a restart would (#1902).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Catalog

func Catalog(toolkits []registry.Toolkit, catalogID string)

Catalog rebuilds every connection that mounts the given catalog. A catalog serves both kinds that reference one: an api connection takes its OpenAPI specs from it, and a graphql connection the GraphQL schema it holds (#1745).

func Connections

func Connections(stored []StoredConnection, toolkits connreconcile.ToolkitSource, declared connid.Declarer, builtin func(kind, name string) bool)

Connections makes the live toolkits match stored. Every stored connection is adopted as a peer's upsert would adopt it, and a live connection the store no longer holds is removed as a peer's delete would remove it. The connections the configuration file declares are left as they are, which is what a restart does with them, and so are those builtin reports the platform registers itself: neither the file nor the store holds one, so its absence from the store is not a deletion.

func Personas

func Personas[D any, PD interface {
	*D
	ToPersona() *persona.Persona
}](ctx context.Context, store PersonaLister[D], reg *persona.Registry, file map[string]personacfg.PersonaDef, src Sources)

Personas makes the persona registry match the database. Every stored definition is registered, overriding a file persona of the same name. A registered persona that came from the database and is no longer stored was deleted on another replica: it reverts to the file's definition when the file has one and is removed otherwise, as the replica that deleted it did (#1902). A store that cannot be read changes nothing.

func Removed

func Removed(toolkits connreconcile.ToolkitSource, declared connid.Declarer, kind, name, msg string)

Removed drops a connection the reload bus says is gone from this replica's toolkits, unless the configuration file declares it. A peer that predates the delete refusal, or one racing a delete, can still broadcast the removal of such a connection; honoring it would take it out of service here until a restart put it back, and the file is unaffected by anything the store did (#1400). A delete is applied without a store read, so a transient store failure can never leave a deleted connection live. A failed removal is logged at WARN under msg, not ERROR: removing an already-absent connection is not state-corrupting.

func Upserted

func Upserted(toolkits connreconcile.ToolkitSource, declared connid.Declarer, kind, name string, read Read)

Upserted applies a peer's save once this replica has read the store. The read's outcome drives a three-way branch so a transient read failure never silently drops a live connection (#885):

  • Err set (a failure, not a not-found): log at ERROR and leave the live config in place. Removing here would drop a healthy connection over a database blip; a later upsert event re-materializes it.
  • not found (raced with a concurrent delete): remove it, as Removed does.
  • found: adopt the stored config, so the changed config takes effect with the state the saving replica stored (#1714). A toolkit that fails is logged at ERROR, since it is out of sync with the store; the others are still updated.

Types

type PersonaLister

type PersonaLister[D any] interface {
	List(ctx context.Context) ([]D, error)
}

PersonaLister lists the stored persona definitions. The persona store satisfies it with D its definition type, which this package does not import (internal/platform seams do not depend back on pkg/platform).

type Read

type Read struct {
	Config map[string]any
	Found  bool
	Err    error
}

Read is what this replica's store read found for a connection a peer announced as saved: its config when Found, or the read's failure.

type Sources

type Sources struct{ File, Database, Both string }

Sources are the Persona.Source values a registered persona carries: from the file alone, from the database alone, or from the database over the file.

type StoredConnection

type StoredConnection struct {
	Kind, Name string
	Config     map[string]any
}

StoredConnection is one row of the connection store.

Jump to

Keyboard shortcuts

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