18
18
using Google . Cloud . Bigtable . Common . V2 ;
19
19
using Grpc . Auth ;
20
20
using Grpc . Core ;
21
- using System ;
22
- using System . Collections . Generic ;
23
- using System . Linq ;
24
- using System . Threading . Tasks ;
25
21
26
- namespace Google . Cloud . Bigtable . V2 . ConformanceTests ;
22
+ namespace Google . Cloud . Bigtable . V2 . ConformanceTests . Services ;
27
23
28
24
public sealed class CloudBigtableV2TestProxyImpl : CloudBigtableV2TestProxy . CloudBigtableV2TestProxyBase
29
25
{
30
26
private class CbtClient
31
27
{
32
- public BigtableClient Client { get ; set ; }
33
- public ChannelBase LastCreatedChannel { get ; set ; }
34
- public InstanceName InstanceName { get ; set ; }
28
+ public BigtableClient Client { get ; private set ; }
29
+ public ChannelBase LastCreatedChannel { get ; private set ; }
30
+ public InstanceName InstanceName { get ; private set ; }
31
+
32
+ public CbtClient ( BigtableClient bigtableClient , ChannelBase channelBase , InstanceName instanceName )
33
+ {
34
+ Client = bigtableClient ;
35
+ LastCreatedChannel = channelBase ;
36
+ InstanceName = instanceName ;
37
+ }
35
38
}
36
39
37
40
private readonly Dictionary < string , CbtClient > _idClientMap ;
@@ -52,11 +55,13 @@ public override async Task<CreateClientResponse> CreateClient(CreateClientReques
52
55
|| ( securityOptions . SslRootCertsPem is not ( "" or null ) ) , "SecurityOptions" ,
53
56
"security_options.ssl_root_certs_pem must be provided if security_options.use_ssl is true" ) ;
54
57
58
+ #pragma warning disable CS8604 // Possible null reference argument.
55
59
if ( _idClientMap . ContainsKey ( clientId ) )
56
60
{
57
61
context . Status = new Status ( StatusCode . AlreadyExists , $ "Client { clientId } already exists") ;
58
62
throw new RpcException ( context . Status ) ;
59
63
}
64
+ #pragma warning restore CS8604 // Possible null reference argument.
60
65
61
66
try
62
67
{
@@ -77,7 +82,9 @@ public override async Task<CreateClientResponse> CreateClient(CreateClientReques
77
82
if ( dataTarget != "emulator" )
78
83
{
79
84
builder . Endpoint = dataTarget ;
85
+ #pragma warning disable CS8604 // Possible null reference argument.
80
86
builder . ChannelCredentials = GetChannelCredentials ( securityOptions . UseSsl , securityOptions . SslRootCertsPem , securityOptions . AccessToken ) ;
87
+ #pragma warning restore CS8604 // Possible null reference argument.
81
88
builder . GrpcChannelOptions = ( securityOptions . UseSsl && securityOptions . SslEndpointOverride is not null )
82
89
? GrpcChannelOptions . Empty . WithCustomOption ( "grpc.ssl_target_name_override" , securityOptions . SslEndpointOverride )
83
90
: GrpcChannelOptions . Empty ;
@@ -89,12 +96,7 @@ public override async Task<CreateClientResponse> CreateClient(CreateClientReques
89
96
InstanceName instanceName = new InstanceName ( projectId , instanceId ) ;
90
97
BigtableServiceApiClient apiClient = await builder . BuildAsync ( ) ;
91
98
92
- CbtClient cbtClient = new CbtClient
93
- {
94
- Client = BigtableClient . Create ( apiClient ) ,
95
- LastCreatedChannel = builder . LastCreatedChannel ,
96
- InstanceName = instanceName
97
- } ;
99
+ CbtClient cbtClient = new CbtClient ( BigtableClient . Create ( apiClient ) , builder . LastCreatedChannel , instanceName ) ;
98
100
_idClientMap [ clientId ] = cbtClient ;
99
101
}
100
102
catch ( Exception e )
@@ -126,7 +128,9 @@ public override Task<RemoveClientResponse> RemoveClient(RemoveClientRequest requ
126
128
{
127
129
string clientId = request . ClientId ;
128
130
GaxPreconditions . CheckArgument ( clientId is not ( "" or null ) , "ClientId" , "client id must be provided" , context ) ;
131
+ #pragma warning disable CS8604 // Possible null reference argument.
129
132
bool removed = _idClientMap . Remove ( clientId ) ;
133
+ #pragma warning restore CS8604 // Possible null reference argument.
130
134
if ( ! removed )
131
135
{
132
136
context . Status = new Status ( StatusCode . NotFound , $ "Client { clientId } not found.") ;
@@ -147,7 +151,7 @@ public override async Task<RowResult> ReadRow(ReadRowRequest request, ServerCall
147
151
{
148
152
Status = new Rpc . Status ( )
149
153
{
150
- Code = ( int ) Rpc . Code . InvalidArgument ,
154
+ Code = ( int ) Rpc . Code . InvalidArgument ,
151
155
Message = "Invalid TableName"
152
156
}
153
157
} ;
@@ -355,17 +359,19 @@ public override async Task<ExecuteQueryResult> ExecuteQuery(ExecuteQueryRequest
355
359
356
360
public static CloudBigtableV2TestProxyImpl Create ( ) => new ( ) ;
357
361
358
- private CloudBigtableV2TestProxyImpl ( ) => _idClientMap = new ( ) ;
362
+ public CloudBigtableV2TestProxyImpl ( ) => _idClientMap = new ( ) ;
359
363
360
364
private CbtClient GetClient ( string clientId , ServerCallContext context )
361
365
{
362
366
GaxPreconditions . CheckArgument ( clientId is not ( "" or null ) , "ClientId" , "client id must be provided" , context ) ;
363
367
368
+ #pragma warning disable CS8604 // Possible null reference argument.
364
369
if ( ! _idClientMap . ContainsKey ( clientId ) )
365
370
{
366
371
context . Status = new Status ( StatusCode . NotFound , $ "Client { clientId } not found.") ;
367
372
throw new RpcException ( context . Status ) ;
368
373
}
374
+ #pragma warning restore CS8604 // Possible null reference argument.
369
375
return _idClientMap [ clientId ] ;
370
376
}
371
377
@@ -399,7 +405,7 @@ private static Rpc.Status SetExceptionStatus(Exception e, ServerCallContext cont
399
405
context . Status = new Status ( StatusCode . Internal , e . Message , e ) ;
400
406
return new Rpc . Status ( )
401
407
{
402
- Code = ( int ) Rpc . Code . Internal ,
408
+ Code = ( int ) Rpc . Code . Internal ,
403
409
Message = e . Message
404
410
} ;
405
411
}
@@ -409,7 +415,7 @@ private static Rpc.Status SetSuccessStatus(string message, ServerCallContext con
409
415
context . Status = new Status ( StatusCode . OK , message ) ;
410
416
return new Rpc . Status ( )
411
417
{
412
- Code = ( int ) Rpc . Code . Ok ,
418
+ Code = ( int ) Rpc . Code . Ok ,
413
419
Message = message
414
420
} ;
415
421
}
0 commit comments