@@ -63,13 +63,13 @@ type Result struct {
63
63
Trace * traceutil.Trace
64
64
}
65
65
66
- type applyFunc func (r * pb.InternalRaftRequest ) * Result
66
+ type applyFunc func (* pb.InternalRaftRequest , membership. ShouldApplyV3 ) * Result
67
67
68
68
// applierV3 is the interface for processing V3 raft messages
69
69
type applierV3 interface {
70
70
// Apply executes the generic portion of application logic for the current applier, but
71
71
// delegates the actual execution to the applyFunc method.
72
- Apply (r * pb.InternalRaftRequest , applyFunc applyFunc ) * Result
72
+ Apply (r * pb.InternalRaftRequest , shouldApplyV3 membership. ShouldApplyV3 , applyFunc applyFunc ) * Result
73
73
74
74
Put (p * pb.PutRequest ) (* pb.PutResponse , * traceutil.Trace , error )
75
75
Range (r * pb.RangeRequest ) (* pb.RangeResponse , * traceutil.Trace , error )
@@ -103,6 +103,9 @@ type applierV3 interface {
103
103
RoleDelete (ua * pb.AuthRoleDeleteRequest ) (* pb.AuthRoleDeleteResponse , error )
104
104
UserList (ua * pb.AuthUserListRequest ) (* pb.AuthUserListResponse , error )
105
105
RoleList (ua * pb.AuthRoleListRequest ) (* pb.AuthRoleListResponse , error )
106
+ ClusterVersionSet (r * membershippb.ClusterVersionSetRequest , shouldApplyV3 membership.ShouldApplyV3 )
107
+ ClusterMemberAttrSet (r * membershippb.ClusterMemberAttrSetRequest , shouldApplyV3 membership.ShouldApplyV3 )
108
+ DowngradeInfoSet (r * membershippb.DowngradeInfoSetRequest , shouldApplyV3 membership.ShouldApplyV3 )
106
109
}
107
110
108
111
type ApplierOptions struct {
@@ -135,8 +138,8 @@ func newApplierV3Backend(opts ApplierOptions) applierV3 {
135
138
}
136
139
}
137
140
138
- func (a * applierV3backend ) Apply (r * pb.InternalRaftRequest , applyFunc applyFunc ) * Result {
139
- return applyFunc (r )
141
+ func (a * applierV3backend ) Apply (r * pb.InternalRaftRequest , shouldApplyV3 membership. ShouldApplyV3 , applyFunc applyFunc ) * Result {
142
+ return applyFunc (r , shouldApplyV3 )
140
143
}
141
144
142
145
func (a * applierV3backend ) Put (p * pb.PutRequest ) (resp * pb.PutResponse , trace * traceutil.Trace , err error ) {
@@ -384,39 +387,25 @@ func (a *applierV3backend) RoleList(r *pb.AuthRoleListRequest) (*pb.AuthRoleList
384
387
return resp , err
385
388
}
386
389
387
- type ApplierMembership struct {
388
- lg * zap.Logger
389
- cluster * membership.RaftCluster
390
- snapshotServer SnapshotServer
391
- }
392
-
393
- func NewApplierMembership (lg * zap.Logger , cluster * membership.RaftCluster , snapshotServer SnapshotServer ) * ApplierMembership {
394
- return & ApplierMembership {
395
- lg : lg ,
396
- cluster : cluster ,
397
- snapshotServer : snapshotServer ,
398
- }
399
- }
400
-
401
- func (a * ApplierMembership ) ClusterVersionSet (r * membershippb.ClusterVersionSetRequest , shouldApplyV3 membership.ShouldApplyV3 ) {
402
- prevVersion := a .cluster .Version ()
390
+ func (a * applierV3backend ) ClusterVersionSet (r * membershippb.ClusterVersionSetRequest , shouldApplyV3 membership.ShouldApplyV3 ) {
391
+ prevVersion := a .options .Cluster .Version ()
403
392
newVersion := semver .Must (semver .NewVersion (r .Ver ))
404
- a .cluster .SetVersion (newVersion , api .UpdateCapability , shouldApplyV3 )
393
+ a .options . Cluster .SetVersion (newVersion , api .UpdateCapability , shouldApplyV3 )
405
394
// Force snapshot after cluster version downgrade.
406
395
if prevVersion != nil && newVersion .LessThan (* prevVersion ) {
407
- lg := a .lg
396
+ lg := a .options . Logger
408
397
if lg != nil {
409
398
lg .Info ("Cluster version downgrade detected, forcing snapshot" ,
410
399
zap .String ("prev-cluster-version" , prevVersion .String ()),
411
400
zap .String ("new-cluster-version" , newVersion .String ()),
412
401
)
413
402
}
414
- a .snapshotServer .ForceSnapshot ()
403
+ a .options . SnapshotServer .ForceSnapshot ()
415
404
}
416
405
}
417
406
418
- func (a * ApplierMembership ) ClusterMemberAttrSet (r * membershippb.ClusterMemberAttrSetRequest , shouldApplyV3 membership.ShouldApplyV3 ) {
419
- a .cluster .UpdateAttributes (
407
+ func (a * applierV3backend ) ClusterMemberAttrSet (r * membershippb.ClusterMemberAttrSetRequest , shouldApplyV3 membership.ShouldApplyV3 ) {
408
+ a .options . Cluster .UpdateAttributes (
420
409
types .ID (r .Member_ID ),
421
410
membership.Attributes {
422
411
Name : r .MemberAttributes .Name ,
@@ -426,12 +415,12 @@ func (a *ApplierMembership) ClusterMemberAttrSet(r *membershippb.ClusterMemberAt
426
415
)
427
416
}
428
417
429
- func (a * ApplierMembership ) DowngradeInfoSet (r * membershippb.DowngradeInfoSetRequest , shouldApplyV3 membership.ShouldApplyV3 ) {
418
+ func (a * applierV3backend ) DowngradeInfoSet (r * membershippb.DowngradeInfoSetRequest , shouldApplyV3 membership.ShouldApplyV3 ) {
430
419
d := version.DowngradeInfo {Enabled : false }
431
420
if r .Enabled {
432
421
d = version.DowngradeInfo {Enabled : true , TargetVersion : r .Ver }
433
422
}
434
- a .cluster .SetDowngradeInfo (& d , shouldApplyV3 )
423
+ a .options . Cluster .SetDowngradeInfo (& d , shouldApplyV3 )
435
424
}
436
425
437
426
type quotaApplierV3 struct {
0 commit comments