Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to input streaming messages in cli mode #78

Closed
frxstrem opened this issue Aug 2, 2018 · 4 comments
Closed

Not able to input streaming messages in cli mode #78

frxstrem opened this issue Aug 2, 2018 · 4 comments
Labels

Comments

@frxstrem
Copy link

frxstrem commented Aug 2, 2018

I'm trying to send a stream of messages in cli mode, but I can't find any information about how this is done. I tried the two most obvious ways (in my mind at least):

  • Sending objects as an array [{}], but evans complain about an unexpected character [. (failed to read input from JSON: Bad input. Expecting start of JSON object: '{'. Instead got: [.)
  • Sending objects as a JSON stream (one JSON object per line), e.g. the regular output from jq, but evans complains about unexpected EOF. (failed to read input from JSON: EOF)

Is this even possible, and if it is, could you point me in the right direction to get this to work? And possibly add some documentation somewhere about it?

@ktr0731
Copy link
Owner

ktr0731 commented Aug 2, 2018

Thanks for pointing to a problem related to streaming in CLI mode!

Right ways to send requests to streaming APIs are (JSON inputs, packages, services are pseudo):

  1. server-side streaming
$ echo '{ "name": "a request" }' | evans --package api --service ServerStreamingAPI
  1. client-side streaming (send two requests)
$ echo '{ "name": "request1" } { "name": "request2" }' | evans --package api --service ClientStreamingAPI
  1. bidi sreaming
$ echo '{ "name": "request1" } { "name": "request2" }' | evans --package api --service BidiStreamingAPI

You might think that inputs which are sent as client-side/bidi streaming API requests look strange.
In the implementation, Evans decodes input JSON text as a proto.Message sequentially. So users have to send JSON with the above format.

I'm planning to add more documentation to Evans repository. (#57)
But, I think it takes a little until I begin.

@frxstrem
Copy link
Author

@ktr0731 Would it be possible to also support newline as an object delimiter? That way evans would work nicely with tools such as jq.

@ktr0731
Copy link
Owner

ktr0731 commented Aug 23, 2018

Could you show me an example input?

@frxstrem
Copy link
Author

Oh nevermind it already seems to work after all, I must have done something wrong when I tried previously...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants