99 "github.com/src-d/lookout"
1010 "github.com/src-d/lookout/service/bblfsh"
1111 "github.com/src-d/lookout/service/git"
12+ "github.com/src-d/lookout/util/flags"
13+ "github.com/src-d/lookout/util/grpchelper"
1214 "google.golang.org/grpc"
1315
1416 gogit "gopkg.in/src-d/go-git.v4"
@@ -17,6 +19,7 @@ import (
1719)
1820
1921type EventCommand struct {
22+ flags.CommonOptions
2023 DataServer string `long:"data-server" default:"ipv4://localhost:10301" env:"LOOKOUT_DATA_SERVER" description:"gRPC URL to bind the data server to"`
2124 Bblfshd string `long:"bblfshd" default:"ipv4://localhost:9432" env:"LOOKOUT_BBLFSHD" description:"gRPC URL of the Bblfshd server"`
2225 GitDir string `long:"git-dir" default:"." env:"GIT_DIR" description:"path to the .git directory to analyze"`
@@ -84,13 +87,13 @@ func (c *EventCommand) makeDataServerHandler() (*lookout.DataServerHandler, erro
8487 loader := git .NewStorerCommitLoader (c .repo .Storer )
8588 dataService = git .NewService (loader )
8689
87- c .Bblfshd , err = lookout .ToGoGrpcAddress (c .Bblfshd )
90+ c .Bblfshd , err = grpchelper .ToGoGrpcAddress (c .Bblfshd )
8891 if err != nil {
8992 return nil , err
9093 }
9194 timeoutCtx , cancel := context .WithTimeout (context .Background (), time .Second )
9295 defer cancel ()
93- bblfshConn , err := grpc .DialContext (timeoutCtx , c .Bblfshd , grpc .WithInsecure (), grpc .WithBlock ())
96+ bblfshConn , err := grpchelper .DialContext (timeoutCtx , c .Bblfshd , grpc .WithInsecure (), grpc .WithBlock ())
9497 if err != nil {
9598 log .Warningf ("bblfsh service is unavailable. No UAST will be provided to analyzer. Error: %s" , err )
9699 } else {
@@ -110,10 +113,10 @@ func (c *EventCommand) bindDataServer(srv *lookout.DataServerHandler, serveResul
110113 setGrpcLogger ()
111114 }
112115
113- grpcSrv := grpc .NewServer ()
116+ grpcSrv := grpchelper .NewServer ()
114117 lookout .RegisterDataServer (grpcSrv , srv )
115118
116- lis , err := lookout .Listen (c .DataServer )
119+ lis , err := grpchelper .Listen (c .DataServer )
117120 if err != nil {
118121 return nil , err
119122 }
@@ -126,19 +129,18 @@ func (c *EventCommand) bindDataServer(srv *lookout.DataServerHandler, serveResul
126129func (c * EventCommand ) analyzerClient () (lookout.AnalyzerClient , error ) {
127130 var err error
128131
129- c .Args .Analyzer , err = lookout .ToGoGrpcAddress (c .Args .Analyzer )
132+ c .Args .Analyzer , err = grpchelper .ToGoGrpcAddress (c .Args .Analyzer )
130133 if err != nil {
131134 return nil , err
132135 }
133136
134137 timeoutCtx , cancel := context .WithTimeout (context .Background (), time .Second )
135138 defer cancel ()
136- conn , err := grpc .DialContext (
139+ conn , err := grpchelper .DialContext (
137140 timeoutCtx ,
138141 c .Args .Analyzer ,
139142 grpc .WithInsecure (),
140143 grpc .WithBlock (),
141- grpc .WithDefaultCallOptions (grpc .MaxCallRecvMsgSize (maxMsgSize )),
142144 )
143145 if err != nil {
144146 return nil , err
0 commit comments