multitenancy

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FeatureFlag

type FeatureFlag struct {
	Name    string `json:"name"`
	Enabled bool   `json:"enabled"`
	Tenant  string `json:"tenant,omitempty"`
}

type FeatureFlagManager

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

func NewFeatureFlagManager

func NewFeatureFlagManager() *FeatureFlagManager

func (*FeatureFlagManager) IsEnabled

func (m *FeatureFlagManager) IsEnabled(name, tenant string) bool

func (*FeatureFlagManager) List

func (m *FeatureFlagManager) List() []*FeatureFlag

func (*FeatureFlagManager) Set

func (m *FeatureFlagManager) Set(name string, enabled bool, tenant string)

type Permission

type Permission struct {
	Resource string `json:"resource"`
	Action   string `json:"action"`
}

type RBACManager

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

func NewRBACManager

func NewRBACManager() *RBACManager

func (*RBACManager) AssignRole

func (m *RBACManager) AssignRole(userID string, role RBACRole)

func (*RBACManager) CheckPermission

func (m *RBACManager) CheckPermission(userID, resource, action string) bool

type RBACRole

type RBACRole string
const (
	RoleAdmin  RBACRole = "admin"
	RoleUser   RBACRole = "user"
	RoleViewer RBACRole = "viewer"
)

type Tenant

type Tenant struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	Plan      string    `json:"plan"`
	Quota     int       `json:"quota"`
	Used      int       `json:"used"`
	Features  []string  `json:"features"`
	CreatedAt time.Time `json:"created_at"`
}

type TenantManager

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

func NewTenantManager

func NewTenantManager(db *sql.DB) *TenantManager

func (*TenantManager) Create

func (tm *TenantManager) Create(tenant *Tenant) error

func (*TenantManager) Get

func (tm *TenantManager) Get(id string) *Tenant

func (*TenantManager) HasFeature

func (tm *TenantManager) HasFeature(id, feature string) bool

func (*TenantManager) Init

func (tm *TenantManager) Init() error

func (*TenantManager) IsWithinQuota

func (tm *TenantManager) IsWithinQuota(id string) bool

func (*TenantManager) List

func (tm *TenantManager) List() []*Tenant

func (*TenantManager) RecordUsage

func (tm *TenantManager) RecordUsage(id string, tokens int)

Jump to

Keyboard shortcuts

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