load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

package(default_visibility = ["//enterprise:__subpackages__"])

go_library(
    name = "distributed",
    srcs = ["distributed.go"],
    importpath = "github.com/buildbuddy-io/buildbuddy/enterprise/server/backends/distributed",
    deps = [
        "//enterprise/server/backends/pubsub",
        "//enterprise/server/util/cacheproxy",
        "//enterprise/server/util/heartbeat",
        "//enterprise/server/util/redisutil",
        "//proto:distributed_cache_go_proto",
        "//proto:remote_execution_go_proto",
        "//proto:resource_go_proto",
        "//server/environment",
        "//server/interfaces",
        "//server/metrics",
        "//server/real_environment",
        "//server/remote_cache/content_addressable_storage_server",
        "//server/remote_cache/digest",
        "//server/resources",
        "//server/util/background",
        "//server/util/consistent_hash",
        "//server/util/flag",
        "//server/util/ioutil",
        "//server/util/log",
        "//server/util/lru",
        "//server/util/peerset",
        "//server/util/status",
        "@com_github_prometheus_client_golang//prometheus",
        "@org_golang_google_grpc//metadata",
        "@org_golang_x_sync//errgroup",
    ],
)

go_test(
    name = "distributed_test",
    size = "small",
    srcs = ["distributed_test.go"],
    embed = [":distributed"],
    shard_count = 10,
    deps = [
        "//proto:remote_execution_go_proto",
        "//proto:resource_go_proto",
        "//server/backends/memory_cache",
        "//server/environment",
        "//server/interfaces",
        "//server/metrics",
        "//server/remote_cache/content_addressable_storage_server",
        "//server/testutil/testauth",
        "//server/testutil/testcompression",
        "//server/testutil/testdigest",
        "//server/testutil/testenv",
        "//server/testutil/testmetrics",
        "//server/testutil/testport",
        "//server/util/compression",
        "//server/util/grpc_client",
        "//server/util/log",
        "//server/util/prefix",
        "//server/util/proto",
        "//server/util/testing/flags",
        "@com_github_stretchr_testify//assert",
        "@com_github_stretchr_testify//require",
        "@org_golang_google_grpc//:grpc",
    ],
)
