kafka-scheduler
v0.0.7
Published
Schedule Kafka messages on your descired topic
Downloads
1
Readme
Kafka Scheduler
Schedule Kafka messages on your desired topic.
- Time used for topic:
- Topic1: (startTime * coef^1),
- Topic2: (startTime *coef^2),
- Topicn: (startTime * coef^n) n=>step
- New Topics naming will be:
${prefix}_reschedule_${time}
- Default precision: 60 seconds
-- Initialize topics
await init(kafkaConfig: KafkaConfig, schedulerConfig: KafkaScheduleConfig)
-- Config
export interface KafkaScheduleConfig {
startTime?: number; // Starting time
step?: number; // Number of topics created
coef?: number; // Coeficient for time increasing
prefix?: string; // Topic name prefix
}
-- Schedule message
/**
* @param {KafkaMessage || Message} message A raw or new message
* @param {string} topic Message Topic
* @param {number} retryAfter Time in seconds
*/
await scheduleMessage(message: RescheduleMessage, topic: string, retryAfter: number) {