Skip to content

Commit d9f55b4

Browse files
facchinmcmaglie
authored andcommitted
Remove watcher, add endpoint to explicitely drop cache
1 parent ae6b635 commit d9f55b4

File tree

3 files changed

+104
-32
lines changed

3 files changed

+104
-32
lines changed

Diff for: grpc/proto/builder.pb.go

+80-27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: grpc/proto/builder.proto

+6
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ service Builder {
3434
rpc Build(BuildParams) returns (stream Response) {}
3535

3636
rpc Autocomplete(BuildParams) returns (Response) {}
37+
38+
rpc DropCache(VerboseParams) returns (Response) {}
3739
}
3840

3941
message BuildParams {
@@ -52,6 +54,10 @@ message BuildParams {
5254
bool verbose = 13;
5355
}
5456

57+
message VerboseParams {
58+
bool verbose = 1;
59+
}
60+
5561
message Response {
5662
string line = 1;
5763
}

Diff for: grpc/rpc.go

+18-5
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ func (s *builderServer) watch() {
7171
}
7272
}
7373

74+
func (s *builderServer) DropCache(ctx context.Context, args *pb.VerboseParams) (*pb.Response, error) {
75+
s.ctx.CanUseCachedTools = false
76+
response := pb.Response{Line: "Tools cache dropped"}
77+
return &response, nil
78+
}
79+
7480
// GetFeature returns the feature at the given point.
7581
func (s *builderServer) Autocomplete(ctx context.Context, args *pb.BuildParams) (*pb.Response, error) {
7682

@@ -97,7 +103,8 @@ func (s *builderServer) Autocomplete(ctx context.Context, args *pb.BuildParams)
97103

98104
s.ctx.ImportedLibraries = s.ctx.ImportedLibraries[0:0]
99105

100-
s.watch()
106+
//s.watch()
107+
101108
oldlogger := s.ctx.GetLogger()
102109
logger := i18n.NoopLogger{}
103110
s.ctx.SetLogger(logger)
@@ -140,7 +147,7 @@ func (s *builderServer) Build(args *pb.BuildParams, stream pb.Builder_BuildServe
140147
logger := StreamLogger{stream}
141148
s.ctx.SetLogger(logger)
142149

143-
s.watch()
150+
//s.watch()
144151

145152
err := builder.RunBuilder(s.ctx)
146153
s.ctx.SetLogger(oldlogger)
@@ -190,22 +197,28 @@ func startWatching(ctx *types.Context) *fsnotify.Watcher {
190197
return watcher
191198
}
192199

193-
func newServer(ctx *types.Context, watcher *fsnotify.Watcher) *builderServer {
200+
func newServerWithWatcher(ctx *types.Context, watcher *fsnotify.Watcher) *builderServer {
194201
s := new(builderServer)
195202
s.ctx = ctx
196203
s.watcher = watcher
197204
return s
198205
}
199206

207+
func newServer(ctx *types.Context) *builderServer {
208+
s := new(builderServer)
209+
s.ctx = ctx
210+
return s
211+
}
212+
200213
func RegisterAndServeJsonRPC(ctx *types.Context) {
201214
lis, err := net.Listen("tcp", "localhost:12345")
202215
if err != nil {
203216
//can't spawn two grpc servers on the same port
204217
os.Exit(0)
205218
}
206-
watcher := startWatching(ctx)
219+
//watcher := startWatching(ctx)
207220

208221
grpcServer := grpc.NewServer()
209-
pb.RegisterBuilderServer(grpcServer, newServer(ctx, watcher))
222+
pb.RegisterBuilderServer(grpcServer, newServer(ctx))
210223
grpcServer.Serve(lis)
211224
}

0 commit comments

Comments
 (0)