ApeWorX / silverback

Blockchain automation library, and SDK for the (upcoming) Silverback Platform
https://www.apeworx.io/silverback
Apache License 2.0
79 stars 9 forks source link

Managed Parameters #58

Open fubuloubu opened 5 months ago

fubuloubu commented 5 months ago

Overview

When designing a Silverback app, it is typically very useful to design parameterization into the logic of the app so that you can adjust this behavior. We should have a deeper integration for updating and managing these parameters, both when running live or when starting/restarting the app in a cloud environment.

Specification

We need some way for a user to describe a parameter, and add a method for it to get added to state, so that all worker tasks can see the parameter update:

@app.parameter("something", int, lower_limit=200)  # or `upper_limit=`, defaults to None
def handle_parameter(value, state):
    # NOTE: Raises if not using the same parameter name above
    state.something = value  # or, could generate a more complex handler
    # no return, but task handle will automatically return the update 

# OR, more simply:

app.add_parameter("something", int, lower_limit=...)
# basically the same as above, no ability to handle it specially

After this is done, the parameter becomes a part of both the App's environment variables (e.g. SILVERBACK_APP_something=...) as well as accepts updates triggered by the platform or management dashboard for the app (see #39)

Lastly, when accepting parameter updates, it should be possible to accept a batch of updates and process them at the same time, scheduling the tasks to take effect all before any other tasks are allowed to proceed using the new variables (all updates are atomic when batched)

Dependencies

No dependencies

linear[bot] commented 5 months ago

SBK-426 Managed Parameters