Built-in Stamps
This page lists all the built-in Stamps that Missive.js provides. Stamps are a way to handle cross-cutting concerns in your application. They are key to keeping your code clean and maintainable. Most of all, they are easy to write and use, and they can be generic!
Added by the Bus
Section titled “Added by the Bus”IdentityStamp
Section titled “IdentityStamp”type AsyncStamp = Stamp<undefined, 'missive:async'>;Added on bus.dispatch(intent|envelope).
HandledStamp
Section titled “HandledStamp”type HandledStamp<R> = Stamp<R, 'missive:handled'>;Added when the intent is handled by the handler.
ReprocessedStamp
Section titled “ReprocessedStamp”type ReprocessedStamp = Stamp<{ stamps: Stamp[] }, 'missive:reprocessed'>;Added when an envelope is dispatched through the bus instead of an intent.
The bus will save the original
stampsin theReprocessedStampstamp.
This happens with 2 built-in middlewares:
- Using the Async middleware in a consumer, you will get a
ReprocessedStampbecause you should dispatch theenvelopeinstead of theintent. - Using the Cacher middleware you will get a
ReprocessedStampbecause the middleware will redispatch theenvelopeto thequeryBusfor Stale While Revalidating purposes.
Added by the Middlewares
Section titled “Added by the Middlewares”AsyncStamp
Section titled “AsyncStamp”type AsyncStamp = Stamp<undefined, 'missive:async'>;Added when the envelope is sent to a queue via the Async middleware.
FromCacheStamp
Section titled “FromCacheStamp”type FromCacheStamp = Stamp<{ age: number; stale: boolean }, 'missive:cache:hit'>;Added when the Cacher middleware finds the result in the cache.
CacheableStamp
Section titled “CacheableStamp”export type CacheableStamp = Stamp<{ ttl?: number; staleTtl?: number }, 'missive:cacheable'>;That you can add in your handler to have cache on demand. See Cacher middleware.
FeatureFlagFallbackStamp
Section titled “FeatureFlagFallbackStamp”type FeatureFlagFallbackStamp = Stamp<undefined, 'missive:feature-flag-fallback'>;When the Feature Flag Middleware uses a fallbackHandler.
TimingsStamp
Section titled “TimingsStamp”type TimingsStamp = Stamp<{ total: number }, 'missive:timings'>Add by the Logger middleware when the message is handled or errored with the total time elapsed in nanoseconds.
RetriedStamp
Section titled “RetriedStamp”type RetriedStamp = Stamp<{ attempt: number; errorMessage: string }, 'missive:retried'>;Added by the Retryer middleware when the middleware retries the handling of the intent.
WebhookCalledStamp
Section titled “WebhookCalledStamp”type WebhookCalledStamp = Stamp<{ attempt: number; text?: string, status?: number }, 'missive:webhook-called'>;Add by the Webhook middleware when the middleware succeed to call the webhook(s) or ultimately at the end of the retries.
Missive.js. MIT License.
Powered by Astro Starlight.
Inspired by Symfony Messenger