infinyon / fluvio-client-node

Node.js client for Fluvio
https://infinyon.github.io/fluvio-client-node/
Apache License 2.0
9 stars 10 forks source link

[Bug]: Create topic from node, gets 1 replica & 3 partitions, creating from CLI gets 1 replica & 1 partition #37

Closed ajhunyady closed 2 years ago

ajhunyady commented 3 years ago

1) Create a topic from CLI

$ fluvio topic create topic-from-cli
topic "topic-from-cli" created
$ fluvio topic list
 NAME            TYPE      PARTITIONS  REPLICAS  IGNORE-RACK  STATUS                   REASON 
 topic-from-cli  computed      1          1                   resolution::provisioned   

2) Setup Node Environment

$ mkdir custom-chat && cd custom-chat && npm init -y && \
npm install typescript ts-node @types/node -D && \
npm install @fluvio/client -S

3) create producer.ts with the following content

import Fluvio, { TopicReplicaParam } from "@fluvio/client";

// Create Fluvio Client Instance
const fluvio = new Fluvio();

// Handle Fluvio errors
process.on('unhandledRejection', error => {
    console.log(error);
});

(async () => {
    // Connect the fluvio cluster;
    await fluvio.connect();

    // Connect to admin interface
    const admin = await fluvio.admin();
    const topic = await admin.findTopic("topic-from-node");

    if (topic == null) {
       await admin.createTopic("topic-from-node");
    }

})();

5) Check the topics at the CLI:

$ fluvio topic list
 NAME             TYPE      PARTITIONS  REPLICAS  IGNORE-RACK  STATUS                              REASON 
 topic-from-cli   computed      1          1                        resolution::provisioned         
 topic-from-node  computed      1          3                   resolution::insufficient-resources  need 2 more SPU 

Topic from node has 3 replicas, whereas topic from cli has only 1.

There are 2 issues here

ajhunyady commented 2 years ago

Fixed.