# @blued-core/kafka-client

> 基于 kafka-node 的一层封装。

Latest version **2.0.1** (published 2022-07-07) · ISC license · 0 weekly downloads

## Install

```sh
npm install @blued-core/kafka-client
pnpm add @blued-core/kafka-client
yarn add @blued-core/kafka-client
bun add @blued-core/kafka-client
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2022-07-07 |
| First published | 2019-04-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 10 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | jiasm, ryli, nieweidong, fengcang2020 |

## Links

- npm: https://www.npmjs.com/package/@blued-core/kafka-client
- npm.io page: https://npm.io/package/@blued-core/kafka-client

## Dependencies (2)

- [kafka-node](https://npm.io/package/kafka-node.md) ^5.0.0
- [@blued-core/client](https://npm.io/package/@blued-core/client.md) ^0.0.15

## Recent versions

- 2.0.1 (latest) — 2022-07-07
- 1.0.1 (next) — 2020-02-20
- 2.0.0 — 2022-03-09
- 1.0.2 — 2020-07-02
- 1.0.0 — 2020-02-12
- 0.1.2 — 2019-07-04
- 0.1.1 — 2019-07-04
- 0.1.0 — 2019-06-20
- 0.0.10 — 2019-04-25
- 0.0.9 — 2019-04-25
- 0.0.8 — 2019-04-25
- 0.0.7 — 2019-04-25
- 0.0.6 — 2019-04-25
- 0.0.5 — 2019-04-24
- 0.0.4 — 2019-04-23
- … 3 more at https://npm.io/package/@blued-core/kafka-client/versions

## README

基于 kafka-node 的一层封装。

```bash
npm i @blued-core/kafka-client
```

> cache 与 qconf-conf 组件都为可选的，可以自己根据描述自定义

使用方式：

```typescript
import KafkaClient from '@blued-core/kafka-client'
import { QconfConf } from '@blued-core/qconf-conf'
import Cache from '@blued-core/cache'

async function main () {
  const qconfConf = new QconfConf({
    path: 'XXXX'
  })

  const kafkaClient = new KafkaClient(qconfConf, new Cache())

  const bootstrapKafka = kafkaClient.getClient('path')

  bootstrapKafka.send('topics', 'Hello World')
}

main()
```

### API

#### send

参数|类型|是否必填|描述
:--|:--|:--|:--
topic|`string`|✅|消息对应的 topic
message|`string`|✅|消息体
options|`Object`|❌|发送消息时的部分参数

##### options 结构描述

参数|类型|描述
:--|:--|:--
key|`string`|__only needed when using keyed partitioner__
partition|`number`|写入的分区
attributes|`number`|

---
_Source: https://npm.io/package/@blued-core/kafka-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
