From: Dan Fuhry Date: Wed, 3 Jun 2026 04:10:12 +0000 (-0400) Subject: [grpc] add nodep version of client, use in ephs X-Git-Url: https://go.fuhry.dev/?a=commitdiff_plain;h=d151cb39b732d32b2e67167c6da0f6ac27ca89e3;p=runtime.git [grpc] add nodep version of client, use in ephs go is now enforcing that internal packages must stay internal, so we need a nodep version of //grpc's client functionality for ephs libs --- diff --git a/ephs/BUILD.bazel b/ephs/BUILD.bazel index 8222d85..3e9dbe1 100644 --- a/ephs/BUILD.bazel +++ b/ephs/BUILD.bazel @@ -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", diff --git a/ephs/client.go b/ephs/client.go index c2006c5..00683bc 100644 --- a/ephs/client.go +++ b/ephs/client.go @@ -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 index 0000000..2bf78ad --- /dev/null +++ b/grpc/client_nodep/BUILD.bazel @@ -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 index 0000000..8fdbad5 --- /dev/null +++ b/grpc/client_nodep/imports.go @@ -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