---
# Required. Configuration for datastore connections and index definitions used by all parts of
# ElasticGraph.
datastore:
  # Configuration of the faraday adapter to use with the datastore client.
  # Default: {"name" => nil, "require" => nil}
  client_faraday_adapter:
    # The faraday adapter to use with the datastore client, such as `httpx` or `typhoeus`.
    # Default: null
    name: "httpx"
    # A Ruby library to require which provides the named adapter (optional).
    # Default: null
    require: "httpx/adapters/faraday"
  # Required. Map of datastore cluster definitions, keyed by cluster name. The names will be
  # referenced within `index_definitions` by `query_cluster` and `index_into_clusters` to identify
  # datastore clusters.
  clusters:
    # Configuration for a specific datastore cluster.
    main:
      # Required. The URL of the datastore cluster.
      url: "http://localhost:9200"
      # Required. Determines whether `elasticgraph-elasticsearch` or `elasticgraph-opensearch` is
      # used for the datastore client.
      backend: "elasticsearch"
      # Datastore settings in flattened (i.e. dot-separated) name form.
      # Default: {}
      settings:
        cluster.max_shards_per_node: 2000
  # Required. Map of index definition names to `IndexDefinition` objects containing customizations
  # for the named index definitions for this environment.
  index_definitions:
    # Configuration for a specific index definition.
    widgets:
      # Required. Named search cluster to be used for queries on this index. The value must match be
      # a key in the `clusters` map. Set to `null` to hide this index's types in the GraphQL schema
      # returned from the GraphQL endpoint.
      query_cluster: "main"
      # Required. Named search clusters to index data into. The values must match keys in the
      # `clusters` map.
      index_into_clusters:
        - "main"
      # Shard routing values for which the data should be spread across all shards instead of
      # concentrating it on a single shard. This is intended to be used when a handful of known
      # routing value contain such a large portion of the dataset that it extremely lopsided shards
      # would result. Spreading the data across all shards may perform better.
      # Default: []
      ignore_routing_values:
        - "ABC1234567"
      # Overrides for index (or index template) settings. The settings specified here will override
      # any settings specified on the Ruby schema definition. This is commonly used to configure a
      # different `number_of_shards` in each environment. An `index.` prefix will be added to the
      # names of all settings before submitting them to the datastore.
      # Default: {}
      setting_overrides:
        number_of_shards: 256
      # Overrides for index template settings for specific dates, allowing variation of settings for
      # different rollover indices. This is commonly used to configure a different
      # `number_of_shards` for each year or month when using yearly or monthly rollover.
      # Default: {}
      setting_overrides_by_timestamp:
        '2022-01-01T00:00:00Z':
          number_of_shards: 64
        '2023-01-01T00:00:00Z':
          number_of_shards: 96
        '2024-01-01T00:00:00Z':
          number_of_shards: 128
      # Array of custom timestamp ranges that allow different index settings for specific time
      # periods.
      # Default: []
      custom_timestamp_ranges:
        - # Array item 1
          # Required. Suffix to append to the index name for this custom range.
          index_name_suffix: "before_2022"
          # Less than timestamp boundary (ISO 8601 format).
          # Default: null
          lt: "2022-01-01T00:00:00Z"
          # Required. Setting overrides for this custom timestamp range.
          setting_overrides:
            number_of_shards: 32
        - # Array item 2
          # Required. Suffix to append to the index name for this custom range.
          index_name_suffix: "after_2026"
          # Greater than or equal timestamp boundary (ISO 8601 format).
          # Default: null
          gte: "2027-01-01T00:00:00Z"
          # Required. Setting overrides for this custom timestamp range.
          setting_overrides:
            number_of_shards: 32
  # Determines if we log requests/responses to/from the datastore.
  # Default: false
  log_traffic: false
  # Passed down to the datastore client. Controls the number of times ElasticGraph attempts a call
  # against the datastore before failing. Retrying a handful of times is generally advantageous,
  # since some sporadic failures are expected during the course of operation, and better to retry
  # than fail the entire call.
  # Default: 3
  max_client_retries: 3

# Required. Configuration for GraphQL behavior used by `elasticgraph-graphql`.
graphql:
  # Determines the `size` of our datastore search requests if the query does not specify via `first`
  # or `last`.
  # Default: 50
  default_page_size: 25
  # Determines the maximum size of a requested page. If the client requests a page larger than this
  # value, the `size` will be capped by this value.
  # Default: 500
  max_page_size: 100
  # Queries that take longer than this configured threshold will have a sanitized version logged so
  # that they can be investigated.
  # Default: 5000
  slow_query_latency_warning_threshold_in_ms: 3000
  # Object used to identify the client of a GraphQL query based on the HTTP request.
  # Default: {}
  client_resolver:
    # Name of the client resolver class.
    # Default: null
    name: "ElasticGraph::GraphQL::ClientResolvers::ViaHTTPHeader"
    # The path to require to load the client resolver class.
    # Default: null
    require_path: "support/client_resolvers"
    header_name: "X-Client-Name"
  # Array of modules that will be extended onto the `GraphQL` instance to support extension
  # libraries.
  # Default: []
  extension_modules:
    - # Array item 1
      # Required. The name of the extension module class to load.
      name: "MyExtensionModule"
      # Required. The path to require to load the extension module.
      require_path: "./my_extension_module"

