Repository navigation
Description
Problem
FOCA 0.18's plugin engine gives plugins no storage. Plugins that cache or count can only keep state per process, so with several workers or replicas:
- caches are not shared: each process repeats the same expensive or rate-limited lookups;
- counters can't be enforced across processes, e.g. a per-user or per-day budget for a third-party API.
Example: tes.routing.distance in elixir-cloud-aai/foca-plugins (PR #13). With its opt-in dbip provider it caches geolocations per process and can't cap lookups per user, so users who submit many tasks can use up DB-IP's free daily quota (500 requests); distance routing then stops applying until the quota resets. A shared cache and per-user counters would fix both.
Proposal
Give plugins a small, namespaced key-value store through the plugin context (e.g. ctx.store), backed by the app's MongoDB:
- one namespace per plugin distribution, so plugins can't read each other's data;
get,setwith an optional TTL (MongoDB TTL index),delete, and an atomicincrementwith TTL for counters and budgets;- size limits per entry and per namespace, configurable by the operator;
- an in-memory fallback when no database is configured (current behaviour), so plugins work without it.
Open questions: which collections and indexes FOCA creates; whether operators can turn storage off per plugin; how it shows up in the plugin listing (e.g. a capability or data_transfers-like field).
Done when
- the store is available to plugins, documented in the plugin guide, and tested (unit and integration, 100% coverage);
tes.routing.distancecan use it for its cache and a per-user lookup budget (follow-up in foca-plugins).
Activity