]> go.fuhry.dev Git - runtime.git/commitdiff
[grpc] add nodep version of client, use in ephs
authorDan Fuhry <dan@fuhry.com>
Wed, 3 Jun 2026 04:10:12 +0000 (00:10 -0400)
committerDan Fuhry <dan@fuhry.com>
Wed, 3 Jun 2026 04:10:12 +0000 (00:10 -0400)
go is now enforcing that internal packages must stay internal, so we need a nodep version of //grpc's client functionality for ephs libs

ephs/BUILD.bazel
ephs/client.go
grpc/client_nodep/BUILD.bazel [new file with mode: 0644]
grpc/client_nodep/imports.go [new file with mode: 0644]

index 8222d851901dd9c98983946f5d4c4fd0b3510f4d..3e9dbe19c686c7ef4a814c6ed1e4784835229bf5 100644 (file)
@@ -9,8 +9,7 @@ go_multi_library(
     importpath = "go.fuhry.dev/runtime/ephs",
     visibility = ["//visibility:public"],
     deps = [
-        "//grpc/internal/client",
-        "//grpc/internal/common",
+        "//grpc/client_nodep",
         "//mtls",
         "//proto/service/ephs",
         "//utils/context",
index c2006c5431058a7a08a136b0feff1e9158cf8157..00683bcceb91acbc3e93e1daab514fc1e08ba960 100644 (file)
@@ -21,20 +21,22 @@ import (
        "time"
 
        "github.com/quic-go/quic-go"
-       grpc "go.fuhry.dev/runtime/grpc/internal/client"
-       grpc_common "go.fuhry.dev/runtime/grpc/internal/common"
+       "google.golang.org/grpc/codes"
+       "google.golang.org/grpc/status"
+
+       grpc "go.fuhry.dev/runtime/grpc/client_nodep"
        "go.fuhry.dev/runtime/mtls"
        ephs_pb "go.fuhry.dev/runtime/proto/service/ephs"
        "go.fuhry.dev/runtime/utils/context"
        "go.fuhry.dev/runtime/utils/log"
        "go.fuhry.dev/runtime/utils/option"
-       "google.golang.org/grpc/codes"
-       "google.golang.org/grpc/status"
 )
 
-const KeyPrefix = "/ephs/"
-const PathSeparator = "/"
-const ChunkSize = 262144
+const (
+       KeyPrefix     = "/ephs/"
+       PathSeparator = "/"
+       ChunkSize     = 262144
+)
 
 const formatEntryDateFormat = "Monday, 2 Jan 2006 15:04:05 -0700"
 
@@ -90,8 +92,10 @@ var ephsQuicConfig = &quic.Config{
 
 var defaultClientAddr string
 
-var defaultClient Client
-var defaultClientMu sync.Mutex
+var (
+       defaultClient   Client
+       defaultClientMu sync.Mutex
+)
 
 type notFoundError struct {
        ephsPath string
@@ -225,7 +229,7 @@ func NewClient(ctx context.Context, localId mtls.Identity, opts ...ClientOption)
                defaultTimeout: 15 * time.Second,
                id:             localId,
                grpcOpts: []grpc.ClientOption{
-                       grpc.WithConnectionFactory(&grpc_common.QUICConnectionFactory{
+                       grpc.WithConnectionFactory(&grpc.QUICConnectionFactory{
                                QUICConfig: ephsQuicConfig.Clone(),
                        }),
                },
diff --git a/grpc/client_nodep/BUILD.bazel b/grpc/client_nodep/BUILD.bazel
new file mode 100644 (file)
index 0000000..2bf78ad
--- /dev/null
@@ -0,0 +1,12 @@
+load("//bazel:go.bzl", "go_multi_library")
+
+go_multi_library(
+    name = "client_nodep",
+    srcs = ["imports.go"],
+    importpath = "go.fuhry.dev/runtime/grpc/client_nodep",
+    visibility = ["//visibility:public"],
+    deps = [
+        "//grpc/internal/client",
+        "//grpc/internal/common",
+    ],
+)
diff --git a/grpc/client_nodep/imports.go b/grpc/client_nodep/imports.go
new file mode 100644 (file)
index 0000000..8fdbad5
--- /dev/null
@@ -0,0 +1,38 @@
+package client_nodep
+
+import (
+       "go.fuhry.dev/runtime/grpc/internal/client"
+       "go.fuhry.dev/runtime/grpc/internal/common"
+)
+
+// type aliases: common
+type (
+       ConnectionFactory     = common.ConnectionFactory
+       ContextDialer         = common.ContextDialer
+       QUICConnectionFactory = common.QUICConnectionFactory
+       TCPConnectionFactory  = common.TCPConnectionFactory
+)
+
+// type aliases: client
+type (
+       Client          = client.Client
+       ClientOption    = client.ClientOption
+       AddressProvider = client.AddressProvider
+       ClientConn      = client.ClientConn
+)
+
+// function aliases: common
+var (
+       NewDefaultConnectionFactory = common.NewDefaultConnectionFactory
+       RegisterTransport           = common.RegisterTransport
+)
+
+// function aliases: client
+var (
+       WithConnectionFactory = client.WithConnectionFactory
+       WithAddressProvider   = client.WithAddressProvider
+       WithStaticAddress     = client.WithStaticAddress
+       WithDNSSRV            = client.WithDNSSRV
+)
+
+var NewGrpcClient = client.NewGrpcClient