diff --git a/changelog/20.0/20.0.0/summary.md b/changelog/20.0/20.0.0/summary.md
index 49642dc8734..3845f8aced5 100644
--- a/changelog/20.0/20.0.0/summary.md
+++ b/changelog/20.0/20.0.0/summary.md
@@ -7,6 +7,7 @@
- [`shutdown_grace_period` Default Change](#shutdown-grace-period-default)
- [New `unmanaged` Flag and `disable_active_reparents` deprecation](#unmanaged-flag)
- [`mysqlctld` `onterm-timeout` Default Change](#mysqlctld-onterm-timeout)
+ - [`Durabler` interface method renaming](#durabler-interface-method-renaming)
- **[Query Compatibility](#query-compatibility)**
- [Vindex Hints](#vindex-hints)
- [Update with Limit Support](#update-limit)
@@ -45,6 +46,17 @@ The `--onterm_timeout` flag default value has changed for `mysqlctld`. It now is
This is necessary since otherwise MySQL would never shut down cleanly with the old defaults, since `mysqlctld` would shut down already after 10 seconds by default.
+#### `Durabler` interface method renaming
+
+The methods of [the `Durabler` interface](https://github.com/vitessio/vitess/blob/main/go/vt/vtctl/reparentutil/durability.go#L70-L79) in `go/vt/vtctl/reparentutil` were renamed to be public _(capitalized)_ methods to make it easier to integrate custom Durability Policies from external packages. See [RFC for details](https://github.com/vitessio/vitess/issues/15544).
+
+Users of custom Durability Policies must rename private `Durabler` methods.
+
+Changes:
+- The `promotionRule` method was renamed to `PromotionRule`
+- The `semiSyncAckers` method was renamed to `SemiSyncAckers`
+- The `isReplicaSemiSync` method was renamed to `IsReplicaSemiSync`
+
### Query Compatibility
#### Vindex Hints
diff --git a/go/vt/vtctl/reparentutil/durability.go b/go/vt/vtctl/reparentutil/durability.go
index e68485a395c..29a5b2e712a 100644
--- a/go/vt/vtctl/reparentutil/durability.go
+++ b/go/vt/vtctl/reparentutil/durability.go
@@ -69,13 +69,13 @@ func init() {
// Durabler is the interface which is used to get the promotion rules for candidates and the semi sync setup
type Durabler interface {
- // promotionRule represents the precedence in which we want to tablets to be promoted.
+ // PromotionRule represents the precedence in which we want to tablets to be promoted.
// The higher the promotion rule of a tablet, the more we want it to be promoted in case of a failover
- promotionRule(*topodatapb.Tablet) promotionrule.CandidatePromotionRule
- // semiSyncAckers represents the number of semi-sync ackers required for a given tablet if it were to become the PRIMARY instance
- semiSyncAckers(*topodatapb.Tablet) int
- // isReplicaSemiSync returns whether the "replica" should send semi-sync acks if "primary" were to become the PRIMARY instance
- isReplicaSemiSync(primary, replica *topodatapb.Tablet) bool
+ PromotionRule(*topodatapb.Tablet) promotionrule.CandidatePromotionRule
+ // SemiSyncAckers represents the number of semi-sync ackers required for a given tablet if it were to become the PRIMARY instance
+ SemiSyncAckers(*topodatapb.Tablet) int
+ // IsReplicaSemiSync returns whether the "replica" should send semi-sync acks if "primary" were to become the PRIMARY instance
+ IsReplicaSemiSync(primary, replica *topodatapb.Tablet) bool
}
func RegisterDurability(name string, newDurablerFunc NewDurabler) {
@@ -108,13 +108,13 @@ func PromotionRule(durability Durabler, tablet *topodatapb.Tablet) promotionrule
if tablet == nil || tablet.Alias == nil {
return promotionrule.MustNot
}
- return durability.promotionRule(tablet)
+ return durability.PromotionRule(tablet)
}
// SemiSyncAckers returns the primary semi-sync setting for the instance.
// 0 means none. Non-zero specifies the number of required ackers.
func SemiSyncAckers(durability Durabler, tablet *topodatapb.Tablet) int {
- return durability.semiSyncAckers(tablet)
+ return durability.SemiSyncAckers(tablet)
}
// IsReplicaSemiSync returns the replica semi-sync setting from the tablet record.
@@ -124,7 +124,7 @@ func IsReplicaSemiSync(durability Durabler, primary, replica *topodatapb.Tablet)
if primary == nil || primary.Alias == nil || replica == nil || replica.Alias == nil {
return false
}
- return durability.isReplicaSemiSync(primary, replica)
+ return durability.IsReplicaSemiSync(primary, replica)
}
//=======================================================================
@@ -132,8 +132,8 @@ func IsReplicaSemiSync(durability Durabler, primary, replica *topodatapb.Tablet)
// durabilityNone has no semi-sync and returns NeutralPromoteRule for Primary and Replica tablet types, MustNotPromoteRule for everything else
type durabilityNone struct{}
-// promotionRule implements the Durabler interface
-func (d *durabilityNone) promotionRule(tablet *topodatapb.Tablet) promotionrule.CandidatePromotionRule {
+// PromotionRule implements the Durabler interface
+func (d *durabilityNone) PromotionRule(tablet *topodatapb.Tablet) promotionrule.CandidatePromotionRule {
switch tablet.Type {
case topodatapb.TabletType_PRIMARY, topodatapb.TabletType_REPLICA:
return promotionrule.Neutral
@@ -141,13 +141,13 @@ func (d *durabilityNone) promotionRule(tablet *topodatapb.Tablet) promotionrule.
return promotionrule.MustNot
}
-// semiSyncAckers implements the Durabler interface
-func (d *durabilityNone) semiSyncAckers(tablet *topodatapb.Tablet) int {
+// SemiSyncAckers implements the Durabler interface
+func (d *durabilityNone) SemiSyncAckers(tablet *topodatapb.Tablet) int {
return 0
}
-// isReplicaSemiSync implements the Durabler interface
-func (d *durabilityNone) isReplicaSemiSync(primary, replica *topodatapb.Tablet) bool {
+// IsReplicaSemiSync implements the Durabler interface
+func (d *durabilityNone) IsReplicaSemiSync(primary, replica *topodatapb.Tablet) bool {
return false
}
@@ -159,8 +159,8 @@ type durabilitySemiSync struct {
rdonlySemiSync bool
}
-// promotionRule implements the Durabler interface
-func (d *durabilitySemiSync) promotionRule(tablet *topodatapb.Tablet) promotionrule.CandidatePromotionRule {
+// PromotionRule implements the Durabler interface
+func (d *durabilitySemiSync) PromotionRule(tablet *topodatapb.Tablet) promotionrule.CandidatePromotionRule {
switch tablet.Type {
case topodatapb.TabletType_PRIMARY, topodatapb.TabletType_REPLICA:
return promotionrule.Neutral
@@ -168,13 +168,13 @@ func (d *durabilitySemiSync) promotionRule(tablet *topodatapb.Tablet) promotionr
return promotionrule.MustNot
}
-// semiSyncAckers implements the Durabler interface
-func (d *durabilitySemiSync) semiSyncAckers(tablet *topodatapb.Tablet) int {
+// SemiSyncAckers implements the Durabler interface
+func (d *durabilitySemiSync) SemiSyncAckers(tablet *topodatapb.Tablet) int {
return 1
}
-// isReplicaSemiSync implements the Durabler interface
-func (d *durabilitySemiSync) isReplicaSemiSync(primary, replica *topodatapb.Tablet) bool {
+// IsReplicaSemiSync implements the Durabler interface
+func (d *durabilitySemiSync) IsReplicaSemiSync(primary, replica *topodatapb.Tablet) bool {
switch replica.Type {
case topodatapb.TabletType_PRIMARY, topodatapb.TabletType_REPLICA:
return true
@@ -193,8 +193,8 @@ type durabilityCrossCell struct {
rdonlySemiSync bool
}
-// promotionRule implements the Durabler interface
-func (d *durabilityCrossCell) promotionRule(tablet *topodatapb.Tablet) promotionrule.CandidatePromotionRule {
+// PromotionRule implements the Durabler interface
+func (d *durabilityCrossCell) PromotionRule(tablet *topodatapb.Tablet) promotionrule.CandidatePromotionRule {
switch tablet.Type {
case topodatapb.TabletType_PRIMARY, topodatapb.TabletType_REPLICA:
return promotionrule.Neutral
@@ -202,13 +202,13 @@ func (d *durabilityCrossCell) promotionRule(tablet *topodatapb.Tablet) promotion
return promotionrule.MustNot
}
-// semiSyncAckers implements the Durabler interface
-func (d *durabilityCrossCell) semiSyncAckers(tablet *topodatapb.Tablet) int {
+// SemiSyncAckers implements the Durabler interface
+func (d *durabilityCrossCell) SemiSyncAckers(tablet *topodatapb.Tablet) int {
return 1
}
-// isReplicaSemiSync implements the Durabler interface
-func (d *durabilityCrossCell) isReplicaSemiSync(primary, replica *topodatapb.Tablet) bool {
+// IsReplicaSemiSync implements the Durabler interface
+func (d *durabilityCrossCell) IsReplicaSemiSync(primary, replica *topodatapb.Tablet) bool {
switch replica.Type {
case topodatapb.TabletType_PRIMARY, topodatapb.TabletType_REPLICA:
return primary.Alias.Cell != replica.Alias.Cell
@@ -223,8 +223,8 @@ func (d *durabilityCrossCell) isReplicaSemiSync(primary, replica *topodatapb.Tab
// durabilityTest is like durabilityNone. It overrides the type for a specific tablet to prefer. It is only meant to be used for testing purposes!
type durabilityTest struct{}
-// promotionRule implements the Durabler interface
-func (d *durabilityTest) promotionRule(tablet *topodatapb.Tablet) promotionrule.CandidatePromotionRule {
+// PromotionRule implements the Durabler interface
+func (d *durabilityTest) PromotionRule(tablet *topodatapb.Tablet) promotionrule.CandidatePromotionRule {
if topoproto.TabletAliasString(tablet.Alias) == "zone2-0000000200" {
return promotionrule.Prefer
}
@@ -236,12 +236,12 @@ func (d *durabilityTest) promotionRule(tablet *topodatapb.Tablet) promotionrule.
return promotionrule.MustNot
}
-// semiSyncAckers implements the Durabler interface
-func (d *durabilityTest) semiSyncAckers(tablet *topodatapb.Tablet) int {
+// SemiSyncAckers implements the Durabler interface
+func (d *durabilityTest) SemiSyncAckers(tablet *topodatapb.Tablet) int {
return 0
}
-// isReplicaSemiSync implements the Durabler interface
-func (d *durabilityTest) isReplicaSemiSync(primary, replica *topodatapb.Tablet) bool {
+// IsReplicaSemiSync implements the Durabler interface
+func (d *durabilityTest) IsReplicaSemiSync(primary, replica *topodatapb.Tablet) bool {
return false
}
diff --git a/go/vt/vtctl/reparentutil/durability_test.go b/go/vt/vtctl/reparentutil/durability_test.go
index f1429b29621..5745da64f7e 100644
--- a/go/vt/vtctl/reparentutil/durability_test.go
+++ b/go/vt/vtctl/reparentutil/durability_test.go
@@ -326,7 +326,7 @@ func TestDurabilityTest(t *testing.T) {
for _, testcase := range testcases {
t.Run(topoproto.TabletAliasString(testcase.tablet.Alias), func(t *testing.T) {
- rule := durabilityRules.promotionRule(testcase.tablet)
+ rule := durabilityRules.PromotionRule(testcase.tablet)
assert.Equal(t, testcase.promotionRule, rule)
})
}