WeaviateEx.Schema.MultiTenancyConfig (WeaviateEx v0.7.4)

View Source

Multi-tenancy configuration for collection schema.

Provides configuration options for multi-tenant collections including auto-tenant creation and activation features.

Features

  • Auto-Tenant Creation: Automatically create tenants on first data insertion
  • Auto-Tenant Activation: Automatically activate tenants when accessed

Examples

# Basic multi-tenancy enabled
config = MultiTenancyConfig.new(enabled: true)

# With auto-tenant creation
config = MultiTenancyConfig.new(
  enabled: true,
  auto_tenant_creation: true
)

# With auto-tenant activation
config = MultiTenancyConfig.new(
  enabled: true,
  auto_tenant_activation: true
)

# Full configuration
config = MultiTenancyConfig.new(
  enabled: true,
  auto_tenant_creation: true,
  auto_tenant_activation: true
)

Summary

Functions

Create a configuration with multi-tenancy disabled.

Create a configuration with multi-tenancy enabled.

Create a configuration from a map (e.g., from API response).

Create a fully automatic tenant configuration.

Create a new multi-tenancy configuration.

Convert the configuration to a map for the Weaviate API.

Create a configuration with auto-tenant activation enabled.

Create a configuration with auto-tenant creation enabled.

Types

t()

@type t() :: %WeaviateEx.Schema.MultiTenancyConfig{
  auto_tenant_activation: boolean(),
  auto_tenant_creation: boolean(),
  enabled: boolean()
}

Functions

disabled()

@spec disabled() :: t()

Create a configuration with multi-tenancy disabled.

Examples

MultiTenancyConfig.disabled()
# => %MultiTenancyConfig{enabled: false, auto_tenant_creation: false, auto_tenant_activation: false}

enabled()

@spec enabled() :: t()

Create a configuration with multi-tenancy enabled.

This is a convenience function for creating a basic multi-tenant configuration.

Examples

MultiTenancyConfig.enabled()
# => %MultiTenancyConfig{enabled: true, auto_tenant_creation: false, auto_tenant_activation: false}

from_map(map)

@spec from_map(map()) :: t()

Create a configuration from a map (e.g., from API response).

Examples

map = %{"enabled" => true, "autoTenantCreation" => true}
MultiTenancyConfig.from_map(map)
# => %MultiTenancyConfig{enabled: true, auto_tenant_creation: true, auto_tenant_activation: false}

fully_automatic()

@spec fully_automatic() :: t()

Create a fully automatic tenant configuration.

This enables both auto-tenant creation and activation.

Examples

MultiTenancyConfig.fully_automatic()
# => %MultiTenancyConfig{enabled: true, auto_tenant_creation: true, auto_tenant_activation: true}

new(opts \\ [])

@spec new(keyword()) :: t()

Create a new multi-tenancy configuration.

Options

  • :enabled - Enable multi-tenancy for the collection (default: false)
  • :auto_tenant_creation - Automatically create tenants on first data insertion (default: false)
  • :auto_tenant_activation - Automatically activate tenants when accessed (default: false)

Examples

MultiTenancyConfig.new(enabled: true)
# => %MultiTenancyConfig{enabled: true, auto_tenant_creation: false, auto_tenant_activation: false}

MultiTenancyConfig.new(enabled: true, auto_tenant_creation: true)
# => %MultiTenancyConfig{enabled: true, auto_tenant_creation: true, auto_tenant_activation: false}

to_map(config)

@spec to_map(t()) :: map()

Convert the configuration to a map for the Weaviate API.

Examples

config = MultiTenancyConfig.new(enabled: true, auto_tenant_creation: true)
MultiTenancyConfig.to_map(config)
# => %{"enabled" => true, "autoTenantCreation" => true, "autoTenantActivation" => false}

with_auto_activation()

@spec with_auto_activation() :: t()

Create a configuration with auto-tenant activation enabled.

When auto-tenant activation is enabled, inactive tenants are automatically activated when they are accessed.

Examples

MultiTenancyConfig.with_auto_activation()
# => %MultiTenancyConfig{enabled: true, auto_tenant_creation: false, auto_tenant_activation: true}

with_auto_creation()

@spec with_auto_creation() :: t()

Create a configuration with auto-tenant creation enabled.

When auto-tenant creation is enabled, tenants are automatically created when data is first inserted for a non-existent tenant.

Examples

MultiTenancyConfig.with_auto_creation()
# => %MultiTenancyConfig{enabled: true, auto_tenant_creation: true, auto_tenant_activation: false}