Skip to content

Commit

Permalink
fix: TECH review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
eugene-taran committed Jan 16, 2025
1 parent 2c6907c commit 8b6867d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
3 changes: 1 addition & 2 deletions packages/pubsub/src/MessageHandlerIdempotent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { ISubscriber } from './SubscriberFactory'
type GetIdempotencyKeyFunction<T> = (msg: T, info: IMessageInfo) => string | undefined

export abstract class IdempotencyStorage {

public abstract exists(key: string): Promise<boolean>

public abstract save(key: string): Promise<void>
Expand Down Expand Up @@ -60,7 +59,7 @@ export abstract class MessageHandlerIdempotent<T = unknown> {
if (idempotencyKey) {
const alreadyProcessed = await this.idempotencyStorage.exists(idempotencyKey)
.catch(e => {
this.subscriber.logger?.info(`Error checking idempotency key: ${idempotencyKey}`, e)
this.subscriber.logger?.info(`Error checking idempotency key existence: ${idempotencyKey}`, e)
return false
})
if (alreadyProcessed) {
Expand Down
7 changes: 2 additions & 5 deletions packages/pubsub/src/redis-types/IRedisClient.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* This file contains interfaces from https://github.com/join-com/caching ,
* for a less duplicated code when implementing idempotent handler on services.
* This file contains interfaces from https://github.com/join-com/caching, to be able to have RedisIdempotencyStorage
* in the lib, to duplicate less code, when implementing idempotent handler in the services.
*/

export interface IFailure<T> {
Expand All @@ -22,13 +22,10 @@ export type RedisResult<T, R> = ISuccess<T> | IFailure<R>
export type OptionalRedisResult<T, R> = ISuccess<T> | ISuccess<undefined> | IFailure<R>

export interface IRedisError {

error: Error
}


export interface IRedisClient {

get(key: string): Promise<OptionalRedisResult<Buffer, IRedisError>>

setex(key: string, secondsTtl: number, value: Buffer): Promise<RedisResult<void, IRedisError>>
Expand Down

0 comments on commit 8b6867d

Please sign in to comment.