google-cloud-datastream-v1 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8010f92edc29881e3100047ddc49cb5933579b26eff3c2627830fc81ed3650ff
4
- data.tar.gz: bf943cf84295f12e58f9b930fe88373b33232eb4af44a5789740e6c59b95b924
3
+ metadata.gz: c960b2d557d89b73c50f44dbedc890c419b3f44bb74daf3fac49d6cbf0b565f7
4
+ data.tar.gz: 78f172cfda7a70eff319a91af5d19b903375f2eb4822d87027fbe9bf549423bf
5
5
  SHA512:
6
- metadata.gz: abffd5dc51f759de885ce0e3245fbbccab21e8d892200b533fac1e050b53e5705ae696fa1c67c6d5805e6545648ce484c1343ca98e408e854b14684bd3ddc11a
7
- data.tar.gz: d5156bcd2a01b9c86697140a4a4fc697fa0aa166b24c5e933d76239c12c109451fb3eee07b9254092f053b68df146a0d120cf5211dd1ec34af1a38c9a30e7eac
6
+ metadata.gz: e9265dd470e5e0843d5239e20413f9906d9b694989fea61bb0908412d8986f75846b15df566d254520fd4d31a9160ff65538d7c4233d1c286b12423879dca278
7
+ data.tar.gz: d411760690defb9af10cbb62cb33c71bff13c557dde38b68da1021afeb6d8c9e593e83d2fc2afffde0d7502eeb2455d2e93cc9395fc4375e7ae897b857bf4c76
data/README.md CHANGED
@@ -43,33 +43,43 @@ for class and method documentation.
43
43
  See also the [Product Documentation](https://cloud.google.com/datastream/)
44
44
  for general usage information.
45
45
 
46
- ## Enabling Logging
47
-
48
- To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
49
- The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/current/stdlibs/logger/Logger.html) as shown below,
50
- or a [`Google::Cloud::Logging::Logger`](https://cloud.google.com/ruby/docs/reference/google-cloud-logging/latest)
51
- that will write logs to [Cloud Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
52
- and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
53
-
54
- Configuring a Ruby stdlib logger:
46
+ ## Debug Logging
47
+
48
+ This library comes with opt-in Debug Logging that can help you troubleshoot
49
+ your application's integration with the API. When logging is activated, key
50
+ events such as requests and responses, along with data payloads and metadata
51
+ such as headers and client configuration, are logged to the standard error
52
+ stream.
53
+
54
+ **WARNING:** Client Library Debug Logging includes your data payloads in
55
+ plaintext, which could include sensitive data such as PII for yourself or your
56
+ customers, private keys, or other security data that could be compromising if
57
+ leaked. Always practice good data hygiene with your application logs, and follow
58
+ the principle of least access. Google also recommends that Client Library Debug
59
+ Logging be enabled only temporarily during active debugging, and not used
60
+ permanently in production.
61
+
62
+ To enable logging, set the environment variable `GOOGLE_SDK_RUBY_LOGGING_GEMS`
63
+ to the value `all`. Alternatively, you can set the value to a comma-delimited
64
+ list of client library gem names. This will select the default logging behavior,
65
+ which writes logs to the standard error stream. On a local workstation, this may
66
+ result in logs appearing on the console. When running on a Google Cloud hosting
67
+ service such as [Google Cloud Run](https://cloud.google.com/run), this generally
68
+ results in logs appearing alongside your application logs in the
69
+ [Google Cloud Logging](https://cloud.google.com/logging/) service.
70
+
71
+ You can customize logging by modifying the `logger` configuration when
72
+ constructing a client object. For example:
55
73
 
56
74
  ```ruby
75
+ require "google/cloud/datastream/v1"
57
76
  require "logger"
58
77
 
59
- module MyLogger
60
- LOGGER = Logger.new $stderr, level: Logger::WARN
61
- def logger
62
- LOGGER
63
- end
64
- end
65
-
66
- # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
67
- module GRPC
68
- extend MyLogger
78
+ client = ::Google::Cloud::Datastream::V1::Datastream::Client.new do |config|
79
+ config.logger = Logger.new "my-app.log"
69
80
  end
70
81
  ```
71
82
 
72
-
73
83
  ## Google Cloud Samples
74
84
 
75
85
  To browse ready to use code samples check [Google Cloud Samples](https://cloud.google.com/docs/samples).
@@ -191,14 +191,26 @@ module Google
191
191
  universe_domain: @config.universe_domain,
192
192
  channel_args: @config.channel_args,
193
193
  interceptors: @config.interceptors,
194
- channel_pool_config: @config.channel_pool
194
+ channel_pool_config: @config.channel_pool,
195
+ logger: @config.logger
195
196
  )
196
197
 
198
+ @datastream_stub.stub_logger&.info do |entry|
199
+ entry.set_system_name
200
+ entry.set_service
201
+ entry.message = "Created client for #{entry.service}"
202
+ entry.set_credentials_fields credentials
203
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
204
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
205
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
206
+ end
207
+
197
208
  @location_client = Google::Cloud::Location::Locations::Client.new do |config|
198
209
  config.credentials = credentials
199
210
  config.quota_project = @quota_project_id
200
211
  config.endpoint = @datastream_stub.endpoint
201
212
  config.universe_domain = @datastream_stub.universe_domain
213
+ config.logger = @datastream_stub.logger if config.respond_to? :logger=
202
214
  end
203
215
 
204
216
  @iam_policy_client = Google::Iam::V1::IAMPolicy::Client.new do |config|
@@ -206,6 +218,7 @@ module Google
206
218
  config.quota_project = @quota_project_id
207
219
  config.endpoint = @datastream_stub.endpoint
208
220
  config.universe_domain = @datastream_stub.universe_domain
221
+ config.logger = @datastream_stub.logger if config.respond_to? :logger=
209
222
  end
210
223
  end
211
224
 
@@ -230,6 +243,15 @@ module Google
230
243
  #
231
244
  attr_reader :iam_policy_client
232
245
 
246
+ ##
247
+ # The logger used for request/response debug logging.
248
+ #
249
+ # @return [Logger]
250
+ #
251
+ def logger
252
+ @datastream_stub.logger
253
+ end
254
+
233
255
  # Service calls
234
256
 
235
257
  ##
@@ -332,7 +354,7 @@ module Google
332
354
  @datastream_stub.call_rpc :list_connection_profiles, request, options: options do |response, operation|
333
355
  response = ::Gapic::PagedEnumerable.new @datastream_stub, :list_connection_profiles, request, response, operation, options
334
356
  yield response, operation if block_given?
335
- return response
357
+ throw :response, response
336
358
  end
337
359
  rescue ::GRPC::BadStatus => e
338
360
  raise ::Google::Cloud::Error.from_error(e)
@@ -418,7 +440,6 @@ module Google
418
440
 
419
441
  @datastream_stub.call_rpc :get_connection_profile, request, options: options do |response, operation|
420
442
  yield response, operation if block_given?
421
- return response
422
443
  end
423
444
  rescue ::GRPC::BadStatus => e
424
445
  raise ::Google::Cloud::Error.from_error(e)
@@ -535,7 +556,7 @@ module Google
535
556
  @datastream_stub.call_rpc :create_connection_profile, request, options: options do |response, operation|
536
557
  response = ::Gapic::Operation.new response, @operations_client, options: options
537
558
  yield response, operation if block_given?
538
- return response
559
+ throw :response, response
539
560
  end
540
561
  rescue ::GRPC::BadStatus => e
541
562
  raise ::Google::Cloud::Error.from_error(e)
@@ -654,7 +675,7 @@ module Google
654
675
  @datastream_stub.call_rpc :update_connection_profile, request, options: options do |response, operation|
655
676
  response = ::Gapic::Operation.new response, @operations_client, options: options
656
677
  yield response, operation if block_given?
657
- return response
678
+ throw :response, response
658
679
  end
659
680
  rescue ::GRPC::BadStatus => e
660
681
  raise ::Google::Cloud::Error.from_error(e)
@@ -762,7 +783,7 @@ module Google
762
783
  @datastream_stub.call_rpc :delete_connection_profile, request, options: options do |response, operation|
763
784
  response = ::Gapic::Operation.new response, @operations_client, options: options
764
785
  yield response, operation if block_given?
765
- return response
786
+ throw :response, response
766
787
  end
767
788
  rescue ::GRPC::BadStatus => e
768
789
  raise ::Google::Cloud::Error.from_error(e)
@@ -869,7 +890,6 @@ module Google
869
890
 
870
891
  @datastream_stub.call_rpc :discover_connection_profile, request, options: options do |response, operation|
871
892
  yield response, operation if block_given?
872
- return response
873
893
  end
874
894
  rescue ::GRPC::BadStatus => e
875
895
  raise ::Google::Cloud::Error.from_error(e)
@@ -974,7 +994,7 @@ module Google
974
994
  @datastream_stub.call_rpc :list_streams, request, options: options do |response, operation|
975
995
  response = ::Gapic::PagedEnumerable.new @datastream_stub, :list_streams, request, response, operation, options
976
996
  yield response, operation if block_given?
977
- return response
997
+ throw :response, response
978
998
  end
979
999
  rescue ::GRPC::BadStatus => e
980
1000
  raise ::Google::Cloud::Error.from_error(e)
@@ -1060,7 +1080,6 @@ module Google
1060
1080
 
1061
1081
  @datastream_stub.call_rpc :get_stream, request, options: options do |response, operation|
1062
1082
  yield response, operation if block_given?
1063
- return response
1064
1083
  end
1065
1084
  rescue ::GRPC::BadStatus => e
1066
1085
  raise ::Google::Cloud::Error.from_error(e)
@@ -1177,7 +1196,7 @@ module Google
1177
1196
  @datastream_stub.call_rpc :create_stream, request, options: options do |response, operation|
1178
1197
  response = ::Gapic::Operation.new response, @operations_client, options: options
1179
1198
  yield response, operation if block_given?
1180
- return response
1199
+ throw :response, response
1181
1200
  end
1182
1201
  rescue ::GRPC::BadStatus => e
1183
1202
  raise ::Google::Cloud::Error.from_error(e)
@@ -1296,7 +1315,7 @@ module Google
1296
1315
  @datastream_stub.call_rpc :update_stream, request, options: options do |response, operation|
1297
1316
  response = ::Gapic::Operation.new response, @operations_client, options: options
1298
1317
  yield response, operation if block_given?
1299
- return response
1318
+ throw :response, response
1300
1319
  end
1301
1320
  rescue ::GRPC::BadStatus => e
1302
1321
  raise ::Google::Cloud::Error.from_error(e)
@@ -1404,7 +1423,7 @@ module Google
1404
1423
  @datastream_stub.call_rpc :delete_stream, request, options: options do |response, operation|
1405
1424
  response = ::Gapic::Operation.new response, @operations_client, options: options
1406
1425
  yield response, operation if block_given?
1407
- return response
1426
+ throw :response, response
1408
1427
  end
1409
1428
  rescue ::GRPC::BadStatus => e
1410
1429
  raise ::Google::Cloud::Error.from_error(e)
@@ -1505,7 +1524,7 @@ module Google
1505
1524
  @datastream_stub.call_rpc :run_stream, request, options: options do |response, operation|
1506
1525
  response = ::Gapic::Operation.new response, @operations_client, options: options
1507
1526
  yield response, operation if block_given?
1508
- return response
1527
+ throw :response, response
1509
1528
  end
1510
1529
  rescue ::GRPC::BadStatus => e
1511
1530
  raise ::Google::Cloud::Error.from_error(e)
@@ -1591,7 +1610,6 @@ module Google
1591
1610
 
1592
1611
  @datastream_stub.call_rpc :get_stream_object, request, options: options do |response, operation|
1593
1612
  yield response, operation if block_given?
1594
- return response
1595
1613
  end
1596
1614
  rescue ::GRPC::BadStatus => e
1597
1615
  raise ::Google::Cloud::Error.from_error(e)
@@ -1679,7 +1697,6 @@ module Google
1679
1697
 
1680
1698
  @datastream_stub.call_rpc :lookup_stream_object, request, options: options do |response, operation|
1681
1699
  yield response, operation if block_given?
1682
- return response
1683
1700
  end
1684
1701
  rescue ::GRPC::BadStatus => e
1685
1702
  raise ::Google::Cloud::Error.from_error(e)
@@ -1780,7 +1797,7 @@ module Google
1780
1797
  @datastream_stub.call_rpc :list_stream_objects, request, options: options do |response, operation|
1781
1798
  response = ::Gapic::PagedEnumerable.new @datastream_stub, :list_stream_objects, request, response, operation, options
1782
1799
  yield response, operation if block_given?
1783
- return response
1800
+ throw :response, response
1784
1801
  end
1785
1802
  rescue ::GRPC::BadStatus => e
1786
1803
  raise ::Google::Cloud::Error.from_error(e)
@@ -1867,7 +1884,6 @@ module Google
1867
1884
 
1868
1885
  @datastream_stub.call_rpc :start_backfill_job, request, options: options do |response, operation|
1869
1886
  yield response, operation if block_given?
1870
- return response
1871
1887
  end
1872
1888
  rescue ::GRPC::BadStatus => e
1873
1889
  raise ::Google::Cloud::Error.from_error(e)
@@ -1954,7 +1970,6 @@ module Google
1954
1970
 
1955
1971
  @datastream_stub.call_rpc :stop_backfill_job, request, options: options do |response, operation|
1956
1972
  yield response, operation if block_given?
1957
- return response
1958
1973
  end
1959
1974
  rescue ::GRPC::BadStatus => e
1960
1975
  raise ::Google::Cloud::Error.from_error(e)
@@ -2047,7 +2062,6 @@ module Google
2047
2062
 
2048
2063
  @datastream_stub.call_rpc :fetch_static_ips, request, options: options do |response, operation|
2049
2064
  yield response, operation if block_given?
2050
- return response
2051
2065
  end
2052
2066
  rescue ::GRPC::BadStatus => e
2053
2067
  raise ::Google::Cloud::Error.from_error(e)
@@ -2161,7 +2175,7 @@ module Google
2161
2175
  @datastream_stub.call_rpc :create_private_connection, request, options: options do |response, operation|
2162
2176
  response = ::Gapic::Operation.new response, @operations_client, options: options
2163
2177
  yield response, operation if block_given?
2164
- return response
2178
+ throw :response, response
2165
2179
  end
2166
2180
  rescue ::GRPC::BadStatus => e
2167
2181
  raise ::Google::Cloud::Error.from_error(e)
@@ -2247,7 +2261,6 @@ module Google
2247
2261
 
2248
2262
  @datastream_stub.call_rpc :get_private_connection, request, options: options do |response, operation|
2249
2263
  yield response, operation if block_given?
2250
- return response
2251
2264
  end
2252
2265
  rescue ::GRPC::BadStatus => e
2253
2266
  raise ::Google::Cloud::Error.from_error(e)
@@ -2356,7 +2369,7 @@ module Google
2356
2369
  @datastream_stub.call_rpc :list_private_connections, request, options: options do |response, operation|
2357
2370
  response = ::Gapic::PagedEnumerable.new @datastream_stub, :list_private_connections, request, response, operation, options
2358
2371
  yield response, operation if block_given?
2359
- return response
2372
+ throw :response, response
2360
2373
  end
2361
2374
  rescue ::GRPC::BadStatus => e
2362
2375
  raise ::Google::Cloud::Error.from_error(e)
@@ -2467,7 +2480,7 @@ module Google
2467
2480
  @datastream_stub.call_rpc :delete_private_connection, request, options: options do |response, operation|
2468
2481
  response = ::Gapic::Operation.new response, @operations_client, options: options
2469
2482
  yield response, operation if block_given?
2470
- return response
2483
+ throw :response, response
2471
2484
  end
2472
2485
  rescue ::GRPC::BadStatus => e
2473
2486
  raise ::Google::Cloud::Error.from_error(e)
@@ -2580,7 +2593,7 @@ module Google
2580
2593
  @datastream_stub.call_rpc :create_route, request, options: options do |response, operation|
2581
2594
  response = ::Gapic::Operation.new response, @operations_client, options: options
2582
2595
  yield response, operation if block_given?
2583
- return response
2596
+ throw :response, response
2584
2597
  end
2585
2598
  rescue ::GRPC::BadStatus => e
2586
2599
  raise ::Google::Cloud::Error.from_error(e)
@@ -2666,7 +2679,6 @@ module Google
2666
2679
 
2667
2680
  @datastream_stub.call_rpc :get_route, request, options: options do |response, operation|
2668
2681
  yield response, operation if block_given?
2669
- return response
2670
2682
  end
2671
2683
  rescue ::GRPC::BadStatus => e
2672
2684
  raise ::Google::Cloud::Error.from_error(e)
@@ -2774,7 +2786,7 @@ module Google
2774
2786
  @datastream_stub.call_rpc :list_routes, request, options: options do |response, operation|
2775
2787
  response = ::Gapic::PagedEnumerable.new @datastream_stub, :list_routes, request, response, operation, options
2776
2788
  yield response, operation if block_given?
2777
- return response
2789
+ throw :response, response
2778
2790
  end
2779
2791
  rescue ::GRPC::BadStatus => e
2780
2792
  raise ::Google::Cloud::Error.from_error(e)
@@ -2882,7 +2894,7 @@ module Google
2882
2894
  @datastream_stub.call_rpc :delete_route, request, options: options do |response, operation|
2883
2895
  response = ::Gapic::Operation.new response, @operations_client, options: options
2884
2896
  yield response, operation if block_given?
2885
- return response
2897
+ throw :response, response
2886
2898
  end
2887
2899
  rescue ::GRPC::BadStatus => e
2888
2900
  raise ::Google::Cloud::Error.from_error(e)
@@ -2971,6 +2983,11 @@ module Google
2971
2983
  # default endpoint URL. The default value of nil uses the environment
2972
2984
  # universe (usually the default "googleapis.com" universe).
2973
2985
  # @return [::String,nil]
2986
+ # @!attribute [rw] logger
2987
+ # A custom logger to use for request/response debug logging, or the value
2988
+ # `:default` (the default) to construct a default logger, or `nil` to
2989
+ # explicitly disable logging.
2990
+ # @return [::Logger,:default,nil]
2974
2991
  #
2975
2992
  class Configuration
2976
2993
  extend ::Gapic::Config
@@ -2995,6 +3012,7 @@ module Google
2995
3012
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
2996
3013
  config_attr :quota_project, nil, ::String, nil
2997
3014
  config_attr :universe_domain, nil, ::String, nil
3015
+ config_attr :logger, :default, ::Logger, nil, :default
2998
3016
 
2999
3017
  # @private
3000
3018
  def initialize parent_config = nil
@@ -213,7 +213,7 @@ module Google
213
213
  wrap_lro_operation = ->(op_response) { ::Gapic::Operation.new op_response, @operations_client }
214
214
  response = ::Gapic::PagedEnumerable.new @operations_stub, :list_operations, request, response, operation, options, format_resource: wrap_lro_operation
215
215
  yield response, operation if block_given?
216
- return response
216
+ throw :response, response
217
217
  end
218
218
  rescue ::GRPC::BadStatus => e
219
219
  raise ::Google::Cloud::Error.from_error(e)
@@ -309,7 +309,7 @@ module Google
309
309
  @operations_stub.call_rpc :get_operation, request, options: options do |response, operation|
310
310
  response = ::Gapic::Operation.new response, @operations_client, options: options
311
311
  yield response, operation if block_given?
312
- return response
312
+ throw :response, response
313
313
  end
314
314
  rescue ::GRPC::BadStatus => e
315
315
  raise ::Google::Cloud::Error.from_error(e)
@@ -398,7 +398,6 @@ module Google
398
398
 
399
399
  @operations_stub.call_rpc :delete_operation, request, options: options do |response, operation|
400
400
  yield response, operation if block_given?
401
- return response
402
401
  end
403
402
  rescue ::GRPC::BadStatus => e
404
403
  raise ::Google::Cloud::Error.from_error(e)
@@ -494,7 +493,6 @@ module Google
494
493
 
495
494
  @operations_stub.call_rpc :cancel_operation, request, options: options do |response, operation|
496
495
  yield response, operation if block_given?
497
- return response
498
496
  end
499
497
  rescue ::GRPC::BadStatus => e
500
498
  raise ::Google::Cloud::Error.from_error(e)
@@ -592,7 +590,7 @@ module Google
592
590
  @operations_stub.call_rpc :wait_operation, request, options: options do |response, operation|
593
591
  response = ::Gapic::Operation.new response, @operations_client, options: options
594
592
  yield response, operation if block_given?
595
- return response
593
+ throw :response, response
596
594
  end
597
595
  rescue ::GRPC::BadStatus => e
598
596
  raise ::Google::Cloud::Error.from_error(e)
@@ -681,6 +679,11 @@ module Google
681
679
  # default endpoint URL. The default value of nil uses the environment
682
680
  # universe (usually the default "googleapis.com" universe).
683
681
  # @return [::String,nil]
682
+ # @!attribute [rw] logger
683
+ # A custom logger to use for request/response debug logging, or the value
684
+ # `:default` (the default) to construct a default logger, or `nil` to
685
+ # explicitly disable logging.
686
+ # @return [::Logger,:default,nil]
684
687
  #
685
688
  class Configuration
686
689
  extend ::Gapic::Config
@@ -705,6 +708,7 @@ module Google
705
708
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
706
709
  config_attr :quota_project, nil, ::String, nil
707
710
  config_attr :universe_domain, nil, ::String, nil
711
+ config_attr :logger, :default, ::Logger, nil, :default
708
712
 
709
713
  # @private
710
714
  def initialize parent_config = nil