yapapi. If this is your first time using Golem and yapapi, please first refer to the resources linked above.
yapapi. It instantiates the runtime on a Provider and periodically fetches the current state of usage counters to demonstrate fetching of custom usage counter updates.
metric_reporter()function which periodically increments a value of a counter named
golem.usage.custom.counter, then notifies the runtime about this new value via an
RuntimeCounterstruct is used to pass the value of a counter using
counter()method. The RuntimeCounter instance will be propagated by the ExeUnit to the Provider agent (for the purposes of pricing and invoicing) and to Requestor side where it can be fetched by the Requestor agent's code.
ExampleRuntime, which is fairly simple, as it includes some non-void implementations of
start()action launches a local thread running the
EventEmitterinstance cloned from runtime's
run_command()implements two explicitly named commands which can be triggered by calling a RUN <command> ExeScript call. The commands are:
sleep n- forces the runtime to wait
stop- causes the runtime shutdown.
ya-test-runtime-counters.jsonconfig file, which includes metadata for the runtime, required to plug it into a yagna provider service, under the name
config.countersstructure is used to specify the custom usage counter metadata.
ya-test-runtime-counters.jsonwhere you describe the plugin:
runtime-pathin above file) where
ya-test-runtime-countersbinary along with Erigon binaries are placed.
$HOME/.local/share/ya-provider/presets.json. Preset object can be copied from other presets. Please note that
exeunit-namehas to match to the
nameproperty of the plugin above:
golem.usage.custom.counteris to be included in the pricing function (linear model) with a coefficient of 0.0003 GLM.
test-countersruntime as payload:
run()handler, it periodically fetches the usage vector as published by the ExeUnit alongside the accumulated cost and displays it in console:
golem.usage.custom.countercounter being periodically incremented.