Skip to content

Commit 8625cf0

Browse files
Google APIscopybara-github
authored andcommitted
feat: [Cloud Memorystore for Redis] Support Multiple Read Replicas when creating Instance
PiperOrigin-RevId: 408360267
1 parent be4be3d commit 8625cf0

3 files changed

Lines changed: 123 additions & 37 deletions

File tree

google/cloud/redis/v1/BUILD.bazel

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
# This file was automatically generated by BuildFileGenerator
2+
# https://github.com/googleapis/rules_gapic/tree/master/bazel
3+
4+
# Most of the manual changes to this file will be overwritten.
5+
# It's **only** allowed to change the following rule attribute values:
6+
# - names of *_gapic_assembly_* rules
7+
# - certain parameters of *_gapic_library rules, including but not limited to:
8+
# * extra_protoc_parameters
9+
# * extra_protoc_file_parameters
10+
# The complete list of preserved parameters can be found in the source code.
211

312
# This is an API workspace, having public visibility by default makes perfect sense.
413
package(default_visibility = ["//visibility:public"])
@@ -61,11 +70,13 @@ java_gapic_library(
6170
srcs = [":redis_proto_with_info"],
6271
gapic_yaml = "redis_gapic.yaml",
6372
grpc_service_config = "redis_grpc_service_config.json",
73+
service_yaml = "redis_v1.yaml",
6474
test_deps = [
6575
":redis_java_grpc",
6676
],
6777
deps = [
6878
":redis_java_proto",
79+
"//google/api:api_java_proto",
6980
],
7081
)
7182