# Required. Configuration for indexing operations and metrics used by `elasticgraph-indexer`.
indexer:
  # Map of indexing latency thresholds (in milliseconds), keyed by the name of the indexing latency
  # metric. When an event is indexed with an indexing latency exceeding the threshold, a warning
  # with the event type, id, and version will be logged, so the issue can be investigated.
  # Default: {}
  latency_slo_thresholds_by_timestamp_in_ms:
    ingested_from_topic_at: 10000
    entity_updated_at: 15000
  # Setting that can be used to specify some derived indexing type updates that should be skipped.
  # This setting should be a map keyed by the name of the derived indexing type, and the values
  # should be sets of ids. This can be useful when you have a "hot spot" of a single derived
  # document that is receiving a ton of updates. During a backfill (or whatever) you may want to
  # skip the derived type updates.
  # Default: {}
  skip_derived_indexing_type_updates:
    WidgetWorkspace:
      - "ABC12345678"

# Required. Configuration for logging used by all parts of ElasticGraph.
logger:
  # Determines what severity level we log.
  # Default: "INFO"
  level: "INFO"
  # Determines where we log to. "stdout" or "stderr" are interpreted as being those output streams;
  # any other value is assumed to be a file path.
  # Default: "stdout"
  device: "logs/development.log"
  # Class used to format log messages.
  # Default: "ElasticGraph::Support::Logger::JSONAwareFormatter"
  formatter: "ElasticGraph::Support::Logger::JSONAwareFormatter"

# Required. Configuration for schema artifact management used by all parts of ElasticGraph.
schema_artifacts:
  # Path to the directory where schema artifacts are stored.
  # Default: "config/schema/artifacts"
  directory: "config/schema/artifacts"

# Configuration for health checks used by `elasticgraph-health_check`.
health_check:
  # The list of clusters to perform datastore status health checks on. A `green` status maps to
  # `healthy`, a `yellow` status maps to `degraded`, and a `red` status maps to `unhealthy`. The
  # returned status is the minimum status from all clusters in the list (a `yellow` cluster and a
  # `green` cluster will result in a `degraded` status).
  # Default: []
  clusters_to_consider:
    - "cluster-one"
    - "cluster-two"
  # A map of types to perform recency checks on. If no new records for that type have been indexed
  # within the specified period, a `degraded` status will be returned.
  # Default: {}
  data_recency_checks:
    # Configuration for data recency checks on a specific type.
    Widget:
      # Required. The name of the timestamp field to use for recency checks.
      timestamp_field: "createdAt"
      # Required. The maximum number of seconds since the last record was indexed for this type
      # before considering it stale.
      expected_max_recency_seconds: 30

# Configuration of datastore query interceptors used by `elasticgraph-query_interceptor`.
query_interceptor:
  # List of query interceptors to apply to datastore queries before they are executed.
  # Default: []
  interceptors:
    - # Array item 1
      # Required. The name of the interceptor extension class.
      name: "HideInternalRecordsInterceptor"
      # Required. The path to require to load the interceptor extension. This should be a relative
      # path from a directory on the Ruby `$LOAD_PATH` or a a relative path from the ElasticGraph
      # application root.
      require_path: "./lib/interceptors/hide_internal_records_interceptor"

# Configuration for client and query registration used by `elasticgraph-query_registry`.
query_registry:
  # Required. Path to the directory containing the query registry files.
  path_to_registry: "config/queries"
  # Whether to allow clients that are not registered in the registry.
  # Default: true
  allow_unregistered_clients: true
  # List of client names that are allowed to execute any query, even if not registered.
  # Default: []
  allow_any_query_for_clients:
    - "admin"
    - "internal"

# Configuration for the warehouse lambda used by `elasticgraph-warehouse_lambda`.
warehouse:
  # Required. The S3 path prefix to use when storing data files.
  s3_path_prefix: "my-prefix"
  # Required. The S3 bucket name to write JSONL files into.
  s3_bucket_name: "my-warehouse-bucket"
  # Optional AWS region for the S3 bucket. If not specified, uses AWS SDK default region resolution
  # (AWS_REGION env var, instance metadata, etc.).
  # Default: null
  aws_region: "eu-central-1"
