Effect API - Bye-Bye Experimental Prefix 🧪
Effect API, released on May 8, served us well, and we officially removed the experimental_ prefix from createEffect.
This change comes with two new features:
- The
rateLimitoption (required) which allows you to set explicitely how freaquently the effect might be called. Use eitherfalseto disable, or provide an object with custom calls per duration. Duration might besecond,minuteor a number in milliseconds. - Ability to overwrite
cacheoption for specific call. Setcontext.cache = falseto prevent caching the result which failed.
export const getMetadata = createEffect(
{
name: "getMetadata",
input: S.string,
output: S.optional(S.schema({
description: S.string,
value: S.bigint,
})),
// Protect your API from burst Effect calls
rateLimit: {
calls: 5,
per: "second"
},
cache: true,
},
async ({ input, context }) => {
try {
const response = await fetch(`https://api.example.com/metadata/${input}`);
const data = await response.json();
return {
description: data.description,
value: data.value,
};
} catch(_) {
// Don't cache failed response
context.cache = false
return undefined;
}
}
);Development Console Insights 📺
With this version, the Development Console now provides more performance metrics for Effect API execution, as well as loading entities from your handlers.
See a detailed time overview to identify what's slowing down your processing time. Use Batched metric to find what can be better optimized with Preload Optimization. And get useful insigts about your indexer execution in general. As a nice bonus, the Development Console now works even with TUI disabled.
Tip: Hover over question marks to get better understanding of the data.
Access Development Console at envio.dev/console
New getWhere.lt Query 🔎
Use context.<Entity>.getWhere.<FieldName>.lt to get all entities where the field value is lower than the given value.
Internal Improvements 🧹
- Librarify config and stop using global db client by @DZakh in #803
- Update Cursor rules by @DZakh in #806
- Librarify InMemoryTable code by @DZakh in #807
Full Changelog: v2.31.1...v2.32.0