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

state

package
v0.1.2 Latest Latest
Warning

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

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

Documentation

Overview

Package state safely maintains the global registry consumed by ACC's CoreDNS plugin. It deliberately has no CoreDNS dependency: the JSON schema is the contract between the host-side ACC process and the plugin container.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath() (string, error)

DefaultPath returns ACC's default host-global CoreDNS state path.

Types

type Container

type Container struct {
	ID          string                       `json:"id"`
	Service     string                       `json:"service"`
	Nameservers []string                     `json:"nameservers,omitempty"`
	Networks    map[string]NetworkAttachment `json:"networks"`
}

Container is one service endpoint in the global registry.

type NetworkAttachment

type NetworkAttachment struct {
	Addresses []string `json:"addresses"`
	Aliases   []string `json:"aliases,omitempty"`
}

NetworkAttachment holds one container's addresses and Compose aliases on a runtime network.

type State

type State struct {
	Version    int         `json:"version"`
	Containers []Container `json:"containers"`
}

State is the versioned CoreDNS registry persisted by ACC.

type Store

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

Store atomically edits a single state file. Its lock file serializes read-modify-write cycles across independent ACC processes.

func NewStore

func NewStore(path string) (*Store, error)

NewStore constructs a store for an absolute state-file path.

func (*Store) Ensure

func (s *Store) Ensure(ctx context.Context) error

Ensure creates a valid empty state file when one does not yet exist.

func (*Store) Read

func (s *Store) Read(ctx context.Context) (State, error)

Read returns the current validated state. It does not create a missing file.

func (*Store) Remove

func (s *Store) Remove(ctx context.Context, ids []string) error

Remove deletes records with the supplied container IDs. Empty IDs are rejected to prevent an accidental broad mutation.

func (*Store) Update

func (s *Store) Update(ctx context.Context, mutate func(*State) error) (State, error)

Update serializes a state mutation, validates its result, and atomically replaces the state file. A missing state file is initialized as an empty version-1 registry before mutate is called.

func (*Store) Upsert

func (s *Store) Upsert(ctx context.Context, container Container) error

Upsert replaces any existing record with the same container ID.

Jump to

Keyboard shortcuts

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