Move query matching before publication (#17121)
- new channel EVENT_STREAM_CHANNEL based on event stream id - on event, perform the matching and publish only to the right streams - store a list of active streams per workspace - store the user id along with the queries for each stream Bonus: - remove onSubscriptionMatch
This commit is contained in:
@@ -22,6 +22,14 @@ export type AuthContext = {
|
||||
};
|
||||
};
|
||||
|
||||
export type SerializableAuthContext = {
|
||||
userId?: string;
|
||||
userWorkspaceId?: string;
|
||||
workspaceMemberId?: string;
|
||||
apiKeyId?: string;
|
||||
applicationId?: string;
|
||||
};
|
||||
|
||||
export enum JwtTokenTypeEnum {
|
||||
ACCESS = 'ACCESS',
|
||||
REFRESH = 'REFRESH',
|
||||
|
||||
+34
@@ -106,6 +106,32 @@ export class CacheStorageService {
|
||||
});
|
||||
}
|
||||
|
||||
async setRemove(key: string, values: string[]): Promise<number> {
|
||||
if (values.length === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (this.isRedisCache()) {
|
||||
return (this.cache as RedisCache).store.client.sRem(
|
||||
this.getKey(key),
|
||||
values,
|
||||
);
|
||||
}
|
||||
|
||||
const existing = await this.get<string[]>(key);
|
||||
|
||||
if (!existing) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const filtered = existing.filter((v) => !values.includes(v));
|
||||
const removed = existing.length - filtered.length;
|
||||
|
||||
await this.set(key, filtered);
|
||||
|
||||
return removed;
|
||||
}
|
||||
|
||||
async countAllSetMembers(cacheKeys: string[]) {
|
||||
return (
|
||||
await Promise.all(cacheKeys.map((key) => this.getSetLength(key) || 0))
|
||||
@@ -143,6 +169,14 @@ export class CacheStorageService {
|
||||
});
|
||||
}
|
||||
|
||||
async setMembers(key: string): Promise<string[]> {
|
||||
if (this.isRedisCache()) {
|
||||
return (this.cache as RedisCache).store.client.sMembers(this.getKey(key));
|
||||
}
|
||||
|
||||
return (await this.get<string[]>(key)) ?? [];
|
||||
}
|
||||
|
||||
async flush() {
|
||||
return this.cache.reset();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user