@@ -9,10 +9,35 @@ import (
9
9
"context"
10
10
11
11
"github.com/cockroachdb/cockroach/pkg/roachpb"
12
+ "github.com/cockroachdb/cockroach/pkg/settings"
13
+ "github.com/cockroachdb/cockroach/pkg/util/buildutil"
14
+ "github.com/cockroachdb/cockroach/pkg/util/envutil"
15
+ "github.com/cockroachdb/errors"
12
16
"google.golang.org/grpc"
13
17
"storj.io/drpc"
14
18
)
15
19
20
+ var envExperimentalDRPCEnabled = envutil .EnvOrDefaultBool ("COCKROACH_EXPERIMENTAL_DRPC_ENABLED" , false )
21
+
22
+ // ExperimentalDRPCEnabled determines whether a drpc server accepting BatchRequest
23
+ // is enabled. This server is experimental and completely unsuitable to production
24
+ // usage (for example, does not implement authorization checks).
25
+ var ExperimentalDRPCEnabled = settings .RegisterBoolSetting (
26
+ settings .ApplicationLevel ,
27
+ "rpc.experimental_drpc.enabled" ,
28
+ "if true, use drpc to execute Batch RPCs (instead of gRPC)" ,
29
+ envExperimentalDRPCEnabled ,
30
+ settings .WithValidateBool (func (values * settings.Values , b bool ) error {
31
+ // drpc support is highly experimental and should not be enabled in production.
32
+ // Since authorization is not implemented, we only even host the server if the
33
+ // env var is set or it's a CRDB test build. Consequently, these are prereqs
34
+ // for setting the cluster setting.
35
+ if b && ! (envExperimentalDRPCEnabled || buildutil .CrdbTestBuild ) {
36
+ return errors .New ("experimental drpc is not allowed in this environment" )
37
+ }
38
+ return nil
39
+ }))
40
+
16
41
// TODODRPC is a marker to identify each RPC client creation site that needs to
17
42
// be updated to support DRPC.
18
43
const TODODRPC = false
0 commit comments