memory

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package memory provides a fully in-memory implementation of store.Store. Safe for concurrent access. Intended for unit testing and development.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store is a fully in-memory implementation of store.Store.

func New

func New() *Store

New returns a new empty Store.

func (*Store) ClaimDueRotation

func (m *Store) ClaimDueRotation(_ context.Context, key, appID string, now, until time.Time) (bool, error)

ClaimDueRotation claims a due policy for one rotation run. The check and the write happen under the store's write lock, so only one caller can see a given due time. A missing policy returns false and a nil error.

func (*Store) Close

func (m *Store) Close() error

Close is a no-op for the memory store.

func (*Store) CountAudit

func (m *Store) CountAudit(_ context.Context, appID string) (int64, error)

CountAudit returns the number of audit entries belonging to appID.

func (*Store) CountAuditMatching

func (m *Store) CountAuditMatching(_ context.Context, appID string, opts audit.ListOpts) (int64, error)

CountAuditMatching returns the number of audit entries belonging to appID that match opts. Limit and Offset are ignored.

func (*Store) CountConfig

func (m *Store) CountConfig(_ context.Context, appID string) (int64, error)

CountConfig returns the number of config entries belonging to appID.

func (*Store) CountConfigMatching

func (m *Store) CountConfigMatching(_ context.Context, appID string, opts config.ListOpts) (int64, error)

CountConfigMatching returns the number of config entries belonging to appID whose key starts with opts.KeyPrefix. Limit and Offset are ignored.

func (*Store) CountFlagDefinitions

func (m *Store) CountFlagDefinitions(_ context.Context, appID string) (int64, error)

CountFlagDefinitions returns the number of flag definitions belonging to appID.

func (*Store) CountFlagDefinitionsMatching

func (m *Store) CountFlagDefinitionsMatching(_ context.Context, appID string, opts flag.ListOpts) (int64, error)

CountFlagDefinitionsMatching returns the number of flag definitions belonging to appID that match opts. Limit and Offset are ignored.

func (*Store) CountOverrides

func (m *Store) CountOverrides(_ context.Context, appID string) (int64, error)

CountOverrides returns the number of tenant overrides belonging to appID, across every key and tenant.

func (*Store) CountRotationPolicies

func (m *Store) CountRotationPolicies(_ context.Context, appID string) (int64, error)

CountRotationPolicies returns the number of rotation policies belonging to appID.

func (*Store) CountSecrets

func (m *Store) CountSecrets(_ context.Context, appID string) (int64, error)

CountSecrets returns the number of secrets belonging to appID, across every tenant.

func (*Store) CountSecretsMatching

func (m *Store) CountSecretsMatching(_ context.Context, appID string, opts secret.ListOpts) (int64, error)

CountSecretsMatching returns the number of secrets belonging to appID, across every tenant, that pass the expiry bounds in opts. TenantID, Limit and Offset are ignored.

func (*Store) CountSecretsUnencrypted

func (m *Store) CountSecretsUnencrypted(_ context.Context, appID string) (int64, error)

CountSecretsUnencrypted returns the number of secrets belonging to appID, across every tenant, that were stored without an encryption algorithm.

func (*Store) CountVersionEncryption

func (m *Store) CountVersionEncryption(_ context.Context, appID string) (secret.VersionEncryptionCounts, error)

CountVersionEncryption tallies appID's version rows, across every tenant, by recorded algorithm, leaving out each secret's current version.

func (*Store) DefineFlag

func (m *Store) DefineFlag(_ context.Context, f *flag.Definition) error

DefineFlag creates or updates a flag definition.

func (*Store) DeleteConfig

func (m *Store) DeleteConfig(_ context.Context, key, appID string) error

DeleteConfig removes a config entry.

func (*Store) DeleteFlagDefinition

func (m *Store) DeleteFlagDefinition(_ context.Context, key, appID string) error

DeleteFlagDefinition removes a flag definition and its rules.

func (*Store) DeleteFlagTenantOverride

func (m *Store) DeleteFlagTenantOverride(_ context.Context, key, appID, tenantID string) error

DeleteFlagTenantOverride removes a tenant override.

func (*Store) DeleteOverride

func (m *Store) DeleteOverride(_ context.Context, key, appID, tenantID string) error

DeleteOverride removes a tenant override.

func (*Store) DeleteRotationPolicy

func (m *Store) DeleteRotationPolicy(_ context.Context, key, appID string) error

DeleteRotationPolicy removes a rotation policy.

func (*Store) DeleteSecret

func (m *Store) DeleteSecret(_ context.Context, key, appID, tenantID string) error

DeleteSecret removes a secret and all its versions.

func (*Store) GetConfig

func (m *Store) GetConfig(_ context.Context, key, appID string) (*config.Entry, error)

GetConfig retrieves a config entry by key and app ID.

func (*Store) GetConfigVersion

func (m *Store) GetConfigVersion(_ context.Context, key, appID string, version int64) (*config.Entry, error)

GetConfigVersion retrieves a specific version of a config entry.

func (*Store) GetFlagDefinition

func (m *Store) GetFlagDefinition(_ context.Context, key, appID string) (*flag.Definition, error)

GetFlagDefinition retrieves a flag definition by key and app ID.

func (*Store) GetFlagRules

func (m *Store) GetFlagRules(_ context.Context, key, appID string) ([]*flag.Rule, error)

GetFlagRules returns targeting rules for a flag, ordered by priority.

func (*Store) GetFlagTenantOverride

func (m *Store) GetFlagTenantOverride(_ context.Context, key, appID, tenantID string) (any, error)

GetFlagTenantOverride retrieves a tenant override for a flag.

func (*Store) GetOverride

