@tsailab/ioredis-mq
v0.0.4
Published
Implementing simple pub/sub based on redis.
Downloads
257
Maintainers
Readme
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.
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
- Twitter - @lamborghini171
: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.