## Server configuration
api.listening_addr = "127.0.0.1:5005"   # Address and port on which the API server will listen.
webui.listening_addr = "127.0.0.1:8080" # Address and port on which the webui will listen.
# Note: listening on all interfaces using [::]:port is not advised, as there is no auth yet.

## SQLite configuration (enabled by default)
# database.sqlite.directory = "${DATA_DIR}/obelisk-sqlite" # Path to sqlite directory. Supports path prefixes.
## Customize PRAGMA statements.
## Defaults are in `crates/db-sqlite/src/sqlite_dao.rs`.
# database.sqlite.pragma = { "cache_size" = "3000" }

## Postgres configuration, keys support environment variable interpolation.
# database.postgres.host =     "${POSTGRES_HOST}"
# database.postgres.user =     "${POSTGRES_USER}"
# database.postgres.password = "${POSTGRES_PASSWORD}"
# database.postgres.db_name =  "${POSTGRES_DATABASE}"
# database.postgres.provision_policy = "never" # One of "auto"|"never". If `auto` is selected, missing database will be created on startup.

## Global WASM Configuration
# [wasm]
## WASM Cache dir
## Path to directory where downloaded or transformed WASM files are stored. Supports path prefixes.
## By default "${CACHE_DIR}/wasm" or "./cache/wasm" if no valid home directory path could be retrieved from the operating system.
# cache_directory = "${CACHE_DIR}/wasm"
# backtrace.persist = true                       # Persist backtraces on effect calls for all workflows and webhook endpoints.
# allocator_config = "auto"                      # One of "auto"|"on_demand"|"pooling"
# global_executor_instance_limiter = "unlimited" # If set to an integer, limits the number of concurrent workflow and activity executions.
# global_webhook_instance_limiter = "unlimited"  # If set to an integer, limits the number of concurrent webhook requests.
# fuel = "unlimited"                             # If set to an integer, WASM instances consume fuel, details: https://docs.wasmtime.dev/api/wasmtime/struct.Store.html#method.set_fuel
# build_semaphore = "unlimited"                  # If set to an integer, limit the number of AOT compilations that can run in parallel
# parallel_compilation = true                    # Enable (default) or disable parallel AOT compilation of each WASM component.
# debug = false                                  # Enable debugging of WASM components: Instruct wasmtime to emit DWARF debug info and disable cranelift optimizations.

## Global Preopened Directories Configuration
# [activities.directories]
# enabled = false                           # Disabled by default.
# parent_directory = "${TEMP_DIR}/obelisk"  # Make sure the folder is not on a RAM-backed filesystem if you plan to write large files.
# cleanup.enabled = true                    # Periodic cleanup job can be disabled, it is enabled by default.
# cleanup.run_every.minutes = 1             # Run the cleanup every minute by default.
# cleanup.older_than.minutes = 5            # Delete folders belonging to executions that finished 5 minutes earlier by default.

## Global Workflow Configuration
# [workflows]
# lock_extension_leeway.milliseconds = 100 # Starts extending the lock a little before it expires, specifically at expires_at minus the configured leeway.
# subscription_interruption.seconds = 1    # Interrupts listening for notifications periodically, needed for Postgres with a local-only subscription mechanism. Value can be "none" or a duration.

# [wasm.codegen_cache]
## Defaults:
# enabled = true
# directory = "${CACHE_DIR}/codegen" # Path to directory where AOT generated code is cached. Supports path prefixes.

## Timers Watcher Configuration
# [timers_watcher]
# enabled = true
# leeway.milliseconds = 500
# tick_sleep.milliseconds = 100


### WASM Component Configuration
## Each WASM component is configured separately in a `[[activity_wasm]]`, `[[workflow]]` or `[[webhook_endpoint]]` table.
## Common settings for all components
# name = "name" # Each component must be named.
## Location can be a file path or an OCI registry reference.
# location.path = "path/to/wasm"
# location.oci = "docker.io/repo/image:tag"
# content_digest = "sha256:AA.." # Optional. If specified, the WASM file must have a matching hash.

## Common executor settings
# exec.batch_size = 5 # Number of executions to lock for every event loop tick.
# exec.lock_expiry.seconds = 1 # Each execution is locked for 1s by default.
# exec.tick_sleep.milliseconds = 200 # Sleep between event loop ticks.
# exec.locking_strategy = "by_ffqn" # Specify how pending executions are selected. One of "by_ffqn"|"by_component_id"


