tenancy

package
v1.4.26 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package tenancy defines tier-neutral organization scoping primitives.

Index

Constants

View Source
const DefaultOrgID = "default"

DefaultOrgID is the organization used when no explicit organization is supplied. It preserves the single-tenant OSS data layout.

Variables

This section is empty.

Functions

func NormalizeOrgID

func NormalizeOrgID(orgID string) string

NormalizeOrgID returns a non-empty organization ID.

Types

type OrgScope

type OrgScope struct {
	Write string
	Read  []string
}

OrgScope is the ordered set of organizations a data read may see. Write is where new records go. Read is ordered by precedence, with Write first.

func DefaultOrgScope

func DefaultOrgScope() OrgScope

DefaultOrgScope returns the single-tenant OSS scope.

func NewOrgScope

func NewOrgScope(write string, read ...string) OrgScope

NewOrgScope constructs a normalized scope. The write organization is always first, blank read organizations normalize to default, and duplicates are removed without changing precedence.

func ScopeForWrite added in v1.4.26

func ScopeForWrite(source any, writeOrg string) OrgScope

ScopeForWrite returns source's trusted read scope when it is pinned to the requested write org. A missing or mismatched source fails closed to a single-org scope for writeOrg.

func (OrgScope) Contains added in v1.4.26

func (s OrgScope) Contains(orgID string) bool

Contains reports whether orgID is in the normalized read scope.

func (OrgScope) Normalized

func (s OrgScope) Normalized() OrgScope

Normalized returns a valid, independently owned copy of the scope.

func (OrgScope) OrgIDs

func (s OrgScope) OrgIDs() []string

OrgIDs returns the normalized ordered read organizations as a defensive copy.

type ScopeSource added in v1.4.26

type ScopeSource interface {
	OrgScope() OrgScope
}

ScopeSource exposes a trusted organization scope computed by a storage or tenancy boundary. Implementations must not derive it from request input.

Jump to

Keyboard shortcuts

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