WeaviateEx.Batch.Config (WeaviateEx v0.7.4)

View Source

Configuration options for batch operations.

This module provides centralized configuration for batch safety features including MAX_STORED_RESULTS limits, auto-retry settings, and callbacks.

Examples

# Create config with defaults
config = Batch.Config.new()

# Customize options
config = Batch.Config.new(
  max_stored_results: 50_000,
  auto_retry: true,
  max_retries: 5,
  retry_delay_ms: 2000,
  on_permanent_failure: fn objects ->
    Logger.error("Permanent failures: #{length(objects)}")
  end
)

# Use with batch operations
{:ok, results} = Batch.with_batch(client, [config: config], fn batch ->
  batch |> Batch.add_object("Article", %{title: "Test"})
end)

Summary

Functions

Check if auto-retry is enabled in the config.

Get the default maximum retries.

Get the default maximum stored results.

Get the default retry delay in milliseconds.

Merge two configurations, with the second taking precedence.

Create a new batch configuration with optional overrides.

Convert config to keyword list (for passing to functions).

Types

t()

@type t() :: %WeaviateEx.Batch.Config{
  auto_retry: boolean(),
  max_retries: pos_integer(),
  max_retry_delay_ms: pos_integer(),
  max_stored_results: pos_integer(),
  on_permanent_failure: ([map()] -> any()) | nil,
  on_retry: ([map()], non_neg_integer() -> any()) | nil,
  retry_delay_ms: pos_integer()
}

Functions

auto_retry_enabled?(config)

@spec auto_retry_enabled?(t()) :: boolean()

Check if auto-retry is enabled in the config.

default_max_retries()

@spec default_max_retries() :: pos_integer()

Get the default maximum retries.

default_max_stored_results()

@spec default_max_stored_results() :: pos_integer()

Get the default maximum stored results.

default_retry_delay_ms()

@spec default_retry_delay_ms() :: pos_integer()

Get the default retry delay in milliseconds.

merge(base, override)

@spec merge(t(), t() | keyword()) :: t()

Merge two configurations, with the second taking precedence.

new(opts \\ [])

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

Create a new batch configuration with optional overrides.

Options

  • :max_stored_results - Maximum stored result UUIDs (default: 100,000)
  • :auto_retry - Automatically re-queue failed objects (default: true)
  • :max_retries - Maximum retry attempts per object (default: 3)
  • :retry_delay_ms - Base delay for retry backoff in ms (default: 1000)
  • :max_retry_delay_ms - Maximum retry delay in ms (default: 60,000)
  • :on_permanent_failure - Callback for objects exceeding max_retries
  • :on_retry - Callback when objects are retried

Examples

config = Config.new(max_retries: 5)
config = Config.new(auto_retry: false)

to_keyword(config)

@spec to_keyword(t()) :: keyword()

Convert config to keyword list (for passing to functions).