0.0.8 • Published 4 months ago

@tsailab/ioredis-mq v0.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

Description

In the world of distributed systems, ensuring that a message is processed exactly once can be a significant challenge.

The @tsailab/ioredis-mq make sure exactly-once message processing using Redis Pub/Sub with distributed locks in a NestJS application, running on Kubernetes, and deployed using Helm. This solution ensures that multiple instances of a service receive the same message, but only one instance processes it, avoiding duplicate processing.

ioredis-mq architecture

Installation

$ npm install -g @tsailab/ioredis-mq

Usage

IORedisMQModule providers : RedisService ,RedisMQService and yamlConfigLoader

  • RedisService: a ioredis client wrapper
  • RedisMQService: a ioredis pub/sub client wrapper
  • yamlConfigLoader : a environment yaml configuration files loader tool

Configuration forRoot

@Module(
  imports:[
    IORedisMqModule.forRoot({
      type: 'single',// single
      redisOptions: {
        host: '172.20.0.1',
        port: 6379,
        db: 0,
        password: 'RDS123',
      },
    }),
    ... // others
  ]
)
export class ProducerAppModule{}

Configuration forRoot

import {
  IORedisModuleAsyncOptions,
  IORedisMQModule,
  yamlConfigLoader,
} from '@tsailab/ioredis-mq'
@Module({
  imports: [
    ConfigModule.forRoot({
      isGlobal: true,
      load: [yamlConfigLoader],
    }),
    IORedisMQModule.forRootAsync(
      {
        useFactory(config: ConfigService) {
          // load form your app environments .conf/<stage>/*.yaml files
          // stage: dev,prod,test,stage 
          const cfg = config.get('ioredis');
          return cfg 
        },
        inject: [ConfigService],
      } as IORedisModuleAsyncOptions,
      true,
    ),
  ],
})

:boom: :boom: :boom: :star2: :star2: :two_hearts: :two_hearts: :two_hearts:

:star: :star: :star: :star: :star: :star: :star: :star:

Learn more usages in the source ioredis-mq docs


Stay in touch

:revolving_hearts::revolving_hearts::revolving_hearts: :raising_hand: :raising_hand: :raising_hand: :raising_hand: :raising_hand: :raising_hand: :raising_hand: :raising_hand: :raising_hand: :raising_hand: :raising_hand: :raising_hand::raising_hand::raising_hand::revolving_hearts::revolving_hearts::revolving_hearts:

Sincerely invite experts to improve the project functions together !

:revolving_hearts::revolving_hearts::revolving_hearts: :raising_hand: :raising_hand: :raising_hand: :raising_hand: :raising_hand: :raising_hand: :raising_hand: :raising_hand: :raising_hand: :raising_hand: :raising_hand: :raising_hand::raising_hand::raising_hand::revolving_hearts: :revolving_hearts::revolving_hearts:

License

The @Tsailab/ioredis-mq packages is MIT licensed.

Give me a cup of coffee? Thanks much.

Wechat QRCode

Etherum

0.0.8

4 months ago

0.0.7

5 months ago

0.0.5

6 months ago

0.0.3

7 months ago

0.0.4

7 months ago

0.0.2

7 months ago

0.0.1

7 months ago