sourcegraph/internal/codeintel/shared
Erik Seliger f999dd3420
gitserver: Unify filereader API (#59782)
This PR consolidates two methods that were effectively doing the same thing: `ReadFile` and `NewFileReader` - where `ReadFile` used the latter under the hood, and wrapped an `io.ReadAll`.
Given entire files are returned from this function that can be of arbitrary size, exposing a simple high-memory-use footgun made me uneasy here, and having to use io.ReadAll explicitly as the consumer hopefully makes the person using this API feel the same way.
Sometimes, we can currently not avoid it (GQL layer), but where possible, using the reader is very likely the better option. 

Since there would've been a slight change in how errors are reported, I also fixed that. Previously, `NewFileReader` would NOT return `os.ErrNotExist` errors, those would only be discovered when the returned reader is called.
Now, like `ReadFile`, and like `os.Open` we immediately return that error.

This comes at the cost of making a second gRPC request. This is not great, but we will migrate the FileReader API to a proper gRPC hopefully ASAP, which will let us optimize it better on the server-side.
Since Varun also asked for perf improvements here, this is probably one of the first things that would be easy to switch over to go-git, eliminating probably 50%+ of the overhead here.
2024-01-24 13:53:57 +01:00
..
background codeintel: consolidate enterprise & oss codeintel packages (#54431) 2023-07-05 14:58:41 +01:00
lsifuploadstore codeintel: consolidate enterprise & oss codeintel packages (#54431) 2023-07-05 14:58:41 +01:00
ranges codeintel: consolidate enterprise & oss codeintel packages (#54431) 2023-07-05 14:58:41 +01:00
resolvers gitserver: Unify filereader API (#59782) 2024-01-24 13:53:57 +01:00
trie codeintel: consolidate enterprise & oss codeintel packages (#54431) 2023-07-05 14:58:41 +01:00
BUILD.bazel codeintel: consolidate enterprise & oss codeintel packages (#54431) 2023-07-05 14:58:41 +01:00
db.go codeintel: consolidate enterprise & oss codeintel packages (#54431) 2023-07-05 14:58:41 +01:00
noop.go codeintel: consolidate enterprise & oss codeintel packages (#54431) 2023-07-05 14:58:41 +01:00