# =============================================================================
# Hazelcast Client Configuration for FT QoE Web
# =============================================================================
# This configuration connects FT QoE Web to the Hazelcast cluster for
# distributed caching and messaging. FT QoE Web reads the member list and the
# cluster name ONLY from this file -- HZ_MEMBERS in .env is not read.

hazelcast-client:
  # Cluster name must match the server-side cluster configuration
  cluster-name: dev

  properties:
    # Shuffle member list to distribute load
    hazelcast.client.shuffle.member.list: true
    # Heartbeat timeout (ms) - increase for slow networks
    hazelcast.client.heartbeat.timeout: 60000
    # Heartbeat interval (ms)
    hazelcast.client.heartbeat.interval: 5000
    # Event thread pool size
    hazelcast.client.event.thread.count: 5
    # Event queue capacity
    hazelcast.client.event.queue.capacity: 1000000
    # Invocation timeout (seconds)
    hazelcast.client.invocation.timeout.seconds: 120

  network:
    # List of Hazelcast cluster members -- replace with your cluster.
    # 'hazelcast:5701' works only when Hazelcast is the 'hazelcast' container
    # on the same Docker bridge; otherwise list every member's <ip>:5701.
    cluster-members:
      - hazelcast:5701

    # Cluster routing mode - connect to all members
    cluster-routing:
      mode: "ALL_MEMBERS"

    # Retry failed operations
    redo-operation: true

    # Connection timeout (ms)
    connection-timeout: 60000

    # TCP socket options
    socket-options:
      tcp-no-delay: false
      keep-alive: true
      reuse-address: true
      linger-seconds: 3
      buffer-size: 128

  # Near cache configuration for frequently accessed data
  near-cache:
    default:
      # Time to live (seconds) - data expires after this time
      time-to-live-seconds: 90
      # Max idle time (seconds) - data expires if not accessed
      max-idle-seconds: 100
      # Invalidate cache entries when they change on server
      invalidate-on-change: true
      # Store format in memory
      in-memory-format: OBJECT
      # Serialize keys for efficient storage
      serialize-keys: true
      # Local update policy
      local-update-policy: INVALIDATE
      # Preloader settings (disabled by default)
      preloader:
        enabled: false
        directory: directory
        store-initial-delay-seconds: 50
        store-interval-seconds: 10

  # Connection strategy for handling cluster disconnections
  connection-strategy:
    # Wait for the cluster at startup: FT QoE Web fills its KPI cache while
    # starting and fails immediately if the client is not connected yet
    async-start: false
    # Reconnect mode - async reconnection
    reconnect-mode: ASYNC
    # Connection retry policy
    connection-retry:
      # Initial backoff delay (ms)
      initial-backoff-millis: 2000
      # Maximum backoff delay (ms)
      max-backoff-millis: 60000
      # Backoff multiplier
      multiplier: 3
      # How long to keep trying to reach the cluster before the client shuts
      # down for good; -1 = never give up (survives a Hazelcast restart)
      cluster-connect-timeout-millis: -1
      # Jitter factor (0.0 - 1.0)
      jitter: 0.5

  # User code deployment (disabled - not needed for QoE)
  user-code-deployment:
    enabled: false
