WebAssembly / wasi-config

10 stars 8 forks source link

Specify config to never change during the lifetime of the component. #21

Open badeend opened 1 month ago

badeend commented 1 month ago

Currently, the spec does not specify whether config values are allowed to change during the lifetime of the component. I'd suggest: No. :slightly_smiling_face: Because: simpler semantics & API design.

This is in line with wasi-cli's environment variables: https://github.com/WebAssembly/wasi-cli/blob/main/wit/environment.wit

In my personal experience, it typically doesn't make much sense to do it any other way.

thomastaylor312 commented 1 month ago

This is an interesting discussion for sure! So I completely agree that for short lived components, this is a good rule to have. For longer running ones, many of the people we discussed this with initially actually really liked the possibility of the config hot reloading. It is difficult because there are shades here. There might be some top level config (or secrets) that you set once at the beginning of the process (like TLS certs or the like), but something like an upstream URL or redirect would be totally fine/easy to pull from config and use that instead in a dynamically updated way. For context, wasmCloud implemented it to be dynamically updated, but we can change that depending on consensus

Curious what @devigned has to say here as well

badeend commented 1 month ago

many of the people we discussed this with initially actually really liked the possibility of the config hot reloading

For extra context, are you able to share some of these use-cases?

badeend commented 1 month ago

Aside: For proper hot reloading support, wouldn't there also need to be some kind of mechanism to get notified of config changes?

Maybe, an interface like this would be more fitting to explicitly model the "changes over time" aspect?

interface store {
  type config-map = list<tuple<string, string>>;

  initial: func() -> config-map; // The config values at startup. Never changes. Effectively a "value import" which the component-model doesn't support (yet).
  current: func() -> stream<config-map>; // Get a stream that is automatically updated with the latest config values.
}