UNPKG

@hotmeshio/hotmesh

Version:

Serverless Workflow

68 lines (67 loc) 3.67 kB
/** * The Cache is a key/value store and used to store commonly accessed Redis metadata * (mainly the execution rules for the app) to save time accessing them as they * are immutable per verison. Rules are only ejected when a new version * (a new distributed executable) is deployed to the quorum * and the cache is invalidated/cleared of the prior version. */ import { ActivityType } from '../../types/activity'; import { HookRule } from '../../types/hook'; import { HotMeshApp, HotMeshSettings } from '../../types/hotmesh'; import { Symbols } from '../../types/serializer'; import { Transitions } from '../../types/transition'; declare class Cache { settings: HotMeshSettings; appId: string; apps: Record<string, HotMeshApp>; schemas: Record<string, ActivityType>; subscriptions: Record<string, Record<string, string>>; symbols: Record<string, Symbols>; symvals: Record<string, Symbols>; transitions: Record<string, Record<string, unknown>>; hookRules: Record<string, Record<string, HookRule[]>>; workItems: Record<string, string>; /** * The cache is ALWAYS initialized with HotMeshSettings. The other parameters are optional. * @param settings * @param apps * @param schemas * @param subscriptions * @param transitions * @param hookRules */ constructor(appId: string, settings: HotMeshSettings, apps?: Record<string, HotMeshApp>, schemas?: Record<string, ActivityType>, subscriptions?: Record<string, Record<string, string>>, symbols?: Record<string, Symbols>, symvals?: Record<string, Symbols>, transitions?: Record<string, Record<string, unknown>>, hookRules?: Record<string, Record<string, HookRule[]>>, workItems?: Record<string, string>); /** * invalidate the cache; settings are not invalidated! */ invalidate(): void; getSettings(): HotMeshSettings; setSettings(settings: HotMeshSettings): void; getApps(): Record<string, HotMeshApp>; getApp(appId: string): HotMeshApp; setApps(apps: Record<string, HotMeshApp>): void; setApp(appId: string, app: HotMeshApp): void; getSchemas(appId: string, version: string): Record<string, ActivityType>; getSchema(appId: string, version: string, activityId: string): ActivityType; setSchemas(appId: string, version: string, schemas: Record<string, ActivityType>): void; setSchema(appId: string, version: string, activityId: string, schema: ActivityType): void; getSubscriptions(appId: string, version: string): Record<string, string>; getSubscription(appId: string, version: string, topic: string): unknown; setSubscriptions(appId: string, version: string, subscriptions: Record<string, string>): void; getSymbols(appId: string, targetEntityId: string): Symbols; setSymbols(appId: string, targetEntityId: string, symbols: Symbols): void; deleteSymbols(appId: string, targetEntityId: string): void; getSymbolValues(appId: string): Symbols; setSymbolValues(appId: string, symvals: Symbols): void; deleteSymbolValues(appId: string): void; getTransitions(appId: string, version: string): Transitions; setTransitions(appId: string, version: string, transitions: Transitions): void; getHookRules(appId: string): Record<string, HookRule[]>; setHookRules(appId: string, hookRules: Record<string, HookRule[]>): void; getSignals(appId: string, version: string): Record<string, unknown>; setSignals(appId: string, version: string): Record<string, unknown>; getActiveTaskQueue(appId: string): string; setWorkItem(appId: string, workItem: string): void; removeWorkItem(appId: string): void; } export { Cache };