Skip to content

Commit

Permalink
ccl/sqlproxyccl: add postgres interceptors for message forwarding
Browse files Browse the repository at this point in the history
Informs #76000.

This commit implements postgres interceptors, namely FrontendInterceptor and
BackendInterceptor, as described in the sqlproxy connection migration RFC.
These interceptors will be used as building blocks for the forwarder component
that we will be adding in a later PR. Since the forwarder component has not
been added, a simple proxy test (i.e. TestSimpleProxy) has been added to
illustrate how the frontend and backend interceptors can be used within the
proxy.

Release note: None
  • Loading branch information
jaylim-crl committed Feb 7, 2022
1 parent d69ef24 commit e02a13d
Show file tree
Hide file tree
Showing 4 changed files with 1,335 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ ALL_TESTS = [
"//pkg/ccl/spanconfigccl/spanconfigsqlwatcherccl:spanconfigsqlwatcherccl_test",
"//pkg/ccl/sqlproxyccl/denylist:denylist_test",
"//pkg/ccl/sqlproxyccl/idle:idle_test",
"//pkg/ccl/sqlproxyccl/interceptor:interceptor_test",
"//pkg/ccl/sqlproxyccl/tenant:tenant_test",
"//pkg/ccl/sqlproxyccl/throttler:throttler_test",
"//pkg/ccl/sqlproxyccl:sqlproxyccl_test",
Expand Down
26 changes: 26 additions & 0 deletions pkg/ccl/sqlproxyccl/interceptor/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "interceptor",
srcs = ["interceptor.go"],
importpath = "github.com/cockroachdb/cockroach/pkg/ccl/sqlproxyccl/interceptor",
visibility = ["//visibility:public"],
deps = [
"//pkg/sql/pgwire/pgwirebase",
"@com_github_cockroachdb_errors//:errors",
"@com_github_jackc_pgproto3_v2//:pgproto3",
],
)

go_test(
name = "interceptor_test",
srcs = ["interceptor_test.go"],
embed = [":interceptor"],
deps = [
"//pkg/sql/pgwire/pgwirebase",
"//pkg/util/leaktest",
"@com_github_cockroachdb_errors//:errors",
"@com_github_jackc_pgproto3_v2//:pgproto3",
"@com_github_stretchr_testify//require",
],
)
Loading

0 comments on commit e02a13d

Please sign in to comment.