lib/google/cloud/redis.rb in google-cloud-redis-1.3.0 vs lib/google/cloud/redis.rb in google-cloud-redis-1.4.0
- old
+ new
@@ -47,15 +47,17 @@
##
# Create a new client object for CloudRedis.
#
# By default, this returns an instance of
# [Google::Cloud::Redis::V1::CloudRedis::Client](https://googleapis.dev/ruby/google-cloud-redis-v1/latest/Google/Cloud/Redis/V1/CloudRedis/Client.html)
- # for version V1 of the API.
- # However, you can specify specify a different API version by passing it in the
+ # for a gRPC client for version V1 of the API.
+ # However, you can specify a different API version by passing it in the
# `version` parameter. If the CloudRedis service is
# supported by that API version, and the corresponding gem is available, the
# appropriate versioned client will be returned.
+ # You can also specify a different transport by passing `:rest` or `:grpc` in
+ # the `transport` parameter.
#
# ## About CloudRedis
#
# Configures and manages Cloud Memorystore for Redis instances
#
@@ -73,21 +75,23 @@
# Note that location_id must be referring to a GCP `region`; for example:
# * `projects/redpepper-1290/locations/us-central1/instances/my-redis`
#
# @param version [::String, ::Symbol] The API version to connect to. Optional.
# Defaults to `:v1`.
- # @return [CloudRedis::Client] A client object for the specified version.
+ # @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`.
+ # @return [::Object] A client object for the specified version.
#
- def self.cloud_redis version: :v1, &block
+ def self.cloud_redis version: :v1, transport: :grpc, &block
require "google/cloud/redis/#{version.to_s.downcase}"
package_name = Google::Cloud::Redis
.constants
.select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
.first
- package_module = Google::Cloud::Redis.const_get package_name
- package_module.const_get(:CloudRedis).const_get(:Client).new(&block)
+ service_module = Google::Cloud::Redis.const_get(package_name).const_get(:CloudRedis)
+ service_module = service_module.const_get(:Rest) if transport == :rest
+ service_module.const_get(:Client).new(&block)
end
##
# Configure the google-cloud-redis library.
#
@@ -103,10 +107,10 @@
# * `interceptors` (*type:* `Array<GRPC::ClientInterceptor>`) -
# An array of interceptors that are run before calls are executed.
# * `timeout` (*type:* `Numeric`) -
# Default timeout in seconds.
# * `metadata` (*type:* `Hash{Symbol=>String}`) -
- # Additional gRPC headers to be sent with the call.
+ # Additional headers to be sent with the call.
# * `retry_policy` (*type:* `Hash`) -
# The retry policy. The value is a hash with the following keys:
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.