@@ -115,6 +126,7 @@ go_gapic_library(
115126
srcs = [":redis_proto_with_info"],
116127
grpc_service_config = "redis_grpc_service_config.json",
117128
importpath = "cloud.google.com/go/redis/apiv1;redis",
129+
metadata = True,
118130
service_yaml = "redis_v1.yaml",
119131
deps = [
120132
":redis_go_proto",
@@ -136,6 +148,7 @@ go_gapic_assembly_pkg(
136148
name = "gapi-cloud-redis-v1-go",
137149
deps = [
138150
":redis_go_gapic",
151+
":redis_go_gapic_srcjar-metadata.srcjar",
139152
":redis_go_gapic_srcjar-test.srcjar",
140153
":redis_go_proto",
141154
],
@@ -156,6 +169,7 @@ py_gapic_library(
156169
grpc_service_config = "redis_grpc_service_config.json",
157170
)
158171

172+
# Open Source Packages
159173
py_gapic_assembly_pkg(
160174
name = "redis-v1-py",
161175
deps = [
@@ -188,7 +202,6 @@ php_grpc_library(
188202
php_gapic_library(
189203
name = "redis_php_gapic",
190204
srcs = [":redis_proto_with_info"],
191-
gapic_yaml = "redis_gapic.yaml",
192205
grpc_service_config = "redis_grpc_service_config.json",
193206
service_yaml = "redis_v1.yaml",
194207
deps = [
@@ -261,11 +274,11 @@ ruby_cloud_gapic_library(
261274
name = "redis_ruby_gapic",
262275
srcs = [":redis_proto_with_info"],
263276
extra_protoc_parameters = [
264-
"ruby-cloud-gem-name=google-cloud-redis-v1",
265-
"ruby-cloud-env-prefix=REDIS",
266-
"ruby-cloud-product-url=https://cloud.google.com/memorystore/docs/redis",
267277
"ruby-cloud-api-id=redis.googleapis.com",
268278
"ruby-cloud-api-shortname=redis",
279+
"ruby-cloud-env-prefix=REDIS",
280+
"ruby-cloud-gem-name=google-cloud-redis-v1",
281+
"ruby-cloud-product-url=https://cloud.google.com/memorystore/docs/redis",
269282
],
270283
grpc_service_config = "redis_grpc_service_config.json",
271284
ruby_cloud_description = "Creates and manages Redis instances on the Google Cloud Platform.",

google/cloud/redis/v1/cloud_redis.proto

Lines changed: 76 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2020 Google LLC
1+
// Copyright 2021 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -165,7 +165,7 @@ service CloudRedis {
165165
};
166166
}
167167

168-
// Initiates a failover of the master node to current replica node for a
168+
// Initiates a failover of the primary node to current replica node for a
169169
// specific STANDARD tier Cloud Memorystore for Redis instance.
170170
rpc FailoverInstance(FailoverInstanceRequest) returns (google.longrunning.Operation) {
171171
option (google.api.http) = {
@@ -193,6 +193,15 @@ service CloudRedis {
193193
}
194194
}
195195

196+
// Node specific properties.
197+
message NodeInfo {
198+
// Output only. Node identifying string. e.g. 'node-0', 'node-1'
199+
string id = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
200+
201+
// Output only. Location of the node.
202+
string zone = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
203+
}
204+
196205
// A Google Cloud Redis instance.
197206
message Instance {
198207
option (google.api.resource) = {
@@ -258,6 +267,21 @@ message Instance {
258267
PRIVATE_SERVICE_ACCESS = 2;
259268
}
260269

270+
// Read replicas mode.
271+
enum ReadReplicasMode {
272+
// If not set, Memorystore Redis backend will pick the mode based on other fields in
273+
// the request.
274+
READ_REPLICAS_MODE_UNSPECIFIED = 0;
275+
276+
// If disabled, read endpoint will not be provided and the instance cannot
277+
// scale up or down the number of replicas.
278+
READ_REPLICAS_DISABLED = 1;
279+
280+
// If enabled, read endpoint will be provided and the instance can scale
281+
// up and down the number of replicas.
282+
READ_REPLICAS_ENABLED = 2;
283+
}
284+
261285
// Required. Unique name of the resource in this scope including project and
262286
// location using the form:
263287
// `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
@@ -276,15 +300,17 @@ message Instance {
276300
map<string, string> labels = 3;
277301

278302
// Optional. The zone where the instance will be provisioned. If not provided,
279-
// the service will choose a zone for the instance. For STANDARD_HA tier,
280-
// instances will be created across two zones for protection against zonal
281-
// failures. If [alternative_location_id][google.cloud.redis.v1.Instance.alternative_location_id] is also provided, it must be
282-
// different from [location_id][google.cloud.redis.v1.Instance.location_id].
303+
// the service will choose a zone from the specified region for the instance.
304+
// For standard tier, additional nodes will be added across multiple zones for
305+
// protection against zonal failures. If specified, at least one node will be
306+
// provisioned in this zone.
283307
string location_id = 4 [(google.api.field_behavior) = OPTIONAL];
284308

285-
// Optional. Only applicable to STANDARD_HA tier which protects the instance
286-
// against zonal failures by provisioning it across two zones. If provided, it
287-
// must be a different zone from the one provided in [location_id][google.cloud.redis.v1.Instance.location_id].
309+
// Optional. If specified, at least one node will be provisioned in this zone
310+
// in addition to the zone specified in location_id. Only applicable to
311+
// standard tier. If provided, it must be a different zone from the one
312+
// provided in [location_id]. Additional nodes beyond the first 2 will be
313+
// placed in zones selected by the service.
288314
string alternative_location_id = 5 [(google.api.field_behavior) = OPTIONAL];
289315

290316
// Optional. The version of Redis software.
@@ -294,12 +320,17 @@ message Instance {
294320
// * `REDIS_3_2` for Redis 3.2 compatibility
295321
// * `REDIS_4_0` for Redis 4.0 compatibility (default)
296322
// * `REDIS_5_0` for Redis 5.0 compatibility
323+
// * `REDIS_6_X` for Redis 6.x compatibility
297324
string redis_version = 7 [(google.api.field_behavior) = OPTIONAL];
298325

299-
// Optional. The CIDR range of internal addresses that are reserved for this
300-
// instance. If not provided, the service will choose an unused /29 block,
301-
// for example, 10.0.0.0/29 or 192.168.0.0/29. Ranges must be unique
302-
// and non-overlapping with existing subnets in an authorized network.
326+
// Optional. For DIRECT_PEERING mode, the CIDR range of internal addresses
327+
// that are reserved for this instance. Range must
328+
// be unique and non-overlapping with existing subnets in an authorized
329+
// network. For PRIVATE_SERVICE_ACCESS mode, the name of one allocated IP
330+
// address ranges associated with this private service access connection.
331+
// If not provided, the service will choose an unused /29 block, for
332+
// example, 10.0.0.0/29 or 192.168.0.0/29. For READ_REPLICAS_ENABLED
333+
// the default block size is /28.
303334
string reserved_ip_range = 9 [(google.api.field_behavior) = OPTIONAL];
304335

305336
// Output only. Hostname or IP address of the exposed Redis endpoint used by
@@ -309,11 +340,9 @@ message Instance {
309340
// Output only. The port number of the exposed Redis endpoint.
310341
int32 port = 11 [(google.api.field_behavior) = OUTPUT_ONLY];
311342

312-
// Output only. The current zone where the Redis endpoint is placed. For Basic
313-
// Tier instances, this will always be the same as the [location_id][google.cloud.redis.v1.Instance.location_id]
314-
// provided by the user at creation time. For Standard Tier instances,
315-
// this can be either [location_id][google.cloud.redis.v1.Instance.location_id] or [alternative_location_id][google.cloud.redis.v1.Instance.alternative_location_id] and can
316-
// change after a failover event.
343+
// Output only. The current zone where the Redis primary node is located. In
344+
// basic tier, this will always be the same as [location_id]. In
345+
// standard tier, this can be the zone of any node in the instance.
317346
string current_location_id = 12 [(google.api.field_behavior) = OUTPUT_ONLY];
318347

319348
// Output only. The time the instance was created.
@@ -370,6 +399,27 @@ message Instance {
370399
// Optional. The network connect mode of the Redis instance.
371400
// If not provided, the connect mode defaults to DIRECT_PEERING.
372401
ConnectMode connect_mode = 22 [(google.api.field_behavior) = OPTIONAL];
402+
403+
// Optional. The number of replica nodes. Valid range for standard tier
404+
// is [1-5] and defaults to 1. Valid value for basic tier is 0 and defaults
405+
// to 0.
406+
int32 replica_count = 31 [(google.api.field_behavior) = OPTIONAL];
407+
408+
// Output only. Info per node.
409+
repeated NodeInfo nodes = 32 [(google.api.field_behavior) = OUTPUT_ONLY];
410+
411+
// Output only. Hostname or IP address of the exposed readonly Redis
412+
// endpoint. Standard tier only. Targets all healthy replica nodes in
413+
// instance. Replication is asynchronous and replica nodes will exhibit some
414+
// lag behind the primary. Write requests must target 'host'.
415+
string read_endpoint = 33 [(google.api.field_behavior) = OUTPUT_ONLY];
416+
417+
// Output only. The port number of the exposed readonly redis
418+
// endpoint. Standard tier only. Write requests should target 'port'.
419+
int32 read_endpoint_port = 34 [(google.api.field_behavior) = OUTPUT_ONLY];
420+
421+
// Optional. Read replica mode.
422+
ReadReplicasMode read_replicas_mode = 35 [(google.api.field_behavior) = OPTIONAL];
373423
}
374424

375425
// Request for [ListInstances][google.cloud.redis.v1.CloudRedis.ListInstances].
@@ -405,11 +455,12 @@ message ListInstancesResponse {
405455
//
406456
// If the `location_id` in the parent field of the request is "-", all regions
407457
// available to the project are queried, and the results aggregated.
408-
// If in such an aggregated query a location is unavailable, a dummy Redis
409-
// entry is included in the response with the `name` field set to a value of
410-
// the form `projects/{project_id}/locations/{location_id}/instances/`- and
411-
// the `status` field set to ERROR and `status_message` field set to "location
412-
// not available for ListInstances".
458+
// If in such an aggregated query a location is unavailable, a placeholder
459+
// Redis entry is included in the response with the `name` field set to a
460+
// value of the form
461+
// `projects/{project_id}/locations/{location_id}/instances/`- and the
462+
// `status` field set to ERROR and `status_message` field set to "location not
463+
// available for ListInstances".
413464
repeated Instance instances = 1;
414465

415466
// Token to retrieve the next page of results, or empty if there are no more
@@ -469,6 +520,7 @@ message UpdateInstanceRequest {
469520
// * `labels`
470521
// * `memorySizeGb`
471522
// * `redisConfig`
523+
// * `replica_count`
472524
google.protobuf.FieldMask update_mask = 1 [(google.api.field_behavior) = REQUIRED];
473525

474526
// Required. Update description.
@@ -568,7 +620,7 @@ message FailoverInstanceRequest {
568620

569621
// Instance failover will be protected with data loss control. More
570622
// specifically, the failover will only be performed if the current
571-
// replication offset diff between master and replica is under a certain
623+
// replication offset diff between primary and replica is under a certain
572624
// threshold.
573625
LIMITED_DATA_LOSS = 1;
574626

google/cloud/redis/v1/redis_v1.yaml

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,51 @@ types:
1313

1414
documentation:
1515
summary: Creates and manages Redis instances on the Google Cloud Platform.
16+
rules:
17+
- selector: google.cloud.location.Locations.GetLocation
18+
description: Gets information about a location.
19+
20+
- selector: google.cloud.location.Locations.ListLocations
21+
description: Lists information about the supported locations for this service.
1622

1723
backend:
1824
rules:
25+
- selector: google.cloud.location.Locations.GetLocation
26+
deadline: 60.0
27+
- selector: google.cloud.location.Locations.ListLocations
28+
deadline: 60.0
1929
- selector: 'google.cloud.redis.v1.CloudRedis.*'
2030
deadline: 60.0
31+
- selector: google.cloud.redis.v1.CloudRedis.ListInstances
32+
deadline: 20.0
2133
- selector: 'google.longrunning.Operations.*'
2234
deadline: 60.0
2335

2436
http:
2537
rules:
26-
- selector: google.longrunning.Operations.ListOperations
27-
get: '/v1/{name=projects/*/locations/*}/operations'
28-
29-
- selector: google.longrunning.Operations.GetOperation
30-
get: '/v1/{name=projects/*/locations/*/operations/*}'
31-
32-
- selector: google.longrunning.Operations.DeleteOperation
33-
delete: '/v1/{name=projects/*/locations/*/operations/*}'
34-
38+
- selector: google.cloud.location.Locations.GetLocation
39+
get: '/v1/{name=projects/*/locations/*}'
40+
- selector: google.cloud.location.Locations.ListLocations
41+
get: '/v1/{name=projects/*}/locations'
3542
- selector: google.longrunning.Operations.CancelOperation
3643
post: '/v1/{name=projects/*/locations/*/operations/*}:cancel'
44+
- selector: google.longrunning.Operations.DeleteOperation
45+
delete: '/v1/{name=projects/*/locations/*/operations/*}'
46+
- selector: google.longrunning.Operations.GetOperation
47+
get: '/v1/{name=projects/*/locations/*/operations/*}'
48+
- selector: google.longrunning.Operations.ListOperations
49+
get: '/v1/{name=projects/*/locations/*}/operations'
3750

3851
authentication:
3952
rules:
53+
- selector: google.cloud.location.Locations.GetLocation
54+
oauth:
55+
canonical_scopes: |-
56+
https://www.googleapis.com/auth/cloud-platform
57+
- selector: google.cloud.location.Locations.ListLocations
58+
oauth:
59+
canonical_scopes: |-
60+
https://www.googleapis.com/auth/cloud-platform
4061
- selector: 'google.cloud.redis.v1.CloudRedis.*'
4162
oauth:
4263
canonical_scopes: |-

0 commit comments

Comments
 (0)