Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

feat: add automated RDB, also known as persistence #153

Merged
merged 2 commits into from
Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions google/cloud/redis_v1beta1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from .types.cloud_redis import MaintenanceSchedule
from .types.cloud_redis import NodeInfo
from .types.cloud_redis import OutputConfig
from .types.cloud_redis import PersistenceConfig
from .types.cloud_redis import RescheduleMaintenanceRequest
from .types.cloud_redis import TlsCertificate
from .types.cloud_redis import UpdateInstanceRequest
Expand Down Expand Up @@ -65,6 +66,7 @@
"MaintenanceSchedule",
"NodeInfo",
"OutputConfig",
"PersistenceConfig",
"RescheduleMaintenanceRequest",
"TlsCertificate",
"UpdateInstanceRequest",
Expand Down
2 changes: 2 additions & 0 deletions google/cloud/redis_v1beta1/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
MaintenanceSchedule,
NodeInfo,
OutputConfig,
PersistenceConfig,
RescheduleMaintenanceRequest,
TlsCertificate,
UpdateInstanceRequest,
Expand Down Expand Up @@ -61,6 +62,7 @@
"MaintenanceSchedule",
"NodeInfo",
"OutputConfig",
"PersistenceConfig",
"RescheduleMaintenanceRequest",
"TlsCertificate",
"UpdateInstanceRequest",
Expand Down
57 changes: 57 additions & 0 deletions google/cloud/redis_v1beta1/types/cloud_redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
manifest={
"NodeInfo",
"Instance",
"PersistenceConfig",
"RescheduleMaintenanceRequest",
"MaintenancePolicy",
"WeeklyMaintenanceWindow",
Expand Down Expand Up @@ -230,6 +231,9 @@ class Instance(proto.Message):
read_replicas_mode (google.cloud.redis_v1beta1.types.Instance.ReadReplicasMode):
Optional. Read replica mode. Can only be
specified when trying to create the instance.
persistence_config (google.cloud.redis_v1beta1.types.PersistenceConfig):
Optional. Persistence configuration
parameters
"""

class State(proto.Enum):
Expand Down Expand Up @@ -307,6 +311,59 @@ class ReadReplicasMode(proto.Enum):
read_endpoint = proto.Field(proto.STRING, number=33,)
read_endpoint_port = proto.Field(proto.INT32, number=34,)
read_replicas_mode = proto.Field(proto.ENUM, number=35, enum=ReadReplicasMode,)
persistence_config = proto.Field(
proto.MESSAGE, number=37, message="PersistenceConfig",
)


class PersistenceConfig(proto.Message):
r"""Configuration of the persistence functionality.

Attributes:
persistence_mode (google.cloud.redis_v1beta1.types.PersistenceConfig.PersistenceMode):
Optional. Controls whether Persistence
features are enabled. If not provided, the
existing value will be used.
rdb_snapshot_period (google.cloud.redis_v1beta1.types.PersistenceConfig.SnapshotPeriod):
Optional. Period between RDB snapshots. Snapshots will be
attempted every period starting from the provided snapshot
start time. For example, a start time of 01/01/2033 06:45
and SIX_HOURS snapshot period will do nothing until
01/01/2033, and then trigger snapshots every day at 06:45,
12:45, 18:45, and 00:45 the next day, and so on. If not
provided, TWENTY_FOUR_HOURS will be used as default.
rdb_next_snapshot_time (google.protobuf.timestamp_pb2.Timestamp):
Output only. The next time that a snapshot
attempt is scheduled to occur.
rdb_snapshot_start_time (google.protobuf.timestamp_pb2.Timestamp):
Optional. Date and time that the first
snapshot was/will be attempted, and to which
future snapshots will be aligned. If not
provided, the current time will be used.
"""

class PersistenceMode(proto.Enum):
r"""Available Persistence modes."""
PERSISTENCE_MODE_UNSPECIFIED = 0
DISABLED = 1
RDB = 2

class SnapshotPeriod(proto.Enum):
r"""Available snapshot periods for scheduling."""
SNAPSHOT_PERIOD_UNSPECIFIED = 0
ONE_HOUR = 3
SIX_HOURS = 4
TWELVE_HOURS = 5
TWENTY_FOUR_HOURS = 6

persistence_mode = proto.Field(proto.ENUM, number=1, enum=PersistenceMode,)
rdb_snapshot_period = proto.Field(proto.ENUM, number=2, enum=SnapshotPeriod,)
rdb_next_snapshot_time = proto.Field(
proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,
)
rdb_snapshot_start_time = proto.Field(
proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,
)


class RescheduleMaintenanceRequest(proto.Message):
Expand Down