types

package
v0.1.4 Latest Latest
Warning

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

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

Documentation

Overview

Package types defines tenant identifiers, tenant metadata, lifecycle statuses, and host/tenant side markers.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptyTenantID reports an empty tenant identifier.
	ErrEmptyTenantID = errors.New("gotenancy/types: empty tenant id")

	// ErrInvalidTenantID reports a tenant identifier that does not match the configured strategy.
	ErrInvalidTenantID = errors.New("gotenancy/types: invalid tenant id")
)

Functions

This section is empty.

Types

type MultiTenancySide

type MultiTenancySide string

MultiTenancySide identifies whether an operation runs as host infrastructure or inside a tenant boundary.

const (
	MultiTenancySideHost   MultiTenancySide = "host"
	MultiTenancySideTenant MultiTenancySide = "tenant"
)

type Tenant

type Tenant struct {
	ID     TenantID
	Name   string
	Status TenantStatus
	PlanID string
	Config map[string]string
}

Tenant is the shared metadata shape used by the core abstractions.

type TenantID

type TenantID string

TenantID is the default public tenant identifier type.

func NewTenantIDFromInt

func NewTenantIDFromInt(value int64) TenantID

NewTenantIDFromInt creates a tenant identifier from an int64 value.

func ParseTenantID

func ParseTenantID(raw string, strategy TenantIDStrategy) (TenantID, error)

ParseTenantID validates raw with the configured strategy and returns a TenantID.

func (TenantID) Int64

func (id TenantID) Int64() (int64, error)

Int64 returns the integer form of an int-strategy tenant identifier.

func (TenantID) String

func (id TenantID) String() string

String returns the string form of the tenant identifier.

type TenantIDStrategy

type TenantIDStrategy string

TenantIDStrategy describes how incoming tenant identifiers should be validated before they are accepted by resolver and store implementations.

const (
	// TenantIDStrategyString accepts any non-empty string.
	TenantIDStrategyString TenantIDStrategy = "string"

	// TenantIDStrategyInt accepts base-10 integer identifiers.
	TenantIDStrategyInt TenantIDStrategy = "int"

	// TenantIDStrategyUUID accepts canonical UUID strings.
	TenantIDStrategyUUID TenantIDStrategy = "uuid"
)

type TenantStatus

type TenantStatus string

TenantStatus describes the lifecycle state of a tenant.

const (
	TenantStatusPending     TenantStatus = "pending"
	TenantStatusActive      TenantStatus = "active"
	TenantStatusSuspended   TenantStatus = "suspended"
	TenantStatusSoftDeleted TenantStatus = "soft_deleted"
	TenantStatusHardDeleted TenantStatus = "hard_deleted"
)

Jump to

Keyboard shortcuts

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