@1mill/kafka 中文文档教程

发布于 3年前 浏览 21 项目主页 更新于 3年前

@1mill/kafka

npm install @1mill/kafka
const { Kafka } = require('@1mill/kafka')

const kafka = new Kafka({
  brokers: 'https://rapids-1:9092,https://rapids-2:9092/' || process.env.1MILL_KAFKA_KAFKAJS_BROKERS,
  id: 'my-kafka-client-id' || process.env.1MILL_KAFKA_KAFKAJS_ID,
  mechanism: 'scram-sha-256' || process.env.1MILL_KAFKA_KAFKAJS_MECHANISM,
  password: 'my-password' || process.env.1MILL_KAFKA_KAFKAJS_PASSWORD,
  username: 'my-username' || process.env.1MILL_KAFKA_KAFKAJS_USERNAME,
})
RequiredTypeDefaultNotes
brokersyes[String, Array]process.env.1MILLKAFKAKAFKAJS_BROKERS'https://my-broker-1:9092/,https://my-broker-2:9092/' OR ['https://my-broker-1:9092/', 'https://my-broker-2:9092/']
idyesStringprocess.env.1MILLKAFKAKAFKAJS_ID
mechanismStringprocess.env.1MILLKAFKAKAFKAJS_MECHANISMOptions: 'plain', 'scram-sha-256', or 'scram-sha-512'
passwordStringprocess.env.1MILLKAFKAKAFKAJS_PASSWORD
usernameStringprocess.env.1MILLKAFKAKAFKAJS_USERNAME
const { Cloudevent } = require('@1mill/cloudevents')
const { Kafka } = require('@1mill/kafka')

const cloudevent = new Cloudevent({ ... })
const kafka = new Kafka({ ... })

await kafka.emit({ cloudevent })

@1mill/kafka

npm install @1mill/kafka
const { Kafka } = require('@1mill/kafka')

const kafka = new Kafka({
  brokers: 'https://rapids-1:9092,https://rapids-2:9092/' || process.env.1MILL_KAFKA_KAFKAJS_BROKERS,
  id: 'my-kafka-client-id' || process.env.1MILL_KAFKA_KAFKAJS_ID,
  mechanism: 'scram-sha-256' || process.env.1MILL_KAFKA_KAFKAJS_MECHANISM,
  password: 'my-password' || process.env.1MILL_KAFKA_KAFKAJS_PASSWORD,
  username: 'my-username' || process.env.1MILL_KAFKA_KAFKAJS_USERNAME,
})
RequiredTypeDefaultNotes
brokersyes[String, Array]process.env.1MILLKAFKAKAFKAJS_BROKERS'https://my-broker-1:9092/,https://my-broker-2:9092/' OR ['https://my-broker-1:9092/', 'https://my-broker-2:9092/']
idyesStringprocess.env.1MILLKAFKAKAFKAJS_ID
mechanismStringprocess.env.1MILLKAFKAKAFKAJS_MECHANISMOptions: 'plain', 'scram-sha-256', or 'scram-sha-512'
passwordStringprocess.env.1MILLKAFKAKAFKAJS_PASSWORD
usernameStringprocess.env.1MILLKAFKAKAFKAJS_USERNAME
const { Cloudevent } = require('@1mill/cloudevents')
const { Kafka } = require('@1mill/kafka')

const cloudevent = new Cloudevent({ ... })
const kafka = new Kafka({ ... })

await kafka.emit({ cloudevent })
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文