### WASM Activity components configuration
# [[activity_wasm]]
## Common settings for all components - see above.
## Common executor settings - see above.
## Specific settings for activity_wasm:
## Retry customization: All activities are retried on trap (panic) and timeouts until `max_retries` condition is met.
# max_retries = 5
# retry_exp_backoff.milliseconds = 100 # First retry is scheduled after 100ms after the failure, the next one after 200ms, then after 400ms...
## Retry on err setting
# Activities are retried on timeouts and traps.
# Moreover, with `retry_on_err`, a function that returns the `err` variant will be retried as well.
# retry_on_err = true # default is true
## Guest std stream forwarding to host: one of "stdout","stderr","none". Default is "none".
# forward_stdout="stderr" # forwards stdout to host's stderr
# forward_stderr="stderr" # forwards stderr to host's stderr
## Environment variables: Set to a specific value or forward from the host. Default is empty.
# env_vars = ["ENV1", "ENV2=somevalue"]
## Preopened directory support
## When enabled, `.` will be available to the activity with all permissions.
## On host the folder is mapped to `activities.directories.parent_directory`/ExecutionID.
# directories.enabled = false # Disabled by default.
## If `reuse_on_retry` is enabled, the directory is not wiped clean on retries. Enable only if all disk IO is idempotent.
# directories.reuse_on_retry = false
## Activities that need process API must enable it explicitly. See `obelisk:activity/process@1.0.0` WIT interface.
## When running on linux, the `native` process API provider attempts to kill the spawned processes using process groups.
# directories.process_provider = "none" # Default is "none". Possible value: "none"|"native"

### Workflow components configuration
# [[workflow]]
## Common settings for all components - see above.
## Common executor settings - see above.

## Retry customization: All workflows are retried on trap (panic) and timeouts forever. Therefore, `retry_exp_backoff` must not be zero.
# retry_exp_backoff.milliseconds = 100 # First retry is scheduled after 100ms after the failure, the next one after 200ms, then after 400ms...

## Automatic lock extension can be disabled by setting the duration to zero.
# lock_extension.seconds = 1

## Blocking strategy: When workflow requests a child execution result, it can either be interrupted, or kept in the memory until its execution lock expires or the response arrives.
## When "interrupt" is selected, after every child execution result the whole event history must be replayed.
# blocking_strategy = "await" # Default blocking strategy is "await"
# blocking_strategy = { kind = "await", non_blocking_event_batching = 100 } # Number of non-blocking events that can be cached and written in a batch.

# convert_core_module = true # Transparently convert Core WASM modules to WASM Components during startup.

## Map from frame symbol file names to corresponding file paths on local filesystem. Supports path path prefixes on both sides.
## If frame symbol path starts with `...`, only the suffix will be used to find the matching source file.
# backtrace.sources = {"frame symbol file path" = "path to the source file", ".../src/lib.rs" = "path to source file"}

# Stub WASI CLI world imports. Only needed for workflows authored in TinyGo.
# stub_wasi = false # Default is false.


### Webhook Endpoint section
# [[http_server]]
# name = "external"
# listening_addr = "0.0.0.0:9000"
# max_inflight_requests = "unlimited" # If set to an integer, limits the number of inflight requests
#
# [[webhook_endpoint]]
## Common settings for all components - see above.
# http_server = "external" # link to a `http_server`'s name

### Routes section
## An array of routes that will be matched against incoming requests.
## Only the path portion of a URL is taken into cosideration, the query part
## ("?param_name=value") is ignored by the matcher.
## Syntax of a route:
## "/"                                          # Only the root URL path is matched.
## "/path"                                      # All methods are matched, URL path must be exactly '/path'.
## "/path/*"                                    # All methods are matched, URL path must start with '/path/'.
## { methods = ["GET"], route = "/some/path" }  # Method must be GET and path '/some/path'.
## "/status/:param1/:param2"                    # When URL matches, `param1` and `param2` values will be exposed as env vars.
## ""                                           # Matches every possible URL, same as `/*`
## For details about the matching engine please see https://docs.rs/route-recognizer/latest/route_recognizer/
# routes = [{ methods = [ "GET" ], route = "/some"}, "/other"]

## Guest std stream forwarding to host: one of "stdout","stderr","none". Default is "none".
# forward_stdout="stderr" # forwards stdout to host's stderr
# forward_stderr="stderr" # forwards stderr to host's stderr

## Environment variables: Set to a specific value or forward from the host. Default is empty.
# env_vars = ["ENV1", "ENV2=somevalue"]

[[http_server]]
name = "external_webhook"
listening_addr = "127.0.0.1:9090"

[[activity_wasm]]
name = "test_programs_fibo_activity"
location.oci = "docker.io/getobelisk/test_programs_fibo_activity:2025-12-08@sha256:a05d32fb111b8ac142393a97c36c411816dddf94839db5ff16633e1d3270f702"
max_retries = 0

[[workflow]]
name = "test_programs_fibo_workflow"
location.oci = "docker.io/getobelisk/test_programs_fibo_workflow:2025-12-08@sha256:3b171d325a832ad58c86ec1c2a33eac468ed951b57aaa9284a99dbc58abf1245"
exec.lock_expiry.seconds = 2
backtrace.sources = { ".../src/lib.rs" = "${OBELISK_TOML_DIR}/crates/testing/test-programs/fibo/workflow/src/lib.rs" }

[[webhook_endpoint]]
name = "test_programs_fibo_webhook"
location.oci = "docker.io/getobelisk/test_programs_fibo_webhook:2025-12-08@sha256:d48247d9f5c538c4c584c6f149f896a26a6f51efdc39ae73d6194b10f8cf0c12"
http_server = "external_webhook"
routes = [{ methods = ["GET"], route = "/fibo/:N/:ITERATIONS" }]

[[activity_wasm]]
name = "test_programs_http_get_activity"
location.oci = "docker.io/getobelisk/test_programs_http_get_activity:2025-12-08@sha256:135a686ea62a9f15289b2783af26fb1ee300140b38c1eb64a7f82377d3756b51"
forward_stdout = "stderr"
forward_stderr = "stderr"

[[workflow]]
name = "test_programs_http_get_workflow"
location.oci = "docker.io/getobelisk/test_programs_http_get_workflow:2025-12-08@sha256:5256f3dbec47cdcc8e76dbf9fc81ed90e8c16a409c14a34ffc1bae35fd291d20"
backtrace.sources = { ".../src/lib.rs" = "${OBELISK_TOML_DIR}/crates/testing/test-programs/http/workflow/src/lib.rs" }

[[activity_wasm]]
name = "test_programs_sleep_activity"
location.oci = "docker.io/getobelisk/test_programs_sleep_activity:2025-12-08@sha256:05b4882412b3fbe1949954c5948aab273fce5d627ac81483908ec02edf887ae7"
exec.lock_expiry.seconds = 10

[[workflow]]
name = "test_programs_sleep_workflow"
location.oci = "docker.io/getobelisk/test_programs_sleep_workflow:2025-12-08@sha256:b833454a0c4befaa2767957ed1ddbcd4210510c7075ebf9d22ca7e2f14445ff4"
backtrace.sources = { ".../src/lib.rs" = "${OBELISK_TOML_DIR}/crates/testing/test-programs/sleep/workflow/src/lib.rs" }

### Send spans via gRPC to an OTLP collector.
# [otlp]
## Run `docker run --rm -it  -p 4317:4317 -p 16686:16686 jaegertracing/all-in-one:1.60` to start collecting traces.
# enabled = true
## Defaults:
# level = "info,app=trace"
# service_name = "obelisk-server"
# otlp_endpoint = "http://localhost:4317"

### Stdout configuration, by default logs INFO and above.
[log.stdout]
enabled = true
## Defaults:
# level = "info,app=trace"
# style = "plain" # One of "plain","plain_compact","json"
# span = "none" # One of "none","new","enter","exit","close","active","full"
# target = false

### Sample (rolling) file configuration
# [log.file]
# enabled = true
# level = "info,obeli=debug,app=trace"
# style = "plain"                           # One of "plain","plain_compact","json"
# span = "none"                             # One of "none","new","enter","exit","close","active","full"
# target = false
# rotation = "daily"                        # One of "minutely"|"hourly"|"daily"|"never"
# directory = "."
# prefix = "obelisk_server_daily" # File name prefix

[log.file]
enabled = true
level = "info,obeli=debug,app=trace"
style = "plain"
span = "none"
target = true
rotation = "never"
directory = "."
prefix = "obelisk.log"


## Appendix: Supported path prefixes:
# | Prefix               | Default path           | Details
# | ~                    | ~                      | Current user's home directory
# | ${DATA_DIR}          | ~/.local/share/obelisk | https://docs.rs/directories/6.0.0/directories/struct.ProjectDirs.html#method.data_dir
# | ${CACHE_DIR}         | ~/.cache/obelisk       | https://docs.rs/directories/6.0.0/directories/struct.ProjectDirs.html#method.cache_dir
# | ${CONFIG_DIR}        | ~/.config/obelisk      | https://docs.rs/directories/6.0.0/directories/struct.ProjectDirs.html#method.config_dir
# | ${OBELISK_TOML_DIR}  | N/A                    | Directory where the obelisk.toml file is located
# | ${TEMP_DIR}          | /tmp                   | https://doc.rust-lang.org/std/env/fn.temp_dir.html

## Appendix: Environment variable interpolation
# Keys that support environment variable interpolation can use `${SOME}` to get the value of environment variable `SOME`.
