Eric Burel
Eric Burel

Reputation: 4944

Streaming with ZeroRPC

As you may know, ZeroRPC documentation is sparse. I can't get Streaming between a Python server and a Node client to work.

Here is the Python method:

@zerorpc.stream
def PublishWhaterver(self, some_args):
    yield "love"
    yield "stack"
    yield "overflow"

Here is the Node call:

export const tryStream = () => {
      connectedZerorpcClient.invoke('PublishWhatever', (error, res, more) => {
      console.log('STREAM', res, more);
  });
};

This code will log "STREAM love", and then do nothing.

So here are my questions:

What I am trying to implement is a Pub/Sub system but right now implementation seems to only exists for a Python server and a Python client, there are no Node example.

The example on the main page and tests are not relevant either, it shows how to stream an array that already exists when the invoke method is called.Here the messages are generated during some heavy computations, I want the server to be able to tell the client "here, some data are ready" and never disconnect.

Upvotes: 4

Views: 956

Answers (1)

user3666197
user3666197

Reputation: 1

Well, ZeroRPC actively promotes, that it is using its own python implementation code as a self-documentation how things work. In other words, no one has spent such additional efforts needed so as to publish a user-focused, the less a learning-process focused documentation.

Anyway, try to obey the few "visible" statements from the ZeroRPC description.

@zerorpc.stream
def PublishWhaterver(self, some_args):
    yield ( "love", "stack", "overflow", ) # one, tuple-wrapped result-container

Upvotes: 3

Related Questions