ktr0731 / evans

Evans: more expressive universal gRPC client
MIT License
4.24k stars 187 forks source link

reflection: "show message" gives 0 lines #88

Closed neopaf closed 6 years ago

neopaf commented 6 years ago
$ go get github.com/chemidy/goheroe-code-examples/gRPC-Service-Discovery-With-Server-Reflection-in-go/cmd/server
$ /.../server 
starting server on port : :6666

connecting with reflection:

rualpe-ws:grpc-master paf$ evans --host localhost --port 6666 -r

  ______
 |  ____|
 | |__    __   __   __ _   _ __    ___
 |  __|   \ \ / /  / _. | | '_ \  / __|
 | |____   \ V /  | (_| | | | | | \__ \
 |______|   \_/    \__,_| |_| |_| |___/

 more expressive universal gRPC client

default@localhost:6666> service GoHeroe

default.GoHeroe@localhost:6666> show rpc
+------+-------------+--------------+
| RPC  | REQUESTTYPE | RESPONSETYPE |
+------+-------------+--------------+
| List | Filter      | SuperPowers  |
| Add  | SuperPower  | SuperPowers  |
+------+-------------+--------------+

default.GoHeroe@localhost:6666> show message
+---------+
| MESSAGE |
+---------+
+---------+

default.GoHeroe@localhost:6666> 

I expected to see possible messages:

proto here: https://github.com/chemidy/goheroe-code-examples/blob/master/gRPC-Service-Discovery-With-Server-Reflection-in-go/proto/goheroe.proto

neopaf commented 6 years ago

actual call works, though (which is COOL!):

default.GoHeroe@localhost:6666> call List
? Filter All
{
  "superPow": [
    {
      "name": "Flash power",
      "cat": "SciencePowers"
    },
    {
      "name": "Superman power",
      "cat": "CosmicBasedPowers"
    },
    {
      "name": "Spiderman power",
      "cat": "SupernaturalPowers"
    }
  ]
}
neopaf commented 6 years ago

Yet to know how invoke this from command line one does not know which json to send. Message type is "Filter" but what fields are there are not clear.

This works:

rualpe-ws:grpc-master paf$ echo '{"category": "SupernaturalPowers"}' | evans --host localhost --port 6666 -r --service GoHeroe --call List --cli
{
  "superPow": [
    {
      "name": "Spiderman power",
      "cat": "SupernaturalPowers"
    }
  ]
}
rualpe-ws:grpc-master paf$ 

But to known this "category" I had to dive into .proto file. Dream: to have it all in dear Evans.

neopaf commented 6 years ago

If this helps, using .proto file it works:

rualpe-ws:Downloads paf$ evans --host localhost --port 6666  goheroe.proto 

  ______
 |  ____|
 | |__    __   __   __ _   _ __    ___
 |  __|   \ \ / /  / _. | | '_ \  / __|
 | |____   \ V /  | (_| | | | | | \__ \
 |______|   \_/    \__,_| |_| |_| |___/

 more expressive universal gRPC client

localhost:6666> package superpower

superpower@localhost:6666> show message
+-------------+
|   MESSAGE   |
+-------------+
| SuperPower  |
| SuperPowers |
| Filter      |
+-------------+

superpower@localhost:6666> desc Filter
+----------+-----------+
|  FIELD   |   TYPE    |
+----------+-----------+
| category | TYPE_ENUM |
+----------+-----------+

superpower@localhost:6666> 

Noticed different package name...

Noticed that even this way one does not know possible enum values (this is not vital, I'm not planning to use ENUMs much).

neopaf commented 6 years ago

(enums can be played with in REPL mode, all possible values are auto-suggested)

ktr0731 commented 6 years ago

Thank you for pointed out an issue! I fixed it at #89. Can you update Evans to 0.6.1?

neopaf commented 6 years ago

bliss! thanks, Ktr ;)

==> Upgrading 1 outdated package, with result:
ktr0731/evans/evans 0.6.0 -> 0.6.1
==> Upgrading ktr0731/evans/evans 
==> Downloading https://github.com/ktr0731/evans/releases/download/0.6.1/evans_darwin_amd64.tar.gz
==> Downloading from https://github-production-release-asset-2e65be.s3.amazonaws.com/97361468/f5761c00-ab28-11e8-8c84-0c359c18cb32?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F201808
######################################################################## 100.0%
🍺  /usr/local/Cellar/evans/0.6.1: 3 files, 20.2MB, built in 13 seconds
rualpe-ws:Downloads paf$ evans --host localhost --port 6666 -r

  ______
 |  ____|
 | |__    __   __   __ _   _ __    ___
 |  __|   \ \ / /  / _. | | '_ \  / __|
 | |____   \ V /  | (_| | | | | | \__ \
 |______|   \_/    \__,_| |_| |_| |___/

 more expressive universal gRPC client

default@localhost:6666> show message
+-------------+
|   MESSAGE   |
+-------------+
| Filter      |
| SuperPowers |
| SuperPower  |
+-------------+

default@localhost:6666> desc Filter
+----------+-----------+
|  FIELD   |   TYPE    |
+----------+-----------+
| category | TYPE_ENUM |
+----------+-----------+