-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tenantcapabilities: restructure interfaces
This commit is mostly just a refactoring of what we have. The previous iteration had some unfortunate coupling between the protobufs and the top-level package. Having the protobuf generated code not be a leaf hurts. Another pain point was the lack of strong typing when interacting with capabilities. Given this is go, somewhere there's a need to do some type assertion when dealing sets of variant instance types. The biggest change is that the `TenantCapabilities` concept is no longer wrapped in an interface implemented by the protobuf. Instead, the `Capability` implementations now live inside the `tenantcapabilities` package, and can be looked up with `FromName` and `FromID`, without any access to concrete capabilities. These capabilies then know how to look up values in a strongly typed way from the concrete capabilities. Epic: none Release note: None
- Loading branch information
Showing
60 changed files
with
634 additions
and
541 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,46 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") | ||
load("//build/bazelutil/unused_checker:unused.bzl", "get_x_data") | ||
load("//build:STRINGER.bzl", "stringer") | ||
|
||
go_library( | ||
name = "tenantcapabilities", | ||
srcs = [ | ||
"capabilities.go", | ||
"capability.go", | ||
"interfaces.go", | ||
"testingknobs.go", | ||
":capabilityid-stringer", # keep | ||
"value.go", | ||
"values.go", | ||
":id-stringer", # keep | ||
], | ||
importpath = "github.com/cockroachdb/cockroach/pkg/multitenant/tenantcapabilities", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//pkg/base", | ||
"//pkg/kv/kvpb", | ||
"//pkg/multitenant/tenantcapabilities/tenantcapabilitiespb", | ||
"//pkg/roachpb", | ||
"//pkg/spanconfig/spanconfigbounds", | ||
"//pkg/util/stringerutil", | ||
"@com_github_cockroachdb_errors//:errors", | ||
"@com_github_cockroachdb_redact//:redact", | ||
"@com_github_cockroachdb_redact//interfaces", | ||
], | ||
) | ||
|
||
stringer( | ||
name = "capabilityid-stringer", | ||
name = "id-stringer", | ||
src = "capabilities.go", | ||
additional_args = ["--linecomment"], | ||
typ = "CapabilityID", | ||
typ = "ID", | ||
) | ||
|
||
go_test( | ||
name = "tenantcapabilities_test", | ||
srcs = ["values_test.go"], | ||
args = ["-test.timeout=295s"], | ||
embed = [":tenantcapabilities"], | ||
deps = ["@com_github_stretchr_testify//require"], | ||
) | ||
|
||
get_x_data(name = "get_x_data") |
Oops, something went wrong.