apache / apache/pulsar-client-node

Support for Avro schema on `createProducer`

Abierto
#61 1 comentario 9 reacciones 0 asignados Ver en GitHub
triage/week-3 type/feature
Lenguaje dominante
C++
Estrellas
164
Forks
98
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

Would it be possible to add a `schema` property on the config object that initializes `createProducer`? Similar to what Python does, we could initialize [avro-js](https://www.npmjs.com/package/avro-js) with the JSON schema and call `type.getSchema()` to initialize the producer.

Having to disable schema validation on topics isn't ideal for some cases and I think only Java and Python are the clients that have schema support.

A pseudo code would look like:

```js
const client = new Pulsar.Client({
serviceUrl: 'pulsar://localhost:6650',
});

const type = avro.parse({
name: 'Pet',
type: 'record',
fields: [
{name: 'kind', type: {name: 'Kind', type: 'enum', symbols: ['CAT', 'DOG']}},
{name: 'name', type: 'string'}
]
});

const producer = await client.createProducer({
topic: 'persistent://public/default/my-topic',
schema: type.getSchema(),
});
```

I'm not sure if the schema validation happens on the client when creating the producer, even if that is the case `avro-js` has methods to check whether JS objects are valid for a given schema.

On that same line, alternatively, is there any guidelines on how to implement a client? What makes it more difficult for me is that I don't know c++ and I would like to contribute with the JS library (specially Typescript).

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

Comienza en el punto de entrada createProducer del cliente Node y revisa cómo se pasa su configuración a la creación del producer. El issue propone avro-js y type.getSchema(); determina cómo debería una propiedad schema inicializar el producer y cómo debería comportarse la validación del schema, y después verifica la ruta del producer Avro con respecto al comportamiento existente del cliente.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript, node.js, typescript
Área
backend, distributed-systems
Tipo de issue
Nueva funcionalidad
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
38/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.