# The backend will exit after this many seconds of inactivity
idle_timeout_seconds = 600

# The path for the hints database, containing information about the sequence
# in which slabs are typically loaded. This DB is used to make guesses and
# try to load slabs preemptively.
hints_database_path = "/var/potatofs/backend_s3_hints.db"

# When computing the time that passed between loading two slabs in a sequence,
# decrease the computed time by this many milliseconds. This way we can give
# us a bit of time to download the slab ahead of it being used, hopefully.
hint_skew_ms = 30000

# How many hints can be queued for preloading. This is mostly to keep memory
# usage under control and possibly avoid trying to preload too many things
# when a large chain of slab hints is triggered.
hints_preload_queue_size = 10000

# Maximum number of hints per slab. This is so we keep a cap on the database
# size and don't trigger more than this many preloads anytime to load a slab.
# Together with hint_slab_max_age_seconds, this is used to rate-limit how many
# hints we accept over time. We allow bursting up to 50% of that value, then
# the token bucket refills at one per
# hint_slab_max_age_seconds/(max_preload_per_hint/2) second.
max_preload_per_hint = <%= @max_preload_per_hint %>

# How many slab record to keep in memory for the purpose of updating their
# hints. Hints may be updated for this many slabs each time we get a get/hint
# request. Holding too many slabs in memory at once will use up more CPU and
# may cause lock contention on the hints table as we have to issue this many
# SQL updates each time.
hint_slabs_max_open = 100

# How long to keep track of open slabs. As long as a slab is considered
# in-memory, any new coming hint will be added to the "tree" of hints for
# preloading.
hint_slab_max_age_seconds = 120

s3_endpoint = "<%= @s3_endpoint %>"
s3_bucket = "<%= @s3_bucket %>"
s3_region = "<%= @s3_region %>"

# syslog mimimum log level. Priorities lower than this are silently
# discarded.
log_level = "info"

# S3 credentials
access_key_id = "<%= @s3_access_key_id.unwrap %>"
secret_access_key = "<%= @s3_secret_access_key.unwrap %>"

# Unix socket path to communicate with the background child that keeps
# our S3 session active.
socket_path = "/var/potatofs/backend_s3.sock"

# Because this backend has infinite capacity, put a cap to it so we can
# correctly compute how much capacity our filesystem has.
# Here is 0.5TB.
backend_bytes = <%= @backend_bytes %>

# Timeout for S3 operations. Needs to be a bit longer than the
# potatofs backend timeout so we can properly receive the signal.
backend_timeout_seconds = 60

# Encryption key
backend_secret_key_path = "/etc/potatofs/backend.secret"

# The command to preload slabs as predicted by the hints database. This should,
# for now, always point to the right "potatoctl claim <ino> <base>" command,
# optionally with the right config path. This is currently the only safe way
# to trigger a claim. The "%inode%" and "%base%" tokens will be replaced
# by the slab's inode/base that needs to be preloaded.
backend_claim_command = "/usr/bin/potatoctl claim %inode% %base%"
