Google Cloud Bigtable C++ Client 2.13.0
A C++ Client Library for Google Cloud Bigtable
Loading...
Searching...
No Matches
idempotent_mutation_policy.h
1// Copyright 2017 Google Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_IDEMPOTENT_MUTATION_POLICY_H
16#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_IDEMPOTENT_MUTATION_POLICY_H
17
18#include "google/cloud/bigtable/mutations.h"
19#include "google/cloud/bigtable/version.h"
20#include <memory>
21
22namespace google {
23namespace cloud {
24namespace bigtable {
25GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
26
27/**
28 * Defines the interface to control which mutations are idempotent and therefore
29 * can be re-tried.
30 */
32 public:
33 virtual ~IdempotentMutationPolicy() = default;
34
35 /// Return a copy of the policy.
36 virtual std::unique_ptr<IdempotentMutationPolicy> clone() const = 0;
37
38 /// Return true if the mutation is idempotent.
39 virtual bool is_idempotent(google::bigtable::v2::Mutation const&) = 0;
40 /// Return true if a conditional mutation is idempotent
41 virtual bool is_idempotent(
42 google::bigtable::v2::CheckAndMutateRowRequest const&) = 0;
43};
44
45/// Return an instance of the default IdempotentMutationPolicy.
47
48/**
49 * Implements a policy that only accepts truly idempotent mutations.
50 *
51 * This policy accepts only truly idempotent mutations, that is, it rejects
52 * mutations where the server sets the timestamp. Some applications may find
53 * this too restrictive and can set their own policies if they wish.
54 */
56 public:
58
59 std::unique_ptr<IdempotentMutationPolicy> clone() const override;
60 bool is_idempotent(google::bigtable::v2::Mutation const&) override;
61 bool is_idempotent(
62 google::bigtable::v2::CheckAndMutateRowRequest const&) override;
63};
64
65/**
66 * Implements a policy that retries all mutations.
67 *
68 * Notice that this will may result in non-idempotent mutations being resent
69 * to the server. Re-trying a SetCell() mutation where the server selects the
70 * timestamp can result in multiple copies of the data stored with different
71 * timestamps. Only use this policy if your application is prepared to handle
72 * such problems, for example, by only querying the last value and setting
73 * garbage collection policies to delete the old values.
74 */
76 public:
77 AlwaysRetryMutationPolicy() = default;
78
79 std::unique_ptr<IdempotentMutationPolicy> clone() const override;
80 bool is_idempotent(google::bigtable::v2::Mutation const&) override;
81 bool is_idempotent(
82 google::bigtable::v2::CheckAndMutateRowRequest const&) override;
83};
84
85GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
86} // namespace bigtable
87} // namespace cloud
88} // namespace google
89
90#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_IDEMPOTENT_MUTATION_POLICY_H
Implements a policy that retries all mutations.
Definition: idempotent_mutation_policy.h:75
bool is_idempotent(google::bigtable::v2::Mutation const &) override
Return true if the mutation is idempotent.
std::unique_ptr< IdempotentMutationPolicy > clone() const override
Return a copy of the policy.
bool is_idempotent(google::bigtable::v2::CheckAndMutateRowRequest const &) override
Return true if a conditional mutation is idempotent.
Defines the interface to control which mutations are idempotent and therefore can be re-tried.
Definition: idempotent_mutation_policy.h:31
virtual bool is_idempotent(google::bigtable::v2::Mutation const &)=0
Return true if the mutation is idempotent.
virtual std::unique_ptr< IdempotentMutationPolicy > clone() const =0
Return a copy of the policy.
virtual bool is_idempotent(google::bigtable::v2::CheckAndMutateRowRequest const &)=0
Return true if a conditional mutation is idempotent.
Implements a policy that only accepts truly idempotent mutations.
Definition: idempotent_mutation_policy.h:55
bool is_idempotent(google::bigtable::v2::Mutation const &) override
Return true if the mutation is idempotent.
bool is_idempotent(google::bigtable::v2::CheckAndMutateRowRequest const &) override
Return true if a conditional mutation is idempotent.
std::unique_ptr< IdempotentMutationPolicy > clone() const override
Return a copy of the policy.
Contains all the Cloud Bigtable C++ client APIs.
Definition: admin_client.h:28
std::unique_ptr< IdempotentMutationPolicy > DefaultIdempotentMutationPolicy()
Return an instance of the default IdempotentMutationPolicy.