Skip to content

Commit

Permalink
Remove RequestV2
Browse files Browse the repository at this point in the history
Signed-off-by: Marek Siarkowicz <[email protected]>
  • Loading branch information
serathius committed Nov 19, 2023
1 parent d47cb7b commit b162002
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 43 deletions.
15 changes: 2 additions & 13 deletions server/etcdserver/apply_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,21 @@ package etcdserver
import (
"encoding/json"
"path"
"time"

"github.com/coreos/go-semver/semver"

"go.etcd.io/etcd/server/v3/etcdserver/api"

"go.uber.org/zap"

"go.etcd.io/etcd/pkg/v3/pbutil"
pb "go.etcd.io/etcd/api/v3/etcdserverpb"
"go.etcd.io/etcd/server/v3/etcdserver/api/membership"
"go.etcd.io/etcd/server/v3/etcdserver/api/v2store"
"go.etcd.io/etcd/server/v3/etcdserver/errors"
)

// applyV2Request interprets r as a call to v2store.X
// and returns a Response interpreted from v2store.Event
func (s *EtcdServer) applyV2Request(r *RequestV2, shouldApplyV3 membership.ShouldApplyV3) (resp Response) {
func (s *EtcdServer) applyV2Request(r *pb.Request, shouldApplyV3 membership.ShouldApplyV3) (resp Response) {
switch r.Method {
case "PUT":
if storeMemberAttributeRegexp.MatchString(r.Path) {
Expand All @@ -60,12 +58,3 @@ func (s *EtcdServer) applyV2Request(r *RequestV2, shouldApplyV3 membership.Shoul
return Response{Err: errors.ErrUnknownMethod}
}
}

func (r *RequestV2) TTLOptions() v2store.TTLOptionSet {
refresh, _ := pbutil.GetBool(r.Refresh)
ttlOptions := v2store.TTLOptionSet{Refresh: refresh}
if r.Expiration != 0 {
ttlOptions.ExpireTime = time.Unix(0, r.Expiration)
}
return ttlOptions
}
5 changes: 2 additions & 3 deletions server/etcdserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1897,14 +1897,13 @@ func (s *EtcdServer) applyEntryNormal(e *raftpb.Entry) {
rp := &r
pbutil.MustUnmarshal(rp, e.Data)
s.lg.Debug("applyEntryNormal", zap.Stringer("V2request", rp))
s.w.Trigger(r.ID, s.applyV2Request((*RequestV2)(rp), shouldApplyV3))
s.w.Trigger(r.ID, s.applyV2Request(rp, shouldApplyV3))
return
}
s.lg.Debug("applyEntryNormal", zap.Stringer("raftReq", &raftReq))

if raftReq.V2 != nil {
req := (*RequestV2)(raftReq.V2)
s.w.Trigger(req.ID, s.applyV2Request(req, shouldApplyV3))
s.w.Trigger(raftReq.V2.ID, s.applyV2Request(raftReq.V2, shouldApplyV3))
return
}

Expand Down
2 changes: 1 addition & 1 deletion server/etcdserver/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func TestApplyRequestOnAdminMemberAttributes(t *testing.T) {
Path: membership.MemberAttributesStorePath(1),
Val: `{"Name":"abc","ClientURLs":["http://127.0.0.1:2379"]}`,
}
srv.applyV2Request((*RequestV2)(&req), membership.ApplyBoth)
srv.applyV2Request(&req, membership.ApplyBoth)
w := membership.Attributes{Name: "abc", ClientURLs: []string{"http://127.0.0.1:2379"}}
if g := cl.Member(1).Attributes; !reflect.DeepEqual(g, w) {
t.Errorf("attributes = %v, want %v", g, w)
Expand Down
26 changes: 0 additions & 26 deletions server/etcdserver/v2_server.go

This file was deleted.

0 comments on commit b162002

Please sign in to comment.