Skip to content

Commit

Permalink
collect messages from services if reflection enabled (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktr0731 authored Aug 29, 2018
1 parent 5b6a5aa commit 6956d79
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions entity/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,23 @@ func NewEnv(pkgs []*Package, config *config.Config) *Env {
// NewEnvFromServices is called if the target server has enabled gRPC reflection.
// gRPC reflection has no packages, so Evans creates pseudo package "default".
func NewEnvFromServices(svcs []Service, config *config.Config) *Env {
mmsgs := map[string]Message{}
for _, svc := range svcs {
for _, rpc := range svc.RPCs() {
mmsgs[rpc.RequestMessage().Name()] = rpc.RequestMessage()
mmsgs[rpc.ResponseMessage().Name()] = rpc.ResponseMessage()
}
}
var msgs []Message
for _, msg := range mmsgs {
msgs = append(msgs, msg)
}

env := NewEnv([]*Package{
{
Name: "default",
Services: svcs,
Messages: msgs,
},
}, config)

Expand Down
2 changes: 1 addition & 1 deletion meta/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ import (
const AppName = "evans"

var (
Version = semver.MustParse("0.6.0")
Version = semver.MustParse("0.6.1")
)

0 comments on commit 6956d79

Please sign in to comment.