async function scaleMemorystoreCluster()

in src/scaler/scaler-core/index.js [296:337]


async function scaleMemorystoreCluster(cluster, suggestedSize) {
  logger.info({
    message: `----- ${cluster.projectId}/${cluster.regionId}/${cluster.clusterId}: Scaling Memorystore cluster to ${suggestedSize} ${cluster.units} -----`,
    projectId: cluster.projectId,
    regionId: cluster.regionId,
    clusterId: cluster.clusterId,
    payload: cluster,
  });

  const updateMask = {
    paths: ['shard_count'],
  };

  const requestRedis = {
    cluster: {
      name: `projects/${cluster.projectId}/locations/${cluster.regionId}/clusters/${cluster.clusterId}`,
      shardCount: suggestedSize,
    },
    updateMask: updateMask,
  };

  const requestValkey = {
    instance: {
      name: `projects/${cluster.projectId}/locations/${cluster.regionId}/instances/${cluster.clusterId}`,
      shardCount: suggestedSize,
    },
    updateMask: updateMask,
  };

  const [operation] =
    cluster.engine === AutoscalerEngine.REDIS
      ? await memorystoreRedisClient.updateCluster(requestRedis)
      : await memorystoreValkeyClient.updateInstance(requestValkey);

  logger.debug({
    message: `Started the scaling operation: ${operation.name}`,
    projectId: cluster.projectId,
    regionId: cluster.regionId,
    clusterId: cluster.clusterId,
  });
  return operation?.name || null;
}