1.2.6 • Published 7 years ago

egg-kafka v1.2.6

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

eggjs kafka插件

NPM version build status Test coverage David deps Known Vulnerabilities npm download

  • 待完善

Install

npm install egg-kafka --save
  • config/config.{env}.js:
module.exports = appInfo => {
  config.kafka = {
    client: {
      host: 'localhost', // host
      port: '3306', // 端口号
    },
    app: true, // 是否加载到 app 上,默认开启
    agent: true, // 是否加载到 agent 上,默认关闭
  };
  return config;
}

API

Producer

example:

'use strict'

module.exports = function * () {
    //producer() optionl arguments true/false it`s aysnc/sync to create topics in kafka-node
  let createTopicsResult = yield this.app.kafka.producer().createTopicsAsync(['topic5'], true)
  // send create topics request to the kafka server , but there not anything response,why ?
  let sendResult = yield this.app.kafka.producer().sendAsync([{ topic: 'topic5', messages: 'test' + new Date().getSeconds(), partition: 0 }])
}

HighLevelProducer same as Producer

example:

'use strict'

module.exports = function * () {
    //producer() optionl arguments true/false it`s aysnc/sync to create topics in kafka-node
  let createTopicsResult = yield this.app.kafka.highLevelProducer().createTopicsAsync(['topic5'], true)
  // send create topics request to the kafka server , but there not anything response,why ?
  let sendResult = yield this.app.kafka.highLevelProducer().sendAsync([{ topic: 'topic5', messages: 'test' + new Date().getSeconds(), partition: 0 }])
}

-------------- 待完善 ----------------

Comuser

HighLevelConsumer

ConsumerGroup

Offset

1.2.6

7 years ago

1.2.4

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago