multitenancy

package
v0.2.26 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoOrgID is returned when no organization ID is found in the context
	ErrNoOrgID = errors.New("no organization ID found in context")
)
View Source
var (
	// ErrTenantNotFound is returned when a tenant is not found
	ErrTenantNotFound = errors.New("tenant not found")
)

Functions

func GetOrgID

func GetOrgID(ctx context.Context) (string, error)

GetOrgID returns the organization ID from the context

func HasOrgID

func HasOrgID(ctx context.Context) bool

HasOrgID returns true if the context has an organization ID

func MustGetOrgID

func MustGetOrgID(ctx context.Context) string

MustGetOrgID returns the organization ID from the context or panics

func WithOrgID

func WithOrgID(ctx context.Context, orgID string) context.Context

WithOrgID returns a new context with the given organization ID

Types

type ConfigManager

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

ConfigManager manages tenant configurations

func NewConfigManager

func NewConfigManager() *ConfigManager

NewConfigManager creates a new config manager

func (*ConfigManager) GetCustomConfig

func (m *ConfigManager) GetCustomConfig(ctx context.Context, key string) (interface{}, error)

GetCustomConfig returns a custom configuration value

func (*ConfigManager) GetDataStoreConfig

func (m *ConfigManager) GetDataStoreConfig(ctx context.Context) (map[string]interface{}, error)

GetDataStoreConfig returns the data store configuration

func (*ConfigManager) GetLLMAPIKey

func (m *ConfigManager) GetLLMAPIKey(ctx context.Context, provider string) (string, error)

GetLLMAPIKey returns the API key for the given LLM provider

func (*ConfigManager) GetTenantConfig

func (m *ConfigManager) GetTenantConfig(ctx context.Context) (*TenantConfig, error)

GetTenantConfig returns the configuration for a tenant

func (*ConfigManager) GetVectorStoreConfig

func (m *ConfigManager) GetVectorStoreConfig(ctx context.Context) (map[string]interface{}, error)

GetVectorStoreConfig returns the vector store configuration

func (*ConfigManager) RegisterTenant

func (m *ConfigManager) RegisterTenant(config *TenantConfig) error

RegisterTenant registers a new tenant

type TenantConfig

type TenantConfig struct {
	// OrgID is the organization ID
	OrgID string

	// LLMAPIKeys maps LLM provider names to API keys
	LLMAPIKeys map[string]string

	// VectorStoreConfig contains vector store configuration
	VectorStoreConfig map[string]interface{}

	// DataStoreConfig contains data store configuration
	DataStoreConfig map[string]interface{}

	// Custom contains custom configuration values
	Custom map[string]interface{}
}

TenantConfig represents the configuration for a tenant

Jump to

Keyboard shortcuts

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