func (m *Store) GetOverride(_ context.Context, key, appID, tenantID string) (*override.Override, error)

GetOverride retrieves a tenant override by key, app ID, and tenant ID.

func (*Store) GetRotationPolicy

func (m *Store) GetRotationPolicy(_ context.Context, key, appID string) (*rotation.Policy, error)

GetRotationPolicy retrieves a rotation policy by secret key and app ID.

func (*Store) GetSecret

func (m *Store) GetSecret(_ context.Context, key, appID, tenantID string) (*secret.Secret, error)

GetSecret retrieves the latest version of a secret by key, app ID and tenant ID.

func (*Store) GetSecretVersion

func (m *Store) GetSecretVersion(_ context.Context, key, appID, tenantID string, version int64) (*secret.Secret, error)

GetSecretVersion retrieves a specific version of a secret.

func (*Store) ListAudit

func (m *Store) ListAudit(_ context.Context, appID string, opts audit.ListOpts) ([]*audit.Entry, error)

ListAudit returns audit entries for an app.

func (*Store) ListAuditByKey

func (m *Store) ListAuditByKey(_ context.Context, key, appID string, opts audit.ListOpts) ([]*audit.Entry, error)

ListAuditByKey returns audit entries for a specific key within an app.

func (*Store) ListConfig

func (m *Store) ListConfig(_ context.Context, appID string, opts config.ListOpts) ([]*config.Entry, error)

ListConfig returns config entries for an app.

func (*Store) ListConfigVersions

func (m *Store) ListConfigVersions(_ context.Context, key, appID string) ([]*config.EntryVersion, error)

ListConfigVersions returns all versions of a config entry.

func (*Store) ListFlagDefinitions

func (m *Store) ListFlagDefinitions(_ context.Context, appID string, opts flag.ListOpts) ([]*flag.Definition, error)

ListFlagDefinitions returns the flag definitions for an app in key order, filtered by opts.Type before paging. An empty result is an empty slice.

func (*Store) ListFlagTenantOverrides

func (m *Store) ListFlagTenantOverrides(_ context.Context, key, appID string) ([]*flag.TenantOverride, error)

ListFlagTenantOverrides returns all tenant overrides for a flag.

func (*Store) ListOverridesByKey

func (m *Store) ListOverridesByKey(_ context.Context, key, appID string) ([]*override.Override, error)

ListOverridesByKey returns all tenant overrides for a specific config key.

func (*Store) ListOverridesByTenant

func (m *Store) ListOverridesByTenant(_ context.Context, appID, tenantID string) ([]*override.Override, error)

ListOverridesByTenant returns all overrides for a specific tenant.

func (*Store) ListRotationPolicies

func (m *Store) ListRotationPolicies(_ context.Context, appID string) ([]*rotation.Policy, error)

ListRotationPolicies returns all rotation policies for an app.

func (*Store) ListRotationRecords

func (m *Store) ListRotationRecords(_ context.Context, key, appID string, opts rotation.ListOpts) ([]*rotation.Record, error)

ListRotationRecords returns rotation history for a secret.

func (*Store) ListSecretVersions

func (m *Store) ListSecretVersions(_ context.Context, key, appID, tenantID string) ([]*secret.Version, error)

ListSecretVersions returns all versions of a secret.

func (*Store) ListSecrets

func (m *Store) ListSecrets(_ context.Context, appID string, opts secret.ListOpts) ([]*secret.Meta, error)

ListSecrets returns secret metadata for an app and the tenant in opts.TenantID, matched exactly.

func (*Store) ListUnrecordedVersions

func (m *Store) ListUnrecordedVersions(_ context.Context, appID, after string, limit int) ([]*secret.Version, error)

ListUnrecordedVersions returns up to limit version rows of appID, across every tenant, whose encryption algorithm was never recorded, in ascending id order, after the id after.

func (*Store) Migrate

func (m *Store) Migrate(_ context.Context) error

Migrate is a no-op for the memory store.

func (*Store) Ping

func (m *Store) Ping(_ context.Context) error

Ping always succeeds for the memory store.

func (*Store) RecordAudit

func (m *Store) RecordAudit(_ context.Context, e *audit.Entry) error

RecordAudit persists an audit log entry.

func (*Store) RecordRotation

func (m *Store) RecordRotation(_ context.Context, r *rotation.Record) error

RecordRotation records a completed rotation event.

func (*Store) SaveRotationPolicy

func (m *Store) SaveRotationPolicy(_ context.Context, p *rotation.Policy) error

SaveRotationPolicy creates or updates a rotation policy.

func (*Store) SetConfig

func (m *Store) SetConfig(_ context.Context, e *config.Entry) error

SetConfig creates or updates a config entry with auto-versioning.

func (*Store) SetFlagRules

func (m *Store) SetFlagRules(_ context.Context, key, appID string, rules []*flag.Rule) error

SetFlagRules replaces all targeting rules for a flag.

func (*Store) SetFlagTenantOverride

func (m *Store) SetFlagTenantOverride(_ context.Context, key, appID, tenantID string, value any) error

SetFlagTenantOverride sets a direct per-tenant override value.

func (*Store) SetOverride

func (m *Store) SetOverride(_ context.Context, o *override.Override) error

SetOverride creates or updates a tenant override.

func (*Store) SetSecret

func (m *Store) SetSecret(_ context.Context, s *secret.Secret) error

SetSecret creates or updates a secret with auto-versioning.

func (*Store) SetVersionEncryption

func (m *Store) SetVersionEncryption(_ context.Context, versionID id.ID, alg string) error

SetVersionEncryption records the algorithm of the version row with the given id. An unknown id is not an error.

Jump to

Keyboard shortcuts

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