1.2.0 • Published 1 year ago

schema-safe-kafkajs v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Schema Safe Kafka Producer

This is a simple Kafka producer that uses the Schema Registry to ensure that the data being sent to Kafka is compatible with the schema that is registered for the topic.

Usage

import {KafkaClient, Partitioners} from "schema-safe-kafka";

const client = new KafkaClient({
	cluster: {
		clientId: "CLIENT_ID",
		brokers: ["BOOTSTRAP_SERVER"],
		ssl: true,
		sasl: {
			mechanism: "plain",
			username: "API_KEY",
			password: "API_SECRET"
		}
	},
	schemaRegistry: {
		host: "SCHEMA_REGISTRY_URL",
		auth: {
			username: "SCHEMA_REGISTRY_API_KEY",
			password: "SCHEMA_REGISTRY_API_SECRET"
		}
	}
})

const producer = client.producer({
	createPartitioner: Partitioners.LegacyPartitioner,
	allowAutoTopicCreation: false,
	idempotent: true,
})

async function run() {
	await producer.connect()
	await client.publish(producer, {
		topic: "topic-name",
		messages: [{
			key: "key",
			value: {
				"foo": "bar",
				"baz": 1
			},
			headers: {
				"meta": "data"
			},
			schemaId: 1
		}]
	})

	await producer.disconnect()

}

run().catch(console.error)

Deploying new Version

npm version patch
git push
gh release create
1.2.0

1 year ago

1.1.0

1 year ago

1.0.1

1 year ago

0.0.25

1 year ago

0.1.0

1 year ago

0.0.26

1 year ago

0.0.27

1 year ago

0.0.24

1 year ago

0.0.20

1 year ago

0.0.21

1 year ago

0.0.22

1 year ago

0.0.23

1 year ago

0.0.19

1 year ago

0.0.12

1 year ago

0.0.13

1 year ago

0.0.14

1 year ago

0.0.15

1 year ago

0.0.16

1 year ago

0.0.17

1 year ago

0.0.18

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago

1.0.0

1 year ago