Skip to content

Commit

Permalink
Add a gRPC API (#577)
Browse files Browse the repository at this point in the history
This adds a gRPC API alongside the existing gob API.

It is enabled whenever the RPC setting is enabled. I didn't think it made sense to have a separate setting to enable it. It is only used when a gRPC request is detected (Content-Type: application/grpc). Eventually, we should likely open a separate port for gRPC traffic, but this should be okay for now.

In order to minimize the footprint of this change, we only use the protobuf definitions in the RPC layer. They are translated to/from the existing go types. This results in a small perf penalty.
  • Loading branch information
camdencheek committed Jun 5, 2023
1 parent c4c4a21 commit b45da91
Show file tree
Hide file tree
Showing 24 changed files with 7,690 additions and 7 deletions.
8 changes: 8 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ go_library(
name = "zoekt",
srcs = [
"api.go",
"api_proto.go",
"bits.go",
"btree.go",
"contentprovider.go",
Expand All @@ -45,12 +46,15 @@ go_library(
importpath = "github.com/sourcegraph/zoekt",
visibility = ["//visibility:public"],
deps = [
"//grpc/v1:grpc",
"//query",
"@com_github_edsrzf_mmap_go//:mmap-go",
"@com_github_go_enry_go_enry_v2//:go-enry",
"@com_github_go_enry_go_enry_v2//data",
"@com_github_grafana_regexp//:regexp",
"@com_github_rs_xid//:xid",
"@org_golang_google_protobuf//types/known/durationpb",
"@org_golang_google_protobuf//types/known/timestamppb",
] + select({
"@io_bazel_rules_go//go/platform:aix": [
"@org_golang_x_sys//unix",
Expand Down Expand Up @@ -98,6 +102,7 @@ go_library(
go_test(
name = "zoekt_test",
srcs = [
"api_proto_test.go",
"api_test.go",
"bits_test.go",
"btree_test.go",
Expand All @@ -114,12 +119,15 @@ go_test(
],
data = [":testdata"],
embed = [":zoekt"],
embedsrcs = ["//testdata:search_result_1.pb"], #keep
deps = [
"//grpc/v1:grpc",
"//query",
"@com_github_google_go_cmp//cmp",
"@com_github_google_go_cmp//cmp/cmpopts",
"@com_github_grafana_regexp//:regexp",
"@com_github_kylelemons_godebug//pretty",
"@com_github_roaringbitmap_roaring//:roaring",
"@org_golang_google_protobuf//proto",
],
)
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ http_archive(

# Go toolchain setup
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
load("//:deps.bzl", "go_dependencies")

# gazelle:repository_macro deps.bzl%go_dependencies
Expand Down
2 changes: 1 addition & 1 deletion api.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ func (r RepositoryBranch) String() string {

// Repository holds repository metadata.
type Repository struct {
// Sourcergaph's repository ID
// Sourcegraph's repository ID
ID uint32

// The repository name
Expand Down
Loading

0 comments on commit b45da91

Please sign in to comment.