failoverShard method

Future<FailoverShardResponse> failoverShard({
  1. required String clusterName,
  2. required String shardName,
})

Used to failover a shard. This API is designed for testing the behavior of your application in case of MemoryDB failover. It is not designed to be used as a production-level tool for initiating a failover to overcome a problem you may have with the cluster. Moreover, in certain conditions such as large scale operational events, Amazon may block this API.

May throw APICallRateForCustomerExceededFault. May throw ClusterNotFoundFault. May throw InvalidClusterStateFault. May throw InvalidKMSKeyFault. May throw InvalidParameterCombinationException. May throw InvalidParameterValueException. May throw ShardNotFoundFault. May throw TestFailoverNotAvailableFault.

Parameter clusterName : The cluster being failed over.

Parameter shardName : The name of the shard.

Implementation

Future<FailoverShardResponse> failoverShard({
  required String clusterName,
  required String shardName,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AmazonMemoryDB.FailoverShard'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ClusterName': clusterName,
      'ShardName': shardName,
    },
  );

  return FailoverShardResponse.fromJson(jsonResponse.body);
}