[VOL-4291] Rw-core updates for gRPC migration
Change-Id: I8d5a554409115b29318089671ca4e1ab3fa98810
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/capability.go b/vendor/go.etcd.io/etcd/etcdserver/api/capability.go
deleted file mode 100644
index 09b754d..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/capability.go
+++ /dev/null
@@ -1,99 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package api
-
-import (
- "sync"
-
- "go.etcd.io/etcd/version"
- "go.uber.org/zap"
-
- "github.com/coreos/go-semver/semver"
- "github.com/coreos/pkg/capnslog"
-)
-
-type Capability string
-
-const (
- AuthCapability Capability = "auth"
- V3rpcCapability Capability = "v3rpc"
-)
-
-var (
- plog = capnslog.NewPackageLogger("go.etcd.io/etcd", "etcdserver/api")
-
- // capabilityMaps is a static map of version to capability map.
- capabilityMaps = map[string]map[Capability]bool{
- "3.0.0": {AuthCapability: true, V3rpcCapability: true},
- "3.1.0": {AuthCapability: true, V3rpcCapability: true},
- "3.2.0": {AuthCapability: true, V3rpcCapability: true},
- "3.3.0": {AuthCapability: true, V3rpcCapability: true},
- "3.4.0": {AuthCapability: true, V3rpcCapability: true},
- "3.5.0": {AuthCapability: true, V3rpcCapability: true},
- }
-
- enableMapMu sync.RWMutex
- // enabledMap points to a map in capabilityMaps
- enabledMap map[Capability]bool
-
- curVersion *semver.Version
-)
-
-func init() {
- enabledMap = map[Capability]bool{
- AuthCapability: true,
- V3rpcCapability: true,
- }
-}
-
-// UpdateCapability updates the enabledMap when the cluster version increases.
-func UpdateCapability(lg *zap.Logger, v *semver.Version) {
- if v == nil {
- // if recovered but version was never set by cluster
- return
- }
- enableMapMu.Lock()
- if curVersion != nil && !curVersion.LessThan(*v) {
- enableMapMu.Unlock()
- return
- }
- curVersion = v
- enabledMap = capabilityMaps[curVersion.String()]
- enableMapMu.Unlock()
-
- if lg != nil {
- lg.Info(
- "enabled capabilities for version",
- zap.String("cluster-version", version.Cluster(v.String())),
- )
- } else {
- plog.Infof("enabled capabilities for version %s", version.Cluster(v.String()))
- }
-}
-
-func IsCapabilityEnabled(c Capability) bool {
- enableMapMu.RLock()
- defer enableMapMu.RUnlock()
- if enabledMap == nil {
- return false
- }
- return enabledMap[c]
-}
-
-func EnableCapability(c Capability) {
- enableMapMu.Lock()
- defer enableMapMu.Unlock()
- enabledMap[c] = true
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/cluster.go b/vendor/go.etcd.io/etcd/etcdserver/api/cluster.go
deleted file mode 100644
index 901be9d..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/cluster.go
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2016 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package api
-
-import (
- "go.etcd.io/etcd/etcdserver/api/membership"
- "go.etcd.io/etcd/pkg/types"
-
- "github.com/coreos/go-semver/semver"
-)
-
-// Cluster is an interface representing a collection of members in one etcd cluster.
-type Cluster interface {
- // ID returns the cluster ID
- ID() types.ID
- // ClientURLs returns an aggregate set of all URLs on which this
- // cluster is listening for client requests
- ClientURLs() []string
- // Members returns a slice of members sorted by their ID
- Members() []*membership.Member
- // Member retrieves a particular member based on ID, or nil if the
- // member does not exist in the cluster
- Member(id types.ID) *membership.Member
- // Version is the cluster-wide minimum major.minor version.
- Version() *semver.Version
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/doc.go b/vendor/go.etcd.io/etcd/etcdserver/api/doc.go
deleted file mode 100644
index f44881b..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/doc.go
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2016 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package api manages the capabilities and features that are exposed to clients by the etcd cluster.
-package api
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/etcdhttp/base.go b/vendor/go.etcd.io/etcd/etcdserver/api/etcdhttp/base.go
deleted file mode 100644
index c9df62e..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/etcdhttp/base.go
+++ /dev/null
@@ -1,203 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package etcdhttp
-
-import (
- "encoding/json"
- "expvar"
- "fmt"
- "net/http"
- "strings"
-
- "go.etcd.io/etcd/etcdserver"
- "go.etcd.io/etcd/etcdserver/api"
- "go.etcd.io/etcd/etcdserver/api/v2error"
- "go.etcd.io/etcd/etcdserver/api/v2http/httptypes"
- "go.etcd.io/etcd/pkg/logutil"
- "go.etcd.io/etcd/version"
-
- "github.com/coreos/pkg/capnslog"
- "go.uber.org/zap"
-)
-
-var (
- plog = capnslog.NewPackageLogger("go.etcd.io/etcd", "etcdserver/api/etcdhttp")
- mlog = logutil.NewMergeLogger(plog)
-)
-
-const (
- configPath = "/config"
- varsPath = "/debug/vars"
- versionPath = "/version"
-)
-
-// HandleBasic adds handlers to a mux for serving JSON etcd client requests
-// that do not access the v2 store.
-func HandleBasic(mux *http.ServeMux, server etcdserver.ServerPeer) {
- mux.HandleFunc(varsPath, serveVars)
-
- // TODO: deprecate '/config/local/log' in v3.5
- mux.HandleFunc(configPath+"/local/log", logHandleFunc)
-
- HandleMetricsHealth(mux, server)
- mux.HandleFunc(versionPath, versionHandler(server.Cluster(), serveVersion))
-}
-
-func versionHandler(c api.Cluster, fn func(http.ResponseWriter, *http.Request, string)) http.HandlerFunc {
- return func(w http.ResponseWriter, r *http.Request) {
- v := c.Version()
- if v != nil {
- fn(w, r, v.String())
- } else {
- fn(w, r, "not_decided")
- }
- }
-}
-
-func serveVersion(w http.ResponseWriter, r *http.Request, clusterV string) {
- if !allowMethod(w, r, "GET") {
- return
- }
- vs := version.Versions{
- Server: version.Version,
- Cluster: clusterV,
- }
-
- w.Header().Set("Content-Type", "application/json")
- b, err := json.Marshal(&vs)
- if err != nil {
- plog.Panicf("cannot marshal versions to json (%v)", err)
- }
- w.Write(b)
-}
-
-// TODO: deprecate '/config/local/log' in v3.5
-func logHandleFunc(w http.ResponseWriter, r *http.Request) {
- if !allowMethod(w, r, "PUT") {
- return
- }
-
- in := struct{ Level string }{}
-
- d := json.NewDecoder(r.Body)
- if err := d.Decode(&in); err != nil {
- WriteError(nil, w, r, httptypes.NewHTTPError(http.StatusBadRequest, "Invalid json body"))
- return
- }
-
- logl, err := capnslog.ParseLevel(strings.ToUpper(in.Level))
- if err != nil {
- WriteError(nil, w, r, httptypes.NewHTTPError(http.StatusBadRequest, "Invalid log level "+in.Level))
- return
- }
-
- plog.Noticef("globalLogLevel set to %q", logl.String())
- capnslog.SetGlobalLogLevel(logl)
- w.WriteHeader(http.StatusNoContent)
-}
-
-func serveVars(w http.ResponseWriter, r *http.Request) {
- if !allowMethod(w, r, "GET") {
- return
- }
-
- w.Header().Set("Content-Type", "application/json; charset=utf-8")
- fmt.Fprintf(w, "{\n")
- first := true
- expvar.Do(func(kv expvar.KeyValue) {
- if !first {
- fmt.Fprintf(w, ",\n")
- }
- first = false
- fmt.Fprintf(w, "%q: %s", kv.Key, kv.Value)
- })
- fmt.Fprintf(w, "\n}\n")
-}
-
-func allowMethod(w http.ResponseWriter, r *http.Request, m string) bool {
- if m == r.Method {
- return true
- }
- w.Header().Set("Allow", m)
- http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
- return false
-}
-
-// WriteError logs and writes the given Error to the ResponseWriter
-// If Error is an etcdErr, it is rendered to the ResponseWriter
-// Otherwise, it is assumed to be a StatusInternalServerError
-func WriteError(lg *zap.Logger, w http.ResponseWriter, r *http.Request, err error) {
- if err == nil {
- return
- }
- switch e := err.(type) {
- case *v2error.Error:
- e.WriteTo(w)
-
- case *httptypes.HTTPError:
- if et := e.WriteTo(w); et != nil {
- if lg != nil {
- lg.Debug(
- "failed to write v2 HTTP error",
- zap.String("remote-addr", r.RemoteAddr),
- zap.String("internal-server-error", e.Error()),
- zap.Error(et),
- )
- } else {
- plog.Debugf("error writing HTTPError (%v) to %s", et, r.RemoteAddr)
- }
- }
-
- default:
- switch err {
- case etcdserver.ErrTimeoutDueToLeaderFail, etcdserver.ErrTimeoutDueToConnectionLost, etcdserver.ErrNotEnoughStartedMembers,
- etcdserver.ErrUnhealthy:
- if lg != nil {
- lg.Warn(
- "v2 response error",
- zap.String("remote-addr", r.RemoteAddr),
- zap.String("internal-server-error", err.Error()),
- )
- } else {
- mlog.MergeError(err)
- }
-
- default:
- if lg != nil {
- lg.Warn(
- "unexpected v2 response error",
- zap.String("remote-addr", r.RemoteAddr),
- zap.String("internal-server-error", err.Error()),
- )
- } else {
- mlog.MergeErrorf("got unexpected response error (%v)", err)
- }
- }
-
- herr := httptypes.NewHTTPError(http.StatusInternalServerError, "Internal Server Error")
- if et := herr.WriteTo(w); et != nil {
- if lg != nil {
- lg.Debug(
- "failed to write v2 HTTP error",
- zap.String("remote-addr", r.RemoteAddr),
- zap.String("internal-server-error", err.Error()),
- zap.Error(et),
- )
- } else {
- plog.Debugf("error writing HTTPError (%v) to %s", et, r.RemoteAddr)
- }
- }
- }
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/etcdhttp/doc.go b/vendor/go.etcd.io/etcd/etcdserver/api/etcdhttp/doc.go
deleted file mode 100644
index a03b626..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/etcdhttp/doc.go
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2017 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package etcdhttp implements HTTP transportation layer for etcdserver.
-package etcdhttp
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/etcdhttp/metrics.go b/vendor/go.etcd.io/etcd/etcdserver/api/etcdhttp/metrics.go
deleted file mode 100644
index f455e40..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/etcdhttp/metrics.go
+++ /dev/null
@@ -1,123 +0,0 @@
-// Copyright 2017 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package etcdhttp
-
-import (
- "context"
- "encoding/json"
- "net/http"
- "time"
-
- "go.etcd.io/etcd/etcdserver"
- "go.etcd.io/etcd/etcdserver/etcdserverpb"
- "go.etcd.io/etcd/raft"
-
- "github.com/prometheus/client_golang/prometheus"
- "github.com/prometheus/client_golang/prometheus/promhttp"
-)
-
-const (
- PathMetrics = "/metrics"
- PathHealth = "/health"
-)
-
-// HandleMetricsHealth registers metrics and health handlers.
-func HandleMetricsHealth(mux *http.ServeMux, srv etcdserver.ServerV2) {
- mux.Handle(PathMetrics, promhttp.Handler())
- mux.Handle(PathHealth, NewHealthHandler(func() Health { return checkHealth(srv) }))
-}
-
-// HandlePrometheus registers prometheus handler on '/metrics'.
-func HandlePrometheus(mux *http.ServeMux) {
- mux.Handle(PathMetrics, promhttp.Handler())
-}
-
-// NewHealthHandler handles '/health' requests.
-func NewHealthHandler(hfunc func() Health) http.HandlerFunc {
- return func(w http.ResponseWriter, r *http.Request) {
- if r.Method != http.MethodGet {
- w.Header().Set("Allow", http.MethodGet)
- http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
- return
- }
- h := hfunc()
- d, _ := json.Marshal(h)
- if h.Health != "true" {
- http.Error(w, string(d), http.StatusServiceUnavailable)
- return
- }
- w.WriteHeader(http.StatusOK)
- w.Write(d)
- }
-}
-
-var (
- healthSuccess = prometheus.NewCounter(prometheus.CounterOpts{
- Namespace: "etcd",
- Subsystem: "server",
- Name: "health_success",
- Help: "The total number of successful health checks",
- })
- healthFailed = prometheus.NewCounter(prometheus.CounterOpts{
- Namespace: "etcd",
- Subsystem: "server",
- Name: "health_failures",
- Help: "The total number of failed health checks",
- })
-)
-
-func init() {
- prometheus.MustRegister(healthSuccess)
- prometheus.MustRegister(healthFailed)
-}
-
-// Health defines etcd server health status.
-// TODO: remove manual parsing in etcdctl cluster-health
-type Health struct {
- Health string `json:"health"`
-}
-
-// TODO: server NOSPACE, etcdserver.ErrNoLeader in health API
-
-func checkHealth(srv etcdserver.ServerV2) Health {
- h := Health{Health: "true"}
-
- as := srv.Alarms()
- if len(as) > 0 {
- h.Health = "false"
- }
-
- if h.Health == "true" {
- if uint64(srv.Leader()) == raft.None {
- h.Health = "false"
- }
- }
-
- if h.Health == "true" {
- ctx, cancel := context.WithTimeout(context.Background(), time.Second)
- _, err := srv.Do(ctx, etcdserverpb.Request{Method: "QGET"})
- cancel()
- if err != nil {
- h.Health = "false"
- }
- }
-
- if h.Health == "true" {
- healthSuccess.Inc()
- } else {
- healthFailed.Inc()
- }
- return h
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/etcdhttp/peer.go b/vendor/go.etcd.io/etcd/etcdserver/api/etcdhttp/peer.go
deleted file mode 100644
index 6c61bf5..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/etcdhttp/peer.go
+++ /dev/null
@@ -1,159 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package etcdhttp
-
-import (
- "encoding/json"
- "fmt"
- "net/http"
- "strconv"
- "strings"
-
- "go.etcd.io/etcd/etcdserver"
- "go.etcd.io/etcd/etcdserver/api"
- "go.etcd.io/etcd/etcdserver/api/membership"
- "go.etcd.io/etcd/etcdserver/api/rafthttp"
- "go.etcd.io/etcd/lease/leasehttp"
- "go.etcd.io/etcd/pkg/types"
-
- "go.uber.org/zap"
-)
-
-const (
- peerMembersPath = "/members"
- peerMemberPromotePrefix = "/members/promote/"
-)
-
-// NewPeerHandler generates an http.Handler to handle etcd peer requests.
-func NewPeerHandler(lg *zap.Logger, s etcdserver.ServerPeer) http.Handler {
- return newPeerHandler(lg, s, s.RaftHandler(), s.LeaseHandler())
-}
-
-func newPeerHandler(lg *zap.Logger, s etcdserver.Server, raftHandler http.Handler, leaseHandler http.Handler) http.Handler {
- peerMembersHandler := newPeerMembersHandler(lg, s.Cluster())
- peerMemberPromoteHandler := newPeerMemberPromoteHandler(lg, s)
-
- mux := http.NewServeMux()
- mux.HandleFunc("/", http.NotFound)
- mux.Handle(rafthttp.RaftPrefix, raftHandler)
- mux.Handle(rafthttp.RaftPrefix+"/", raftHandler)
- mux.Handle(peerMembersPath, peerMembersHandler)
- mux.Handle(peerMemberPromotePrefix, peerMemberPromoteHandler)
- if leaseHandler != nil {
- mux.Handle(leasehttp.LeasePrefix, leaseHandler)
- mux.Handle(leasehttp.LeaseInternalPrefix, leaseHandler)
- }
- mux.HandleFunc(versionPath, versionHandler(s.Cluster(), serveVersion))
- return mux
-}
-
-func newPeerMembersHandler(lg *zap.Logger, cluster api.Cluster) http.Handler {
- return &peerMembersHandler{
- lg: lg,
- cluster: cluster,
- }
-}
-
-type peerMembersHandler struct {
- lg *zap.Logger
- cluster api.Cluster
-}
-
-func newPeerMemberPromoteHandler(lg *zap.Logger, s etcdserver.Server) http.Handler {
- return &peerMemberPromoteHandler{
- lg: lg,
- cluster: s.Cluster(),
- server: s,
- }
-}
-
-type peerMemberPromoteHandler struct {
- lg *zap.Logger
- cluster api.Cluster
- server etcdserver.Server
-}
-
-func (h *peerMembersHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
- if !allowMethod(w, r, "GET") {
- return
- }
- w.Header().Set("X-Etcd-Cluster-ID", h.cluster.ID().String())
-
- if r.URL.Path != peerMembersPath {
- http.Error(w, "bad path", http.StatusBadRequest)
- return
- }
- ms := h.cluster.Members()
- w.Header().Set("Content-Type", "application/json")
- if err := json.NewEncoder(w).Encode(ms); err != nil {
- if h.lg != nil {
- h.lg.Warn("failed to encode membership members", zap.Error(err))
- } else {
- plog.Warningf("failed to encode members response (%v)", err)
- }
- }
-}
-
-func (h *peerMemberPromoteHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
- if !allowMethod(w, r, "POST") {
- return
- }
- w.Header().Set("X-Etcd-Cluster-ID", h.cluster.ID().String())
-
- if !strings.HasPrefix(r.URL.Path, peerMemberPromotePrefix) {
- http.Error(w, "bad path", http.StatusBadRequest)
- return
- }
- idStr := strings.TrimPrefix(r.URL.Path, peerMemberPromotePrefix)
- id, err := strconv.ParseUint(idStr, 10, 64)
- if err != nil {
- http.Error(w, fmt.Sprintf("member %s not found in cluster", idStr), http.StatusNotFound)
- return
- }
-
- resp, err := h.server.PromoteMember(r.Context(), id)
- if err != nil {
- switch err {
- case membership.ErrIDNotFound:
- http.Error(w, err.Error(), http.StatusNotFound)
- case membership.ErrMemberNotLearner:
- http.Error(w, err.Error(), http.StatusPreconditionFailed)
- case etcdserver.ErrLearnerNotReady:
- http.Error(w, err.Error(), http.StatusPreconditionFailed)
- default:
- WriteError(h.lg, w, r, err)
- }
- if h.lg != nil {
- h.lg.Warn(
- "failed to promote a member",
- zap.String("member-id", types.ID(id).String()),
- zap.Error(err),
- )
- } else {
- plog.Errorf("error promoting member %s (%v)", types.ID(id).String(), err)
- }
- return
- }
-
- w.Header().Set("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK)
- if err := json.NewEncoder(w).Encode(resp); err != nil {
- if h.lg != nil {
- h.lg.Warn("failed to encode members response", zap.Error(err))
- } else {
- plog.Warningf("failed to encode members response (%v)", err)
- }
- }
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/membership/cluster.go b/vendor/go.etcd.io/etcd/etcdserver/api/membership/cluster.go
deleted file mode 100644
index 89a6edd..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/membership/cluster.go
+++ /dev/null
@@ -1,841 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package membership
-
-import (
- "bytes"
- "context"
- "crypto/sha1"
- "encoding/binary"
- "encoding/json"
- "fmt"
- "path"
- "sort"
- "strings"
- "sync"
- "time"
-
- "go.etcd.io/etcd/etcdserver/api/v2store"
- "go.etcd.io/etcd/mvcc/backend"
- "go.etcd.io/etcd/pkg/netutil"
- "go.etcd.io/etcd/pkg/types"
- "go.etcd.io/etcd/raft"
- "go.etcd.io/etcd/raft/raftpb"
- "go.etcd.io/etcd/version"
-
- "github.com/coreos/go-semver/semver"
- "github.com/prometheus/client_golang/prometheus"
- "go.uber.org/zap"
-)
-
-const maxLearners = 1
-
-// RaftCluster is a list of Members that belong to the same raft cluster
-type RaftCluster struct {
- lg *zap.Logger
-
- localID types.ID
- cid types.ID
- token string
-
- v2store v2store.Store
- be backend.Backend
-
- sync.Mutex // guards the fields below
- version *semver.Version
- members map[types.ID]*Member
- // removed contains the ids of removed members in the cluster.
- // removed id cannot be reused.
- removed map[types.ID]bool
-}
-
-// ConfigChangeContext represents a context for confChange.
-type ConfigChangeContext struct {
- Member
- // IsPromote indicates if the config change is for promoting a learner member.
- // This flag is needed because both adding a new member and promoting a learner member
- // uses the same config change type 'ConfChangeAddNode'.
- IsPromote bool `json:"isPromote"`
-}
-
-// NewClusterFromURLsMap creates a new raft cluster using provided urls map. Currently, it does not support creating
-// cluster with raft learner member.
-func NewClusterFromURLsMap(lg *zap.Logger, token string, urlsmap types.URLsMap) (*RaftCluster, error) {
- c := NewCluster(lg, token)
- for name, urls := range urlsmap {
- m := NewMember(name, urls, token, nil)
- if _, ok := c.members[m.ID]; ok {
- return nil, fmt.Errorf("member exists with identical ID %v", m)
- }
- if uint64(m.ID) == raft.None {
- return nil, fmt.Errorf("cannot use %x as member id", raft.None)
- }
- c.members[m.ID] = m
- }
- c.genID()
- return c, nil
-}
-
-func NewClusterFromMembers(lg *zap.Logger, token string, id types.ID, membs []*Member) *RaftCluster {
- c := NewCluster(lg, token)
- c.cid = id
- for _, m := range membs {
- c.members[m.ID] = m
- }
- return c
-}
-
-func NewCluster(lg *zap.Logger, token string) *RaftCluster {
- return &RaftCluster{
- lg: lg,
- token: token,
- members: make(map[types.ID]*Member),
- removed: make(map[types.ID]bool),
- }
-}
-
-func (c *RaftCluster) ID() types.ID { return c.cid }
-
-func (c *RaftCluster) Members() []*Member {
- c.Lock()
- defer c.Unlock()
- var ms MembersByID
- for _, m := range c.members {
- ms = append(ms, m.Clone())
- }
- sort.Sort(ms)
- return []*Member(ms)
-}
-
-func (c *RaftCluster) Member(id types.ID) *Member {
- c.Lock()
- defer c.Unlock()
- return c.members[id].Clone()
-}
-
-func (c *RaftCluster) VotingMembers() []*Member {
- c.Lock()
- defer c.Unlock()
- var ms MembersByID
- for _, m := range c.members {
- if !m.IsLearner {
- ms = append(ms, m.Clone())
- }
- }
- sort.Sort(ms)
- return []*Member(ms)
-}
-
-// MemberByName returns a Member with the given name if exists.
-// If more than one member has the given name, it will panic.
-func (c *RaftCluster) MemberByName(name string) *Member {
- c.Lock()
- defer c.Unlock()
- var memb *Member
- for _, m := range c.members {
- if m.Name == name {
- if memb != nil {
- if c.lg != nil {
- c.lg.Panic("two member with same name found", zap.String("name", name))
- } else {
- plog.Panicf("two members with the given name %q exist", name)
- }
- }
- memb = m
- }
- }
- return memb.Clone()
-}
-
-func (c *RaftCluster) MemberIDs() []types.ID {
- c.Lock()
- defer c.Unlock()
- var ids []types.ID
- for _, m := range c.members {
- ids = append(ids, m.ID)
- }
- sort.Sort(types.IDSlice(ids))
- return ids
-}
-
-func (c *RaftCluster) IsIDRemoved(id types.ID) bool {
- c.Lock()
- defer c.Unlock()
- return c.removed[id]
-}
-
-// PeerURLs returns a list of all peer addresses.
-// The returned list is sorted in ascending lexicographical order.
-func (c *RaftCluster) PeerURLs() []string {
- c.Lock()
- defer c.Unlock()
- urls := make([]string, 0)
- for _, p := range c.members {
- urls = append(urls, p.PeerURLs...)
- }
- sort.Strings(urls)
- return urls
-}
-
-// ClientURLs returns a list of all client addresses.
-// The returned list is sorted in ascending lexicographical order.
-func (c *RaftCluster) ClientURLs() []string {
- c.Lock()
- defer c.Unlock()
- urls := make([]string, 0)
- for _, p := range c.members {
- urls = append(urls, p.ClientURLs...)
- }
- sort.Strings(urls)
- return urls
-}
-
-func (c *RaftCluster) String() string {
- c.Lock()
- defer c.Unlock()
- b := &bytes.Buffer{}
- fmt.Fprintf(b, "{ClusterID:%s ", c.cid)
- var ms []string
- for _, m := range c.members {
- ms = append(ms, fmt.Sprintf("%+v", m))
- }
- fmt.Fprintf(b, "Members:[%s] ", strings.Join(ms, " "))
- var ids []string
- for id := range c.removed {
- ids = append(ids, id.String())
- }
- fmt.Fprintf(b, "RemovedMemberIDs:[%s]}", strings.Join(ids, " "))
- return b.String()
-}
-
-func (c *RaftCluster) genID() {
- mIDs := c.MemberIDs()
- b := make([]byte, 8*len(mIDs))
- for i, id := range mIDs {
- binary.BigEndian.PutUint64(b[8*i:], uint64(id))
- }
- hash := sha1.Sum(b)
- c.cid = types.ID(binary.BigEndian.Uint64(hash[:8]))
-}
-
-func (c *RaftCluster) SetID(localID, cid types.ID) {
- c.localID = localID
- c.cid = cid
-}
-
-func (c *RaftCluster) SetStore(st v2store.Store) { c.v2store = st }
-
-func (c *RaftCluster) SetBackend(be backend.Backend) {
- c.be = be
- mustCreateBackendBuckets(c.be)
-}
-
-func (c *RaftCluster) Recover(onSet func(*zap.Logger, *semver.Version)) {
- c.Lock()
- defer c.Unlock()
-
- c.members, c.removed = membersFromStore(c.lg, c.v2store)
- c.version = clusterVersionFromStore(c.lg, c.v2store)
- mustDetectDowngrade(c.lg, c.version)
- onSet(c.lg, c.version)
-
- for _, m := range c.members {
- if c.lg != nil {
- c.lg.Info(
- "recovered/added member from store",
- zap.String("cluster-id", c.cid.String()),
- zap.String("local-member-id", c.localID.String()),
- zap.String("recovered-remote-peer-id", m.ID.String()),
- zap.Strings("recovered-remote-peer-urls", m.PeerURLs),
- )
- } else {
- plog.Infof("added member %s %v to cluster %s from store", m.ID, m.PeerURLs, c.cid)
- }
- }
- if c.version != nil {
- if c.lg != nil {
- c.lg.Info(
- "set cluster version from store",
- zap.String("cluster-version", version.Cluster(c.version.String())),
- )
- } else {
- plog.Infof("set the cluster version to %v from store", version.Cluster(c.version.String()))
- }
- }
-}
-
-// ValidateConfigurationChange takes a proposed ConfChange and
-// ensures that it is still valid.
-func (c *RaftCluster) ValidateConfigurationChange(cc raftpb.ConfChange) error {
- members, removed := membersFromStore(c.lg, c.v2store)
- id := types.ID(cc.NodeID)
- if removed[id] {
- return ErrIDRemoved
- }
- switch cc.Type {
- case raftpb.ConfChangeAddNode, raftpb.ConfChangeAddLearnerNode:
- confChangeContext := new(ConfigChangeContext)
- if err := json.Unmarshal(cc.Context, confChangeContext); err != nil {
- if c.lg != nil {
- c.lg.Panic("failed to unmarshal confChangeContext", zap.Error(err))
- } else {
- plog.Panicf("unmarshal confChangeContext should never fail: %v", err)
- }
- }
-
- if confChangeContext.IsPromote { // promoting a learner member to voting member
- if members[id] == nil {
- return ErrIDNotFound
- }
- if !members[id].IsLearner {
- return ErrMemberNotLearner
- }
- } else { // adding a new member
- if members[id] != nil {
- return ErrIDExists
- }
-
- urls := make(map[string]bool)
- for _, m := range members {
- for _, u := range m.PeerURLs {
- urls[u] = true
- }
- }
- for _, u := range confChangeContext.Member.PeerURLs {
- if urls[u] {
- return ErrPeerURLexists
- }
- }
-
- if confChangeContext.Member.IsLearner { // the new member is a learner
- numLearners := 0
- for _, m := range members {
- if m.IsLearner {
- numLearners++
- }
- }
- if numLearners+1 > maxLearners {
- return ErrTooManyLearners
- }
- }
- }
- case raftpb.ConfChangeRemoveNode:
- if members[id] == nil {
- return ErrIDNotFound
- }
-
- case raftpb.ConfChangeUpdateNode:
- if members[id] == nil {
- return ErrIDNotFound
- }
- urls := make(map[string]bool)
- for _, m := range members {
- if m.ID == id {
- continue
- }
- for _, u := range m.PeerURLs {
- urls[u] = true
- }
- }
- m := new(Member)
- if err := json.Unmarshal(cc.Context, m); err != nil {
- if c.lg != nil {
- c.lg.Panic("failed to unmarshal member", zap.Error(err))
- } else {
- plog.Panicf("unmarshal member should never fail: %v", err)
- }
- }
- for _, u := range m.PeerURLs {
- if urls[u] {
- return ErrPeerURLexists
- }
- }
-
- default:
- if c.lg != nil {
- c.lg.Panic("unknown ConfChange type", zap.String("type", cc.Type.String()))
- } else {
- plog.Panicf("ConfChange type should be either AddNode, RemoveNode or UpdateNode")
- }
- }
- return nil
-}
-
-// AddMember adds a new Member into the cluster, and saves the given member's
-// raftAttributes into the store. The given member should have empty attributes.
-// A Member with a matching id must not exist.
-func (c *RaftCluster) AddMember(m *Member) {
- c.Lock()
- defer c.Unlock()
- if c.v2store != nil {
- mustSaveMemberToStore(c.v2store, m)
- }
- if c.be != nil {
- mustSaveMemberToBackend(c.be, m)
- }
-
- c.members[m.ID] = m
-
- if c.lg != nil {
- c.lg.Info(
- "added member",
- zap.String("cluster-id", c.cid.String()),
- zap.String("local-member-id", c.localID.String()),
- zap.String("added-peer-id", m.ID.String()),
- zap.Strings("added-peer-peer-urls", m.PeerURLs),
- )
- } else {
- plog.Infof("added member %s %v to cluster %s", m.ID, m.PeerURLs, c.cid)
- }
-}
-
-// RemoveMember removes a member from the store.
-// The given id MUST exist, or the function panics.
-func (c *RaftCluster) RemoveMember(id types.ID) {
- c.Lock()
- defer c.Unlock()
- if c.v2store != nil {
- mustDeleteMemberFromStore(c.v2store, id)
- }
- if c.be != nil {
- mustDeleteMemberFromBackend(c.be, id)
- }
-
- m, ok := c.members[id]
- delete(c.members, id)
- c.removed[id] = true
-
- if c.lg != nil {
- if ok {
- c.lg.Info(
- "removed member",
- zap.String("cluster-id", c.cid.String()),
- zap.String("local-member-id", c.localID.String()),
- zap.String("removed-remote-peer-id", id.String()),
- zap.Strings("removed-remote-peer-urls", m.PeerURLs),
- )
- } else {
- c.lg.Warn(
- "skipped removing already removed member",
- zap.String("cluster-id", c.cid.String()),
- zap.String("local-member-id", c.localID.String()),
- zap.String("removed-remote-peer-id", id.String()),
- )
- }
- } else {
- plog.Infof("removed member %s from cluster %s", id, c.cid)
- }
-}
-
-func (c *RaftCluster) UpdateAttributes(id types.ID, attr Attributes) {
- c.Lock()
- defer c.Unlock()
-
- if m, ok := c.members[id]; ok {
- m.Attributes = attr
- if c.v2store != nil {
- mustUpdateMemberAttrInStore(c.v2store, m)
- }
- if c.be != nil {
- mustSaveMemberToBackend(c.be, m)
- }
- return
- }
-
- _, ok := c.removed[id]
- if !ok {
- if c.lg != nil {
- c.lg.Panic(
- "failed to update; member unknown",
- zap.String("cluster-id", c.cid.String()),
- zap.String("local-member-id", c.localID.String()),
- zap.String("unknown-remote-peer-id", id.String()),
- )
- } else {
- plog.Panicf("error updating attributes of unknown member %s", id)
- }
- }
-
- if c.lg != nil {
- c.lg.Warn(
- "skipped attributes update of removed member",
- zap.String("cluster-id", c.cid.String()),
- zap.String("local-member-id", c.localID.String()),
- zap.String("updated-peer-id", id.String()),
- )
- } else {
- plog.Warningf("skipped updating attributes of removed member %s", id)
- }
-}
-
-// PromoteMember marks the member's IsLearner RaftAttributes to false.
-func (c *RaftCluster) PromoteMember(id types.ID) {
- c.Lock()
- defer c.Unlock()
-
- c.members[id].RaftAttributes.IsLearner = false
- if c.v2store != nil {
- mustUpdateMemberInStore(c.v2store, c.members[id])
- }
- if c.be != nil {
- mustSaveMemberToBackend(c.be, c.members[id])
- }
-
- if c.lg != nil {
- c.lg.Info(
- "promote member",
- zap.String("cluster-id", c.cid.String()),
- zap.String("local-member-id", c.localID.String()),
- )
- } else {
- plog.Noticef("promote member %s in cluster %s", id, c.cid)
- }
-}
-
-func (c *RaftCluster) UpdateRaftAttributes(id types.ID, raftAttr RaftAttributes) {
- c.Lock()
- defer c.Unlock()
-
- c.members[id].RaftAttributes = raftAttr
- if c.v2store != nil {
- mustUpdateMemberInStore(c.v2store, c.members[id])
- }
- if c.be != nil {
- mustSaveMemberToBackend(c.be, c.members[id])
- }
-
- if c.lg != nil {
- c.lg.Info(
- "updated member",
- zap.String("cluster-id", c.cid.String()),
- zap.String("local-member-id", c.localID.String()),
- zap.String("updated-remote-peer-id", id.String()),
- zap.Strings("updated-remote-peer-urls", raftAttr.PeerURLs),
- )
- } else {
- plog.Noticef("updated member %s %v in cluster %s", id, raftAttr.PeerURLs, c.cid)
- }
-}
-
-func (c *RaftCluster) Version() *semver.Version {
- c.Lock()
- defer c.Unlock()
- if c.version == nil {
- return nil
- }
- return semver.Must(semver.NewVersion(c.version.String()))
-}
-
-func (c *RaftCluster) SetVersion(ver *semver.Version, onSet func(*zap.Logger, *semver.Version)) {
- c.Lock()
- defer c.Unlock()
- if c.version != nil {
- if c.lg != nil {
- c.lg.Info(
- "updated cluster version",
- zap.String("cluster-id", c.cid.String()),
- zap.String("local-member-id", c.localID.String()),
- zap.String("from", version.Cluster(c.version.String())),
- zap.String("from", version.Cluster(ver.String())),
- )
- } else {
- plog.Noticef("updated the cluster version from %v to %v", version.Cluster(c.version.String()), version.Cluster(ver.String()))
- }
- } else {
- if c.lg != nil {
- c.lg.Info(
- "set initial cluster version",
- zap.String("cluster-id", c.cid.String()),
- zap.String("local-member-id", c.localID.String()),
- zap.String("cluster-version", version.Cluster(ver.String())),
- )
- } else {
- plog.Noticef("set the initial cluster version to %v", version.Cluster(ver.String()))
- }
- }
- c.version = ver
- mustDetectDowngrade(c.lg, c.version)
- if c.v2store != nil {
- mustSaveClusterVersionToStore(c.v2store, ver)
- }
- if c.be != nil {
- mustSaveClusterVersionToBackend(c.be, ver)
- }
- ClusterVersionMetrics.With(prometheus.Labels{"cluster_version": ver.String()}).Set(1)
- onSet(c.lg, ver)
-}
-
-func (c *RaftCluster) IsReadyToAddVotingMember() bool {
- nmembers := 1
- nstarted := 0
-
- for _, member := range c.VotingMembers() {
- if member.IsStarted() {
- nstarted++
- }
- nmembers++
- }
-
- if nstarted == 1 && nmembers == 2 {
- // a case of adding a new node to 1-member cluster for restoring cluster data
- // https://github.com/etcd-io/etcd/blob/master/Documentation/v2/admin_guide.md#restoring-the-cluster
- if c.lg != nil {
- c.lg.Debug("number of started member is 1; can accept add member request")
- } else {
- plog.Debugf("The number of started member is 1. This cluster can accept add member request.")
- }
- return true
- }
-
- nquorum := nmembers/2 + 1
- if nstarted < nquorum {
- if c.lg != nil {
- c.lg.Warn(
- "rejecting member add; started member will be less than quorum",
- zap.Int("number-of-started-member", nstarted),
- zap.Int("quorum", nquorum),
- zap.String("cluster-id", c.cid.String()),
- zap.String("local-member-id", c.localID.String()),
- )
- } else {
- plog.Warningf("Reject add member request: the number of started member (%d) will be less than the quorum number of the cluster (%d)", nstarted, nquorum)
- }
- return false
- }
-
- return true
-}
-
-func (c *RaftCluster) IsReadyToRemoveVotingMember(id uint64) bool {
- nmembers := 0
- nstarted := 0
-
- for _, member := range c.VotingMembers() {
- if uint64(member.ID) == id {
- continue
- }
-
- if member.IsStarted() {
- nstarted++
- }
- nmembers++
- }
-
- nquorum := nmembers/2 + 1
- if nstarted < nquorum {
- if c.lg != nil {
- c.lg.Warn(
- "rejecting member remove; started member will be less than quorum",
- zap.Int("number-of-started-member", nstarted),
- zap.Int("quorum", nquorum),
- zap.String("cluster-id", c.cid.String()),
- zap.String("local-member-id", c.localID.String()),
- )
- } else {
- plog.Warningf("Reject remove member request: the number of started member (%d) will be less than the quorum number of the cluster (%d)", nstarted, nquorum)
- }
- return false
- }
-
- return true
-}
-
-func (c *RaftCluster) IsReadyToPromoteMember(id uint64) bool {
- nmembers := 1
- nstarted := 0
-
- for _, member := range c.VotingMembers() {
- if member.IsStarted() {
- nstarted++
- }
- nmembers++
- }
-
- nquorum := nmembers/2 + 1
- if nstarted < nquorum {
- if c.lg != nil {
- c.lg.Warn(
- "rejecting member promote; started member will be less than quorum",
- zap.Int("number-of-started-member", nstarted),
- zap.Int("quorum", nquorum),
- zap.String("cluster-id", c.cid.String()),
- zap.String("local-member-id", c.localID.String()),
- )
- } else {
- plog.Warningf("Reject promote member request: the number of started member (%d) will be less than the quorum number of the cluster (%d)", nstarted, nquorum)
- }
- return false
- }
-
- return true
-}
-
-func membersFromStore(lg *zap.Logger, st v2store.Store) (map[types.ID]*Member, map[types.ID]bool) {
- members := make(map[types.ID]*Member)
- removed := make(map[types.ID]bool)
- e, err := st.Get(StoreMembersPrefix, true, true)
- if err != nil {
- if isKeyNotFound(err) {
- return members, removed
- }
- if lg != nil {
- lg.Panic("failed to get members from store", zap.String("path", StoreMembersPrefix), zap.Error(err))
- } else {
- plog.Panicf("get storeMembers should never fail: %v", err)
- }
- }
- for _, n := range e.Node.Nodes {
- var m *Member
- m, err = nodeToMember(n)
- if err != nil {
- if lg != nil {
- lg.Panic("failed to nodeToMember", zap.Error(err))
- } else {
- plog.Panicf("nodeToMember should never fail: %v", err)
- }
- }
- members[m.ID] = m
- }
-
- e, err = st.Get(storeRemovedMembersPrefix, true, true)
- if err != nil {
- if isKeyNotFound(err) {
- return members, removed
- }
- if lg != nil {
- lg.Panic(
- "failed to get removed members from store",
- zap.String("path", storeRemovedMembersPrefix),
- zap.Error(err),
- )
- } else {
- plog.Panicf("get storeRemovedMembers should never fail: %v", err)
- }
- }
- for _, n := range e.Node.Nodes {
- removed[MustParseMemberIDFromKey(n.Key)] = true
- }
- return members, removed
-}
-
-func clusterVersionFromStore(lg *zap.Logger, st v2store.Store) *semver.Version {
- e, err := st.Get(path.Join(storePrefix, "version"), false, false)
- if err != nil {
- if isKeyNotFound(err) {
- return nil
- }
- if lg != nil {
- lg.Panic(
- "failed to get cluster version from store",
- zap.String("path", path.Join(storePrefix, "version")),
- zap.Error(err),
- )
- } else {
- plog.Panicf("unexpected error (%v) when getting cluster version from store", err)
- }
- }
- return semver.Must(semver.NewVersion(*e.Node.Value))
-}
-
-// ValidateClusterAndAssignIDs validates the local cluster by matching the PeerURLs
-// with the existing cluster. If the validation succeeds, it assigns the IDs
-// from the existing cluster to the local cluster.
-// If the validation fails, an error will be returned.
-func ValidateClusterAndAssignIDs(lg *zap.Logger, local *RaftCluster, existing *RaftCluster) error {
- ems := existing.Members()
- lms := local.Members()
- if len(ems) != len(lms) {
- return fmt.Errorf("member count is unequal")
- }
-
- ctx, cancel := context.WithTimeout(context.TODO(), 30*time.Second)
- defer cancel()
- for i := range ems {
- var err error
- ok := false
- for j := range lms {
- if ok, err = netutil.URLStringsEqual(ctx, lg, ems[i].PeerURLs, lms[j].PeerURLs); ok {
- lms[j].ID = ems[i].ID
- break
- }
- }
- if !ok {
- return fmt.Errorf("PeerURLs: no match found for existing member (%v, %v), last resolver error (%v)", ems[i].ID, ems[i].PeerURLs, err)
- }
- }
- local.members = make(map[types.ID]*Member)
- for _, m := range lms {
- local.members[m.ID] = m
- }
- return nil
-}
-
-func mustDetectDowngrade(lg *zap.Logger, cv *semver.Version) {
- lv := semver.Must(semver.NewVersion(version.Version))
- // only keep major.minor version for comparison against cluster version
- lv = &semver.Version{Major: lv.Major, Minor: lv.Minor}
- if cv != nil && lv.LessThan(*cv) {
- if lg != nil {
- lg.Fatal(
- "invalid downgrade; server version is lower than determined cluster version",
- zap.String("current-server-version", version.Version),
- zap.String("determined-cluster-version", version.Cluster(cv.String())),
- )
- } else {
- plog.Fatalf("cluster cannot be downgraded (current version: %s is lower than determined cluster version: %s).", version.Version, version.Cluster(cv.String()))
- }
- }
-}
-
-// IsLocalMemberLearner returns if the local member is raft learner
-func (c *RaftCluster) IsLocalMemberLearner() bool {
- c.Lock()
- defer c.Unlock()
- localMember, ok := c.members[c.localID]
- if !ok {
- if c.lg != nil {
- c.lg.Panic(
- "failed to find local ID in cluster members",
- zap.String("cluster-id", c.cid.String()),
- zap.String("local-member-id", c.localID.String()),
- )
- } else {
- plog.Panicf("failed to find local ID %s in cluster %s", c.localID.String(), c.cid.String())
- }
- }
- return localMember.IsLearner
-}
-
-// IsMemberExist returns if the member with the given id exists in cluster.
-func (c *RaftCluster) IsMemberExist(id types.ID) bool {
- c.Lock()
- defer c.Unlock()
- _, ok := c.members[id]
- return ok
-}
-
-// VotingMemberIDs returns the ID of voting members in cluster.
-func (c *RaftCluster) VotingMemberIDs() []types.ID {
- c.Lock()
- defer c.Unlock()
- var ids []types.ID
- for _, m := range c.members {
- if !m.IsLearner {
- ids = append(ids, m.ID)
- }
- }
- sort.Sort(types.IDSlice(ids))
- return ids
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/membership/doc.go b/vendor/go.etcd.io/etcd/etcdserver/api/membership/doc.go
deleted file mode 100644
index b07fb2d..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/membership/doc.go
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2017 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package membership describes individual etcd members and clusters of members.
-package membership
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/membership/errors.go b/vendor/go.etcd.io/etcd/etcdserver/api/membership/errors.go
deleted file mode 100644
index 8f6fe50..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/membership/errors.go
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2016 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package membership
-
-import (
- "errors"
-
- "go.etcd.io/etcd/etcdserver/api/v2error"
-)
-
-var (
- ErrIDRemoved = errors.New("membership: ID removed")
- ErrIDExists = errors.New("membership: ID exists")
- ErrIDNotFound = errors.New("membership: ID not found")
- ErrPeerURLexists = errors.New("membership: peerURL exists")
- ErrMemberNotLearner = errors.New("membership: can only promote a learner member")
- ErrTooManyLearners = errors.New("membership: too many learner members in cluster")
-)
-
-func isKeyNotFound(err error) bool {
- e, ok := err.(*v2error.Error)
- return ok && e.ErrorCode == v2error.EcodeKeyNotFound
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/membership/member.go b/vendor/go.etcd.io/etcd/etcdserver/api/membership/member.go
deleted file mode 100644
index 896cb36..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/membership/member.go
+++ /dev/null
@@ -1,142 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package membership
-
-import (
- "crypto/sha1"
- "encoding/binary"
- "fmt"
- "math/rand"
- "sort"
- "time"
-
- "github.com/coreos/pkg/capnslog"
- "go.etcd.io/etcd/pkg/types"
-)
-
-var (
- plog = capnslog.NewPackageLogger("go.etcd.io/etcd/v3", "etcdserver/membership")
-)
-
-// RaftAttributes represents the raft related attributes of an etcd member.
-type RaftAttributes struct {
- // PeerURLs is the list of peers in the raft cluster.
- // TODO(philips): ensure these are URLs
- PeerURLs []string `json:"peerURLs"`
- // IsLearner indicates if the member is raft learner.
- IsLearner bool `json:"isLearner,omitempty"`
-}
-
-// Attributes represents all the non-raft related attributes of an etcd member.
-type Attributes struct {
- Name string `json:"name,omitempty"`
- ClientURLs []string `json:"clientURLs,omitempty"`
-}
-
-type Member struct {
- ID types.ID `json:"id"`
- RaftAttributes
- Attributes
-}
-
-// NewMember creates a Member without an ID and generates one based on the
-// cluster name, peer URLs, and time. This is used for bootstrapping/adding new member.
-func NewMember(name string, peerURLs types.URLs, clusterName string, now *time.Time) *Member {
- return newMember(name, peerURLs, clusterName, now, false)
-}
-
-// NewMemberAsLearner creates a learner Member without an ID and generates one based on the
-// cluster name, peer URLs, and time. This is used for adding new learner member.
-func NewMemberAsLearner(name string, peerURLs types.URLs, clusterName string, now *time.Time) *Member {
- return newMember(name, peerURLs, clusterName, now, true)
-}
-
-func newMember(name string, peerURLs types.URLs, clusterName string, now *time.Time, isLearner bool) *Member {
- m := &Member{
- RaftAttributes: RaftAttributes{
- PeerURLs: peerURLs.StringSlice(),
- IsLearner: isLearner,
- },
- Attributes: Attributes{Name: name},
- }
-
- var b []byte
- sort.Strings(m.PeerURLs)
- for _, p := range m.PeerURLs {
- b = append(b, []byte(p)...)
- }
-
- b = append(b, []byte(clusterName)...)
- if now != nil {
- b = append(b, []byte(fmt.Sprintf("%d", now.Unix()))...)
- }
-
- hash := sha1.Sum(b)
- m.ID = types.ID(binary.BigEndian.Uint64(hash[:8]))
- return m
-}
-
-// PickPeerURL chooses a random address from a given Member's PeerURLs.
-// It will panic if there is no PeerURLs available in Member.
-func (m *Member) PickPeerURL() string {
- if len(m.PeerURLs) == 0 {
- panic("member should always have some peer url")
- }
- return m.PeerURLs[rand.Intn(len(m.PeerURLs))]
-}
-
-func (m *Member) Clone() *Member {
- if m == nil {
- return nil
- }
- mm := &Member{
- ID: m.ID,
- RaftAttributes: RaftAttributes{
- IsLearner: m.IsLearner,
- },
- Attributes: Attributes{
- Name: m.Name,
- },
- }
- if m.PeerURLs != nil {
- mm.PeerURLs = make([]string, len(m.PeerURLs))
- copy(mm.PeerURLs, m.PeerURLs)
- }
- if m.ClientURLs != nil {
- mm.ClientURLs = make([]string, len(m.ClientURLs))
- copy(mm.ClientURLs, m.ClientURLs)
- }
- return mm
-}
-
-func (m *Member) IsStarted() bool {
- return len(m.Name) != 0
-}
-
-// MembersByID implements sort by ID interface
-type MembersByID []*Member
-
-func (ms MembersByID) Len() int { return len(ms) }
-func (ms MembersByID) Less(i, j int) bool { return ms[i].ID < ms[j].ID }
-func (ms MembersByID) Swap(i, j int) { ms[i], ms[j] = ms[j], ms[i] }
-
-// MembersByPeerURLs implements sort by peer urls interface
-type MembersByPeerURLs []*Member
-
-func (ms MembersByPeerURLs) Len() int { return len(ms) }
-func (ms MembersByPeerURLs) Less(i, j int) bool {
- return ms[i].PeerURLs[0] < ms[j].PeerURLs[0]
-}
-func (ms MembersByPeerURLs) Swap(i, j int) { ms[i], ms[j] = ms[j], ms[i] }
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/membership/metrics.go b/vendor/go.etcd.io/etcd/etcdserver/api/membership/metrics.go
deleted file mode 100644
index b3212bc..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/membership/metrics.go
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2018 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package membership
-
-import "github.com/prometheus/client_golang/prometheus"
-
-var (
- ClusterVersionMetrics = prometheus.NewGaugeVec(prometheus.GaugeOpts{
- Namespace: "etcd",
- Subsystem: "cluster",
- Name: "version",
- Help: "Which version is running. 1 for 'cluster_version' label with current cluster version",
- },
- []string{"cluster_version"})
-)
-
-func init() {
- prometheus.MustRegister(ClusterVersionMetrics)
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/membership/store.go b/vendor/go.etcd.io/etcd/etcdserver/api/membership/store.go
deleted file mode 100644
index 14ab119..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/membership/store.go
+++ /dev/null
@@ -1,193 +0,0 @@
-// Copyright 2016 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package membership
-
-import (
- "encoding/json"
- "fmt"
- "path"
-
- "go.etcd.io/etcd/etcdserver/api/v2store"
- "go.etcd.io/etcd/mvcc/backend"
- "go.etcd.io/etcd/pkg/types"
-
- "github.com/coreos/go-semver/semver"
-)
-
-const (
- attributesSuffix = "attributes"
- raftAttributesSuffix = "raftAttributes"
-
- // the prefix for stroing membership related information in store provided by store pkg.
- storePrefix = "/0"
-)
-
-var (
- membersBucketName = []byte("members")
- membersRemovedBucketName = []byte("members_removed")
- clusterBucketName = []byte("cluster")
-
- StoreMembersPrefix = path.Join(storePrefix, "members")
- storeRemovedMembersPrefix = path.Join(storePrefix, "removed_members")
-)
-
-func mustSaveMemberToBackend(be backend.Backend, m *Member) {
- mkey := backendMemberKey(m.ID)
- mvalue, err := json.Marshal(m)
- if err != nil {
- plog.Panicf("marshal raftAttributes should never fail: %v", err)
- }
-
- tx := be.BatchTx()
- tx.Lock()
- tx.UnsafePut(membersBucketName, mkey, mvalue)
- tx.Unlock()
-}
-
-func mustDeleteMemberFromBackend(be backend.Backend, id types.ID) {
- mkey := backendMemberKey(id)
-
- tx := be.BatchTx()
- tx.Lock()
- tx.UnsafeDelete(membersBucketName, mkey)
- tx.UnsafePut(membersRemovedBucketName, mkey, []byte("removed"))
- tx.Unlock()
-}
-
-func mustSaveClusterVersionToBackend(be backend.Backend, ver *semver.Version) {
- ckey := backendClusterVersionKey()
-
- tx := be.BatchTx()
- tx.Lock()
- defer tx.Unlock()
- tx.UnsafePut(clusterBucketName, ckey, []byte(ver.String()))
-}
-
-func mustSaveMemberToStore(s v2store.Store, m *Member) {
- b, err := json.Marshal(m.RaftAttributes)
- if err != nil {
- plog.Panicf("marshal raftAttributes should never fail: %v", err)
- }
- p := path.Join(MemberStoreKey(m.ID), raftAttributesSuffix)
- if _, err := s.Create(p, false, string(b), false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}); err != nil {
- plog.Panicf("create raftAttributes should never fail: %v", err)
- }
-}
-
-func mustDeleteMemberFromStore(s v2store.Store, id types.ID) {
- if _, err := s.Delete(MemberStoreKey(id), true, true); err != nil {
- plog.Panicf("delete member should never fail: %v", err)
- }
- if _, err := s.Create(RemovedMemberStoreKey(id), false, "", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}); err != nil {
- plog.Panicf("create removedMember should never fail: %v", err)
- }
-}
-
-func mustUpdateMemberInStore(s v2store.Store, m *Member) {
- b, err := json.Marshal(m.RaftAttributes)
- if err != nil {
- plog.Panicf("marshal raftAttributes should never fail: %v", err)
- }
- p := path.Join(MemberStoreKey(m.ID), raftAttributesSuffix)
- if _, err := s.Update(p, string(b), v2store.TTLOptionSet{ExpireTime: v2store.Permanent}); err != nil {
- plog.Panicf("update raftAttributes should never fail: %v", err)
- }
-}
-
-func mustUpdateMemberAttrInStore(s v2store.Store, m *Member) {
- b, err := json.Marshal(m.Attributes)
- if err != nil {
- plog.Panicf("marshal raftAttributes should never fail: %v", err)
- }
- p := path.Join(MemberStoreKey(m.ID), attributesSuffix)
- if _, err := s.Set(p, false, string(b), v2store.TTLOptionSet{ExpireTime: v2store.Permanent}); err != nil {
- plog.Panicf("update raftAttributes should never fail: %v", err)
- }
-}
-
-func mustSaveClusterVersionToStore(s v2store.Store, ver *semver.Version) {
- if _, err := s.Set(StoreClusterVersionKey(), false, ver.String(), v2store.TTLOptionSet{ExpireTime: v2store.Permanent}); err != nil {
- plog.Panicf("save cluster version should never fail: %v", err)
- }
-}
-
-// nodeToMember builds member from a key value node.
-// the child nodes of the given node MUST be sorted by key.
-func nodeToMember(n *v2store.NodeExtern) (*Member, error) {
- m := &Member{ID: MustParseMemberIDFromKey(n.Key)}
- attrs := make(map[string][]byte)
- raftAttrKey := path.Join(n.Key, raftAttributesSuffix)
- attrKey := path.Join(n.Key, attributesSuffix)
- for _, nn := range n.Nodes {
- if nn.Key != raftAttrKey && nn.Key != attrKey {
- return nil, fmt.Errorf("unknown key %q", nn.Key)
- }
- attrs[nn.Key] = []byte(*nn.Value)
- }
- if data := attrs[raftAttrKey]; data != nil {
- if err := json.Unmarshal(data, &m.RaftAttributes); err != nil {
- return nil, fmt.Errorf("unmarshal raftAttributes error: %v", err)
- }
- } else {
- return nil, fmt.Errorf("raftAttributes key doesn't exist")
- }
- if data := attrs[attrKey]; data != nil {
- if err := json.Unmarshal(data, &m.Attributes); err != nil {
- return m, fmt.Errorf("unmarshal attributes error: %v", err)
- }
- }
- return m, nil
-}
-
-func backendMemberKey(id types.ID) []byte {
- return []byte(id.String())
-}
-
-func backendClusterVersionKey() []byte {
- return []byte("clusterVersion")
-}
-
-func mustCreateBackendBuckets(be backend.Backend) {
- tx := be.BatchTx()
- tx.Lock()
- defer tx.Unlock()
- tx.UnsafeCreateBucket(membersBucketName)
- tx.UnsafeCreateBucket(membersRemovedBucketName)
- tx.UnsafeCreateBucket(clusterBucketName)
-}
-
-func MemberStoreKey(id types.ID) string {
- return path.Join(StoreMembersPrefix, id.String())
-}
-
-func StoreClusterVersionKey() string {
- return path.Join(storePrefix, "version")
-}
-
-func MemberAttributesStorePath(id types.ID) string {
- return path.Join(MemberStoreKey(id), attributesSuffix)
-}
-
-func MustParseMemberIDFromKey(key string) types.ID {
- id, err := types.IDFromString(path.Base(key))
- if err != nil {
- plog.Panicf("unexpected parse member id error: %v", err)
- }
- return id
-}
-
-func RemovedMemberStoreKey(id types.ID) string {
- return path.Join(storeRemovedMembersPrefix, id.String())
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/coder.go b/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/coder.go
deleted file mode 100644
index 12c3e44..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/coder.go
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package rafthttp
-
-import "go.etcd.io/etcd/raft/raftpb"
-
-type encoder interface {
- // encode encodes the given message to an output stream.
- encode(m *raftpb.Message) error
-}
-
-type decoder interface {
- // decode decodes the message from an input stream.
- decode() (raftpb.Message, error)
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/doc.go b/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/doc.go
deleted file mode 100644
index a9486a8..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/doc.go
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package rafthttp implements HTTP transportation layer for etcd/raft pkg.
-package rafthttp
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/http.go b/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/http.go
deleted file mode 100644
index d0e0c81..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/http.go
+++ /dev/null
@@ -1,577 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package rafthttp
-
-import (
- "context"
- "errors"
- "fmt"
- "io/ioutil"
- "net/http"
- "path"
- "strings"
- "time"
-
- "go.etcd.io/etcd/etcdserver/api/snap"
- pioutil "go.etcd.io/etcd/pkg/ioutil"
- "go.etcd.io/etcd/pkg/types"
- "go.etcd.io/etcd/raft/raftpb"
- "go.etcd.io/etcd/version"
-
- humanize "github.com/dustin/go-humanize"
- "go.uber.org/zap"
-)
-
-const (
- // connReadLimitByte limits the number of bytes
- // a single read can read out.
- //
- // 64KB should be large enough for not causing
- // throughput bottleneck as well as small enough
- // for not causing a read timeout.
- connReadLimitByte = 64 * 1024
-)
-
-var (
- RaftPrefix = "/raft"
- ProbingPrefix = path.Join(RaftPrefix, "probing")
- RaftStreamPrefix = path.Join(RaftPrefix, "stream")
- RaftSnapshotPrefix = path.Join(RaftPrefix, "snapshot")
-
- errIncompatibleVersion = errors.New("incompatible version")
- errClusterIDMismatch = errors.New("cluster ID mismatch")
-)
-
-type peerGetter interface {
- Get(id types.ID) Peer
-}
-
-type writerToResponse interface {
- WriteTo(w http.ResponseWriter)
-}
-
-type pipelineHandler struct {
- lg *zap.Logger
- localID types.ID
- tr Transporter
- r Raft
- cid types.ID
-}
-
-// newPipelineHandler returns a handler for handling raft messages
-// from pipeline for RaftPrefix.
-//
-// The handler reads out the raft message from request body,
-// and forwards it to the given raft state machine for processing.
-func newPipelineHandler(t *Transport, r Raft, cid types.ID) http.Handler {
- return &pipelineHandler{
- lg: t.Logger,
- localID: t.ID,
- tr: t,
- r: r,
- cid: cid,
- }
-}
-
-func (h *pipelineHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
- if r.Method != "POST" {
- w.Header().Set("Allow", "POST")
- http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
- return
- }
-
- w.Header().Set("X-Etcd-Cluster-ID", h.cid.String())
-
- if err := checkClusterCompatibilityFromHeader(h.lg, h.localID, r.Header, h.cid); err != nil {
- http.Error(w, err.Error(), http.StatusPreconditionFailed)
- return
- }
-
- addRemoteFromRequest(h.tr, r)
-
- // Limit the data size that could be read from the request body, which ensures that read from
- // connection will not time out accidentally due to possible blocking in underlying implementation.
- limitedr := pioutil.NewLimitedBufferReader(r.Body, connReadLimitByte)
- b, err := ioutil.ReadAll(limitedr)
- if err != nil {
- if h.lg != nil {
- h.lg.Warn(
- "failed to read Raft message",
- zap.String("local-member-id", h.localID.String()),
- zap.Error(err),
- )
- } else {
- plog.Errorf("failed to read raft message (%v)", err)
- }
- http.Error(w, "error reading raft message", http.StatusBadRequest)
- recvFailures.WithLabelValues(r.RemoteAddr).Inc()
- return
- }
-
- var m raftpb.Message
- if err := m.Unmarshal(b); err != nil {
- if h.lg != nil {
- h.lg.Warn(
- "failed to unmarshal Raft message",
- zap.String("local-member-id", h.localID.String()),
- zap.Error(err),
- )
- } else {
- plog.Errorf("failed to unmarshal raft message (%v)", err)
- }
- http.Error(w, "error unmarshalling raft message", http.StatusBadRequest)
- recvFailures.WithLabelValues(r.RemoteAddr).Inc()
- return
- }
-
- receivedBytes.WithLabelValues(types.ID(m.From).String()).Add(float64(len(b)))
-
- if err := h.r.Process(context.TODO(), m); err != nil {
- switch v := err.(type) {
- case writerToResponse:
- v.WriteTo(w)
- default:
- if h.lg != nil {
- h.lg.Warn(
- "failed to process Raft message",
- zap.String("local-member-id", h.localID.String()),
- zap.Error(err),
- )
- } else {
- plog.Warningf("failed to process raft message (%v)", err)
- }
- http.Error(w, "error processing raft message", http.StatusInternalServerError)
- w.(http.Flusher).Flush()
- // disconnect the http stream
- panic(err)
- }
- return
- }
-
- // Write StatusNoContent header after the message has been processed by
- // raft, which facilitates the client to report MsgSnap status.
- w.WriteHeader(http.StatusNoContent)
-}
-
-type snapshotHandler struct {
- lg *zap.Logger
- tr Transporter
- r Raft
- snapshotter *snap.Snapshotter
-
- localID types.ID
- cid types.ID
-}
-
-func newSnapshotHandler(t *Transport, r Raft, snapshotter *snap.Snapshotter, cid types.ID) http.Handler {
- return &snapshotHandler{
- lg: t.Logger,
- tr: t,
- r: r,
- snapshotter: snapshotter,
- localID: t.ID,
- cid: cid,
- }
-}
-
-const unknownSnapshotSender = "UNKNOWN_SNAPSHOT_SENDER"
-
-// ServeHTTP serves HTTP request to receive and process snapshot message.
-//
-// If request sender dies without closing underlying TCP connection,
-// the handler will keep waiting for the request body until TCP keepalive
-// finds out that the connection is broken after several minutes.
-// This is acceptable because
-// 1. snapshot messages sent through other TCP connections could still be
-// received and processed.
-// 2. this case should happen rarely, so no further optimization is done.
-func (h *snapshotHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
- start := time.Now()
-
- if r.Method != "POST" {
- w.Header().Set("Allow", "POST")
- http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
- snapshotReceiveFailures.WithLabelValues(unknownSnapshotSender).Inc()
- return
- }
-
- w.Header().Set("X-Etcd-Cluster-ID", h.cid.String())
-
- if err := checkClusterCompatibilityFromHeader(h.lg, h.localID, r.Header, h.cid); err != nil {
- http.Error(w, err.Error(), http.StatusPreconditionFailed)
- snapshotReceiveFailures.WithLabelValues(unknownSnapshotSender).Inc()
- return
- }
-
- addRemoteFromRequest(h.tr, r)
-
- dec := &messageDecoder{r: r.Body}
- // let snapshots be very large since they can exceed 512MB for large installations
- m, err := dec.decodeLimit(uint64(1 << 63))
- from := types.ID(m.From).String()
- if err != nil {
- msg := fmt.Sprintf("failed to decode raft message (%v)", err)
- if h.lg != nil {
- h.lg.Warn(
- "failed to decode Raft message",
- zap.String("local-member-id", h.localID.String()),
- zap.String("remote-snapshot-sender-id", from),
- zap.Error(err),
- )
- } else {
- plog.Error(msg)
- }
- http.Error(w, msg, http.StatusBadRequest)
- recvFailures.WithLabelValues(r.RemoteAddr).Inc()
- snapshotReceiveFailures.WithLabelValues(from).Inc()
- return
- }
-
- msgSize := m.Size()
- receivedBytes.WithLabelValues(from).Add(float64(msgSize))
-
- if m.Type != raftpb.MsgSnap {
- if h.lg != nil {
- h.lg.Warn(
- "unexpected Raft message type",
- zap.String("local-member-id", h.localID.String()),
- zap.String("remote-snapshot-sender-id", from),
- zap.String("message-type", m.Type.String()),
- )
- } else {
- plog.Errorf("unexpected raft message type %s on snapshot path", m.Type)
- }
- http.Error(w, "wrong raft message type", http.StatusBadRequest)
- snapshotReceiveFailures.WithLabelValues(from).Inc()
- return
- }
-
- snapshotReceiveInflights.WithLabelValues(from).Inc()
- defer func() {
- snapshotReceiveInflights.WithLabelValues(from).Dec()
- }()
-
- if h.lg != nil {
- h.lg.Info(
- "receiving database snapshot",
- zap.String("local-member-id", h.localID.String()),
- zap.String("remote-snapshot-sender-id", from),
- zap.Uint64("incoming-snapshot-index", m.Snapshot.Metadata.Index),
- zap.Int("incoming-snapshot-message-size-bytes", msgSize),
- zap.String("incoming-snapshot-message-size", humanize.Bytes(uint64(msgSize))),
- )
- } else {
- plog.Infof("receiving database snapshot [index:%d, from %s] ...", m.Snapshot.Metadata.Index, types.ID(m.From))
- }
-
- // save incoming database snapshot.
- n, err := h.snapshotter.SaveDBFrom(r.Body, m.Snapshot.Metadata.Index)
- if err != nil {
- msg := fmt.Sprintf("failed to save KV snapshot (%v)", err)
- if h.lg != nil {
- h.lg.Warn(
- "failed to save incoming database snapshot",
- zap.String("local-member-id", h.localID.String()),
- zap.String("remote-snapshot-sender-id", from),
- zap.Uint64("incoming-snapshot-index", m.Snapshot.Metadata.Index),
- zap.Error(err),
- )
- } else {
- plog.Error(msg)
- }
- http.Error(w, msg, http.StatusInternalServerError)
- snapshotReceiveFailures.WithLabelValues(from).Inc()
- return
- }
-
- receivedBytes.WithLabelValues(from).Add(float64(n))
-
- if h.lg != nil {
- h.lg.Info(
- "received and saved database snapshot",
- zap.String("local-member-id", h.localID.String()),
- zap.String("remote-snapshot-sender-id", from),
- zap.Uint64("incoming-snapshot-index", m.Snapshot.Metadata.Index),
- zap.Int64("incoming-snapshot-size-bytes", n),
- zap.String("incoming-snapshot-size", humanize.Bytes(uint64(n))),
- )
- } else {
- plog.Infof("received and saved database snapshot [index: %d, from: %s] successfully", m.Snapshot.Metadata.Index, types.ID(m.From))
- }
-
- if err := h.r.Process(context.TODO(), m); err != nil {
- switch v := err.(type) {
- // Process may return writerToResponse error when doing some
- // additional checks before calling raft.Node.Step.
- case writerToResponse:
- v.WriteTo(w)
- default:
- msg := fmt.Sprintf("failed to process raft message (%v)", err)
- if h.lg != nil {
- h.lg.Warn(
- "failed to process Raft message",
- zap.String("local-member-id", h.localID.String()),
- zap.String("remote-snapshot-sender-id", from),
- zap.Error(err),
- )
- } else {
- plog.Error(msg)
- }
- http.Error(w, msg, http.StatusInternalServerError)
- snapshotReceiveFailures.WithLabelValues(from).Inc()
- }
- return
- }
-
- // Write StatusNoContent header after the message has been processed by
- // raft, which facilitates the client to report MsgSnap status.
- w.WriteHeader(http.StatusNoContent)
-
- snapshotReceive.WithLabelValues(from).Inc()
- snapshotReceiveSeconds.WithLabelValues(from).Observe(time.Since(start).Seconds())
-}
-
-type streamHandler struct {
- lg *zap.Logger
- tr *Transport
- peerGetter peerGetter
- r Raft
- id types.ID
- cid types.ID
-}
-
-func newStreamHandler(t *Transport, pg peerGetter, r Raft, id, cid types.ID) http.Handler {
- return &streamHandler{
- lg: t.Logger,
- tr: t,
- peerGetter: pg,
- r: r,
- id: id,
- cid: cid,
- }
-}
-
-func (h *streamHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
- if r.Method != "GET" {
- w.Header().Set("Allow", "GET")
- http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
- return
- }
-
- w.Header().Set("X-Server-Version", version.Version)
- w.Header().Set("X-Etcd-Cluster-ID", h.cid.String())
-
- if err := checkClusterCompatibilityFromHeader(h.lg, h.tr.ID, r.Header, h.cid); err != nil {
- http.Error(w, err.Error(), http.StatusPreconditionFailed)
- return
- }
-
- var t streamType
- switch path.Dir(r.URL.Path) {
- case streamTypeMsgAppV2.endpoint():
- t = streamTypeMsgAppV2
- case streamTypeMessage.endpoint():
- t = streamTypeMessage
- default:
- if h.lg != nil {
- h.lg.Debug(
- "ignored unexpected streaming request path",
- zap.String("local-member-id", h.tr.ID.String()),
- zap.String("remote-peer-id-stream-handler", h.id.String()),
- zap.String("path", r.URL.Path),
- )
- } else {
- plog.Debugf("ignored unexpected streaming request path %s", r.URL.Path)
- }
- http.Error(w, "invalid path", http.StatusNotFound)
- return
- }
-
- fromStr := path.Base(r.URL.Path)
- from, err := types.IDFromString(fromStr)
- if err != nil {
- if h.lg != nil {
- h.lg.Warn(
- "failed to parse path into ID",
- zap.String("local-member-id", h.tr.ID.String()),
- zap.String("remote-peer-id-stream-handler", h.id.String()),
- zap.String("path", fromStr),
- zap.Error(err),
- )
- } else {
- plog.Errorf("failed to parse from %s into ID (%v)", fromStr, err)
- }
- http.Error(w, "invalid from", http.StatusNotFound)
- return
- }
- if h.r.IsIDRemoved(uint64(from)) {
- if h.lg != nil {
- h.lg.Warn(
- "rejected stream from remote peer because it was removed",
- zap.String("local-member-id", h.tr.ID.String()),
- zap.String("remote-peer-id-stream-handler", h.id.String()),
- zap.String("remote-peer-id-from", from.String()),
- )
- } else {
- plog.Warningf("rejected the stream from peer %s since it was removed", from)
- }
- http.Error(w, "removed member", http.StatusGone)
- return
- }
- p := h.peerGetter.Get(from)
- if p == nil {
- // This may happen in following cases:
- // 1. user starts a remote peer that belongs to a different cluster
- // with the same cluster ID.
- // 2. local etcd falls behind of the cluster, and cannot recognize
- // the members that joined after its current progress.
- if urls := r.Header.Get("X-PeerURLs"); urls != "" {
- h.tr.AddRemote(from, strings.Split(urls, ","))
- }
- if h.lg != nil {
- h.lg.Warn(
- "failed to find remote peer in cluster",
- zap.String("local-member-id", h.tr.ID.String()),
- zap.String("remote-peer-id-stream-handler", h.id.String()),
- zap.String("remote-peer-id-from", from.String()),
- zap.String("cluster-id", h.cid.String()),
- )
- } else {
- plog.Errorf("failed to find member %s in cluster %s", from, h.cid)
- }
- http.Error(w, "error sender not found", http.StatusNotFound)
- return
- }
-
- wto := h.id.String()
- if gto := r.Header.Get("X-Raft-To"); gto != wto {
- if h.lg != nil {
- h.lg.Warn(
- "ignored streaming request; ID mismatch",
- zap.String("local-member-id", h.tr.ID.String()),
- zap.String("remote-peer-id-stream-handler", h.id.String()),
- zap.String("remote-peer-id-header", gto),
- zap.String("remote-peer-id-from", from.String()),
- zap.String("cluster-id", h.cid.String()),
- )
- } else {
- plog.Errorf("streaming request ignored (ID mismatch got %s want %s)", gto, wto)
- }
- http.Error(w, "to field mismatch", http.StatusPreconditionFailed)
- return
- }
-
- w.WriteHeader(http.StatusOK)
- w.(http.Flusher).Flush()
-
- c := newCloseNotifier()
- conn := &outgoingConn{
- t: t,
- Writer: w,
- Flusher: w.(http.Flusher),
- Closer: c,
- localID: h.tr.ID,
- peerID: h.id,
- }
- p.attachOutgoingConn(conn)
- <-c.closeNotify()
-}
-
-// checkClusterCompatibilityFromHeader checks the cluster compatibility of
-// the local member from the given header.
-// It checks whether the version of local member is compatible with
-// the versions in the header, and whether the cluster ID of local member
-// matches the one in the header.
-func checkClusterCompatibilityFromHeader(lg *zap.Logger, localID types.ID, header http.Header, cid types.ID) error {
- remoteName := header.Get("X-Server-From")
-
- remoteServer := serverVersion(header)
- remoteVs := ""
- if remoteServer != nil {
- remoteVs = remoteServer.String()
- }
-
- remoteMinClusterVer := minClusterVersion(header)
- remoteMinClusterVs := ""
- if remoteMinClusterVer != nil {
- remoteMinClusterVs = remoteMinClusterVer.String()
- }
-
- localServer, localMinCluster, err := checkVersionCompatibility(remoteName, remoteServer, remoteMinClusterVer)
-
- localVs := ""
- if localServer != nil {
- localVs = localServer.String()
- }
- localMinClusterVs := ""
- if localMinCluster != nil {
- localMinClusterVs = localMinCluster.String()
- }
-
- if err != nil {
- if lg != nil {
- lg.Warn(
- "failed to check version compatibility",
- zap.String("local-member-id", localID.String()),
- zap.String("local-member-cluster-id", cid.String()),
- zap.String("local-member-server-version", localVs),
- zap.String("local-member-server-minimum-cluster-version", localMinClusterVs),
- zap.String("remote-peer-server-name", remoteName),
- zap.String("remote-peer-server-version", remoteVs),
- zap.String("remote-peer-server-minimum-cluster-version", remoteMinClusterVs),
- zap.Error(err),
- )
- } else {
- plog.Errorf("request version incompatibility (%v)", err)
- }
- return errIncompatibleVersion
- }
- if gcid := header.Get("X-Etcd-Cluster-ID"); gcid != cid.String() {
- if lg != nil {
- lg.Warn(
- "request cluster ID mismatch",
- zap.String("local-member-id", localID.String()),
- zap.String("local-member-cluster-id", cid.String()),
- zap.String("local-member-server-version", localVs),
- zap.String("local-member-server-minimum-cluster-version", localMinClusterVs),
- zap.String("remote-peer-server-name", remoteName),
- zap.String("remote-peer-server-version", remoteVs),
- zap.String("remote-peer-server-minimum-cluster-version", remoteMinClusterVs),
- zap.String("remote-peer-cluster-id", gcid),
- )
- } else {
- plog.Errorf("request cluster ID mismatch (got %s want %s)", gcid, cid)
- }
- return errClusterIDMismatch
- }
- return nil
-}
-
-type closeNotifier struct {
- done chan struct{}
-}
-
-func newCloseNotifier() *closeNotifier {
- return &closeNotifier{
- done: make(chan struct{}),
- }
-}
-
-func (n *closeNotifier) Close() error {
- close(n.done)
- return nil
-}
-
-func (n *closeNotifier) closeNotify() <-chan struct{} { return n.done }
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/metrics.go b/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/metrics.go
deleted file mode 100644
index 02fff84..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/metrics.go
+++ /dev/null
@@ -1,186 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package rafthttp
-
-import "github.com/prometheus/client_golang/prometheus"
-
-var (
- activePeers = prometheus.NewGaugeVec(prometheus.GaugeOpts{
- Namespace: "etcd",
- Subsystem: "network",
- Name: "active_peers",
- Help: "The current number of active peer connections.",
- },
- []string{"Local", "Remote"},
- )
-
- disconnectedPeers = prometheus.NewCounterVec(prometheus.CounterOpts{
- Namespace: "etcd",
- Subsystem: "network",
- Name: "disconnected_peers_total",
- Help: "The total number of disconnected peers.",
- },
- []string{"Local", "Remote"},
- )
-
- sentBytes = prometheus.NewCounterVec(prometheus.CounterOpts{
- Namespace: "etcd",
- Subsystem: "network",
- Name: "peer_sent_bytes_total",
- Help: "The total number of bytes sent to peers.",
- },
- []string{"To"},
- )
-
- receivedBytes = prometheus.NewCounterVec(prometheus.CounterOpts{
- Namespace: "etcd",
- Subsystem: "network",
- Name: "peer_received_bytes_total",
- Help: "The total number of bytes received from peers.",
- },
- []string{"From"},
- )
-
- sentFailures = prometheus.NewCounterVec(prometheus.CounterOpts{
- Namespace: "etcd",
- Subsystem: "network",
- Name: "peer_sent_failures_total",
- Help: "The total number of send failures from peers.",
- },
- []string{"To"},
- )
-
- recvFailures = prometheus.NewCounterVec(prometheus.CounterOpts{
- Namespace: "etcd",
- Subsystem: "network",
- Name: "peer_received_failures_total",
- Help: "The total number of receive failures from peers.",
- },
- []string{"From"},
- )
-
- snapshotSend = prometheus.NewCounterVec(prometheus.CounterOpts{
- Namespace: "etcd",
- Subsystem: "network",
- Name: "snapshot_send_success",
- Help: "Total number of successful snapshot sends",
- },
- []string{"To"},
- )
-
- snapshotSendInflights = prometheus.NewGaugeVec(prometheus.GaugeOpts{
- Namespace: "etcd",
- Subsystem: "network",
- Name: "snapshot_send_inflights_total",
- Help: "Total number of inflight snapshot sends",
- },
- []string{"To"},
- )
-
- snapshotSendFailures = prometheus.NewCounterVec(prometheus.CounterOpts{
- Namespace: "etcd",
- Subsystem: "network",
- Name: "snapshot_send_failures",
- Help: "Total number of snapshot send failures",
- },
- []string{"To"},
- )
-
- snapshotSendSeconds = prometheus.NewHistogramVec(prometheus.HistogramOpts{
- Namespace: "etcd",
- Subsystem: "network",
- Name: "snapshot_send_total_duration_seconds",
- Help: "Total latency distributions of v3 snapshot sends",
-
- // lowest bucket start of upper bound 0.1 sec (100 ms) with factor 2
- // highest bucket start of 0.1 sec * 2^9 == 51.2 sec
- Buckets: prometheus.ExponentialBuckets(0.1, 2, 10),
- },
- []string{"To"},
- )
-
- snapshotReceive = prometheus.NewCounterVec(prometheus.CounterOpts{
- Namespace: "etcd",
- Subsystem: "network",
- Name: "snapshot_receive_success",
- Help: "Total number of successful snapshot receives",
- },
- []string{"From"},
- )
-
- snapshotReceiveInflights = prometheus.NewGaugeVec(prometheus.GaugeOpts{
- Namespace: "etcd",
- Subsystem: "network",
- Name: "snapshot_receive_inflights_total",
- Help: "Total number of inflight snapshot receives",
- },
- []string{"From"},
- )
-
- snapshotReceiveFailures = prometheus.NewCounterVec(prometheus.CounterOpts{
- Namespace: "etcd",
- Subsystem: "network",
- Name: "snapshot_receive_failures",
- Help: "Total number of snapshot receive failures",
- },
- []string{"From"},
- )
-
- snapshotReceiveSeconds = prometheus.NewHistogramVec(prometheus.HistogramOpts{
- Namespace: "etcd",
- Subsystem: "network",
- Name: "snapshot_receive_total_duration_seconds",
- Help: "Total latency distributions of v3 snapshot receives",
-
- // lowest bucket start of upper bound 0.1 sec (100 ms) with factor 2
- // highest bucket start of 0.1 sec * 2^9 == 51.2 sec
- Buckets: prometheus.ExponentialBuckets(0.1, 2, 10),
- },
- []string{"From"},
- )
-
- rttSec = prometheus.NewHistogramVec(prometheus.HistogramOpts{
- Namespace: "etcd",
- Subsystem: "network",
- Name: "peer_round_trip_time_seconds",
- Help: "Round-Trip-Time histogram between peers",
-
- // lowest bucket start of upper bound 0.0001 sec (0.1 ms) with factor 2
- // highest bucket start of 0.0001 sec * 2^15 == 3.2768 sec
- Buckets: prometheus.ExponentialBuckets(0.0001, 2, 16),
- },
- []string{"To"},
- )
-)
-
-func init() {
- prometheus.MustRegister(activePeers)
- prometheus.MustRegister(disconnectedPeers)
- prometheus.MustRegister(sentBytes)
- prometheus.MustRegister(receivedBytes)
- prometheus.MustRegister(sentFailures)
- prometheus.MustRegister(recvFailures)
-
- prometheus.MustRegister(snapshotSend)
- prometheus.MustRegister(snapshotSendInflights)
- prometheus.MustRegister(snapshotSendFailures)
- prometheus.MustRegister(snapshotSendSeconds)
- prometheus.MustRegister(snapshotReceive)
- prometheus.MustRegister(snapshotReceiveInflights)
- prometheus.MustRegister(snapshotReceiveFailures)
- prometheus.MustRegister(snapshotReceiveSeconds)
-
- prometheus.MustRegister(rttSec)
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/msg_codec.go b/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/msg_codec.go
deleted file mode 100644
index 2417d22..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/msg_codec.go
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package rafthttp
-
-import (
- "encoding/binary"
- "errors"
- "io"
-
- "go.etcd.io/etcd/pkg/pbutil"
- "go.etcd.io/etcd/raft/raftpb"
-)
-
-// messageEncoder is a encoder that can encode all kinds of messages.
-// It MUST be used with a paired messageDecoder.
-type messageEncoder struct {
- w io.Writer
-}
-
-func (enc *messageEncoder) encode(m *raftpb.Message) error {
- if err := binary.Write(enc.w, binary.BigEndian, uint64(m.Size())); err != nil {
- return err
- }
- _, err := enc.w.Write(pbutil.MustMarshal(m))
- return err
-}
-
-// messageDecoder is a decoder that can decode all kinds of messages.
-type messageDecoder struct {
- r io.Reader
-}
-
-var (
- readBytesLimit uint64 = 512 * 1024 * 1024 // 512 MB
- ErrExceedSizeLimit = errors.New("rafthttp: error limit exceeded")
-)
-
-func (dec *messageDecoder) decode() (raftpb.Message, error) {
- return dec.decodeLimit(readBytesLimit)
-}
-
-func (dec *messageDecoder) decodeLimit(numBytes uint64) (raftpb.Message, error) {
- var m raftpb.Message
- var l uint64
- if err := binary.Read(dec.r, binary.BigEndian, &l); err != nil {
- return m, err
- }
- if l > numBytes {
- return m, ErrExceedSizeLimit
- }
- buf := make([]byte, int(l))
- if _, err := io.ReadFull(dec.r, buf); err != nil {
- return m, err
- }
- return m, m.Unmarshal(buf)
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/msgappv2_codec.go b/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/msgappv2_codec.go
deleted file mode 100644
index 1fa36de..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/msgappv2_codec.go
+++ /dev/null
@@ -1,248 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package rafthttp
-
-import (
- "encoding/binary"
- "fmt"
- "io"
- "time"
-
- stats "go.etcd.io/etcd/etcdserver/api/v2stats"
- "go.etcd.io/etcd/pkg/pbutil"
- "go.etcd.io/etcd/pkg/types"
- "go.etcd.io/etcd/raft/raftpb"
-)
-
-const (
- msgTypeLinkHeartbeat uint8 = 0
- msgTypeAppEntries uint8 = 1
- msgTypeApp uint8 = 2
-
- msgAppV2BufSize = 1024 * 1024
-)
-
-// msgappv2 stream sends three types of message: linkHeartbeatMessage,
-// AppEntries and MsgApp. AppEntries is the MsgApp that is sent in
-// replicate state in raft, whose index and term are fully predictable.
-//
-// Data format of linkHeartbeatMessage:
-// | offset | bytes | description |
-// +--------+-------+-------------+
-// | 0 | 1 | \x00 |
-//
-// Data format of AppEntries:
-// | offset | bytes | description |
-// +--------+-------+-------------+
-// | 0 | 1 | \x01 |
-// | 1 | 8 | length of entries |
-// | 9 | 8 | length of first entry |
-// | 17 | n1 | first entry |
-// ...
-// | x | 8 | length of k-th entry data |
-// | x+8 | nk | k-th entry data |
-// | x+8+nk | 8 | commit index |
-//
-// Data format of MsgApp:
-// | offset | bytes | description |
-// +--------+-------+-------------+
-// | 0 | 1 | \x02 |
-// | 1 | 8 | length of encoded message |
-// | 9 | n | encoded message |
-type msgAppV2Encoder struct {
- w io.Writer
- fs *stats.FollowerStats
-
- term uint64
- index uint64
- buf []byte
- uint64buf []byte
- uint8buf []byte
-}
-
-func newMsgAppV2Encoder(w io.Writer, fs *stats.FollowerStats) *msgAppV2Encoder {
- return &msgAppV2Encoder{
- w: w,
- fs: fs,
- buf: make([]byte, msgAppV2BufSize),
- uint64buf: make([]byte, 8),
- uint8buf: make([]byte, 1),
- }
-}
-
-func (enc *msgAppV2Encoder) encode(m *raftpb.Message) error {
- start := time.Now()
- switch {
- case isLinkHeartbeatMessage(m):
- enc.uint8buf[0] = msgTypeLinkHeartbeat
- if _, err := enc.w.Write(enc.uint8buf); err != nil {
- return err
- }
- case enc.index == m.Index && enc.term == m.LogTerm && m.LogTerm == m.Term:
- enc.uint8buf[0] = msgTypeAppEntries
- if _, err := enc.w.Write(enc.uint8buf); err != nil {
- return err
- }
- // write length of entries
- binary.BigEndian.PutUint64(enc.uint64buf, uint64(len(m.Entries)))
- if _, err := enc.w.Write(enc.uint64buf); err != nil {
- return err
- }
- for i := 0; i < len(m.Entries); i++ {
- // write length of entry
- binary.BigEndian.PutUint64(enc.uint64buf, uint64(m.Entries[i].Size()))
- if _, err := enc.w.Write(enc.uint64buf); err != nil {
- return err
- }
- if n := m.Entries[i].Size(); n < msgAppV2BufSize {
- if _, err := m.Entries[i].MarshalTo(enc.buf); err != nil {
- return err
- }
- if _, err := enc.w.Write(enc.buf[:n]); err != nil {
- return err
- }
- } else {
- if _, err := enc.w.Write(pbutil.MustMarshal(&m.Entries[i])); err != nil {
- return err
- }
- }
- enc.index++
- }
- // write commit index
- binary.BigEndian.PutUint64(enc.uint64buf, m.Commit)
- if _, err := enc.w.Write(enc.uint64buf); err != nil {
- return err
- }
- enc.fs.Succ(time.Since(start))
- default:
- if err := binary.Write(enc.w, binary.BigEndian, msgTypeApp); err != nil {
- return err
- }
- // write size of message
- if err := binary.Write(enc.w, binary.BigEndian, uint64(m.Size())); err != nil {
- return err
- }
- // write message
- if _, err := enc.w.Write(pbutil.MustMarshal(m)); err != nil {
- return err
- }
-
- enc.term = m.Term
- enc.index = m.Index
- if l := len(m.Entries); l > 0 {
- enc.index = m.Entries[l-1].Index
- }
- enc.fs.Succ(time.Since(start))
- }
- return nil
-}
-
-type msgAppV2Decoder struct {
- r io.Reader
- local, remote types.ID
-
- term uint64
- index uint64
- buf []byte
- uint64buf []byte
- uint8buf []byte
-}
-
-func newMsgAppV2Decoder(r io.Reader, local, remote types.ID) *msgAppV2Decoder {
- return &msgAppV2Decoder{
- r: r,
- local: local,
- remote: remote,
- buf: make([]byte, msgAppV2BufSize),
- uint64buf: make([]byte, 8),
- uint8buf: make([]byte, 1),
- }
-}
-
-func (dec *msgAppV2Decoder) decode() (raftpb.Message, error) {
- var (
- m raftpb.Message
- typ uint8
- )
- if _, err := io.ReadFull(dec.r, dec.uint8buf); err != nil {
- return m, err
- }
- typ = dec.uint8buf[0]
- switch typ {
- case msgTypeLinkHeartbeat:
- return linkHeartbeatMessage, nil
- case msgTypeAppEntries:
- m = raftpb.Message{
- Type: raftpb.MsgApp,
- From: uint64(dec.remote),
- To: uint64(dec.local),
- Term: dec.term,
- LogTerm: dec.term,
- Index: dec.index,
- }
-
- // decode entries
- if _, err := io.ReadFull(dec.r, dec.uint64buf); err != nil {
- return m, err
- }
- l := binary.BigEndian.Uint64(dec.uint64buf)
- m.Entries = make([]raftpb.Entry, int(l))
- for i := 0; i < int(l); i++ {
- if _, err := io.ReadFull(dec.r, dec.uint64buf); err != nil {
- return m, err
- }
- size := binary.BigEndian.Uint64(dec.uint64buf)
- var buf []byte
- if size < msgAppV2BufSize {
- buf = dec.buf[:size]
- if _, err := io.ReadFull(dec.r, buf); err != nil {
- return m, err
- }
- } else {
- buf = make([]byte, int(size))
- if _, err := io.ReadFull(dec.r, buf); err != nil {
- return m, err
- }
- }
- dec.index++
- // 1 alloc
- pbutil.MustUnmarshal(&m.Entries[i], buf)
- }
- // decode commit index
- if _, err := io.ReadFull(dec.r, dec.uint64buf); err != nil {
- return m, err
- }
- m.Commit = binary.BigEndian.Uint64(dec.uint64buf)
- case msgTypeApp:
- var size uint64
- if err := binary.Read(dec.r, binary.BigEndian, &size); err != nil {
- return m, err
- }
- buf := make([]byte, int(size))
- if _, err := io.ReadFull(dec.r, buf); err != nil {
- return m, err
- }
- pbutil.MustUnmarshal(&m, buf)
-
- dec.term = m.Term
- dec.index = m.Index
- if l := len(m.Entries); l > 0 {
- dec.index = m.Entries[l-1].Index
- }
- default:
- return m, fmt.Errorf("failed to parse type %d in msgappv2 stream", typ)
- }
- return m, nil
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/peer.go b/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/peer.go
deleted file mode 100644
index 8130c4a..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/peer.go
+++ /dev/null
@@ -1,374 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package rafthttp
-
-import (
- "context"
- "sync"
- "time"
-
- "go.etcd.io/etcd/etcdserver/api/snap"
- stats "go.etcd.io/etcd/etcdserver/api/v2stats"
- "go.etcd.io/etcd/pkg/types"
- "go.etcd.io/etcd/raft"
- "go.etcd.io/etcd/raft/raftpb"
-
- "go.uber.org/zap"
- "golang.org/x/time/rate"
-)
-
-const (
- // ConnReadTimeout and ConnWriteTimeout are the i/o timeout set on each connection rafthttp pkg creates.
- // A 5 seconds timeout is good enough for recycling bad connections. Or we have to wait for
- // tcp keepalive failing to detect a bad connection, which is at minutes level.
- // For long term streaming connections, rafthttp pkg sends application level linkHeartbeatMessage
- // to keep the connection alive.
- // For short term pipeline connections, the connection MUST be killed to avoid it being
- // put back to http pkg connection pool.
- ConnReadTimeout = 5 * time.Second
- ConnWriteTimeout = 5 * time.Second
-
- recvBufSize = 4096
- // maxPendingProposals holds the proposals during one leader election process.
- // Generally one leader election takes at most 1 sec. It should have
- // 0-2 election conflicts, and each one takes 0.5 sec.
- // We assume the number of concurrent proposers is smaller than 4096.
- // One client blocks on its proposal for at least 1 sec, so 4096 is enough
- // to hold all proposals.
- maxPendingProposals = 4096
-
- streamAppV2 = "streamMsgAppV2"
- streamMsg = "streamMsg"
- pipelineMsg = "pipeline"
- sendSnap = "sendMsgSnap"
-)
-
-type Peer interface {
- // send sends the message to the remote peer. The function is non-blocking
- // and has no promise that the message will be received by the remote.
- // When it fails to send message out, it will report the status to underlying
- // raft.
- send(m raftpb.Message)
-
- // sendSnap sends the merged snapshot message to the remote peer. Its behavior
- // is similar to send.
- sendSnap(m snap.Message)
-
- // update updates the urls of remote peer.
- update(urls types.URLs)
-
- // attachOutgoingConn attaches the outgoing connection to the peer for
- // stream usage. After the call, the ownership of the outgoing
- // connection hands over to the peer. The peer will close the connection
- // when it is no longer used.
- attachOutgoingConn(conn *outgoingConn)
- // activeSince returns the time that the connection with the
- // peer becomes active.
- activeSince() time.Time
- // stop performs any necessary finalization and terminates the peer
- // elegantly.
- stop()
-}
-
-// peer is the representative of a remote raft node. Local raft node sends
-// messages to the remote through peer.
-// Each peer has two underlying mechanisms to send out a message: stream and
-// pipeline.
-// A stream is a receiver initialized long-polling connection, which
-// is always open to transfer messages. Besides general stream, peer also has
-// a optimized stream for sending msgApp since msgApp accounts for large part
-// of all messages. Only raft leader uses the optimized stream to send msgApp
-// to the remote follower node.
-// A pipeline is a series of http clients that send http requests to the remote.
-// It is only used when the stream has not been established.
-type peer struct {
- lg *zap.Logger
-
- localID types.ID
- // id of the remote raft peer node
- id types.ID
-
- r Raft
-
- status *peerStatus
-
- picker *urlPicker
-
- msgAppV2Writer *streamWriter
- writer *streamWriter
- pipeline *pipeline
- snapSender *snapshotSender // snapshot sender to send v3 snapshot messages
- msgAppV2Reader *streamReader
- msgAppReader *streamReader
-
- recvc chan raftpb.Message
- propc chan raftpb.Message
-
- mu sync.Mutex
- paused bool
-
- cancel context.CancelFunc // cancel pending works in go routine created by peer.
- stopc chan struct{}
-}
-
-func startPeer(t *Transport, urls types.URLs, peerID types.ID, fs *stats.FollowerStats) *peer {
- if t.Logger != nil {
- t.Logger.Info("starting remote peer", zap.String("remote-peer-id", peerID.String()))
- } else {
- plog.Infof("starting peer %s...", peerID)
- }
- defer func() {
- if t.Logger != nil {
- t.Logger.Info("started remote peer", zap.String("remote-peer-id", peerID.String()))
- } else {
- plog.Infof("started peer %s", peerID)
- }
- }()
-
- status := newPeerStatus(t.Logger, t.ID, peerID)
- picker := newURLPicker(urls)
- errorc := t.ErrorC
- r := t.Raft
- pipeline := &pipeline{
- peerID: peerID,
- tr: t,
- picker: picker,
- status: status,
- followerStats: fs,
- raft: r,
- errorc: errorc,
- }
- pipeline.start()
-
- p := &peer{
- lg: t.Logger,
- localID: t.ID,
- id: peerID,
- r: r,
- status: status,
- picker: picker,
- msgAppV2Writer: startStreamWriter(t.Logger, t.ID, peerID, status, fs, r),
- writer: startStreamWriter(t.Logger, t.ID, peerID, status, fs, r),
- pipeline: pipeline,
- snapSender: newSnapshotSender(t, picker, peerID, status),
- recvc: make(chan raftpb.Message, recvBufSize),
- propc: make(chan raftpb.Message, maxPendingProposals),
- stopc: make(chan struct{}),
- }
-
- ctx, cancel := context.WithCancel(context.Background())
- p.cancel = cancel
- go func() {
- for {
- select {
- case mm := <-p.recvc:
- if err := r.Process(ctx, mm); err != nil {
- if t.Logger != nil {
- t.Logger.Warn("failed to process Raft message", zap.Error(err))
- } else {
- plog.Warningf("failed to process raft message (%v)", err)
- }
- }
- case <-p.stopc:
- return
- }
- }
- }()
-
- // r.Process might block for processing proposal when there is no leader.
- // Thus propc must be put into a separate routine with recvc to avoid blocking
- // processing other raft messages.
- go func() {
- for {
- select {
- case mm := <-p.propc:
- if err := r.Process(ctx, mm); err != nil {
- plog.Warningf("failed to process raft message (%v)", err)
- }
- case <-p.stopc:
- return
- }
- }
- }()
-
- p.msgAppV2Reader = &streamReader{
- lg: t.Logger,
- peerID: peerID,
- typ: streamTypeMsgAppV2,
- tr: t,
- picker: picker,
- status: status,
- recvc: p.recvc,
- propc: p.propc,
- rl: rate.NewLimiter(t.DialRetryFrequency, 1),
- }
- p.msgAppReader = &streamReader{
- lg: t.Logger,
- peerID: peerID,
- typ: streamTypeMessage,
- tr: t,
- picker: picker,
- status: status,
- recvc: p.recvc,
- propc: p.propc,
- rl: rate.NewLimiter(t.DialRetryFrequency, 1),
- }
-
- p.msgAppV2Reader.start()
- p.msgAppReader.start()
-
- return p
-}
-
-func (p *peer) send(m raftpb.Message) {
- p.mu.Lock()
- paused := p.paused
- p.mu.Unlock()
-
- if paused {
- return
- }
-
- writec, name := p.pick(m)
- select {
- case writec <- m:
- default:
- p.r.ReportUnreachable(m.To)
- if isMsgSnap(m) {
- p.r.ReportSnapshot(m.To, raft.SnapshotFailure)
- }
- if p.status.isActive() {
- if p.lg != nil {
- p.lg.Warn(
- "dropped internal Raft message since sending buffer is full (overloaded network)",
- zap.String("message-type", m.Type.String()),
- zap.String("local-member-id", p.localID.String()),
- zap.String("from", types.ID(m.From).String()),
- zap.String("remote-peer-id", p.id.String()),
- zap.Bool("remote-peer-active", p.status.isActive()),
- )
- } else {
- plog.MergeWarningf("dropped internal raft message to %s since %s's sending buffer is full (bad/overloaded network)", p.id, name)
- }
- } else {
- if p.lg != nil {
- p.lg.Warn(
- "dropped internal Raft message since sending buffer is full (overloaded network)",
- zap.String("message-type", m.Type.String()),
- zap.String("local-member-id", p.localID.String()),
- zap.String("from", types.ID(m.From).String()),
- zap.String("remote-peer-id", p.id.String()),
- zap.Bool("remote-peer-active", p.status.isActive()),
- )
- } else {
- plog.Debugf("dropped %s to %s since %s's sending buffer is full", m.Type, p.id, name)
- }
- }
- sentFailures.WithLabelValues(types.ID(m.To).String()).Inc()
- }
-}
-
-func (p *peer) sendSnap(m snap.Message) {
- go p.snapSender.send(m)
-}
-
-func (p *peer) update(urls types.URLs) {
- p.picker.update(urls)
-}
-
-func (p *peer) attachOutgoingConn(conn *outgoingConn) {
- var ok bool
- switch conn.t {
- case streamTypeMsgAppV2:
- ok = p.msgAppV2Writer.attach(conn)
- case streamTypeMessage:
- ok = p.writer.attach(conn)
- default:
- if p.lg != nil {
- p.lg.Panic("unknown stream type", zap.String("type", conn.t.String()))
- } else {
- plog.Panicf("unhandled stream type %s", conn.t)
- }
- }
- if !ok {
- conn.Close()
- }
-}
-
-func (p *peer) activeSince() time.Time { return p.status.activeSince() }
-
-// Pause pauses the peer. The peer will simply drops all incoming
-// messages without returning an error.
-func (p *peer) Pause() {
- p.mu.Lock()
- defer p.mu.Unlock()
- p.paused = true
- p.msgAppReader.pause()
- p.msgAppV2Reader.pause()
-}
-
-// Resume resumes a paused peer.
-func (p *peer) Resume() {
- p.mu.Lock()
- defer p.mu.Unlock()
- p.paused = false
- p.msgAppReader.resume()
- p.msgAppV2Reader.resume()
-}
-
-func (p *peer) stop() {
- if p.lg != nil {
- p.lg.Info("stopping remote peer", zap.String("remote-peer-id", p.id.String()))
- } else {
- plog.Infof("stopping peer %s...", p.id)
- }
-
- defer func() {
- if p.lg != nil {
- p.lg.Info("stopped remote peer", zap.String("remote-peer-id", p.id.String()))
- } else {
- plog.Infof("stopped peer %s", p.id)
- }
- }()
-
- close(p.stopc)
- p.cancel()
- p.msgAppV2Writer.stop()
- p.writer.stop()
- p.pipeline.stop()
- p.snapSender.stop()
- p.msgAppV2Reader.stop()
- p.msgAppReader.stop()
-}
-
-// pick picks a chan for sending the given message. The picked chan and the picked chan
-// string name are returned.
-func (p *peer) pick(m raftpb.Message) (writec chan<- raftpb.Message, picked string) {
- var ok bool
- // Considering MsgSnap may have a big size, e.g., 1G, and will block
- // stream for a long time, only use one of the N pipelines to send MsgSnap.
- if isMsgSnap(m) {
- return p.pipeline.msgc, pipelineMsg
- } else if writec, ok = p.msgAppV2Writer.writec(); ok && isMsgApp(m) {
- return writec, streamAppV2
- } else if writec, ok = p.writer.writec(); ok {
- return writec, streamMsg
- }
- return p.pipeline.msgc, pipelineMsg
-}
-
-func isMsgApp(m raftpb.Message) bool { return m.Type == raftpb.MsgApp }
-
-func isMsgSnap(m raftpb.Message) bool { return m.Type == raftpb.MsgSnap }
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/peer_status.go b/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/peer_status.go
deleted file mode 100644
index 66149ff..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/peer_status.go
+++ /dev/null
@@ -1,96 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package rafthttp
-
-import (
- "errors"
- "fmt"
- "sync"
- "time"
-
- "go.etcd.io/etcd/pkg/types"
-
- "go.uber.org/zap"
-)
-
-type failureType struct {
- source string
- action string
-}
-
-type peerStatus struct {
- lg *zap.Logger
- local types.ID
- id types.ID
- mu sync.Mutex // protect variables below
- active bool
- since time.Time
-}
-
-func newPeerStatus(lg *zap.Logger, local, id types.ID) *peerStatus {
- return &peerStatus{lg: lg, local: local, id: id}
-}
-
-func (s *peerStatus) activate() {
- s.mu.Lock()
- defer s.mu.Unlock()
- if !s.active {
- if s.lg != nil {
- s.lg.Info("peer became active", zap.String("peer-id", s.id.String()))
- } else {
- plog.Infof("peer %s became active", s.id)
- }
- s.active = true
- s.since = time.Now()
-
- activePeers.WithLabelValues(s.local.String(), s.id.String()).Inc()
- }
-}
-
-func (s *peerStatus) deactivate(failure failureType, reason string) {
- s.mu.Lock()
- defer s.mu.Unlock()
- msg := fmt.Sprintf("failed to %s %s on %s (%s)", failure.action, s.id, failure.source, reason)
- if s.active {
- if s.lg != nil {
- s.lg.Warn("peer became inactive (message send to peer failed)", zap.String("peer-id", s.id.String()), zap.Error(errors.New(msg)))
- } else {
- plog.Errorf(msg)
- plog.Infof("peer %s became inactive (message send to peer failed)", s.id)
- }
- s.active = false
- s.since = time.Time{}
-
- activePeers.WithLabelValues(s.local.String(), s.id.String()).Dec()
- disconnectedPeers.WithLabelValues(s.local.String(), s.id.String()).Inc()
- return
- }
-
- if s.lg != nil {
- s.lg.Debug("peer deactivated again", zap.String("peer-id", s.id.String()), zap.Error(errors.New(msg)))
- }
-}
-
-func (s *peerStatus) isActive() bool {
- s.mu.Lock()
- defer s.mu.Unlock()
- return s.active
-}
-
-func (s *peerStatus) activeSince() time.Time {
- s.mu.Lock()
- defer s.mu.Unlock()
- return s.since
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/pipeline.go b/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/pipeline.go
deleted file mode 100644
index 70f9257..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/pipeline.go
+++ /dev/null
@@ -1,180 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package rafthttp
-
-import (
- "bytes"
- "context"
- "errors"
- "io/ioutil"
- "sync"
- "time"
-
- stats "go.etcd.io/etcd/etcdserver/api/v2stats"
- "go.etcd.io/etcd/pkg/pbutil"
- "go.etcd.io/etcd/pkg/types"
- "go.etcd.io/etcd/raft"
- "go.etcd.io/etcd/raft/raftpb"
-
- "go.uber.org/zap"
-)
-
-const (
- connPerPipeline = 4
- // pipelineBufSize is the size of pipeline buffer, which helps hold the
- // temporary network latency.
- // The size ensures that pipeline does not drop messages when the network
- // is out of work for less than 1 second in good path.
- pipelineBufSize = 64
-)
-
-var errStopped = errors.New("stopped")
-
-type pipeline struct {
- peerID types.ID
-
- tr *Transport
- picker *urlPicker
- status *peerStatus
- raft Raft
- errorc chan error
- // deprecate when we depercate v2 API
- followerStats *stats.FollowerStats
-
- msgc chan raftpb.Message
- // wait for the handling routines
- wg sync.WaitGroup
- stopc chan struct{}
-}
-
-func (p *pipeline) start() {
- p.stopc = make(chan struct{})
- p.msgc = make(chan raftpb.Message, pipelineBufSize)
- p.wg.Add(connPerPipeline)
- for i := 0; i < connPerPipeline; i++ {
- go p.handle()
- }
-
- if p.tr != nil && p.tr.Logger != nil {
- p.tr.Logger.Info(
- "started HTTP pipelining with remote peer",
- zap.String("local-member-id", p.tr.ID.String()),
- zap.String("remote-peer-id", p.peerID.String()),
- )
- } else {
- plog.Infof("started HTTP pipelining with peer %s", p.peerID)
- }
-}
-
-func (p *pipeline) stop() {
- close(p.stopc)
- p.wg.Wait()
-
- if p.tr != nil && p.tr.Logger != nil {
- p.tr.Logger.Info(
- "stopped HTTP pipelining with remote peer",
- zap.String("local-member-id", p.tr.ID.String()),
- zap.String("remote-peer-id", p.peerID.String()),
- )
- } else {
- plog.Infof("stopped HTTP pipelining with peer %s", p.peerID)
- }
-}
-
-func (p *pipeline) handle() {
- defer p.wg.Done()
-
- for {
- select {
- case m := <-p.msgc:
- start := time.Now()
- err := p.post(pbutil.MustMarshal(&m))
- end := time.Now()
-
- if err != nil {
- p.status.deactivate(failureType{source: pipelineMsg, action: "write"}, err.Error())
-
- if m.Type == raftpb.MsgApp && p.followerStats != nil {
- p.followerStats.Fail()
- }
- p.raft.ReportUnreachable(m.To)
- if isMsgSnap(m) {
- p.raft.ReportSnapshot(m.To, raft.SnapshotFailure)
- }
- sentFailures.WithLabelValues(types.ID(m.To).String()).Inc()
- continue
- }
-
- p.status.activate()
- if m.Type == raftpb.MsgApp && p.followerStats != nil {
- p.followerStats.Succ(end.Sub(start))
- }
- if isMsgSnap(m) {
- p.raft.ReportSnapshot(m.To, raft.SnapshotFinish)
- }
- sentBytes.WithLabelValues(types.ID(m.To).String()).Add(float64(m.Size()))
- case <-p.stopc:
- return
- }
- }
-}
-
-// post POSTs a data payload to a url. Returns nil if the POST succeeds,
-// error on any failure.
-func (p *pipeline) post(data []byte) (err error) {
- u := p.picker.pick()
- req := createPostRequest(u, RaftPrefix, bytes.NewBuffer(data), "application/protobuf", p.tr.URLs, p.tr.ID, p.tr.ClusterID)
-
- done := make(chan struct{}, 1)
- ctx, cancel := context.WithCancel(context.Background())
- req = req.WithContext(ctx)
- go func() {
- select {
- case <-done:
- case <-p.stopc:
- waitSchedule()
- cancel()
- }
- }()
-
- resp, err := p.tr.pipelineRt.RoundTrip(req)
- done <- struct{}{}
- if err != nil {
- p.picker.unreachable(u)
- return err
- }
- defer resp.Body.Close()
- b, err := ioutil.ReadAll(resp.Body)
- if err != nil {
- p.picker.unreachable(u)
- return err
- }
-
- err = checkPostResponse(resp, b, req, p.peerID)
- if err != nil {
- p.picker.unreachable(u)
- // errMemberRemoved is a critical error since a removed member should
- // always be stopped. So we use reportCriticalError to report it to errorc.
- if err == errMemberRemoved {
- reportCriticalError(err, p.errorc)
- }
- return err
- }
-
- return nil
-}
-
-// waitSchedule waits other goroutines to be scheduled for a while
-func waitSchedule() { time.Sleep(time.Millisecond) }
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/probing_status.go b/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/probing_status.go
deleted file mode 100644
index 474d9a0..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/probing_status.go
+++ /dev/null
@@ -1,104 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package rafthttp
-
-import (
- "time"
-
- "github.com/prometheus/client_golang/prometheus"
- "github.com/xiang90/probing"
- "go.uber.org/zap"
-)
-
-const (
- // RoundTripperNameRaftMessage is the name of round-tripper that sends
- // all other Raft messages, other than "snap.Message".
- RoundTripperNameRaftMessage = "ROUND_TRIPPER_RAFT_MESSAGE"
- // RoundTripperNameSnapshot is the name of round-tripper that sends merged snapshot message.
- RoundTripperNameSnapshot = "ROUND_TRIPPER_SNAPSHOT"
-)
-
-var (
- // proberInterval must be shorter than read timeout.
- // Or the connection will time-out.
- proberInterval = ConnReadTimeout - time.Second
- statusMonitoringInterval = 30 * time.Second
- statusErrorInterval = 5 * time.Second
-)
-
-func addPeerToProber(lg *zap.Logger, p probing.Prober, id string, us []string, roundTripperName string, rttSecProm *prometheus.HistogramVec) {
- hus := make([]string, len(us))
- for i := range us {
- hus[i] = us[i] + ProbingPrefix
- }
-
- p.AddHTTP(id, proberInterval, hus)
-
- s, err := p.Status(id)
- if err != nil {
- if lg != nil {
- lg.Warn("failed to add peer into prober", zap.String("remote-peer-id", id))
- } else {
- plog.Errorf("failed to add peer %s into prober", id)
- }
- return
- }
-
- go monitorProbingStatus(lg, s, id, roundTripperName, rttSecProm)
-}
-
-func monitorProbingStatus(lg *zap.Logger, s probing.Status, id string, roundTripperName string, rttSecProm *prometheus.HistogramVec) {
- // set the first interval short to log error early.
- interval := statusErrorInterval
- for {
- select {
- case <-time.After(interval):
- if !s.Health() {
- if lg != nil {
- lg.Warn(
- "prober detected unhealthy status",
- zap.String("round-tripper-name", roundTripperName),
- zap.String("remote-peer-id", id),
- zap.Duration("rtt", s.SRTT()),
- zap.Error(s.Err()),
- )
- } else {
- plog.Warningf("health check for peer %s could not connect: %v", id, s.Err())
- }
- interval = statusErrorInterval
- } else {
- interval = statusMonitoringInterval
- }
- if s.ClockDiff() > time.Second {
- if lg != nil {
- lg.Warn(
- "prober found high clock drift",
- zap.String("round-tripper-name", roundTripperName),
- zap.String("remote-peer-id", id),
- zap.Duration("clock-drift", s.ClockDiff()),
- zap.Duration("rtt", s.SRTT()),
- zap.Error(s.Err()),
- )
- } else {
- plog.Warningf("the clock difference against peer %s is too high [%v > %v]", id, s.ClockDiff(), time.Second)
- }
- }
- rttSecProm.WithLabelValues(id).Observe(s.SRTT().Seconds())
-
- case <-s.StopNotify():
- return
- }
- }
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/remote.go b/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/remote.go
deleted file mode 100644
index 1ef2493..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/remote.go
+++ /dev/null
@@ -1,99 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package rafthttp
-
-import (
- "go.etcd.io/etcd/pkg/types"
- "go.etcd.io/etcd/raft/raftpb"
-
- "go.uber.org/zap"
-)
-
-type remote struct {
- lg *zap.Logger
- localID types.ID
- id types.ID
- status *peerStatus
- pipeline *pipeline
-}
-
-func startRemote(tr *Transport, urls types.URLs, id types.ID) *remote {
- picker := newURLPicker(urls)
- status := newPeerStatus(tr.Logger, tr.ID, id)
- pipeline := &pipeline{
- peerID: id,
- tr: tr,
- picker: picker,
- status: status,
- raft: tr.Raft,
- errorc: tr.ErrorC,
- }
- pipeline.start()
-
- return &remote{
- lg: tr.Logger,
- localID: tr.ID,
- id: id,
- status: status,
- pipeline: pipeline,
- }
-}
-
-func (g *remote) send(m raftpb.Message) {
- select {
- case g.pipeline.msgc <- m:
- default:
- if g.status.isActive() {
- if g.lg != nil {
- g.lg.Warn(
- "dropped internal Raft message since sending buffer is full (overloaded network)",
- zap.String("message-type", m.Type.String()),
- zap.String("local-member-id", g.localID.String()),
- zap.String("from", types.ID(m.From).String()),
- zap.String("remote-peer-id", g.id.String()),
- zap.Bool("remote-peer-active", g.status.isActive()),
- )
- } else {
- plog.MergeWarningf("dropped internal raft message to %s since sending buffer is full (bad/overloaded network)", g.id)
- }
- } else {
- if g.lg != nil {
- g.lg.Warn(
- "dropped Raft message since sending buffer is full (overloaded network)",
- zap.String("message-type", m.Type.String()),
- zap.String("local-member-id", g.localID.String()),
- zap.String("from", types.ID(m.From).String()),
- zap.String("remote-peer-id", g.id.String()),
- zap.Bool("remote-peer-active", g.status.isActive()),
- )
- } else {
- plog.Debugf("dropped %s to %s since sending buffer is full", m.Type, g.id)
- }
- }
- sentFailures.WithLabelValues(types.ID(m.To).String()).Inc()
- }
-}
-
-func (g *remote) stop() {
- g.pipeline.stop()
-}
-
-func (g *remote) Pause() {
- g.stop()
-}
-
-func (g *remote) Resume() {
- g.pipeline.start()
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/snapshot_sender.go b/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/snapshot_sender.go
deleted file mode 100644
index 62efb0c..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/snapshot_sender.go
+++ /dev/null
@@ -1,207 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package rafthttp
-
-import (
- "bytes"
- "context"
- "io"
- "io/ioutil"
- "net/http"
- "time"
-
- "go.etcd.io/etcd/etcdserver/api/snap"
- "go.etcd.io/etcd/pkg/httputil"
- pioutil "go.etcd.io/etcd/pkg/ioutil"
- "go.etcd.io/etcd/pkg/types"
- "go.etcd.io/etcd/raft"
-
- "github.com/dustin/go-humanize"
- "go.uber.org/zap"
-)
-
-var (
- // timeout for reading snapshot response body
- snapResponseReadTimeout = 5 * time.Second
-)
-
-type snapshotSender struct {
- from, to types.ID
- cid types.ID
-
- tr *Transport
- picker *urlPicker
- status *peerStatus
- r Raft
- errorc chan error
-
- stopc chan struct{}
-}
-
-func newSnapshotSender(tr *Transport, picker *urlPicker, to types.ID, status *peerStatus) *snapshotSender {
- return &snapshotSender{
- from: tr.ID,
- to: to,
- cid: tr.ClusterID,
- tr: tr,
- picker: picker,
- status: status,
- r: tr.Raft,
- errorc: tr.ErrorC,
- stopc: make(chan struct{}),
- }
-}
-
-func (s *snapshotSender) stop() { close(s.stopc) }
-
-func (s *snapshotSender) send(merged snap.Message) {
- start := time.Now()
-
- m := merged.Message
- to := types.ID(m.To).String()
-
- body := createSnapBody(s.tr.Logger, merged)
- defer body.Close()
-
- u := s.picker.pick()
- req := createPostRequest(u, RaftSnapshotPrefix, body, "application/octet-stream", s.tr.URLs, s.from, s.cid)
-
- if s.tr.Logger != nil {
- s.tr.Logger.Info(
- "sending database snapshot",
- zap.Uint64("snapshot-index", m.Snapshot.Metadata.Index),
- zap.String("remote-peer-id", to),
- zap.Int64("bytes", merged.TotalSize),
- zap.String("size", humanize.Bytes(uint64(merged.TotalSize))),
- )
- } else {
- plog.Infof("start to send database snapshot [index: %d, to %s]...", m.Snapshot.Metadata.Index, types.ID(m.To))
- }
-
- snapshotSendInflights.WithLabelValues(to).Inc()
- defer func() {
- snapshotSendInflights.WithLabelValues(to).Dec()
- }()
-
- err := s.post(req)
- defer merged.CloseWithError(err)
- if err != nil {
- if s.tr.Logger != nil {
- s.tr.Logger.Warn(
- "failed to send database snapshot",
- zap.Uint64("snapshot-index", m.Snapshot.Metadata.Index),
- zap.String("remote-peer-id", to),
- zap.Int64("bytes", merged.TotalSize),
- zap.String("size", humanize.Bytes(uint64(merged.TotalSize))),
- zap.Error(err),
- )
- } else {
- plog.Warningf("database snapshot [index: %d, to: %s] failed to be sent out (%v)", m.Snapshot.Metadata.Index, types.ID(m.To), err)
- }
-
- // errMemberRemoved is a critical error since a removed member should
- // always be stopped. So we use reportCriticalError to report it to errorc.
- if err == errMemberRemoved {
- reportCriticalError(err, s.errorc)
- }
-
- s.picker.unreachable(u)
- s.status.deactivate(failureType{source: sendSnap, action: "post"}, err.Error())
- s.r.ReportUnreachable(m.To)
- // report SnapshotFailure to raft state machine. After raft state
- // machine knows about it, it would pause a while and retry sending
- // new snapshot message.
- s.r.ReportSnapshot(m.To, raft.SnapshotFailure)
- sentFailures.WithLabelValues(to).Inc()
- snapshotSendFailures.WithLabelValues(to).Inc()
- return
- }
- s.status.activate()
- s.r.ReportSnapshot(m.To, raft.SnapshotFinish)
-
- if s.tr.Logger != nil {
- s.tr.Logger.Info(
- "sent database snapshot",
- zap.Uint64("snapshot-index", m.Snapshot.Metadata.Index),
- zap.String("remote-peer-id", to),
- zap.Int64("bytes", merged.TotalSize),
- zap.String("size", humanize.Bytes(uint64(merged.TotalSize))),
- )
- } else {
- plog.Infof("database snapshot [index: %d, to: %s] sent out successfully", m.Snapshot.Metadata.Index, types.ID(m.To))
- }
-
- sentBytes.WithLabelValues(to).Add(float64(merged.TotalSize))
- snapshotSend.WithLabelValues(to).Inc()
- snapshotSendSeconds.WithLabelValues(to).Observe(time.Since(start).Seconds())
-}
-
-// post posts the given request.
-// It returns nil when request is sent out and processed successfully.
-func (s *snapshotSender) post(req *http.Request) (err error) {
- ctx, cancel := context.WithCancel(context.Background())
- req = req.WithContext(ctx)
- defer cancel()
-
- type responseAndError struct {
- resp *http.Response
- body []byte
- err error
- }
- result := make(chan responseAndError, 1)
-
- go func() {
- resp, err := s.tr.pipelineRt.RoundTrip(req)
- if err != nil {
- result <- responseAndError{resp, nil, err}
- return
- }
-
- // close the response body when timeouts.
- // prevents from reading the body forever when the other side dies right after
- // successfully receives the request body.
- time.AfterFunc(snapResponseReadTimeout, func() { httputil.GracefulClose(resp) })
- body, err := ioutil.ReadAll(resp.Body)
- result <- responseAndError{resp, body, err}
- }()
-
- select {
- case <-s.stopc:
- return errStopped
- case r := <-result:
- if r.err != nil {
- return r.err
- }
- return checkPostResponse(r.resp, r.body, req, s.to)
- }
-}
-
-func createSnapBody(lg *zap.Logger, merged snap.Message) io.ReadCloser {
- buf := new(bytes.Buffer)
- enc := &messageEncoder{w: buf}
- // encode raft message
- if err := enc.encode(&merged.Message); err != nil {
- if lg != nil {
- lg.Panic("failed to encode message", zap.Error(err))
- } else {
- plog.Panicf("encode message error (%v)", err)
- }
- }
-
- return &pioutil.ReaderAndCloser{
- Reader: io.MultiReader(buf, merged.ReadCloser),
- Closer: merged.ReadCloser,
- }
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/stream.go b/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/stream.go
deleted file mode 100644
index dcb2223..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/stream.go
+++ /dev/null
@@ -1,746 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package rafthttp
-
-import (
- "context"
- "fmt"
- "io"
- "io/ioutil"
- "net/http"
- "path"
- "strings"
- "sync"
- "time"
-
- stats "go.etcd.io/etcd/etcdserver/api/v2stats"
- "go.etcd.io/etcd/pkg/httputil"
- "go.etcd.io/etcd/pkg/transport"
- "go.etcd.io/etcd/pkg/types"
- "go.etcd.io/etcd/raft/raftpb"
- "go.etcd.io/etcd/version"
-
- "github.com/coreos/go-semver/semver"
- "go.uber.org/zap"
- "golang.org/x/time/rate"
-)
-
-const (
- streamTypeMessage streamType = "message"
- streamTypeMsgAppV2 streamType = "msgappv2"
-
- streamBufSize = 4096
-)
-
-var (
- errUnsupportedStreamType = fmt.Errorf("unsupported stream type")
-
- // the key is in string format "major.minor.patch"
- supportedStream = map[string][]streamType{
- "2.0.0": {},
- "2.1.0": {streamTypeMsgAppV2, streamTypeMessage},
- "2.2.0": {streamTypeMsgAppV2, streamTypeMessage},
- "2.3.0": {streamTypeMsgAppV2, streamTypeMessage},
- "3.0.0": {streamTypeMsgAppV2, streamTypeMessage},
- "3.1.0": {streamTypeMsgAppV2, streamTypeMessage},
- "3.2.0": {streamTypeMsgAppV2, streamTypeMessage},
- "3.3.0": {streamTypeMsgAppV2, streamTypeMessage},
- }
-)
-
-type streamType string
-
-func (t streamType) endpoint() string {
- switch t {
- case streamTypeMsgAppV2:
- return path.Join(RaftStreamPrefix, "msgapp")
- case streamTypeMessage:
- return path.Join(RaftStreamPrefix, "message")
- default:
- plog.Panicf("unhandled stream type %v", t)
- return ""
- }
-}
-
-func (t streamType) String() string {
- switch t {
- case streamTypeMsgAppV2:
- return "stream MsgApp v2"
- case streamTypeMessage:
- return "stream Message"
- default:
- return "unknown stream"
- }
-}
-
-var (
- // linkHeartbeatMessage is a special message used as heartbeat message in
- // link layer. It never conflicts with messages from raft because raft
- // doesn't send out messages without From and To fields.
- linkHeartbeatMessage = raftpb.Message{Type: raftpb.MsgHeartbeat}
-)
-
-func isLinkHeartbeatMessage(m *raftpb.Message) bool {
- return m.Type == raftpb.MsgHeartbeat && m.From == 0 && m.To == 0
-}
-
-type outgoingConn struct {
- t streamType
- io.Writer
- http.Flusher
- io.Closer
-
- localID types.ID
- peerID types.ID
-}
-
-// streamWriter writes messages to the attached outgoingConn.
-type streamWriter struct {
- lg *zap.Logger
-
- localID types.ID
- peerID types.ID
-
- status *peerStatus
- fs *stats.FollowerStats
- r Raft
-
- mu sync.Mutex // guard field working and closer
- closer io.Closer
- working bool
-
- msgc chan raftpb.Message
- connc chan *outgoingConn
- stopc chan struct{}
- done chan struct{}
-}
-
-// startStreamWriter creates a streamWrite and starts a long running go-routine that accepts
-// messages and writes to the attached outgoing connection.
-func startStreamWriter(lg *zap.Logger, local, id types.ID, status *peerStatus, fs *stats.FollowerStats, r Raft) *streamWriter {
- w := &streamWriter{
- lg: lg,
-
- localID: local,
- peerID: id,
-
- status: status,
- fs: fs,
- r: r,
- msgc: make(chan raftpb.Message, streamBufSize),
- connc: make(chan *outgoingConn),
- stopc: make(chan struct{}),
- done: make(chan struct{}),
- }
- go w.run()
- return w
-}
-
-func (cw *streamWriter) run() {
- var (
- msgc chan raftpb.Message
- heartbeatc <-chan time.Time
- t streamType
- enc encoder
- flusher http.Flusher
- batched int
- )
- tickc := time.NewTicker(ConnReadTimeout / 3)
- defer tickc.Stop()
- unflushed := 0
-
- if cw.lg != nil {
- cw.lg.Info(
- "started stream writer with remote peer",
- zap.String("local-member-id", cw.localID.String()),
- zap.String("remote-peer-id", cw.peerID.String()),
- )
- } else {
- plog.Infof("started streaming with peer %s (writer)", cw.peerID)
- }
-
- for {
- select {
- case <-heartbeatc:
- err := enc.encode(&linkHeartbeatMessage)
- unflushed += linkHeartbeatMessage.Size()
- if err == nil {
- flusher.Flush()
- batched = 0
- sentBytes.WithLabelValues(cw.peerID.String()).Add(float64(unflushed))
- unflushed = 0
- continue
- }
-
- cw.status.deactivate(failureType{source: t.String(), action: "heartbeat"}, err.Error())
-
- sentFailures.WithLabelValues(cw.peerID.String()).Inc()
- cw.close()
- if cw.lg != nil {
- cw.lg.Warn(
- "lost TCP streaming connection with remote peer",
- zap.String("stream-writer-type", t.String()),
- zap.String("local-member-id", cw.localID.String()),
- zap.String("remote-peer-id", cw.peerID.String()),
- )
- } else {
- plog.Warningf("lost the TCP streaming connection with peer %s (%s writer)", cw.peerID, t)
- }
- heartbeatc, msgc = nil, nil
-
- case m := <-msgc:
- err := enc.encode(&m)
- if err == nil {
- unflushed += m.Size()
-
- if len(msgc) == 0 || batched > streamBufSize/2 {
- flusher.Flush()
- sentBytes.WithLabelValues(cw.peerID.String()).Add(float64(unflushed))
- unflushed = 0
- batched = 0
- } else {
- batched++
- }
-
- continue
- }
-
- cw.status.deactivate(failureType{source: t.String(), action: "write"}, err.Error())
- cw.close()
- if cw.lg != nil {
- cw.lg.Warn(
- "lost TCP streaming connection with remote peer",
- zap.String("stream-writer-type", t.String()),
- zap.String("local-member-id", cw.localID.String()),
- zap.String("remote-peer-id", cw.peerID.String()),
- )
- } else {
- plog.Warningf("lost the TCP streaming connection with peer %s (%s writer)", cw.peerID, t)
- }
- heartbeatc, msgc = nil, nil
- cw.r.ReportUnreachable(m.To)
- sentFailures.WithLabelValues(cw.peerID.String()).Inc()
-
- case conn := <-cw.connc:
- cw.mu.Lock()
- closed := cw.closeUnlocked()
- t = conn.t
- switch conn.t {
- case streamTypeMsgAppV2:
- enc = newMsgAppV2Encoder(conn.Writer, cw.fs)
- case streamTypeMessage:
- enc = &messageEncoder{w: conn.Writer}
- default:
- plog.Panicf("unhandled stream type %s", conn.t)
- }
- if cw.lg != nil {
- cw.lg.Info(
- "set message encoder",
- zap.String("from", conn.localID.String()),
- zap.String("to", conn.peerID.String()),
- zap.String("stream-type", t.String()),
- )
- }
- flusher = conn.Flusher
- unflushed = 0
- cw.status.activate()
- cw.closer = conn.Closer
- cw.working = true
- cw.mu.Unlock()
-
- if closed {
- if cw.lg != nil {
- cw.lg.Warn(
- "closed TCP streaming connection with remote peer",
- zap.String("stream-writer-type", t.String()),
- zap.String("local-member-id", cw.localID.String()),
- zap.String("remote-peer-id", cw.peerID.String()),
- )
- } else {
- plog.Warningf("closed an existing TCP streaming connection with peer %s (%s writer)", cw.peerID, t)
- }
- }
- if cw.lg != nil {
- cw.lg.Warn(
- "established TCP streaming connection with remote peer",
- zap.String("stream-writer-type", t.String()),
- zap.String("local-member-id", cw.localID.String()),
- zap.String("remote-peer-id", cw.peerID.String()),
- )
- } else {
- plog.Infof("established a TCP streaming connection with peer %s (%s writer)", cw.peerID, t)
- }
- heartbeatc, msgc = tickc.C, cw.msgc
-
- case <-cw.stopc:
- if cw.close() {
- if cw.lg != nil {
- cw.lg.Warn(
- "closed TCP streaming connection with remote peer",
- zap.String("stream-writer-type", t.String()),
- zap.String("remote-peer-id", cw.peerID.String()),
- )
- } else {
- plog.Infof("closed the TCP streaming connection with peer %s (%s writer)", cw.peerID, t)
- }
- }
- if cw.lg != nil {
- cw.lg.Warn(
- "stopped TCP streaming connection with remote peer",
- zap.String("stream-writer-type", t.String()),
- zap.String("remote-peer-id", cw.peerID.String()),
- )
- } else {
- plog.Infof("stopped streaming with peer %s (writer)", cw.peerID)
- }
- close(cw.done)
- return
- }
- }
-}
-
-func (cw *streamWriter) writec() (chan<- raftpb.Message, bool) {
- cw.mu.Lock()
- defer cw.mu.Unlock()
- return cw.msgc, cw.working
-}
-
-func (cw *streamWriter) close() bool {
- cw.mu.Lock()
- defer cw.mu.Unlock()
- return cw.closeUnlocked()
-}
-
-func (cw *streamWriter) closeUnlocked() bool {
- if !cw.working {
- return false
- }
- if err := cw.closer.Close(); err != nil {
- if cw.lg != nil {
- cw.lg.Warn(
- "failed to close connection with remote peer",
- zap.String("remote-peer-id", cw.peerID.String()),
- zap.Error(err),
- )
- } else {
- plog.Errorf("peer %s (writer) connection close error: %v", cw.peerID, err)
- }
- }
- if len(cw.msgc) > 0 {
- cw.r.ReportUnreachable(uint64(cw.peerID))
- }
- cw.msgc = make(chan raftpb.Message, streamBufSize)
- cw.working = false
- return true
-}
-
-func (cw *streamWriter) attach(conn *outgoingConn) bool {
- select {
- case cw.connc <- conn:
- return true
- case <-cw.done:
- return false
- }
-}
-
-func (cw *streamWriter) stop() {
- close(cw.stopc)
- <-cw.done
-}
-
-// streamReader is a long-running go-routine that dials to the remote stream
-// endpoint and reads messages from the response body returned.
-type streamReader struct {
- lg *zap.Logger
-
- peerID types.ID
- typ streamType
-
- tr *Transport
- picker *urlPicker
- status *peerStatus
- recvc chan<- raftpb.Message
- propc chan<- raftpb.Message
-
- rl *rate.Limiter // alters the frequency of dial retrial attempts
-
- errorc chan<- error
-
- mu sync.Mutex
- paused bool
- closer io.Closer
-
- ctx context.Context
- cancel context.CancelFunc
- done chan struct{}
-}
-
-func (cr *streamReader) start() {
- cr.done = make(chan struct{})
- if cr.errorc == nil {
- cr.errorc = cr.tr.ErrorC
- }
- if cr.ctx == nil {
- cr.ctx, cr.cancel = context.WithCancel(context.Background())
- }
- go cr.run()
-}
-
-func (cr *streamReader) run() {
- t := cr.typ
-
- if cr.lg != nil {
- cr.lg.Info(
- "started stream reader with remote peer",
- zap.String("stream-reader-type", t.String()),
- zap.String("local-member-id", cr.tr.ID.String()),
- zap.String("remote-peer-id", cr.peerID.String()),
- )
- } else {
- plog.Infof("started streaming with peer %s (%s reader)", cr.peerID, t)
- }
-
- for {
- rc, err := cr.dial(t)
- if err != nil {
- if err != errUnsupportedStreamType {
- cr.status.deactivate(failureType{source: t.String(), action: "dial"}, err.Error())
- }
- } else {
- cr.status.activate()
- if cr.lg != nil {
- cr.lg.Info(
- "established TCP streaming connection with remote peer",
- zap.String("stream-reader-type", cr.typ.String()),
- zap.String("local-member-id", cr.tr.ID.String()),
- zap.String("remote-peer-id", cr.peerID.String()),
- )
- } else {
- plog.Infof("established a TCP streaming connection with peer %s (%s reader)", cr.peerID, cr.typ)
- }
- err = cr.decodeLoop(rc, t)
- if cr.lg != nil {
- cr.lg.Warn(
- "lost TCP streaming connection with remote peer",
- zap.String("stream-reader-type", cr.typ.String()),
- zap.String("local-member-id", cr.tr.ID.String()),
- zap.String("remote-peer-id", cr.peerID.String()),
- zap.Error(err),
- )
- } else {
- plog.Warningf("lost the TCP streaming connection with peer %s (%s reader)", cr.peerID, cr.typ)
- }
- switch {
- // all data is read out
- case err == io.EOF:
- // connection is closed by the remote
- case transport.IsClosedConnError(err):
- default:
- cr.status.deactivate(failureType{source: t.String(), action: "read"}, err.Error())
- }
- }
- // Wait for a while before new dial attempt
- err = cr.rl.Wait(cr.ctx)
- if cr.ctx.Err() != nil {
- if cr.lg != nil {
- cr.lg.Info(
- "stopped stream reader with remote peer",
- zap.String("stream-reader-type", t.String()),
- zap.String("local-member-id", cr.tr.ID.String()),
- zap.String("remote-peer-id", cr.peerID.String()),
- )
- } else {
- plog.Infof("stopped streaming with peer %s (%s reader)", cr.peerID, t)
- }
- close(cr.done)
- return
- }
- if err != nil {
- if cr.lg != nil {
- cr.lg.Warn(
- "rate limit on stream reader with remote peer",
- zap.String("stream-reader-type", t.String()),
- zap.String("local-member-id", cr.tr.ID.String()),
- zap.String("remote-peer-id", cr.peerID.String()),
- zap.Error(err),
- )
- } else {
- plog.Errorf("streaming with peer %s (%s reader) rate limiter error: %v", cr.peerID, t, err)
- }
- }
- }
-}
-
-func (cr *streamReader) decodeLoop(rc io.ReadCloser, t streamType) error {
- var dec decoder
- cr.mu.Lock()
- switch t {
- case streamTypeMsgAppV2:
- dec = newMsgAppV2Decoder(rc, cr.tr.ID, cr.peerID)
- case streamTypeMessage:
- dec = &messageDecoder{r: rc}
- default:
- if cr.lg != nil {
- cr.lg.Panic("unknown stream type", zap.String("type", t.String()))
- } else {
- plog.Panicf("unhandled stream type %s", t)
- }
- }
- select {
- case <-cr.ctx.Done():
- cr.mu.Unlock()
- if err := rc.Close(); err != nil {
- return err
- }
- return io.EOF
- default:
- cr.closer = rc
- }
- cr.mu.Unlock()
-
- // gofail: labelRaftDropHeartbeat:
- for {
- m, err := dec.decode()
- if err != nil {
- cr.mu.Lock()
- cr.close()
- cr.mu.Unlock()
- return err
- }
-
- // gofail-go: var raftDropHeartbeat struct{}
- // continue labelRaftDropHeartbeat
- receivedBytes.WithLabelValues(types.ID(m.From).String()).Add(float64(m.Size()))
-
- cr.mu.Lock()
- paused := cr.paused
- cr.mu.Unlock()
-
- if paused {
- continue
- }
-
- if isLinkHeartbeatMessage(&m) {
- // raft is not interested in link layer
- // heartbeat message, so we should ignore
- // it.
- continue
- }
-
- recvc := cr.recvc
- if m.Type == raftpb.MsgProp {
- recvc = cr.propc
- }
-
- select {
- case recvc <- m:
- default:
- if cr.status.isActive() {
- if cr.lg != nil {
- cr.lg.Warn(
- "dropped internal Raft message since receiving buffer is full (overloaded network)",
- zap.String("message-type", m.Type.String()),
- zap.String("local-member-id", cr.tr.ID.String()),
- zap.String("from", types.ID(m.From).String()),
- zap.String("remote-peer-id", types.ID(m.To).String()),
- zap.Bool("remote-peer-active", cr.status.isActive()),
- )
- } else {
- plog.MergeWarningf("dropped internal raft message from %s since receiving buffer is full (overloaded network)", types.ID(m.From))
- }
- } else {
- if cr.lg != nil {
- cr.lg.Warn(
- "dropped Raft message since receiving buffer is full (overloaded network)",
- zap.String("message-type", m.Type.String()),
- zap.String("local-member-id", cr.tr.ID.String()),
- zap.String("from", types.ID(m.From).String()),
- zap.String("remote-peer-id", types.ID(m.To).String()),
- zap.Bool("remote-peer-active", cr.status.isActive()),
- )
- } else {
- plog.Debugf("dropped %s from %s since receiving buffer is full", m.Type, types.ID(m.From))
- }
- }
- recvFailures.WithLabelValues(types.ID(m.From).String()).Inc()
- }
- }
-}
-
-func (cr *streamReader) stop() {
- cr.mu.Lock()
- cr.cancel()
- cr.close()
- cr.mu.Unlock()
- <-cr.done
-}
-
-func (cr *streamReader) dial(t streamType) (io.ReadCloser, error) {
- u := cr.picker.pick()
- uu := u
- uu.Path = path.Join(t.endpoint(), cr.tr.ID.String())
-
- if cr.lg != nil {
- cr.lg.Debug(
- "dial stream reader",
- zap.String("from", cr.tr.ID.String()),
- zap.String("to", cr.peerID.String()),
- zap.String("address", uu.String()),
- )
- }
- req, err := http.NewRequest("GET", uu.String(), nil)
- if err != nil {
- cr.picker.unreachable(u)
- return nil, fmt.Errorf("failed to make http request to %v (%v)", u, err)
- }
- req.Header.Set("X-Server-From", cr.tr.ID.String())
- req.Header.Set("X-Server-Version", version.Version)
- req.Header.Set("X-Min-Cluster-Version", version.MinClusterVersion)
- req.Header.Set("X-Etcd-Cluster-ID", cr.tr.ClusterID.String())
- req.Header.Set("X-Raft-To", cr.peerID.String())
-
- setPeerURLsHeader(req, cr.tr.URLs)
-
- req = req.WithContext(cr.ctx)
-
- cr.mu.Lock()
- select {
- case <-cr.ctx.Done():
- cr.mu.Unlock()
- return nil, fmt.Errorf("stream reader is stopped")
- default:
- }
- cr.mu.Unlock()
-
- resp, err := cr.tr.streamRt.RoundTrip(req)
- if err != nil {
- cr.picker.unreachable(u)
- return nil, err
- }
-
- rv := serverVersion(resp.Header)
- lv := semver.Must(semver.NewVersion(version.Version))
- if compareMajorMinorVersion(rv, lv) == -1 && !checkStreamSupport(rv, t) {
- httputil.GracefulClose(resp)
- cr.picker.unreachable(u)
- return nil, errUnsupportedStreamType
- }
-
- switch resp.StatusCode {
- case http.StatusGone:
- httputil.GracefulClose(resp)
- cr.picker.unreachable(u)
- reportCriticalError(errMemberRemoved, cr.errorc)
- return nil, errMemberRemoved
-
- case http.StatusOK:
- return resp.Body, nil
-
- case http.StatusNotFound:
- httputil.GracefulClose(resp)
- cr.picker.unreachable(u)
- return nil, fmt.Errorf("peer %s failed to find local node %s", cr.peerID, cr.tr.ID)
-
- case http.StatusPreconditionFailed:
- b, err := ioutil.ReadAll(resp.Body)
- if err != nil {
- cr.picker.unreachable(u)
- return nil, err
- }
- httputil.GracefulClose(resp)
- cr.picker.unreachable(u)
-
- switch strings.TrimSuffix(string(b), "\n") {
- case errIncompatibleVersion.Error():
- if cr.lg != nil {
- cr.lg.Warn(
- "request sent was ignored by remote peer due to server version incompatibility",
- zap.String("local-member-id", cr.tr.ID.String()),
- zap.String("remote-peer-id", cr.peerID.String()),
- zap.Error(errIncompatibleVersion),
- )
- } else {
- plog.Errorf("request sent was ignored by peer %s (server version incompatible)", cr.peerID)
- }
- return nil, errIncompatibleVersion
-
- case errClusterIDMismatch.Error():
- if cr.lg != nil {
- cr.lg.Warn(
- "request sent was ignored by remote peer due to cluster ID mismatch",
- zap.String("remote-peer-id", cr.peerID.String()),
- zap.String("remote-peer-cluster-id", resp.Header.Get("X-Etcd-Cluster-ID")),
- zap.String("local-member-id", cr.tr.ID.String()),
- zap.String("local-member-cluster-id", cr.tr.ClusterID.String()),
- zap.Error(errClusterIDMismatch),
- )
- } else {
- plog.Errorf("request sent was ignored (cluster ID mismatch: peer[%s]=%s, local=%s)",
- cr.peerID, resp.Header.Get("X-Etcd-Cluster-ID"), cr.tr.ClusterID)
- }
- return nil, errClusterIDMismatch
-
- default:
- return nil, fmt.Errorf("unhandled error %q when precondition failed", string(b))
- }
-
- default:
- httputil.GracefulClose(resp)
- cr.picker.unreachable(u)
- return nil, fmt.Errorf("unhandled http status %d", resp.StatusCode)
- }
-}
-
-func (cr *streamReader) close() {
- if cr.closer != nil {
- if err := cr.closer.Close(); err != nil {
- if cr.lg != nil {
- cr.lg.Warn(
- "failed to close remote peer connection",
- zap.String("local-member-id", cr.tr.ID.String()),
- zap.String("remote-peer-id", cr.peerID.String()),
- zap.Error(err),
- )
- } else {
- plog.Errorf("peer %s (reader) connection close error: %v", cr.peerID, err)
- }
- }
- }
- cr.closer = nil
-}
-
-func (cr *streamReader) pause() {
- cr.mu.Lock()
- defer cr.mu.Unlock()
- cr.paused = true
-}
-
-func (cr *streamReader) resume() {
- cr.mu.Lock()
- defer cr.mu.Unlock()
- cr.paused = false
-}
-
-// checkStreamSupport checks whether the stream type is supported in the
-// given version.
-func checkStreamSupport(v *semver.Version, t streamType) bool {
- nv := &semver.Version{Major: v.Major, Minor: v.Minor}
- for _, s := range supportedStream[nv.String()] {
- if s == t {
- return true
- }
- }
- return false
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/transport.go b/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/transport.go
deleted file mode 100644
index 7191c3d..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/transport.go
+++ /dev/null
@@ -1,467 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package rafthttp
-
-import (
- "context"
- "net/http"
- "sync"
- "time"
-
- "go.etcd.io/etcd/etcdserver/api/snap"
- stats "go.etcd.io/etcd/etcdserver/api/v2stats"
- "go.etcd.io/etcd/pkg/logutil"
- "go.etcd.io/etcd/pkg/transport"
- "go.etcd.io/etcd/pkg/types"
- "go.etcd.io/etcd/raft"
- "go.etcd.io/etcd/raft/raftpb"
-
- "github.com/coreos/pkg/capnslog"
- "github.com/xiang90/probing"
- "go.uber.org/zap"
- "golang.org/x/time/rate"
-)
-
-var plog = logutil.NewMergeLogger(capnslog.NewPackageLogger("go.etcd.io/etcd", "rafthttp"))
-
-type Raft interface {
- Process(ctx context.Context, m raftpb.Message) error
- IsIDRemoved(id uint64) bool
- ReportUnreachable(id uint64)
- ReportSnapshot(id uint64, status raft.SnapshotStatus)
-}
-
-type Transporter interface {
- // Start starts the given Transporter.
- // Start MUST be called before calling other functions in the interface.
- Start() error
- // Handler returns the HTTP handler of the transporter.
- // A transporter HTTP handler handles the HTTP requests
- // from remote peers.
- // The handler MUST be used to handle RaftPrefix(/raft)
- // endpoint.
- Handler() http.Handler
- // Send sends out the given messages to the remote peers.
- // Each message has a To field, which is an id that maps
- // to an existing peer in the transport.
- // If the id cannot be found in the transport, the message
- // will be ignored.
- Send(m []raftpb.Message)
- // SendSnapshot sends out the given snapshot message to a remote peer.
- // The behavior of SendSnapshot is similar to Send.
- SendSnapshot(m snap.Message)
- // AddRemote adds a remote with given peer urls into the transport.
- // A remote helps newly joined member to catch up the progress of cluster,
- // and will not be used after that.
- // It is the caller's responsibility to ensure the urls are all valid,
- // or it panics.
- AddRemote(id types.ID, urls []string)
- // AddPeer adds a peer with given peer urls into the transport.
- // It is the caller's responsibility to ensure the urls are all valid,
- // or it panics.
- // Peer urls are used to connect to the remote peer.
- AddPeer(id types.ID, urls []string)
- // RemovePeer removes the peer with given id.
- RemovePeer(id types.ID)
- // RemoveAllPeers removes all the existing peers in the transport.
- RemoveAllPeers()
- // UpdatePeer updates the peer urls of the peer with the given id.
- // It is the caller's responsibility to ensure the urls are all valid,
- // or it panics.
- UpdatePeer(id types.ID, urls []string)
- // ActiveSince returns the time that the connection with the peer
- // of the given id becomes active.
- // If the connection is active since peer was added, it returns the adding time.
- // If the connection is currently inactive, it returns zero time.
- ActiveSince(id types.ID) time.Time
- // ActivePeers returns the number of active peers.
- ActivePeers() int
- // Stop closes the connections and stops the transporter.
- Stop()
-}
-
-// Transport implements Transporter interface. It provides the functionality
-// to send raft messages to peers, and receive raft messages from peers.
-// User should call Handler method to get a handler to serve requests
-// received from peerURLs.
-// User needs to call Start before calling other functions, and call
-// Stop when the Transport is no longer used.
-type Transport struct {
- Logger *zap.Logger
-
- DialTimeout time.Duration // maximum duration before timing out dial of the request
- // DialRetryFrequency defines the frequency of streamReader dial retrial attempts;
- // a distinct rate limiter is created per every peer (default value: 10 events/sec)
- DialRetryFrequency rate.Limit
-
- TLSInfo transport.TLSInfo // TLS information used when creating connection
-
- ID types.ID // local member ID
- URLs types.URLs // local peer URLs
- ClusterID types.ID // raft cluster ID for request validation
- Raft Raft // raft state machine, to which the Transport forwards received messages and reports status
- Snapshotter *snap.Snapshotter
- ServerStats *stats.ServerStats // used to record general transportation statistics
- // used to record transportation statistics with followers when
- // performing as leader in raft protocol
- LeaderStats *stats.LeaderStats
- // ErrorC is used to report detected critical errors, e.g.,
- // the member has been permanently removed from the cluster
- // When an error is received from ErrorC, user should stop raft state
- // machine and thus stop the Transport.
- ErrorC chan error
-
- streamRt http.RoundTripper // roundTripper used by streams
- pipelineRt http.RoundTripper // roundTripper used by pipelines
-
- mu sync.RWMutex // protect the remote and peer map
- remotes map[types.ID]*remote // remotes map that helps newly joined member to catch up
- peers map[types.ID]Peer // peers map
-
- pipelineProber probing.Prober
- streamProber probing.Prober
-}
-
-func (t *Transport) Start() error {
- var err error
- t.streamRt, err = newStreamRoundTripper(t.TLSInfo, t.DialTimeout)
- if err != nil {
- return err
- }
- t.pipelineRt, err = NewRoundTripper(t.TLSInfo, t.DialTimeout)
- if err != nil {
- return err
- }
- t.remotes = make(map[types.ID]*remote)
- t.peers = make(map[types.ID]Peer)
- t.pipelineProber = probing.NewProber(t.pipelineRt)
- t.streamProber = probing.NewProber(t.streamRt)
-
- // If client didn't provide dial retry frequency, use the default
- // (100ms backoff between attempts to create a new stream),
- // so it doesn't bring too much overhead when retry.
- if t.DialRetryFrequency == 0 {
- t.DialRetryFrequency = rate.Every(100 * time.Millisecond)
- }
- return nil
-}
-
-func (t *Transport) Handler() http.Handler {
- pipelineHandler := newPipelineHandler(t, t.Raft, t.ClusterID)
- streamHandler := newStreamHandler(t, t, t.Raft, t.ID, t.ClusterID)
- snapHandler := newSnapshotHandler(t, t.Raft, t.Snapshotter, t.ClusterID)
- mux := http.NewServeMux()
- mux.Handle(RaftPrefix, pipelineHandler)
- mux.Handle(RaftStreamPrefix+"/", streamHandler)
- mux.Handle(RaftSnapshotPrefix, snapHandler)
- mux.Handle(ProbingPrefix, probing.NewHandler())
- return mux
-}
-
-func (t *Transport) Get(id types.ID) Peer {
- t.mu.RLock()
- defer t.mu.RUnlock()
- return t.peers[id]
-}
-
-func (t *Transport) Send(msgs []raftpb.Message) {
- for _, m := range msgs {
- if m.To == 0 {
- // ignore intentionally dropped message
- continue
- }
- to := types.ID(m.To)
-
- t.mu.RLock()
- p, pok := t.peers[to]
- g, rok := t.remotes[to]
- t.mu.RUnlock()
-
- if pok {
- if m.Type == raftpb.MsgApp {
- t.ServerStats.SendAppendReq(m.Size())
- }
- p.send(m)
- continue
- }
-
- if rok {
- g.send(m)
- continue
- }
-
- if t.Logger != nil {
- t.Logger.Debug(
- "ignored message send request; unknown remote peer target",
- zap.String("type", m.Type.String()),
- zap.String("unknown-target-peer-id", to.String()),
- )
- } else {
- plog.Debugf("ignored message %s (sent to unknown peer %s)", m.Type, to)
- }
- }
-}
-
-func (t *Transport) Stop() {
- t.mu.Lock()
- defer t.mu.Unlock()
- for _, r := range t.remotes {
- r.stop()
- }
- for _, p := range t.peers {
- p.stop()
- }
- t.pipelineProber.RemoveAll()
- t.streamProber.RemoveAll()
- if tr, ok := t.streamRt.(*http.Transport); ok {
- tr.CloseIdleConnections()
- }
- if tr, ok := t.pipelineRt.(*http.Transport); ok {
- tr.CloseIdleConnections()
- }
- t.peers = nil
- t.remotes = nil
-}
-
-// CutPeer drops messages to the specified peer.
-func (t *Transport) CutPeer(id types.ID) {
- t.mu.RLock()
- p, pok := t.peers[id]
- g, gok := t.remotes[id]
- t.mu.RUnlock()
-
- if pok {
- p.(Pausable).Pause()
- }
- if gok {
- g.Pause()
- }
-}
-
-// MendPeer recovers the message dropping behavior of the given peer.
-func (t *Transport) MendPeer(id types.ID) {
- t.mu.RLock()
- p, pok := t.peers[id]
- g, gok := t.remotes[id]
- t.mu.RUnlock()
-
- if pok {
- p.(Pausable).Resume()
- }
- if gok {
- g.Resume()
- }
-}
-
-func (t *Transport) AddRemote(id types.ID, us []string) {
- t.mu.Lock()
- defer t.mu.Unlock()
- if t.remotes == nil {
- // there's no clean way to shutdown the golang http server
- // (see: https://github.com/golang/go/issues/4674) before
- // stopping the transport; ignore any new connections.
- return
- }
- if _, ok := t.peers[id]; ok {
- return
- }
- if _, ok := t.remotes[id]; ok {
- return
- }
- urls, err := types.NewURLs(us)
- if err != nil {
- if t.Logger != nil {
- t.Logger.Panic("failed NewURLs", zap.Strings("urls", us), zap.Error(err))
- } else {
- plog.Panicf("newURLs %+v should never fail: %+v", us, err)
- }
- }
- t.remotes[id] = startRemote(t, urls, id)
-
- if t.Logger != nil {
- t.Logger.Info(
- "added new remote peer",
- zap.String("local-member-id", t.ID.String()),
- zap.String("remote-peer-id", id.String()),
- zap.Strings("remote-peer-urls", us),
- )
- }
-}
-
-func (t *Transport) AddPeer(id types.ID, us []string) {
- t.mu.Lock()
- defer t.mu.Unlock()
-
- if t.peers == nil {
- panic("transport stopped")
- }
- if _, ok := t.peers[id]; ok {
- return
- }
- urls, err := types.NewURLs(us)
- if err != nil {
- if t.Logger != nil {
- t.Logger.Panic("failed NewURLs", zap.Strings("urls", us), zap.Error(err))
- } else {
- plog.Panicf("newURLs %+v should never fail: %+v", us, err)
- }
- }
- fs := t.LeaderStats.Follower(id.String())
- t.peers[id] = startPeer(t, urls, id, fs)
- addPeerToProber(t.Logger, t.pipelineProber, id.String(), us, RoundTripperNameSnapshot, rttSec)
- addPeerToProber(t.Logger, t.streamProber, id.String(), us, RoundTripperNameRaftMessage, rttSec)
-
- if t.Logger != nil {
- t.Logger.Info(
- "added remote peer",
- zap.String("local-member-id", t.ID.String()),
- zap.String("remote-peer-id", id.String()),
- zap.Strings("remote-peer-urls", us),
- )
- } else {
- plog.Infof("added peer %s", id)
- }
-}
-
-func (t *Transport) RemovePeer(id types.ID) {
- t.mu.Lock()
- defer t.mu.Unlock()
- t.removePeer(id)
-}
-
-func (t *Transport) RemoveAllPeers() {
- t.mu.Lock()
- defer t.mu.Unlock()
- for id := range t.peers {
- t.removePeer(id)
- }
-}
-
-// the caller of this function must have the peers mutex.
-func (t *Transport) removePeer(id types.ID) {
- if peer, ok := t.peers[id]; ok {
- peer.stop()
- } else {
- if t.Logger != nil {
- t.Logger.Panic("unexpected removal of unknown remote peer", zap.String("remote-peer-id", id.String()))
- } else {
- plog.Panicf("unexpected removal of unknown peer '%d'", id)
- }
- }
- delete(t.peers, id)
- delete(t.LeaderStats.Followers, id.String())
- t.pipelineProber.Remove(id.String())
- t.streamProber.Remove(id.String())
-
- if t.Logger != nil {
- t.Logger.Info(
- "removed remote peer",
- zap.String("local-member-id", t.ID.String()),
- zap.String("removed-remote-peer-id", id.String()),
- )
- } else {
- plog.Infof("removed peer %s", id)
- }
-}
-
-func (t *Transport) UpdatePeer(id types.ID, us []string) {
- t.mu.Lock()
- defer t.mu.Unlock()
- // TODO: return error or just panic?
- if _, ok := t.peers[id]; !ok {
- return
- }
- urls, err := types.NewURLs(us)
- if err != nil {
- if t.Logger != nil {
- t.Logger.Panic("failed NewURLs", zap.Strings("urls", us), zap.Error(err))
- } else {
- plog.Panicf("newURLs %+v should never fail: %+v", us, err)
- }
- }
- t.peers[id].update(urls)
-
- t.pipelineProber.Remove(id.String())
- addPeerToProber(t.Logger, t.pipelineProber, id.String(), us, RoundTripperNameSnapshot, rttSec)
- t.streamProber.Remove(id.String())
- addPeerToProber(t.Logger, t.streamProber, id.String(), us, RoundTripperNameRaftMessage, rttSec)
-
- if t.Logger != nil {
- t.Logger.Info(
- "updated remote peer",
- zap.String("local-member-id", t.ID.String()),
- zap.String("updated-remote-peer-id", id.String()),
- zap.Strings("updated-remote-peer-urls", us),
- )
- } else {
- plog.Infof("updated peer %s", id)
- }
-}
-
-func (t *Transport) ActiveSince(id types.ID) time.Time {
- t.mu.RLock()
- defer t.mu.RUnlock()
- if p, ok := t.peers[id]; ok {
- return p.activeSince()
- }
- return time.Time{}
-}
-
-func (t *Transport) SendSnapshot(m snap.Message) {
- t.mu.Lock()
- defer t.mu.Unlock()
- p := t.peers[types.ID(m.To)]
- if p == nil {
- m.CloseWithError(errMemberNotFound)
- return
- }
- p.sendSnap(m)
-}
-
-// Pausable is a testing interface for pausing transport traffic.
-type Pausable interface {
- Pause()
- Resume()
-}
-
-func (t *Transport) Pause() {
- t.mu.RLock()
- defer t.mu.RUnlock()
- for _, p := range t.peers {
- p.(Pausable).Pause()
- }
-}
-
-func (t *Transport) Resume() {
- t.mu.RLock()
- defer t.mu.RUnlock()
- for _, p := range t.peers {
- p.(Pausable).Resume()
- }
-}
-
-// ActivePeers returns a channel that closes when an initial
-// peer connection has been established. Use this to wait until the
-// first peer connection becomes active.
-func (t *Transport) ActivePeers() (cnt int) {
- t.mu.RLock()
- defer t.mu.RUnlock()
- for _, p := range t.peers {
- if !p.activeSince().IsZero() {
- cnt++
- }
- }
- return cnt
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/urlpick.go b/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/urlpick.go
deleted file mode 100644
index 61ef468..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/urlpick.go
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package rafthttp
-
-import (
- "net/url"
- "sync"
-
- "go.etcd.io/etcd/pkg/types"
-)
-
-type urlPicker struct {
- mu sync.Mutex // guards urls and picked
- urls types.URLs
- picked int
-}
-
-func newURLPicker(urls types.URLs) *urlPicker {
- return &urlPicker{
- urls: urls,
- }
-}
-
-func (p *urlPicker) update(urls types.URLs) {
- p.mu.Lock()
- defer p.mu.Unlock()
- p.urls = urls
- p.picked = 0
-}
-
-func (p *urlPicker) pick() url.URL {
- p.mu.Lock()
- defer p.mu.Unlock()
- return p.urls[p.picked]
-}
-
-// unreachable notices the picker that the given url is unreachable,
-// and it should use other possible urls.
-func (p *urlPicker) unreachable(u url.URL) {
- p.mu.Lock()
- defer p.mu.Unlock()
- if u == p.urls[p.picked] {
- p.picked = (p.picked + 1) % len(p.urls)
- }
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/util.go b/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/util.go
deleted file mode 100644
index 2093864..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/rafthttp/util.go
+++ /dev/null
@@ -1,190 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package rafthttp
-
-import (
- "fmt"
- "io"
- "net"
- "net/http"
- "net/url"
- "strings"
- "time"
-
- "go.etcd.io/etcd/pkg/transport"
- "go.etcd.io/etcd/pkg/types"
- "go.etcd.io/etcd/version"
-
- "github.com/coreos/go-semver/semver"
-)
-
-var (
- errMemberRemoved = fmt.Errorf("the member has been permanently removed from the cluster")
- errMemberNotFound = fmt.Errorf("member not found")
-)
-
-// NewListener returns a listener for raft message transfer between peers.
-// It uses timeout listener to identify broken streams promptly.
-func NewListener(u url.URL, tlsinfo *transport.TLSInfo) (net.Listener, error) {
- return transport.NewTimeoutListener(u.Host, u.Scheme, tlsinfo, ConnReadTimeout, ConnWriteTimeout)
-}
-
-// NewRoundTripper returns a roundTripper used to send requests
-// to rafthttp listener of remote peers.
-func NewRoundTripper(tlsInfo transport.TLSInfo, dialTimeout time.Duration) (http.RoundTripper, error) {
- // It uses timeout transport to pair with remote timeout listeners.
- // It sets no read/write timeout, because message in requests may
- // take long time to write out before reading out the response.
- return transport.NewTimeoutTransport(tlsInfo, dialTimeout, 0, 0)
-}
-
-// newStreamRoundTripper returns a roundTripper used to send stream requests
-// to rafthttp listener of remote peers.
-// Read/write timeout is set for stream roundTripper to promptly
-// find out broken status, which minimizes the number of messages
-// sent on broken connection.
-func newStreamRoundTripper(tlsInfo transport.TLSInfo, dialTimeout time.Duration) (http.RoundTripper, error) {
- return transport.NewTimeoutTransport(tlsInfo, dialTimeout, ConnReadTimeout, ConnWriteTimeout)
-}
-
-// createPostRequest creates a HTTP POST request that sends raft message.
-func createPostRequest(u url.URL, path string, body io.Reader, ct string, urls types.URLs, from, cid types.ID) *http.Request {
- uu := u
- uu.Path = path
- req, err := http.NewRequest("POST", uu.String(), body)
- if err != nil {
- plog.Panicf("unexpected new request error (%v)", err)
- }
- req.Header.Set("Content-Type", ct)
- req.Header.Set("X-Server-From", from.String())
- req.Header.Set("X-Server-Version", version.Version)
- req.Header.Set("X-Min-Cluster-Version", version.MinClusterVersion)
- req.Header.Set("X-Etcd-Cluster-ID", cid.String())
- setPeerURLsHeader(req, urls)
-
- return req
-}
-
-// checkPostResponse checks the response of the HTTP POST request that sends
-// raft message.
-func checkPostResponse(resp *http.Response, body []byte, req *http.Request, to types.ID) error {
- switch resp.StatusCode {
- case http.StatusPreconditionFailed:
- switch strings.TrimSuffix(string(body), "\n") {
- case errIncompatibleVersion.Error():
- plog.Errorf("request sent was ignored by peer %s (server version incompatible)", to)
- return errIncompatibleVersion
- case errClusterIDMismatch.Error():
- plog.Errorf("request sent was ignored (cluster ID mismatch: remote[%s]=%s, local=%s)",
- to, resp.Header.Get("X-Etcd-Cluster-ID"), req.Header.Get("X-Etcd-Cluster-ID"))
- return errClusterIDMismatch
- default:
- return fmt.Errorf("unhandled error %q when precondition failed", string(body))
- }
- case http.StatusForbidden:
- return errMemberRemoved
- case http.StatusNoContent:
- return nil
- default:
- return fmt.Errorf("unexpected http status %s while posting to %q", http.StatusText(resp.StatusCode), req.URL.String())
- }
-}
-
-// reportCriticalError reports the given error through sending it into
-// the given error channel.
-// If the error channel is filled up when sending error, it drops the error
-// because the fact that error has happened is reported, which is
-// good enough.
-func reportCriticalError(err error, errc chan<- error) {
- select {
- case errc <- err:
- default:
- }
-}
-
-// compareMajorMinorVersion returns an integer comparing two versions based on
-// their major and minor version. The result will be 0 if a==b, -1 if a < b,
-// and 1 if a > b.
-func compareMajorMinorVersion(a, b *semver.Version) int {
- na := &semver.Version{Major: a.Major, Minor: a.Minor}
- nb := &semver.Version{Major: b.Major, Minor: b.Minor}
- switch {
- case na.LessThan(*nb):
- return -1
- case nb.LessThan(*na):
- return 1
- default:
- return 0
- }
-}
-
-// serverVersion returns the server version from the given header.
-func serverVersion(h http.Header) *semver.Version {
- verStr := h.Get("X-Server-Version")
- // backward compatibility with etcd 2.0
- if verStr == "" {
- verStr = "2.0.0"
- }
- return semver.Must(semver.NewVersion(verStr))
-}
-
-// serverVersion returns the min cluster version from the given header.
-func minClusterVersion(h http.Header) *semver.Version {
- verStr := h.Get("X-Min-Cluster-Version")
- // backward compatibility with etcd 2.0
- if verStr == "" {
- verStr = "2.0.0"
- }
- return semver.Must(semver.NewVersion(verStr))
-}
-
-// checkVersionCompatibility checks whether the given version is compatible
-// with the local version.
-func checkVersionCompatibility(name string, server, minCluster *semver.Version) (
- localServer *semver.Version,
- localMinCluster *semver.Version,
- err error) {
- localServer = semver.Must(semver.NewVersion(version.Version))
- localMinCluster = semver.Must(semver.NewVersion(version.MinClusterVersion))
- if compareMajorMinorVersion(server, localMinCluster) == -1 {
- return localServer, localMinCluster, fmt.Errorf("remote version is too low: remote[%s]=%s, local=%s", name, server, localServer)
- }
- if compareMajorMinorVersion(minCluster, localServer) == 1 {
- return localServer, localMinCluster, fmt.Errorf("local version is too low: remote[%s]=%s, local=%s", name, server, localServer)
- }
- return localServer, localMinCluster, nil
-}
-
-// setPeerURLsHeader reports local urls for peer discovery
-func setPeerURLsHeader(req *http.Request, urls types.URLs) {
- if urls == nil {
- // often not set in unit tests
- return
- }
- peerURLs := make([]string, urls.Len())
- for i := range urls {
- peerURLs[i] = urls[i].String()
- }
- req.Header.Set("X-PeerURLs", strings.Join(peerURLs, ","))
-}
-
-// addRemoteFromRequest adds a remote peer according to an http request header
-func addRemoteFromRequest(tr Transporter, r *http.Request) {
- if from, err := types.IDFromString(r.Header.Get("X-Server-From")); err == nil {
- if urls := r.Header.Get("X-PeerURLs"); urls != "" {
- tr.AddRemote(from, strings.Split(urls, ","))
- }
- }
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/snap/db.go b/vendor/go.etcd.io/etcd/etcdserver/api/snap/db.go
deleted file mode 100644
index 3002ccd..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/snap/db.go
+++ /dev/null
@@ -1,104 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package snap
-
-import (
- "errors"
- "fmt"
- "io"
- "io/ioutil"
- "os"
- "path/filepath"
- "time"
-
- "go.etcd.io/etcd/pkg/fileutil"
-
- humanize "github.com/dustin/go-humanize"
- "go.uber.org/zap"
-)
-
-var ErrNoDBSnapshot = errors.New("snap: snapshot file doesn't exist")
-
-// SaveDBFrom saves snapshot of the database from the given reader. It
-// guarantees the save operation is atomic.
-func (s *Snapshotter) SaveDBFrom(r io.Reader, id uint64) (int64, error) {
- start := time.Now()
-
- f, err := ioutil.TempFile(s.dir, "tmp")
- if err != nil {
- return 0, err
- }
- var n int64
- n, err = io.Copy(f, r)
- if err == nil {
- fsyncStart := time.Now()
- err = fileutil.Fsync(f)
- snapDBFsyncSec.Observe(time.Since(fsyncStart).Seconds())
- }
- f.Close()
- if err != nil {
- os.Remove(f.Name())
- return n, err
- }
- fn := s.dbFilePath(id)
- if fileutil.Exist(fn) {
- os.Remove(f.Name())
- return n, nil
- }
- err = os.Rename(f.Name(), fn)
- if err != nil {
- os.Remove(f.Name())
- return n, err
- }
-
- if s.lg != nil {
- s.lg.Info(
- "saved database snapshot to disk",
- zap.String("path", fn),
- zap.Int64("bytes", n),
- zap.String("size", humanize.Bytes(uint64(n))),
- )
- } else {
- plog.Infof("saved database snapshot to disk [total bytes: %d]", n)
- }
-
- snapDBSaveSec.Observe(time.Since(start).Seconds())
- return n, nil
-}
-
-// DBFilePath returns the file path for the snapshot of the database with
-// given id. If the snapshot does not exist, it returns error.
-func (s *Snapshotter) DBFilePath(id uint64) (string, error) {
- if _, err := fileutil.ReadDir(s.dir); err != nil {
- return "", err
- }
- fn := s.dbFilePath(id)
- if fileutil.Exist(fn) {
- return fn, nil
- }
- if s.lg != nil {
- s.lg.Warn(
- "failed to find [SNAPSHOT-INDEX].snap.db",
- zap.Uint64("snapshot-index", id),
- zap.String("snapshot-file-path", fn),
- zap.Error(ErrNoDBSnapshot),
- )
- }
- return "", ErrNoDBSnapshot
-}
-
-func (s *Snapshotter) dbFilePath(id uint64) string {
- return filepath.Join(s.dir, fmt.Sprintf("%016x.snap.db", id))
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/snap/doc.go b/vendor/go.etcd.io/etcd/etcdserver/api/snap/doc.go
deleted file mode 100644
index dcc5db5..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/snap/doc.go
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package snap handles Raft nodes' states with snapshots.
-// The snapshot logic is internal to etcd server and raft package.
-package snap
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/snap/message.go b/vendor/go.etcd.io/etcd/etcdserver/api/snap/message.go
deleted file mode 100644
index c1151e2..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/snap/message.go
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package snap
-
-import (
- "io"
-
- "go.etcd.io/etcd/pkg/ioutil"
- "go.etcd.io/etcd/raft/raftpb"
-)
-
-// Message is a struct that contains a raft Message and a ReadCloser. The type
-// of raft message MUST be MsgSnap, which contains the raft meta-data and an
-// additional data []byte field that contains the snapshot of the actual state
-// machine.
-// Message contains the ReadCloser field for handling large snapshot. This avoid
-// copying the entire snapshot into a byte array, which consumes a lot of memory.
-//
-// User of Message should close the Message after sending it.
-type Message struct {
- raftpb.Message
- ReadCloser io.ReadCloser
- TotalSize int64
- closeC chan bool
-}
-
-func NewMessage(rs raftpb.Message, rc io.ReadCloser, rcSize int64) *Message {
- return &Message{
- Message: rs,
- ReadCloser: ioutil.NewExactReadCloser(rc, rcSize),
- TotalSize: int64(rs.Size()) + rcSize,
- closeC: make(chan bool, 1),
- }
-}
-
-// CloseNotify returns a channel that receives a single value
-// when the message sent is finished. true indicates the sent
-// is successful.
-func (m Message) CloseNotify() <-chan bool {
- return m.closeC
-}
-
-func (m Message) CloseWithError(err error) {
- if cerr := m.ReadCloser.Close(); cerr != nil {
- err = cerr
- }
- if err == nil {
- m.closeC <- true
- } else {
- m.closeC <- false
- }
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/snap/metrics.go b/vendor/go.etcd.io/etcd/etcdserver/api/snap/metrics.go
deleted file mode 100644
index 2affecf..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/snap/metrics.go
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package snap
-
-import "github.com/prometheus/client_golang/prometheus"
-
-var (
- snapMarshallingSec = prometheus.NewHistogram(prometheus.HistogramOpts{
- Namespace: "etcd_debugging",
- Subsystem: "snap",
- Name: "save_marshalling_duration_seconds",
- Help: "The marshalling cost distributions of save called by snapshot.",
-
- // lowest bucket start of upper bound 0.001 sec (1 ms) with factor 2
- // highest bucket start of 0.001 sec * 2^13 == 8.192 sec
- Buckets: prometheus.ExponentialBuckets(0.001, 2, 14),
- })
-
- snapSaveSec = prometheus.NewHistogram(prometheus.HistogramOpts{
- Namespace: "etcd_debugging",
- Subsystem: "snap",
- Name: "save_total_duration_seconds",
- Help: "The total latency distributions of save called by snapshot.",
-
- // lowest bucket start of upper bound 0.001 sec (1 ms) with factor 2
- // highest bucket start of 0.001 sec * 2^13 == 8.192 sec
- Buckets: prometheus.ExponentialBuckets(0.001, 2, 14),
- })
-
- snapFsyncSec = prometheus.NewHistogram(prometheus.HistogramOpts{
- Namespace: "etcd",
- Subsystem: "snap",
- Name: "fsync_duration_seconds",
- Help: "The latency distributions of fsync called by snap.",
-
- // lowest bucket start of upper bound 0.001 sec (1 ms) with factor 2
- // highest bucket start of 0.001 sec * 2^13 == 8.192 sec
- Buckets: prometheus.ExponentialBuckets(0.001, 2, 14),
- })
-
- snapDBSaveSec = prometheus.NewHistogram(prometheus.HistogramOpts{
- Namespace: "etcd",
- Subsystem: "snap_db",
- Name: "save_total_duration_seconds",
- Help: "The total latency distributions of v3 snapshot save",
-
- // lowest bucket start of upper bound 0.1 sec (100 ms) with factor 2
- // highest bucket start of 0.1 sec * 2^9 == 51.2 sec
- Buckets: prometheus.ExponentialBuckets(0.1, 2, 10),
- })
-
- snapDBFsyncSec = prometheus.NewHistogram(prometheus.HistogramOpts{
- Namespace: "etcd",
- Subsystem: "snap_db",
- Name: "fsync_duration_seconds",
- Help: "The latency distributions of fsyncing .snap.db file",
-
- // lowest bucket start of upper bound 0.001 sec (1 ms) with factor 2
- // highest bucket start of 0.001 sec * 2^13 == 8.192 sec
- Buckets: prometheus.ExponentialBuckets(0.001, 2, 14),
- })
-)
-
-func init() {
- prometheus.MustRegister(snapMarshallingSec)
- prometheus.MustRegister(snapSaveSec)
- prometheus.MustRegister(snapFsyncSec)
- prometheus.MustRegister(snapDBSaveSec)
- prometheus.MustRegister(snapDBFsyncSec)
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/snap/snappb/snap.pb.go b/vendor/go.etcd.io/etcd/etcdserver/api/snap/snappb/snap.pb.go
deleted file mode 100644
index e72b577..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/snap/snappb/snap.pb.go
+++ /dev/null
@@ -1,336 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: snap.proto
-
-/*
- Package snappb is a generated protocol buffer package.
-
- It is generated from these files:
- snap.proto
-
- It has these top-level messages:
- Snapshot
-*/
-package snappb
-
-import (
- "fmt"
-
- proto "github.com/golang/protobuf/proto"
-
- math "math"
-
- _ "github.com/gogo/protobuf/gogoproto"
-
- io "io"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
-
-type Snapshot struct {
- Crc uint32 `protobuf:"varint,1,opt,name=crc" json:"crc"`
- Data []byte `protobuf:"bytes,2,opt,name=data" json:"data,omitempty"`
- XXX_unrecognized []byte `json:"-"`
-}
-
-func (m *Snapshot) Reset() { *m = Snapshot{} }
-func (m *Snapshot) String() string { return proto.CompactTextString(m) }
-func (*Snapshot) ProtoMessage() {}
-func (*Snapshot) Descriptor() ([]byte, []int) { return fileDescriptorSnap, []int{0} }
-
-func init() {
- proto.RegisterType((*Snapshot)(nil), "snappb.snapshot")
-}
-func (m *Snapshot) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *Snapshot) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- dAtA[i] = 0x8
- i++
- i = encodeVarintSnap(dAtA, i, uint64(m.Crc))
- if m.Data != nil {
- dAtA[i] = 0x12
- i++
- i = encodeVarintSnap(dAtA, i, uint64(len(m.Data)))
- i += copy(dAtA[i:], m.Data)
- }
- if m.XXX_unrecognized != nil {
- i += copy(dAtA[i:], m.XXX_unrecognized)
- }
- return i, nil
-}
-
-func encodeVarintSnap(dAtA []byte, offset int, v uint64) int {
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return offset + 1
-}
-func (m *Snapshot) Size() (n int) {
- var l int
- _ = l
- n += 1 + sovSnap(uint64(m.Crc))
- if m.Data != nil {
- l = len(m.Data)
- n += 1 + l + sovSnap(uint64(l))
- }
- if m.XXX_unrecognized != nil {
- n += len(m.XXX_unrecognized)
- }
- return n
-}
-
-func sovSnap(x uint64) (n int) {
- for {
- n++
- x >>= 7
- if x == 0 {
- break
- }
- }
- return n
-}
-func sozSnap(x uint64) (n int) {
- return sovSnap(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *Snapshot) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowSnap
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: snapshot: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: snapshot: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Crc", wireType)
- }
- m.Crc = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowSnap
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Crc |= (uint32(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowSnap
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthSnap
- }
- postIndex := iNdEx + byteLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...)
- if m.Data == nil {
- m.Data = []byte{}
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipSnap(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthSnap
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipSnap(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowSnap
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowSnap
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- return iNdEx, nil
- case 1:
- iNdEx += 8
- return iNdEx, nil
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowSnap
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- iNdEx += length
- if length < 0 {
- return 0, ErrInvalidLengthSnap
- }
- return iNdEx, nil
- case 3:
- for {
- var innerWire uint64
- var start int = iNdEx
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowSnap
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- innerWire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- innerWireType := int(innerWire & 0x7)
- if innerWireType == 4 {
- break
- }
- next, err := skipSnap(dAtA[start:])
- if err != nil {
- return 0, err
- }
- iNdEx = start + next
- }
- return iNdEx, nil
- case 4:
- return iNdEx, nil
- case 5:
- iNdEx += 4
- return iNdEx, nil
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- }
- panic("unreachable")
-}
-
-var (
- ErrInvalidLengthSnap = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowSnap = fmt.Errorf("proto: integer overflow")
-)
-
-func init() { proto.RegisterFile("snap.proto", fileDescriptorSnap) }
-
-var fileDescriptorSnap = []byte{
- // 126 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2a, 0xce, 0x4b, 0x2c,
- 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x03, 0xb1, 0x0b, 0x92, 0xa4, 0x44, 0xd2, 0xf3,
- 0xd3, 0xf3, 0xc1, 0x42, 0xfa, 0x20, 0x16, 0x44, 0x56, 0xc9, 0x8c, 0x8b, 0x03, 0x24, 0x5f, 0x9c,
- 0x91, 0x5f, 0x22, 0x24, 0xc6, 0xc5, 0x9c, 0x5c, 0x94, 0x2c, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0xeb,
- 0xc4, 0x72, 0xe2, 0x9e, 0x3c, 0x43, 0x10, 0x48, 0x40, 0x48, 0x88, 0x8b, 0x25, 0x25, 0xb1, 0x24,
- 0x51, 0x82, 0x49, 0x81, 0x51, 0x83, 0x27, 0x08, 0xcc, 0x76, 0x12, 0x39, 0xf1, 0x50, 0x8e, 0xe1,
- 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf1, 0x58, 0x8e,
- 0x01, 0x10, 0x00, 0x00, 0xff, 0xff, 0xd8, 0x0f, 0x32, 0xb2, 0x78, 0x00, 0x00, 0x00,
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/snap/snappb/snap.proto b/vendor/go.etcd.io/etcd/etcdserver/api/snap/snappb/snap.proto
deleted file mode 100644
index cd3d21d..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/snap/snappb/snap.proto
+++ /dev/null
@@ -1,14 +0,0 @@
-syntax = "proto2";
-package snappb;
-
-import "gogoproto/gogo.proto";
-
-option (gogoproto.marshaler_all) = true;
-option (gogoproto.sizer_all) = true;
-option (gogoproto.unmarshaler_all) = true;
-option (gogoproto.goproto_getters_all) = false;
-
-message snapshot {
- optional uint32 crc = 1 [(gogoproto.nullable) = false];
- optional bytes data = 2;
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/snap/snapshotter.go b/vendor/go.etcd.io/etcd/etcdserver/api/snap/snapshotter.go
deleted file mode 100644
index 7e79333..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/snap/snapshotter.go
+++ /dev/null
@@ -1,255 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package snap
-
-import (
- "errors"
- "fmt"
- "hash/crc32"
- "io/ioutil"
- "os"
- "path/filepath"
- "sort"
- "strings"
- "time"
-
- "go.etcd.io/etcd/etcdserver/api/snap/snappb"
- pioutil "go.etcd.io/etcd/pkg/ioutil"
- "go.etcd.io/etcd/pkg/pbutil"
- "go.etcd.io/etcd/raft"
- "go.etcd.io/etcd/raft/raftpb"
-
- "github.com/coreos/pkg/capnslog"
- "go.uber.org/zap"
-)
-
-const snapSuffix = ".snap"
-
-var (
- plog = capnslog.NewPackageLogger("go.etcd.io/etcd/v3", "snap")
-
- ErrNoSnapshot = errors.New("snap: no available snapshot")
- ErrEmptySnapshot = errors.New("snap: empty snapshot")
- ErrCRCMismatch = errors.New("snap: crc mismatch")
- crcTable = crc32.MakeTable(crc32.Castagnoli)
-
- // A map of valid files that can be present in the snap folder.
- validFiles = map[string]bool{
- "db": true,
- }
-)
-
-type Snapshotter struct {
- lg *zap.Logger
- dir string
-}
-
-func New(lg *zap.Logger, dir string) *Snapshotter {
- return &Snapshotter{
- lg: lg,
- dir: dir,
- }
-}
-
-func (s *Snapshotter) SaveSnap(snapshot raftpb.Snapshot) error {
- if raft.IsEmptySnap(snapshot) {
- return nil
- }
- return s.save(&snapshot)
-}
-
-func (s *Snapshotter) save(snapshot *raftpb.Snapshot) error {
- start := time.Now()
-
- fname := fmt.Sprintf("%016x-%016x%s", snapshot.Metadata.Term, snapshot.Metadata.Index, snapSuffix)
- b := pbutil.MustMarshal(snapshot)
- crc := crc32.Update(0, crcTable, b)
- snap := snappb.Snapshot{Crc: crc, Data: b}
- d, err := snap.Marshal()
- if err != nil {
- return err
- }
- snapMarshallingSec.Observe(time.Since(start).Seconds())
-
- spath := filepath.Join(s.dir, fname)
-
- fsyncStart := time.Now()
- err = pioutil.WriteAndSyncFile(spath, d, 0666)
- snapFsyncSec.Observe(time.Since(fsyncStart).Seconds())
-
- if err != nil {
- if s.lg != nil {
- s.lg.Warn("failed to write a snap file", zap.String("path", spath), zap.Error(err))
- }
- rerr := os.Remove(spath)
- if rerr != nil {
- if s.lg != nil {
- s.lg.Warn("failed to remove a broken snap file", zap.String("path", spath), zap.Error(err))
- } else {
- plog.Errorf("failed to remove broken snapshot file %s", spath)
- }
- }
- return err
- }
-
- snapSaveSec.Observe(time.Since(start).Seconds())
- return nil
-}
-
-func (s *Snapshotter) Load() (*raftpb.Snapshot, error) {
- names, err := s.snapNames()
- if err != nil {
- return nil, err
- }
- var snap *raftpb.Snapshot
- for _, name := range names {
- if snap, err = loadSnap(s.lg, s.dir, name); err == nil {
- break
- }
- }
- if err != nil {
- return nil, ErrNoSnapshot
- }
- return snap, nil
-}
-
-func loadSnap(lg *zap.Logger, dir, name string) (*raftpb.Snapshot, error) {
- fpath := filepath.Join(dir, name)
- snap, err := Read(lg, fpath)
- if err != nil {
- brokenPath := fpath + ".broken"
- if lg != nil {
- lg.Warn("failed to read a snap file", zap.String("path", fpath), zap.Error(err))
- }
- if rerr := os.Rename(fpath, brokenPath); rerr != nil {
- if lg != nil {
- lg.Warn("failed to rename a broken snap file", zap.String("path", fpath), zap.String("broken-path", brokenPath), zap.Error(rerr))
- } else {
- plog.Warningf("cannot rename broken snapshot file %v to %v: %v", fpath, brokenPath, rerr)
- }
- } else {
- if lg != nil {
- lg.Warn("renamed to a broken snap file", zap.String("path", fpath), zap.String("broken-path", brokenPath))
- }
- }
- }
- return snap, err
-}
-
-// Read reads the snapshot named by snapname and returns the snapshot.
-func Read(lg *zap.Logger, snapname string) (*raftpb.Snapshot, error) {
- b, err := ioutil.ReadFile(snapname)
- if err != nil {
- if lg != nil {
- lg.Warn("failed to read a snap file", zap.String("path", snapname), zap.Error(err))
- } else {
- plog.Errorf("cannot read file %v: %v", snapname, err)
- }
- return nil, err
- }
-
- if len(b) == 0 {
- if lg != nil {
- lg.Warn("failed to read empty snapshot file", zap.String("path", snapname))
- } else {
- plog.Errorf("unexpected empty snapshot")
- }
- return nil, ErrEmptySnapshot
- }
-
- var serializedSnap snappb.Snapshot
- if err = serializedSnap.Unmarshal(b); err != nil {
- if lg != nil {
- lg.Warn("failed to unmarshal snappb.Snapshot", zap.String("path", snapname), zap.Error(err))
- } else {
- plog.Errorf("corrupted snapshot file %v: %v", snapname, err)
- }
- return nil, err
- }
-
- if len(serializedSnap.Data) == 0 || serializedSnap.Crc == 0 {
- if lg != nil {
- lg.Warn("failed to read empty snapshot data", zap.String("path", snapname))
- } else {
- plog.Errorf("unexpected empty snapshot")
- }
- return nil, ErrEmptySnapshot
- }
-
- crc := crc32.Update(0, crcTable, serializedSnap.Data)
- if crc != serializedSnap.Crc {
- if lg != nil {
- lg.Warn("snap file is corrupt",
- zap.String("path", snapname),
- zap.Uint32("prev-crc", serializedSnap.Crc),
- zap.Uint32("new-crc", crc),
- )
- } else {
- plog.Errorf("corrupted snapshot file %v: crc mismatch", snapname)
- }
- return nil, ErrCRCMismatch
- }
-
- var snap raftpb.Snapshot
- if err = snap.Unmarshal(serializedSnap.Data); err != nil {
- if lg != nil {
- lg.Warn("failed to unmarshal raftpb.Snapshot", zap.String("path", snapname), zap.Error(err))
- } else {
- plog.Errorf("corrupted snapshot file %v: %v", snapname, err)
- }
- return nil, err
- }
- return &snap, nil
-}
-
-// snapNames returns the filename of the snapshots in logical time order (from newest to oldest).
-// If there is no available snapshots, an ErrNoSnapshot will be returned.
-func (s *Snapshotter) snapNames() ([]string, error) {
- dir, err := os.Open(s.dir)
- if err != nil {
- return nil, err
- }
- defer dir.Close()
- names, err := dir.Readdirnames(-1)
- if err != nil {
- return nil, err
- }
- snaps := checkSuffix(s.lg, names)
- if len(snaps) == 0 {
- return nil, ErrNoSnapshot
- }
- sort.Sort(sort.Reverse(sort.StringSlice(snaps)))
- return snaps, nil
-}
-
-func checkSuffix(lg *zap.Logger, names []string) []string {
- snaps := []string{}
- for i := range names {
- if strings.HasSuffix(names[i], snapSuffix) {
- snaps = append(snaps, names[i])
- } else {
- // If we find a file which is not a snapshot then check if it's
- // a vaild file. If not throw out a warning.
- if _, ok := validFiles[names[i]]; !ok {
- if lg != nil {
- lg.Warn("found unexpected non-snap file; skipping", zap.String("path", names[i]))
- } else {
- plog.Warningf("skipped unexpected non snapshot file %v", names[i])
- }
- }
- }
- }
- return snaps
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2auth/auth.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2auth/auth.go
deleted file mode 100644
index b438074..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2auth/auth.go
+++ /dev/null
@@ -1,736 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package v2auth implements etcd authentication.
-package v2auth
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net/http"
- "path"
- "reflect"
- "sort"
- "strings"
- "time"
-
- "go.etcd.io/etcd/etcdserver"
- "go.etcd.io/etcd/etcdserver/api/v2error"
- "go.etcd.io/etcd/etcdserver/etcdserverpb"
- "go.etcd.io/etcd/pkg/types"
-
- "github.com/coreos/pkg/capnslog"
- "go.uber.org/zap"
- "golang.org/x/crypto/bcrypt"
-)
-
-const (
- // StorePermsPrefix is the internal prefix of the storage layer dedicated to storing user data.
- StorePermsPrefix = "/2"
-
- // RootRoleName is the name of the ROOT role, with privileges to manage the cluster.
- RootRoleName = "root"
-
- // GuestRoleName is the name of the role that defines the privileges of an unauthenticated user.
- GuestRoleName = "guest"
-)
-
-var (
- plog = capnslog.NewPackageLogger("go.etcd.io/etcd/v3", "etcdserver/auth")
-)
-
-var rootRole = Role{
- Role: RootRoleName,
- Permissions: Permissions{
- KV: RWPermission{
- Read: []string{"/*"},
- Write: []string{"/*"},
- },
- },
-}
-
-var guestRole = Role{
- Role: GuestRoleName,
- Permissions: Permissions{
- KV: RWPermission{
- Read: []string{"/*"},
- Write: []string{"/*"},
- },
- },
-}
-
-type doer interface {
- Do(context.Context, etcdserverpb.Request) (etcdserver.Response, error)
-}
-
-type Store interface {
- AllUsers() ([]string, error)
- GetUser(name string) (User, error)
- CreateOrUpdateUser(user User) (out User, created bool, err error)
- CreateUser(user User) (User, error)
- DeleteUser(name string) error
- UpdateUser(user User) (User, error)
- AllRoles() ([]string, error)
- GetRole(name string) (Role, error)
- CreateRole(role Role) error
- DeleteRole(name string) error
- UpdateRole(role Role) (Role, error)
- AuthEnabled() bool
- EnableAuth() error
- DisableAuth() error
- PasswordStore
-}
-
-type PasswordStore interface {
- CheckPassword(user User, password string) bool
- HashPassword(password string) (string, error)
-}
-
-type store struct {
- lg *zap.Logger
- server doer
- timeout time.Duration
- ensuredOnce bool
-
- PasswordStore
-}
-
-type User struct {
- User string `json:"user"`
- Password string `json:"password,omitempty"`
- Roles []string `json:"roles"`
- Grant []string `json:"grant,omitempty"`
- Revoke []string `json:"revoke,omitempty"`
-}
-
-type Role struct {
- Role string `json:"role"`
- Permissions Permissions `json:"permissions"`
- Grant *Permissions `json:"grant,omitempty"`
- Revoke *Permissions `json:"revoke,omitempty"`
-}
-
-type Permissions struct {
- KV RWPermission `json:"kv"`
-}
-
-func (p *Permissions) IsEmpty() bool {
- return p == nil || (len(p.KV.Read) == 0 && len(p.KV.Write) == 0)
-}
-
-type RWPermission struct {
- Read []string `json:"read"`
- Write []string `json:"write"`
-}
-
-type Error struct {
- Status int
- Errmsg string
-}
-
-func (ae Error) Error() string { return ae.Errmsg }
-func (ae Error) HTTPStatus() int { return ae.Status }
-
-func authErr(hs int, s string, v ...interface{}) Error {
- return Error{Status: hs, Errmsg: fmt.Sprintf("auth: "+s, v...)}
-}
-
-func NewStore(lg *zap.Logger, server doer, timeout time.Duration) Store {
- s := &store{
- lg: lg,
- server: server,
- timeout: timeout,
- PasswordStore: passwordStore{},
- }
- return s
-}
-
-// passwordStore implements PasswordStore using bcrypt to hash user passwords
-type passwordStore struct{}
-
-func (passwordStore) CheckPassword(user User, password string) bool {
- err := bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(password))
- return err == nil
-}
-
-func (passwordStore) HashPassword(password string) (string, error) {
- hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
- return string(hash), err
-}
-
-func (s *store) AllUsers() ([]string, error) {
- resp, err := s.requestResource("/users/", false)
- if err != nil {
- if e, ok := err.(*v2error.Error); ok {
- if e.ErrorCode == v2error.EcodeKeyNotFound {
- return []string{}, nil
- }
- }
- return nil, err
- }
- var nodes []string
- for _, n := range resp.Event.Node.Nodes {
- _, user := path.Split(n.Key)
- nodes = append(nodes, user)
- }
- sort.Strings(nodes)
- return nodes, nil
-}
-
-func (s *store) GetUser(name string) (User, error) { return s.getUser(name, false) }
-
-// CreateOrUpdateUser should be only used for creating the new user or when you are not
-// sure if it is a create or update. (When only password is passed in, we are not sure
-// if it is a update or create)
-func (s *store) CreateOrUpdateUser(user User) (out User, created bool, err error) {
- _, err = s.getUser(user.User, true)
- if err == nil {
- out, err = s.UpdateUser(user)
- return out, false, err
- }
- u, err := s.CreateUser(user)
- return u, true, err
-}
-
-func (s *store) CreateUser(user User) (User, error) {
- // Attach root role to root user.
- if user.User == "root" {
- user = attachRootRole(user)
- }
- u, err := s.createUserInternal(user)
- if err == nil {
- if s.lg != nil {
- s.lg.Info("created a user", zap.String("user-name", user.User))
- } else {
- plog.Noticef("created user %s", user.User)
- }
- }
- return u, err
-}
-
-func (s *store) createUserInternal(user User) (User, error) {
- if user.Password == "" {
- return user, authErr(http.StatusBadRequest, "Cannot create user %s with an empty password", user.User)
- }
- hash, err := s.HashPassword(user.Password)
- if err != nil {
- return user, err
- }
- user.Password = hash
-
- _, err = s.createResource("/users/"+user.User, user)
- if err != nil {
- if e, ok := err.(*v2error.Error); ok {
- if e.ErrorCode == v2error.EcodeNodeExist {
- return user, authErr(http.StatusConflict, "User %s already exists.", user.User)
- }
- }
- }
- return user, err
-}
-
-func (s *store) DeleteUser(name string) error {
- if s.AuthEnabled() && name == "root" {
- return authErr(http.StatusForbidden, "Cannot delete root user while auth is enabled.")
- }
- err := s.deleteResource("/users/" + name)
- if err != nil {
- if e, ok := err.(*v2error.Error); ok {
- if e.ErrorCode == v2error.EcodeKeyNotFound {
- return authErr(http.StatusNotFound, "User %s does not exist", name)
- }
- }
- return err
- }
- if s.lg != nil {
- s.lg.Info("deleted a user", zap.String("user-name", name))
- } else {
- plog.Noticef("deleted user %s", name)
- }
- return nil
-}
-
-func (s *store) UpdateUser(user User) (User, error) {
- old, err := s.getUser(user.User, true)
- if err != nil {
- if e, ok := err.(*v2error.Error); ok {
- if e.ErrorCode == v2error.EcodeKeyNotFound {
- return user, authErr(http.StatusNotFound, "User %s doesn't exist.", user.User)
- }
- }
- return old, err
- }
-
- newUser, err := old.merge(s.lg, user, s.PasswordStore)
- if err != nil {
- return old, err
- }
- if reflect.DeepEqual(old, newUser) {
- return old, authErr(http.StatusBadRequest, "User not updated. Use grant/revoke/password to update the user.")
- }
- _, err = s.updateResource("/users/"+user.User, newUser)
- if err == nil {
- if s.lg != nil {
- s.lg.Info("updated a user", zap.String("user-name", user.User))
- } else {
- plog.Noticef("updated user %s", user.User)
- }
- }
- return newUser, err
-}
-
-func (s *store) AllRoles() ([]string, error) {
- nodes := []string{RootRoleName}
- resp, err := s.requestResource("/roles/", false)
- if err != nil {
- if e, ok := err.(*v2error.Error); ok {
- if e.ErrorCode == v2error.EcodeKeyNotFound {
- return nodes, nil
- }
- }
- return nil, err
- }
- for _, n := range resp.Event.Node.Nodes {
- _, role := path.Split(n.Key)
- nodes = append(nodes, role)
- }
- sort.Strings(nodes)
- return nodes, nil
-}
-
-func (s *store) GetRole(name string) (Role, error) { return s.getRole(name, false) }
-
-func (s *store) CreateRole(role Role) error {
- if role.Role == RootRoleName {
- return authErr(http.StatusForbidden, "Cannot modify role %s: is root role.", role.Role)
- }
- _, err := s.createResource("/roles/"+role.Role, role)
- if err != nil {
- if e, ok := err.(*v2error.Error); ok {
- if e.ErrorCode == v2error.EcodeNodeExist {
- return authErr(http.StatusConflict, "Role %s already exists.", role.Role)
- }
- }
- }
- if err == nil {
- if s.lg != nil {
- s.lg.Info("created a new role", zap.String("role-name", role.Role))
- } else {
- plog.Noticef("created new role %s", role.Role)
- }
- }
- return err
-}
-
-func (s *store) DeleteRole(name string) error {
- if name == RootRoleName {
- return authErr(http.StatusForbidden, "Cannot modify role %s: is root role.", name)
- }
- err := s.deleteResource("/roles/" + name)
- if err != nil {
- if e, ok := err.(*v2error.Error); ok {
- if e.ErrorCode == v2error.EcodeKeyNotFound {
- return authErr(http.StatusNotFound, "Role %s doesn't exist.", name)
- }
- }
- }
- if err == nil {
- if s.lg != nil {
- s.lg.Info("delete a new role", zap.String("role-name", name))
- } else {
- plog.Noticef("deleted role %s", name)
- }
- }
- return err
-}
-
-func (s *store) UpdateRole(role Role) (Role, error) {
- if role.Role == RootRoleName {
- return Role{}, authErr(http.StatusForbidden, "Cannot modify role %s: is root role.", role.Role)
- }
- old, err := s.getRole(role.Role, true)
- if err != nil {
- if e, ok := err.(*v2error.Error); ok {
- if e.ErrorCode == v2error.EcodeKeyNotFound {
- return role, authErr(http.StatusNotFound, "Role %s doesn't exist.", role.Role)
- }
- }
- return old, err
- }
- newRole, err := old.merge(s.lg, role)
- if err != nil {
- return old, err
- }
- if reflect.DeepEqual(old, newRole) {
- return old, authErr(http.StatusBadRequest, "Role not updated. Use grant/revoke to update the role.")
- }
- _, err = s.updateResource("/roles/"+role.Role, newRole)
- if err == nil {
- if s.lg != nil {
- s.lg.Info("updated a new role", zap.String("role-name", role.Role))
- } else {
- plog.Noticef("updated role %s", role.Role)
- }
- }
- return newRole, err
-}
-
-func (s *store) AuthEnabled() bool {
- return s.detectAuth()
-}
-
-func (s *store) EnableAuth() error {
- if s.AuthEnabled() {
- return authErr(http.StatusConflict, "already enabled")
- }
-
- if _, err := s.getUser("root", true); err != nil {
- return authErr(http.StatusConflict, "No root user available, please create one")
- }
- if _, err := s.getRole(GuestRoleName, true); err != nil {
- if s.lg != nil {
- s.lg.Info(
- "no guest role access found; creating default",
- zap.String("role-name", GuestRoleName),
- )
- } else {
- plog.Printf("no guest role access found, creating default")
- }
- if err := s.CreateRole(guestRole); err != nil {
- if s.lg != nil {
- s.lg.Warn(
- "failed to create a guest role; aborting auth enable",
- zap.String("role-name", GuestRoleName),
- zap.Error(err),
- )
- } else {
- plog.Errorf("error creating guest role. aborting auth enable.")
- }
- return err
- }
- }
-
- if err := s.enableAuth(); err != nil {
- if s.lg != nil {
- s.lg.Warn("failed to enable auth", zap.Error(err))
- } else {
- plog.Errorf("error enabling auth (%v)", err)
- }
- return err
- }
-
- if s.lg != nil {
- s.lg.Info("enabled auth")
- } else {
- plog.Noticef("auth: enabled auth")
- }
- return nil
-}
-
-func (s *store) DisableAuth() error {
- if !s.AuthEnabled() {
- return authErr(http.StatusConflict, "already disabled")
- }
-
- err := s.disableAuth()
- if err == nil {
- if s.lg != nil {
- s.lg.Info("disabled auth")
- } else {
- plog.Noticef("auth: disabled auth")
- }
- } else {
- if s.lg != nil {
- s.lg.Warn("failed to disable auth", zap.Error(err))
- } else {
- plog.Errorf("error disabling auth (%v)", err)
- }
- }
- return err
-}
-
-// merge applies the properties of the passed-in User to the User on which it
-// is called and returns a new User with these modifications applied. Think of
-// all Users as immutable sets of data. Merge allows you to perform the set
-// operations (desired grants and revokes) atomically
-func (ou User) merge(lg *zap.Logger, nu User, s PasswordStore) (User, error) {
- var out User
- if ou.User != nu.User {
- return out, authErr(http.StatusConflict, "Merging user data with conflicting usernames: %s %s", ou.User, nu.User)
- }
- out.User = ou.User
- if nu.Password != "" {
- hash, err := s.HashPassword(nu.Password)
- if err != nil {
- return ou, err
- }
- out.Password = hash
- } else {
- out.Password = ou.Password
- }
- currentRoles := types.NewUnsafeSet(ou.Roles...)
- for _, g := range nu.Grant {
- if currentRoles.Contains(g) {
- if lg != nil {
- lg.Warn(
- "attempted to grant a duplicate role for a user",
- zap.String("user-name", nu.User),
- zap.String("role-name", g),
- )
- } else {
- plog.Noticef("granting duplicate role %s for user %s", g, nu.User)
- }
- return User{}, authErr(http.StatusConflict, fmt.Sprintf("Granting duplicate role %s for user %s", g, nu.User))
- }
- currentRoles.Add(g)
- }
- for _, r := range nu.Revoke {
- if !currentRoles.Contains(r) {
- if lg != nil {
- lg.Warn(
- "attempted to revoke a ungranted role for a user",
- zap.String("user-name", nu.User),
- zap.String("role-name", r),
- )
- } else {
- plog.Noticef("revoking ungranted role %s for user %s", r, nu.User)
- }
- return User{}, authErr(http.StatusConflict, fmt.Sprintf("Revoking ungranted role %s for user %s", r, nu.User))
- }
- currentRoles.Remove(r)
- }
- out.Roles = currentRoles.Values()
- sort.Strings(out.Roles)
- return out, nil
-}
-
-// merge for a role works the same as User above -- atomic Role application to
-// each of the substructures.
-func (r Role) merge(lg *zap.Logger, n Role) (Role, error) {
- var out Role
- var err error
- if r.Role != n.Role {
- return out, authErr(http.StatusConflict, "Merging role with conflicting names: %s %s", r.Role, n.Role)
- }
- out.Role = r.Role
- out.Permissions, err = r.Permissions.Grant(n.Grant)
- if err != nil {
- return out, err
- }
- out.Permissions, err = out.Permissions.Revoke(lg, n.Revoke)
- return out, err
-}
-
-func (r Role) HasKeyAccess(key string, write bool) bool {
- if r.Role == RootRoleName {
- return true
- }
- return r.Permissions.KV.HasAccess(key, write)
-}
-
-func (r Role) HasRecursiveAccess(key string, write bool) bool {
- if r.Role == RootRoleName {
- return true
- }
- return r.Permissions.KV.HasRecursiveAccess(key, write)
-}
-
-// Grant adds a set of permissions to the permission object on which it is called,
-// returning a new permission object.
-func (p Permissions) Grant(n *Permissions) (Permissions, error) {
- var out Permissions
- var err error
- if n == nil {
- return p, nil
- }
- out.KV, err = p.KV.Grant(n.KV)
- return out, err
-}
-
-// Revoke removes a set of permissions to the permission object on which it is called,
-// returning a new permission object.
-func (p Permissions) Revoke(lg *zap.Logger, n *Permissions) (Permissions, error) {
- var out Permissions
- var err error
- if n == nil {
- return p, nil
- }
- out.KV, err = p.KV.Revoke(lg, n.KV)
- return out, err
-}
-
-// Grant adds a set of permissions to the permission object on which it is called,
-// returning a new permission object.
-func (rw RWPermission) Grant(n RWPermission) (RWPermission, error) {
- var out RWPermission
- currentRead := types.NewUnsafeSet(rw.Read...)
- for _, r := range n.Read {
- if currentRead.Contains(r) {
- return out, authErr(http.StatusConflict, "Granting duplicate read permission %s", r)
- }
- currentRead.Add(r)
- }
- currentWrite := types.NewUnsafeSet(rw.Write...)
- for _, w := range n.Write {
- if currentWrite.Contains(w) {
- return out, authErr(http.StatusConflict, "Granting duplicate write permission %s", w)
- }
- currentWrite.Add(w)
- }
- out.Read = currentRead.Values()
- out.Write = currentWrite.Values()
- sort.Strings(out.Read)
- sort.Strings(out.Write)
- return out, nil
-}
-
-// Revoke removes a set of permissions to the permission object on which it is called,
-// returning a new permission object.
-func (rw RWPermission) Revoke(lg *zap.Logger, n RWPermission) (RWPermission, error) {
- var out RWPermission
- currentRead := types.NewUnsafeSet(rw.Read...)
- for _, r := range n.Read {
- if !currentRead.Contains(r) {
- if lg != nil {
- lg.Info(
- "revoking ungranted read permission",
- zap.String("read-permission", r),
- )
- } else {
- plog.Noticef("revoking ungranted read permission %s", r)
- }
- continue
- }
- currentRead.Remove(r)
- }
- currentWrite := types.NewUnsafeSet(rw.Write...)
- for _, w := range n.Write {
- if !currentWrite.Contains(w) {
- if lg != nil {
- lg.Info(
- "revoking ungranted write permission",
- zap.String("write-permission", w),
- )
- } else {
- plog.Noticef("revoking ungranted write permission %s", w)
- }
- continue
- }
- currentWrite.Remove(w)
- }
- out.Read = currentRead.Values()
- out.Write = currentWrite.Values()
- sort.Strings(out.Read)
- sort.Strings(out.Write)
- return out, nil
-}
-
-func (rw RWPermission) HasAccess(key string, write bool) bool {
- var list []string
- if write {
- list = rw.Write
- } else {
- list = rw.Read
- }
- for _, pat := range list {
- match, err := simpleMatch(pat, key)
- if err == nil && match {
- return true
- }
- }
- return false
-}
-
-func (rw RWPermission) HasRecursiveAccess(key string, write bool) bool {
- list := rw.Read
- if write {
- list = rw.Write
- }
- for _, pat := range list {
- match, err := prefixMatch(pat, key)
- if err == nil && match {
- return true
- }
- }
- return false
-}
-
-func simpleMatch(pattern string, key string) (match bool, err error) {
- if pattern[len(pattern)-1] == '*' {
- return strings.HasPrefix(key, pattern[:len(pattern)-1]), nil
- }
- return key == pattern, nil
-}
-
-func prefixMatch(pattern string, key string) (match bool, err error) {
- if pattern[len(pattern)-1] != '*' {
- return false, nil
- }
- return strings.HasPrefix(key, pattern[:len(pattern)-1]), nil
-}
-
-func attachRootRole(u User) User {
- inRoles := false
- for _, r := range u.Roles {
- if r == RootRoleName {
- inRoles = true
- break
- }
- }
- if !inRoles {
- u.Roles = append(u.Roles, RootRoleName)
- }
- return u
-}
-
-func (s *store) getUser(name string, quorum bool) (User, error) {
- resp, err := s.requestResource("/users/"+name, quorum)
- if err != nil {
- if e, ok := err.(*v2error.Error); ok {
- if e.ErrorCode == v2error.EcodeKeyNotFound {
- return User{}, authErr(http.StatusNotFound, "User %s does not exist.", name)
- }
- }
- return User{}, err
- }
- var u User
- err = json.Unmarshal([]byte(*resp.Event.Node.Value), &u)
- if err != nil {
- return u, err
- }
- // Attach root role to root user.
- if u.User == "root" {
- u = attachRootRole(u)
- }
- return u, nil
-}
-
-func (s *store) getRole(name string, quorum bool) (Role, error) {
- if name == RootRoleName {
- return rootRole, nil
- }
- resp, err := s.requestResource("/roles/"+name, quorum)
- if err != nil {
- if e, ok := err.(*v2error.Error); ok {
- if e.ErrorCode == v2error.EcodeKeyNotFound {
- return Role{}, authErr(http.StatusNotFound, "Role %s does not exist.", name)
- }
- }
- return Role{}, err
- }
- var r Role
- err = json.Unmarshal([]byte(*resp.Event.Node.Value), &r)
- return r, err
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2auth/auth_requests.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2auth/auth_requests.go
deleted file mode 100644
index d6574ec..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2auth/auth_requests.go
+++ /dev/null
@@ -1,189 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v2auth
-
-import (
- "context"
- "encoding/json"
- "path"
-
- "go.etcd.io/etcd/etcdserver"
- "go.etcd.io/etcd/etcdserver/api/v2error"
- "go.etcd.io/etcd/etcdserver/etcdserverpb"
-
- "go.uber.org/zap"
-)
-
-func (s *store) ensureAuthDirectories() error {
- if s.ensuredOnce {
- return nil
- }
- for _, res := range []string{StorePermsPrefix, StorePermsPrefix + "/users/", StorePermsPrefix + "/roles/"} {
- ctx, cancel := context.WithTimeout(context.Background(), s.timeout)
- pe := false
- rr := etcdserverpb.Request{
- Method: "PUT",
- Path: res,
- Dir: true,
- PrevExist: &pe,
- }
- _, err := s.server.Do(ctx, rr)
- cancel()
- if err != nil {
- if e, ok := err.(*v2error.Error); ok {
- if e.ErrorCode == v2error.EcodeNodeExist {
- continue
- }
- }
- if s.lg != nil {
- s.lg.Warn(
- "failed to create auth directories",
- zap.Error(err),
- )
- } else {
- plog.Errorf("failed to create auth directories in the store (%v)", err)
- }
- return err
- }
- }
- ctx, cancel := context.WithTimeout(context.Background(), s.timeout)
- defer cancel()
- pe := false
- rr := etcdserverpb.Request{
- Method: "PUT",
- Path: StorePermsPrefix + "/enabled",
- Val: "false",
- PrevExist: &pe,
- }
- _, err := s.server.Do(ctx, rr)
- if err != nil {
- if e, ok := err.(*v2error.Error); ok {
- if e.ErrorCode == v2error.EcodeNodeExist {
- s.ensuredOnce = true
- return nil
- }
- }
- return err
- }
- s.ensuredOnce = true
- return nil
-}
-
-func (s *store) enableAuth() error {
- _, err := s.updateResource("/enabled", true)
- return err
-}
-func (s *store) disableAuth() error {
- _, err := s.updateResource("/enabled", false)
- return err
-}
-
-func (s *store) detectAuth() bool {
- if s.server == nil {
- return false
- }
- value, err := s.requestResource("/enabled", false)
- if err != nil {
- if e, ok := err.(*v2error.Error); ok {
- if e.ErrorCode == v2error.EcodeKeyNotFound {
- return false
- }
- }
- if s.lg != nil {
- s.lg.Warn(
- "failed to detect auth settings",
- zap.Error(err),
- )
- } else {
- plog.Errorf("failed to detect auth settings (%s)", err)
- }
- return false
- }
-
- var u bool
- err = json.Unmarshal([]byte(*value.Event.Node.Value), &u)
- if err != nil {
- if s.lg != nil {
- s.lg.Warn(
- "internal bookkeeping value for enabled isn't valid JSON",
- zap.Error(err),
- )
- } else {
- plog.Errorf("internal bookkeeping value for enabled isn't valid JSON (%v)", err)
- }
- return false
- }
- return u
-}
-
-func (s *store) requestResource(res string, quorum bool) (etcdserver.Response, error) {
- ctx, cancel := context.WithTimeout(context.Background(), s.timeout)
- defer cancel()
- p := path.Join(StorePermsPrefix, res)
- method := "GET"
- if quorum {
- method = "QGET"
- }
- rr := etcdserverpb.Request{
- Method: method,
- Path: p,
- Dir: false, // TODO: always false?
- }
- return s.server.Do(ctx, rr)
-}
-
-func (s *store) updateResource(res string, value interface{}) (etcdserver.Response, error) {
- return s.setResource(res, value, true)
-}
-func (s *store) createResource(res string, value interface{}) (etcdserver.Response, error) {
- return s.setResource(res, value, false)
-}
-func (s *store) setResource(res string, value interface{}, prevexist bool) (etcdserver.Response, error) {
- err := s.ensureAuthDirectories()
- if err != nil {
- return etcdserver.Response{}, err
- }
- ctx, cancel := context.WithTimeout(context.Background(), s.timeout)
- defer cancel()
- data, err := json.Marshal(value)
- if err != nil {
- return etcdserver.Response{}, err
- }
- p := path.Join(StorePermsPrefix, res)
- rr := etcdserverpb.Request{
- Method: "PUT",
- Path: p,
- Val: string(data),
- PrevExist: &prevexist,
- }
- return s.server.Do(ctx, rr)
-}
-
-func (s *store) deleteResource(res string) error {
- err := s.ensureAuthDirectories()
- if err != nil {
- return err
- }
- ctx, cancel := context.WithTimeout(context.Background(), s.timeout)
- defer cancel()
- pex := true
- p := path.Join(StorePermsPrefix, res)
- _, err = s.server.Do(ctx, etcdserverpb.Request{
- Method: "DELETE",
- Path: p,
- PrevExist: &pex,
- })
- return err
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2discovery/discovery.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2discovery/discovery.go
deleted file mode 100644
index cf770b3..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2discovery/discovery.go
+++ /dev/null
@@ -1,440 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package v2discovery provides an implementation of the cluster discovery that
-// is used by etcd with v2 client.
-package v2discovery
-
-import (
- "context"
- "errors"
- "fmt"
- "math"
- "net/http"
- "net/url"
- "path"
- "sort"
- "strconv"
- "strings"
- "time"
-
- "go.etcd.io/etcd/client"
- "go.etcd.io/etcd/pkg/transport"
- "go.etcd.io/etcd/pkg/types"
-
- "github.com/coreos/pkg/capnslog"
- "github.com/jonboulle/clockwork"
- "go.uber.org/zap"
-)
-
-var (
- plog = capnslog.NewPackageLogger("go.etcd.io/etcd", "discovery")
-
- ErrInvalidURL = errors.New("discovery: invalid URL")
- ErrBadSizeKey = errors.New("discovery: size key is bad")
- ErrSizeNotFound = errors.New("discovery: size key not found")
- ErrTokenNotFound = errors.New("discovery: token not found")
- ErrDuplicateID = errors.New("discovery: found duplicate id")
- ErrDuplicateName = errors.New("discovery: found duplicate name")
- ErrFullCluster = errors.New("discovery: cluster is full")
- ErrTooManyRetries = errors.New("discovery: too many retries")
- ErrBadDiscoveryEndpoint = errors.New("discovery: bad discovery endpoint")
-)
-
-var (
- // Number of retries discovery will attempt before giving up and erroring out.
- nRetries = uint(math.MaxUint32)
- maxExpoentialRetries = uint(8)
-)
-
-// JoinCluster will connect to the discovery service at the given url, and
-// register the server represented by the given id and config to the cluster
-func JoinCluster(lg *zap.Logger, durl, dproxyurl string, id types.ID, config string) (string, error) {
- d, err := newDiscovery(lg, durl, dproxyurl, id)
- if err != nil {
- return "", err
- }
- return d.joinCluster(config)
-}
-
-// GetCluster will connect to the discovery service at the given url and
-// retrieve a string describing the cluster
-func GetCluster(lg *zap.Logger, durl, dproxyurl string) (string, error) {
- d, err := newDiscovery(lg, durl, dproxyurl, 0)
- if err != nil {
- return "", err
- }
- return d.getCluster()
-}
-
-type discovery struct {
- lg *zap.Logger
- cluster string
- id types.ID
- c client.KeysAPI
- retries uint
- url *url.URL
-
- clock clockwork.Clock
-}
-
-// newProxyFunc builds a proxy function from the given string, which should
-// represent a URL that can be used as a proxy. It performs basic
-// sanitization of the URL and returns any error encountered.
-func newProxyFunc(lg *zap.Logger, proxy string) (func(*http.Request) (*url.URL, error), error) {
- if proxy == "" {
- return nil, nil
- }
- // Do a small amount of URL sanitization to help the user
- // Derived from net/http.ProxyFromEnvironment
- proxyURL, err := url.Parse(proxy)
- if err != nil || !strings.HasPrefix(proxyURL.Scheme, "http") {
- // proxy was bogus. Try prepending "http://" to it and
- // see if that parses correctly. If not, we ignore the
- // error and complain about the original one
- var err2 error
- proxyURL, err2 = url.Parse("http://" + proxy)
- if err2 == nil {
- err = nil
- }
- }
- if err != nil {
- return nil, fmt.Errorf("invalid proxy address %q: %v", proxy, err)
- }
-
- if lg != nil {
- lg.Info("running proxy with discovery", zap.String("proxy-url", proxyURL.String()))
- } else {
- plog.Infof("using proxy %q", proxyURL.String())
- }
- return http.ProxyURL(proxyURL), nil
-}
-
-func newDiscovery(lg *zap.Logger, durl, dproxyurl string, id types.ID) (*discovery, error) {
- u, err := url.Parse(durl)
- if err != nil {
- return nil, err
- }
- token := u.Path
- u.Path = ""
- pf, err := newProxyFunc(lg, dproxyurl)
- if err != nil {
- return nil, err
- }
-
- // TODO: add ResponseHeaderTimeout back when watch on discovery service writes header early
- tr, err := transport.NewTransport(transport.TLSInfo{}, 30*time.Second)
- if err != nil {
- return nil, err
- }
- tr.Proxy = pf
- cfg := client.Config{
- Transport: tr,
- Endpoints: []string{u.String()},
- }
- c, err := client.New(cfg)
- if err != nil {
- return nil, err
- }
- dc := client.NewKeysAPIWithPrefix(c, "")
- return &discovery{
- lg: lg,
- cluster: token,
- c: dc,
- id: id,
- url: u,
- clock: clockwork.NewRealClock(),
- }, nil
-}
-
-func (d *discovery) joinCluster(config string) (string, error) {
- // fast path: if the cluster is full, return the error
- // do not need to register to the cluster in this case.
- if _, _, _, err := d.checkCluster(); err != nil {
- return "", err
- }
-
- if err := d.createSelf(config); err != nil {
- // Fails, even on a timeout, if createSelf times out.
- // TODO(barakmich): Retrying the same node might want to succeed here
- // (ie, createSelf should be idempotent for discovery).
- return "", err
- }
-
- nodes, size, index, err := d.checkCluster()
- if err != nil {
- return "", err
- }
-
- all, err := d.waitNodes(nodes, size, index)
- if err != nil {
- return "", err
- }
-
- return nodesToCluster(all, size)
-}
-
-func (d *discovery) getCluster() (string, error) {
- nodes, size, index, err := d.checkCluster()
- if err != nil {
- if err == ErrFullCluster {
- return nodesToCluster(nodes, size)
- }
- return "", err
- }
-
- all, err := d.waitNodes(nodes, size, index)
- if err != nil {
- return "", err
- }
- return nodesToCluster(all, size)
-}
-
-func (d *discovery) createSelf(contents string) error {
- ctx, cancel := context.WithTimeout(context.Background(), client.DefaultRequestTimeout)
- resp, err := d.c.Create(ctx, d.selfKey(), contents)
- cancel()
- if err != nil {
- if eerr, ok := err.(client.Error); ok && eerr.Code == client.ErrorCodeNodeExist {
- return ErrDuplicateID
- }
- return err
- }
-
- // ensure self appears on the server we connected to
- w := d.c.Watcher(d.selfKey(), &client.WatcherOptions{AfterIndex: resp.Node.CreatedIndex - 1})
- _, err = w.Next(context.Background())
- return err
-}
-
-func (d *discovery) checkCluster() ([]*client.Node, int, uint64, error) {
- configKey := path.Join("/", d.cluster, "_config")
- ctx, cancel := context.WithTimeout(context.Background(), client.DefaultRequestTimeout)
- // find cluster size
- resp, err := d.c.Get(ctx, path.Join(configKey, "size"), nil)
- cancel()
- if err != nil {
- if eerr, ok := err.(*client.Error); ok && eerr.Code == client.ErrorCodeKeyNotFound {
- return nil, 0, 0, ErrSizeNotFound
- }
- if err == client.ErrInvalidJSON {
- return nil, 0, 0, ErrBadDiscoveryEndpoint
- }
- if ce, ok := err.(*client.ClusterError); ok {
- if d.lg != nil {
- d.lg.Warn(
- "failed to get from discovery server",
- zap.String("discovery-url", d.url.String()),
- zap.String("path", path.Join(configKey, "size")),
- zap.Error(err),
- zap.String("err-detail", ce.Detail()),
- )
- } else {
- plog.Error(ce.Detail())
- }
- return d.checkClusterRetry()
- }
- return nil, 0, 0, err
- }
- size, err := strconv.Atoi(resp.Node.Value)
- if err != nil {
- return nil, 0, 0, ErrBadSizeKey
- }
-
- ctx, cancel = context.WithTimeout(context.Background(), client.DefaultRequestTimeout)
- resp, err = d.c.Get(ctx, d.cluster, nil)
- cancel()
- if err != nil {
- if ce, ok := err.(*client.ClusterError); ok {
- if d.lg != nil {
- d.lg.Warn(
- "failed to get from discovery server",
- zap.String("discovery-url", d.url.String()),
- zap.String("path", d.cluster),
- zap.Error(err),
- zap.String("err-detail", ce.Detail()),
- )
- } else {
- plog.Error(ce.Detail())
- }
- return d.checkClusterRetry()
- }
- return nil, 0, 0, err
- }
- var nodes []*client.Node
- // append non-config keys to nodes
- for _, n := range resp.Node.Nodes {
- if path.Base(n.Key) != path.Base(configKey) {
- nodes = append(nodes, n)
- }
- }
-
- snodes := sortableNodes{nodes}
- sort.Sort(snodes)
-
- // find self position
- for i := range nodes {
- if path.Base(nodes[i].Key) == path.Base(d.selfKey()) {
- break
- }
- if i >= size-1 {
- return nodes[:size], size, resp.Index, ErrFullCluster
- }
- }
- return nodes, size, resp.Index, nil
-}
-
-func (d *discovery) logAndBackoffForRetry(step string) {
- d.retries++
- // logAndBackoffForRetry stops exponential backoff when the retries are more than maxExpoentialRetries and is set to a constant backoff afterward.
- retries := d.retries
- if retries > maxExpoentialRetries {
- retries = maxExpoentialRetries
- }
- retryTimeInSecond := time.Duration(0x1<<retries) * time.Second
- if d.lg != nil {
- d.lg.Info(
- "retry connecting to discovery service",
- zap.String("url", d.url.String()),
- zap.String("reason", step),
- zap.Duration("backoff", retryTimeInSecond),
- )
- } else {
- plog.Infof("%s: error connecting to %s, retrying in %s", step, d.url, retryTimeInSecond)
- }
- d.clock.Sleep(retryTimeInSecond)
-}
-
-func (d *discovery) checkClusterRetry() ([]*client.Node, int, uint64, error) {
- if d.retries < nRetries {
- d.logAndBackoffForRetry("cluster status check")
- return d.checkCluster()
- }
- return nil, 0, 0, ErrTooManyRetries
-}
-
-func (d *discovery) waitNodesRetry() ([]*client.Node, error) {
- if d.retries < nRetries {
- d.logAndBackoffForRetry("waiting for other nodes")
- nodes, n, index, err := d.checkCluster()
- if err != nil {
- return nil, err
- }
- return d.waitNodes(nodes, n, index)
- }
- return nil, ErrTooManyRetries
-}
-
-func (d *discovery) waitNodes(nodes []*client.Node, size int, index uint64) ([]*client.Node, error) {
- if len(nodes) > size {
- nodes = nodes[:size]
- }
- // watch from the next index
- w := d.c.Watcher(d.cluster, &client.WatcherOptions{AfterIndex: index, Recursive: true})
- all := make([]*client.Node, len(nodes))
- copy(all, nodes)
- for _, n := range all {
- if path.Base(n.Key) == path.Base(d.selfKey()) {
- if d.lg != nil {
- d.lg.Info(
- "found self from discovery server",
- zap.String("discovery-url", d.url.String()),
- zap.String("self", path.Base(d.selfKey())),
- )
- } else {
- plog.Noticef("found self %s in the cluster", path.Base(d.selfKey()))
- }
- } else {
- if d.lg != nil {
- d.lg.Info(
- "found peer from discovery server",
- zap.String("discovery-url", d.url.String()),
- zap.String("peer", path.Base(n.Key)),
- )
- } else {
- plog.Noticef("found peer %s in the cluster", path.Base(n.Key))
- }
- }
- }
-
- // wait for others
- for len(all) < size {
- if d.lg != nil {
- d.lg.Info(
- "found peers from discovery server; waiting for more",
- zap.String("discovery-url", d.url.String()),
- zap.Int("found-peers", len(all)),
- zap.Int("needed-peers", size-len(all)),
- )
- } else {
- plog.Noticef("found %d peer(s), waiting for %d more", len(all), size-len(all))
- }
- resp, err := w.Next(context.Background())
- if err != nil {
- if ce, ok := err.(*client.ClusterError); ok {
- plog.Error(ce.Detail())
- return d.waitNodesRetry()
- }
- return nil, err
- }
- if d.lg != nil {
- d.lg.Info(
- "found peer from discovery server",
- zap.String("discovery-url", d.url.String()),
- zap.String("peer", path.Base(resp.Node.Key)),
- )
- } else {
- plog.Noticef("found peer %s in the cluster", path.Base(resp.Node.Key))
- }
- all = append(all, resp.Node)
- }
- if d.lg != nil {
- d.lg.Info(
- "found all needed peers from discovery server",
- zap.String("discovery-url", d.url.String()),
- zap.Int("found-peers", len(all)),
- )
- } else {
- plog.Noticef("found %d needed peer(s)", len(all))
- }
- return all, nil
-}
-
-func (d *discovery) selfKey() string {
- return path.Join("/", d.cluster, d.id.String())
-}
-
-func nodesToCluster(ns []*client.Node, size int) (string, error) {
- s := make([]string, len(ns))
- for i, n := range ns {
- s[i] = n.Value
- }
- us := strings.Join(s, ",")
- m, err := types.NewURLsMap(us)
- if err != nil {
- return us, ErrInvalidURL
- }
- if m.Len() != size {
- return us, ErrDuplicateName
- }
- return us, nil
-}
-
-type sortableNodes struct{ Nodes []*client.Node }
-
-func (ns sortableNodes) Len() int { return len(ns.Nodes) }
-func (ns sortableNodes) Less(i, j int) bool {
- return ns.Nodes[i].CreatedIndex < ns.Nodes[j].CreatedIndex
-}
-func (ns sortableNodes) Swap(i, j int) { ns.Nodes[i], ns.Nodes[j] = ns.Nodes[j], ns.Nodes[i] }
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2error/error.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2error/error.go
deleted file mode 100644
index 1244290..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2error/error.go
+++ /dev/null
@@ -1,164 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package v2error describes errors in etcd project. When any change happens,
-// Documentation/v2/errorcode.md needs to be updated correspondingly.
-// To be deprecated in favor of v3 APIs.
-package v2error
-
-import (
- "encoding/json"
- "fmt"
- "net/http"
-)
-
-var errors = map[int]string{
- // command related errors
- EcodeKeyNotFound: "Key not found",
- EcodeTestFailed: "Compare failed", //test and set
- EcodeNotFile: "Not a file",
- ecodeNoMorePeer: "Reached the max number of peers in the cluster",
- EcodeNotDir: "Not a directory",
- EcodeNodeExist: "Key already exists", // create
- ecodeKeyIsPreserved: "The prefix of given key is a keyword in etcd",
- EcodeRootROnly: "Root is read only",
- EcodeDirNotEmpty: "Directory not empty",
- ecodeExistingPeerAddr: "Peer address has existed",
- EcodeUnauthorized: "The request requires user authentication",
-
- // Post form related errors
- ecodeValueRequired: "Value is Required in POST form",
- EcodePrevValueRequired: "PrevValue is Required in POST form",
- EcodeTTLNaN: "The given TTL in POST form is not a number",
- EcodeIndexNaN: "The given index in POST form is not a number",
- ecodeValueOrTTLRequired: "Value or TTL is required in POST form",
- ecodeTimeoutNaN: "The given timeout in POST form is not a number",
- ecodeNameRequired: "Name is required in POST form",
- ecodeIndexOrValueRequired: "Index or value is required",
- ecodeIndexValueMutex: "Index and value cannot both be specified",
- EcodeInvalidField: "Invalid field",
- EcodeInvalidForm: "Invalid POST form",
- EcodeRefreshValue: "Value provided on refresh",
- EcodeRefreshTTLRequired: "A TTL must be provided on refresh",
-
- // raft related errors
- EcodeRaftInternal: "Raft Internal Error",
- EcodeLeaderElect: "During Leader Election",
-
- // etcd related errors
- EcodeWatcherCleared: "watcher is cleared due to etcd recovery",
- EcodeEventIndexCleared: "The event in requested index is outdated and cleared",
- ecodeStandbyInternal: "Standby Internal Error",
- ecodeInvalidActiveSize: "Invalid active size",
- ecodeInvalidRemoveDelay: "Standby remove delay",
-
- // client related errors
- ecodeClientInternal: "Client Internal Error",
-}
-
-var errorStatus = map[int]int{
- EcodeKeyNotFound: http.StatusNotFound,
- EcodeNotFile: http.StatusForbidden,
- EcodeDirNotEmpty: http.StatusForbidden,
- EcodeUnauthorized: http.StatusUnauthorized,
- EcodeTestFailed: http.StatusPreconditionFailed,
- EcodeNodeExist: http.StatusPreconditionFailed,
- EcodeRaftInternal: http.StatusInternalServerError,
- EcodeLeaderElect: http.StatusInternalServerError,
-}
-
-const (
- EcodeKeyNotFound = 100
- EcodeTestFailed = 101
- EcodeNotFile = 102
- ecodeNoMorePeer = 103
- EcodeNotDir = 104
- EcodeNodeExist = 105
- ecodeKeyIsPreserved = 106
- EcodeRootROnly = 107
- EcodeDirNotEmpty = 108
- ecodeExistingPeerAddr = 109
- EcodeUnauthorized = 110
-
- ecodeValueRequired = 200
- EcodePrevValueRequired = 201
- EcodeTTLNaN = 202
- EcodeIndexNaN = 203
- ecodeValueOrTTLRequired = 204
- ecodeTimeoutNaN = 205
- ecodeNameRequired = 206
- ecodeIndexOrValueRequired = 207
- ecodeIndexValueMutex = 208
- EcodeInvalidField = 209
- EcodeInvalidForm = 210
- EcodeRefreshValue = 211
- EcodeRefreshTTLRequired = 212
-
- EcodeRaftInternal = 300
- EcodeLeaderElect = 301
-
- EcodeWatcherCleared = 400
- EcodeEventIndexCleared = 401
- ecodeStandbyInternal = 402
- ecodeInvalidActiveSize = 403
- ecodeInvalidRemoveDelay = 404
-
- ecodeClientInternal = 500
-)
-
-type Error struct {
- ErrorCode int `json:"errorCode"`
- Message string `json:"message"`
- Cause string `json:"cause,omitempty"`
- Index uint64 `json:"index"`
-}
-
-func NewRequestError(errorCode int, cause string) *Error {
- return NewError(errorCode, cause, 0)
-}
-
-func NewError(errorCode int, cause string, index uint64) *Error {
- return &Error{
- ErrorCode: errorCode,
- Message: errors[errorCode],
- Cause: cause,
- Index: index,
- }
-}
-
-// Error is for the error interface
-func (e Error) Error() string {
- return e.Message + " (" + e.Cause + ")"
-}
-
-func (e Error) toJsonString() string {
- b, _ := json.Marshal(e)
- return string(b)
-}
-
-func (e Error) StatusCode() int {
- status, ok := errorStatus[e.ErrorCode]
- if !ok {
- status = http.StatusBadRequest
- }
- return status
-}
-
-func (e Error) WriteTo(w http.ResponseWriter) error {
- w.Header().Add("X-Etcd-Index", fmt.Sprint(e.Index))
- w.Header().Set("Content-Type", "application/json")
- w.WriteHeader(e.StatusCode())
- _, err := w.Write([]byte(e.toJsonString() + "\n"))
- return err
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2http/capability.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2http/capability.go
deleted file mode 100644
index ed6c456..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2http/capability.go
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v2http
-
-import (
- "fmt"
- "net/http"
-
- "go.etcd.io/etcd/etcdserver/api"
- "go.etcd.io/etcd/etcdserver/api/v2http/httptypes"
-)
-
-func authCapabilityHandler(fn func(http.ResponseWriter, *http.Request)) http.HandlerFunc {
- return func(w http.ResponseWriter, r *http.Request) {
- if !api.IsCapabilityEnabled(api.AuthCapability) {
- notCapable(w, r, api.AuthCapability)
- return
- }
- fn(w, r)
- }
-}
-
-func notCapable(w http.ResponseWriter, r *http.Request, c api.Capability) {
- herr := httptypes.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Not capable of accessing %s feature during rolling upgrades.", c))
- if err := herr.WriteTo(w); err != nil {
- plog.Debugf("error writing HTTPError (%v) to %s", err, r.RemoteAddr)
- }
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2http/client.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2http/client.go
deleted file mode 100644
index 1d1e592..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2http/client.go
+++ /dev/null
@@ -1,788 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v2http
-
-import (
- "context"
- "encoding/json"
- "errors"
- "fmt"
- "io/ioutil"
- "net/http"
- "net/url"
- "path"
- "strconv"
- "strings"
- "time"
-
- "go.etcd.io/etcd/etcdserver"
- "go.etcd.io/etcd/etcdserver/api"
- "go.etcd.io/etcd/etcdserver/api/etcdhttp"
- "go.etcd.io/etcd/etcdserver/api/membership"
- "go.etcd.io/etcd/etcdserver/api/v2auth"
- "go.etcd.io/etcd/etcdserver/api/v2error"
- "go.etcd.io/etcd/etcdserver/api/v2http/httptypes"
- stats "go.etcd.io/etcd/etcdserver/api/v2stats"
- "go.etcd.io/etcd/etcdserver/api/v2store"
- "go.etcd.io/etcd/etcdserver/etcdserverpb"
- "go.etcd.io/etcd/pkg/types"
-
- "github.com/jonboulle/clockwork"
- "go.uber.org/zap"
-)
-
-const (
- authPrefix = "/v2/auth"
- keysPrefix = "/v2/keys"
- machinesPrefix = "/v2/machines"
- membersPrefix = "/v2/members"
- statsPrefix = "/v2/stats"
-)
-
-// NewClientHandler generates a muxed http.Handler with the given parameters to serve etcd client requests.
-func NewClientHandler(lg *zap.Logger, server etcdserver.ServerPeer, timeout time.Duration) http.Handler {
- mux := http.NewServeMux()
- etcdhttp.HandleBasic(mux, server)
- handleV2(lg, mux, server, timeout)
- return requestLogger(lg, mux)
-}
-
-func handleV2(lg *zap.Logger, mux *http.ServeMux, server etcdserver.ServerV2, timeout time.Duration) {
- sec := v2auth.NewStore(lg, server, timeout)
- kh := &keysHandler{
- lg: lg,
- sec: sec,
- server: server,
- cluster: server.Cluster(),
- timeout: timeout,
- clientCertAuthEnabled: server.ClientCertAuthEnabled(),
- }
-
- sh := &statsHandler{
- lg: lg,
- stats: server,
- }
-
- mh := &membersHandler{
- lg: lg,
- sec: sec,
- server: server,
- cluster: server.Cluster(),
- timeout: timeout,
- clock: clockwork.NewRealClock(),
- clientCertAuthEnabled: server.ClientCertAuthEnabled(),
- }
-
- mah := &machinesHandler{cluster: server.Cluster()}
-
- sech := &authHandler{
- lg: lg,
- sec: sec,
- cluster: server.Cluster(),
- clientCertAuthEnabled: server.ClientCertAuthEnabled(),
- }
- mux.HandleFunc("/", http.NotFound)
- mux.Handle(keysPrefix, kh)
- mux.Handle(keysPrefix+"/", kh)
- mux.HandleFunc(statsPrefix+"/store", sh.serveStore)
- mux.HandleFunc(statsPrefix+"/self", sh.serveSelf)
- mux.HandleFunc(statsPrefix+"/leader", sh.serveLeader)
- mux.Handle(membersPrefix, mh)
- mux.Handle(membersPrefix+"/", mh)
- mux.Handle(machinesPrefix, mah)
- handleAuth(mux, sech)
-}
-
-type keysHandler struct {
- lg *zap.Logger
- sec v2auth.Store
- server etcdserver.ServerV2
- cluster api.Cluster
- timeout time.Duration
- clientCertAuthEnabled bool
-}
-
-func (h *keysHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
- if !allowMethod(w, r.Method, "HEAD", "GET", "PUT", "POST", "DELETE") {
- return
- }
-
- w.Header().Set("X-Etcd-Cluster-ID", h.cluster.ID().String())
-
- ctx, cancel := context.WithTimeout(context.Background(), h.timeout)
- defer cancel()
- clock := clockwork.NewRealClock()
- startTime := clock.Now()
- rr, noValueOnSuccess, err := parseKeyRequest(r, clock)
- if err != nil {
- writeKeyError(h.lg, w, err)
- return
- }
- // The path must be valid at this point (we've parsed the request successfully).
- if !hasKeyPrefixAccess(h.lg, h.sec, r, r.URL.Path[len(keysPrefix):], rr.Recursive, h.clientCertAuthEnabled) {
- writeKeyNoAuth(w)
- return
- }
- if !rr.Wait {
- reportRequestReceived(rr)
- }
- resp, err := h.server.Do(ctx, rr)
- if err != nil {
- err = trimErrorPrefix(err, etcdserver.StoreKeysPrefix)
- writeKeyError(h.lg, w, err)
- reportRequestFailed(rr, err)
- return
- }
- switch {
- case resp.Event != nil:
- if err := writeKeyEvent(w, resp, noValueOnSuccess); err != nil {
- // Should never be reached
- if h.lg != nil {
- h.lg.Warn("failed to write key event", zap.Error(err))
- } else {
- plog.Errorf("error writing event (%v)", err)
- }
- }
- reportRequestCompleted(rr, startTime)
- case resp.Watcher != nil:
- ctx, cancel := context.WithTimeout(context.Background(), defaultWatchTimeout)
- defer cancel()
- handleKeyWatch(ctx, h.lg, w, resp, rr.Stream)
- default:
- writeKeyError(h.lg, w, errors.New("received response with no Event/Watcher"))
- }
-}
-
-type machinesHandler struct {
- cluster api.Cluster
-}
-
-func (h *machinesHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
- if !allowMethod(w, r.Method, "GET", "HEAD") {
- return
- }
- endpoints := h.cluster.ClientURLs()
- w.Write([]byte(strings.Join(endpoints, ", ")))
-}
-
-type membersHandler struct {
- lg *zap.Logger
- sec v2auth.Store
- server etcdserver.ServerV2
- cluster api.Cluster
- timeout time.Duration
- clock clockwork.Clock
- clientCertAuthEnabled bool
-}
-
-func (h *membersHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
- if !allowMethod(w, r.Method, "GET", "POST", "DELETE", "PUT") {
- return
- }
- if !hasWriteRootAccess(h.lg, h.sec, r, h.clientCertAuthEnabled) {
- writeNoAuth(h.lg, w, r)
- return
- }
- w.Header().Set("X-Etcd-Cluster-ID", h.cluster.ID().String())
-
- ctx, cancel := context.WithTimeout(context.Background(), h.timeout)
- defer cancel()
-
- switch r.Method {
- case "GET":
- switch trimPrefix(r.URL.Path, membersPrefix) {
- case "":
- mc := newMemberCollection(h.cluster.Members())
- w.Header().Set("Content-Type", "application/json")
- if err := json.NewEncoder(w).Encode(mc); err != nil {
- if h.lg != nil {
- h.lg.Warn("failed to encode members response", zap.Error(err))
- } else {
- plog.Warningf("failed to encode members response (%v)", err)
- }
- }
- case "leader":
- id := h.server.Leader()
- if id == 0 {
- writeError(h.lg, w, r, httptypes.NewHTTPError(http.StatusServiceUnavailable, "During election"))
- return
- }
- m := newMember(h.cluster.Member(id))
- w.Header().Set("Content-Type", "application/json")
- if err := json.NewEncoder(w).Encode(m); err != nil {
- if h.lg != nil {
- h.lg.Warn("failed to encode members response", zap.Error(err))
- } else {
- plog.Warningf("failed to encode members response (%v)", err)
- }
- }
- default:
- writeError(h.lg, w, r, httptypes.NewHTTPError(http.StatusNotFound, "Not found"))
- }
-
- case "POST":
- req := httptypes.MemberCreateRequest{}
- if ok := unmarshalRequest(h.lg, r, &req, w); !ok {
- return
- }
- now := h.clock.Now()
- m := membership.NewMember("", req.PeerURLs, "", &now)
- _, err := h.server.AddMember(ctx, *m)
- switch {
- case err == membership.ErrIDExists || err == membership.ErrPeerURLexists:
- writeError(h.lg, w, r, httptypes.NewHTTPError(http.StatusConflict, err.Error()))
- return
- case err != nil:
- if h.lg != nil {
- h.lg.Warn(
- "failed to add a member",
- zap.String("member-id", m.ID.String()),
- zap.Error(err),
- )
- } else {
- plog.Errorf("error adding member %s (%v)", m.ID, err)
- }
- writeError(h.lg, w, r, err)
- return
- }
- res := newMember(m)
- w.Header().Set("Content-Type", "application/json")
- w.WriteHeader(http.StatusCreated)
- if err := json.NewEncoder(w).Encode(res); err != nil {
- if h.lg != nil {
- h.lg.Warn("failed to encode members response", zap.Error(err))
- } else {
- plog.Warningf("failed to encode members response (%v)", err)
- }
- }
-
- case "DELETE":
- id, ok := getID(h.lg, r.URL.Path, w)
- if !ok {
- return
- }
- _, err := h.server.RemoveMember(ctx, uint64(id))
- switch {
- case err == membership.ErrIDRemoved:
- writeError(h.lg, w, r, httptypes.NewHTTPError(http.StatusGone, fmt.Sprintf("Member permanently removed: %s", id)))
- case err == membership.ErrIDNotFound:
- writeError(h.lg, w, r, httptypes.NewHTTPError(http.StatusNotFound, fmt.Sprintf("No such member: %s", id)))
- case err != nil:
- if h.lg != nil {
- h.lg.Warn(
- "failed to remove a member",
- zap.String("member-id", id.String()),
- zap.Error(err),
- )
- } else {
- plog.Errorf("error removing member %s (%v)", id, err)
- }
- writeError(h.lg, w, r, err)
- default:
- w.WriteHeader(http.StatusNoContent)
- }
-
- case "PUT":
- id, ok := getID(h.lg, r.URL.Path, w)
- if !ok {
- return
- }
- req := httptypes.MemberUpdateRequest{}
- if ok := unmarshalRequest(h.lg, r, &req, w); !ok {
- return
- }
- m := membership.Member{
- ID: id,
- RaftAttributes: membership.RaftAttributes{PeerURLs: req.PeerURLs.StringSlice()},
- }
- _, err := h.server.UpdateMember(ctx, m)
- switch {
- case err == membership.ErrPeerURLexists:
- writeError(h.lg, w, r, httptypes.NewHTTPError(http.StatusConflict, err.Error()))
- case err == membership.ErrIDNotFound:
- writeError(h.lg, w, r, httptypes.NewHTTPError(http.StatusNotFound, fmt.Sprintf("No such member: %s", id)))
- case err != nil:
- if h.lg != nil {
- h.lg.Warn(
- "failed to update a member",
- zap.String("member-id", m.ID.String()),
- zap.Error(err),
- )
- } else {
- plog.Errorf("error updating member %s (%v)", m.ID, err)
- }
- writeError(h.lg, w, r, err)
- default:
- w.WriteHeader(http.StatusNoContent)
- }
- }
-}
-
-type statsHandler struct {
- lg *zap.Logger
- stats stats.Stats
-}
-
-func (h *statsHandler) serveStore(w http.ResponseWriter, r *http.Request) {
- if !allowMethod(w, r.Method, "GET") {
- return
- }
- w.Header().Set("Content-Type", "application/json")
- w.Write(h.stats.StoreStats())
-}
-
-func (h *statsHandler) serveSelf(w http.ResponseWriter, r *http.Request) {
- if !allowMethod(w, r.Method, "GET") {
- return
- }
- w.Header().Set("Content-Type", "application/json")
- w.Write(h.stats.SelfStats())
-}
-
-func (h *statsHandler) serveLeader(w http.ResponseWriter, r *http.Request) {
- if !allowMethod(w, r.Method, "GET") {
- return
- }
- stats := h.stats.LeaderStats()
- if stats == nil {
- etcdhttp.WriteError(h.lg, w, r, httptypes.NewHTTPError(http.StatusForbidden, "not current leader"))
- return
- }
- w.Header().Set("Content-Type", "application/json")
- w.Write(stats)
-}
-
-// parseKeyRequest converts a received http.Request on keysPrefix to
-// a server Request, performing validation of supplied fields as appropriate.
-// If any validation fails, an empty Request and non-nil error is returned.
-func parseKeyRequest(r *http.Request, clock clockwork.Clock) (etcdserverpb.Request, bool, error) {
- var noValueOnSuccess bool
- emptyReq := etcdserverpb.Request{}
-
- err := r.ParseForm()
- if err != nil {
- return emptyReq, false, v2error.NewRequestError(
- v2error.EcodeInvalidForm,
- err.Error(),
- )
- }
-
- if !strings.HasPrefix(r.URL.Path, keysPrefix) {
- return emptyReq, false, v2error.NewRequestError(
- v2error.EcodeInvalidForm,
- "incorrect key prefix",
- )
- }
- p := path.Join(etcdserver.StoreKeysPrefix, r.URL.Path[len(keysPrefix):])
-
- var pIdx, wIdx uint64
- if pIdx, err = getUint64(r.Form, "prevIndex"); err != nil {
- return emptyReq, false, v2error.NewRequestError(
- v2error.EcodeIndexNaN,
- `invalid value for "prevIndex"`,
- )
- }
- if wIdx, err = getUint64(r.Form, "waitIndex"); err != nil {
- return emptyReq, false, v2error.NewRequestError(
- v2error.EcodeIndexNaN,
- `invalid value for "waitIndex"`,
- )
- }
-
- var rec, sort, wait, dir, quorum, stream bool
- if rec, err = getBool(r.Form, "recursive"); err != nil {
- return emptyReq, false, v2error.NewRequestError(
- v2error.EcodeInvalidField,
- `invalid value for "recursive"`,
- )
- }
- if sort, err = getBool(r.Form, "sorted"); err != nil {
- return emptyReq, false, v2error.NewRequestError(
- v2error.EcodeInvalidField,
- `invalid value for "sorted"`,
- )
- }
- if wait, err = getBool(r.Form, "wait"); err != nil {
- return emptyReq, false, v2error.NewRequestError(
- v2error.EcodeInvalidField,
- `invalid value for "wait"`,
- )
- }
- // TODO(jonboulle): define what parameters dir is/isn't compatible with?
- if dir, err = getBool(r.Form, "dir"); err != nil {
- return emptyReq, false, v2error.NewRequestError(
- v2error.EcodeInvalidField,
- `invalid value for "dir"`,
- )
- }
- if quorum, err = getBool(r.Form, "quorum"); err != nil {
- return emptyReq, false, v2error.NewRequestError(
- v2error.EcodeInvalidField,
- `invalid value for "quorum"`,
- )
- }
- if stream, err = getBool(r.Form, "stream"); err != nil {
- return emptyReq, false, v2error.NewRequestError(
- v2error.EcodeInvalidField,
- `invalid value for "stream"`,
- )
- }
-
- if wait && r.Method != "GET" {
- return emptyReq, false, v2error.NewRequestError(
- v2error.EcodeInvalidField,
- `"wait" can only be used with GET requests`,
- )
- }
-
- pV := r.FormValue("prevValue")
- if _, ok := r.Form["prevValue"]; ok && pV == "" {
- return emptyReq, false, v2error.NewRequestError(
- v2error.EcodePrevValueRequired,
- `"prevValue" cannot be empty`,
- )
- }
-
- if noValueOnSuccess, err = getBool(r.Form, "noValueOnSuccess"); err != nil {
- return emptyReq, false, v2error.NewRequestError(
- v2error.EcodeInvalidField,
- `invalid value for "noValueOnSuccess"`,
- )
- }
-
- // TTL is nullable, so leave it null if not specified
- // or an empty string
- var ttl *uint64
- if len(r.FormValue("ttl")) > 0 {
- i, err := getUint64(r.Form, "ttl")
- if err != nil {
- return emptyReq, false, v2error.NewRequestError(
- v2error.EcodeTTLNaN,
- `invalid value for "ttl"`,
- )
- }
- ttl = &i
- }
-
- // prevExist is nullable, so leave it null if not specified
- var pe *bool
- if _, ok := r.Form["prevExist"]; ok {
- bv, err := getBool(r.Form, "prevExist")
- if err != nil {
- return emptyReq, false, v2error.NewRequestError(
- v2error.EcodeInvalidField,
- "invalid value for prevExist",
- )
- }
- pe = &bv
- }
-
- // refresh is nullable, so leave it null if not specified
- var refresh *bool
- if _, ok := r.Form["refresh"]; ok {
- bv, err := getBool(r.Form, "refresh")
- if err != nil {
- return emptyReq, false, v2error.NewRequestError(
- v2error.EcodeInvalidField,
- "invalid value for refresh",
- )
- }
- refresh = &bv
- if refresh != nil && *refresh {
- val := r.FormValue("value")
- if _, ok := r.Form["value"]; ok && val != "" {
- return emptyReq, false, v2error.NewRequestError(
- v2error.EcodeRefreshValue,
- `A value was provided on a refresh`,
- )
- }
- if ttl == nil {
- return emptyReq, false, v2error.NewRequestError(
- v2error.EcodeRefreshTTLRequired,
- `No TTL value set`,
- )
- }
- }
- }
-
- rr := etcdserverpb.Request{
- Method: r.Method,
- Path: p,
- Val: r.FormValue("value"),
- Dir: dir,
- PrevValue: pV,
- PrevIndex: pIdx,
- PrevExist: pe,
- Wait: wait,
- Since: wIdx,
- Recursive: rec,
- Sorted: sort,
- Quorum: quorum,
- Stream: stream,
- }
-
- if pe != nil {
- rr.PrevExist = pe
- }
-
- if refresh != nil {
- rr.Refresh = refresh
- }
-
- // Null TTL is equivalent to unset Expiration
- if ttl != nil {
- expr := time.Duration(*ttl) * time.Second
- rr.Expiration = clock.Now().Add(expr).UnixNano()
- }
-
- return rr, noValueOnSuccess, nil
-}
-
-// writeKeyEvent trims the prefix of key path in a single Event under
-// StoreKeysPrefix, serializes it and writes the resulting JSON to the given
-// ResponseWriter, along with the appropriate headers.
-func writeKeyEvent(w http.ResponseWriter, resp etcdserver.Response, noValueOnSuccess bool) error {
- ev := resp.Event
- if ev == nil {
- return errors.New("cannot write empty Event")
- }
- w.Header().Set("Content-Type", "application/json")
- w.Header().Set("X-Etcd-Index", fmt.Sprint(ev.EtcdIndex))
- w.Header().Set("X-Raft-Index", fmt.Sprint(resp.Index))
- w.Header().Set("X-Raft-Term", fmt.Sprint(resp.Term))
-
- if ev.IsCreated() {
- w.WriteHeader(http.StatusCreated)
- }
-
- ev = trimEventPrefix(ev, etcdserver.StoreKeysPrefix)
- if noValueOnSuccess &&
- (ev.Action == v2store.Set || ev.Action == v2store.CompareAndSwap ||
- ev.Action == v2store.Create || ev.Action == v2store.Update) {
- ev.Node = nil
- ev.PrevNode = nil
- }
- return json.NewEncoder(w).Encode(ev)
-}
-
-func writeKeyNoAuth(w http.ResponseWriter) {
- e := v2error.NewError(v2error.EcodeUnauthorized, "Insufficient credentials", 0)
- e.WriteTo(w)
-}
-
-// writeKeyError logs and writes the given Error to the ResponseWriter.
-// If Error is not an etcdErr, the error will be converted to an etcd error.
-func writeKeyError(lg *zap.Logger, w http.ResponseWriter, err error) {
- if err == nil {
- return
- }
- switch e := err.(type) {
- case *v2error.Error:
- e.WriteTo(w)
- default:
- switch err {
- case etcdserver.ErrTimeoutDueToLeaderFail, etcdserver.ErrTimeoutDueToConnectionLost:
- if lg != nil {
- lg.Warn(
- "v2 response error",
- zap.String("internal-server-error", err.Error()),
- )
- } else {
- mlog.MergeError(err)
- }
- default:
- if lg != nil {
- lg.Warn(
- "unexpected v2 response error",
- zap.String("internal-server-error", err.Error()),
- )
- } else {
- mlog.MergeErrorf("got unexpected response error (%v)", err)
- }
- }
- ee := v2error.NewError(v2error.EcodeRaftInternal, err.Error(), 0)
- ee.WriteTo(w)
- }
-}
-
-func handleKeyWatch(ctx context.Context, lg *zap.Logger, w http.ResponseWriter, resp etcdserver.Response, stream bool) {
- wa := resp.Watcher
- defer wa.Remove()
- ech := wa.EventChan()
- var nch <-chan bool
- if x, ok := w.(http.CloseNotifier); ok {
- nch = x.CloseNotify()
- }
-
- w.Header().Set("Content-Type", "application/json")
- w.Header().Set("X-Etcd-Index", fmt.Sprint(wa.StartIndex()))
- w.Header().Set("X-Raft-Index", fmt.Sprint(resp.Index))
- w.Header().Set("X-Raft-Term", fmt.Sprint(resp.Term))
- w.WriteHeader(http.StatusOK)
-
- // Ensure headers are flushed early, in case of long polling
- w.(http.Flusher).Flush()
-
- for {
- select {
- case <-nch:
- // Client closed connection. Nothing to do.
- return
- case <-ctx.Done():
- // Timed out. net/http will close the connection for us, so nothing to do.
- return
- case ev, ok := <-ech:
- if !ok {
- // If the channel is closed this may be an indication of
- // that notifications are much more than we are able to
- // send to the client in time. Then we simply end streaming.
- return
- }
- ev = trimEventPrefix(ev, etcdserver.StoreKeysPrefix)
- if err := json.NewEncoder(w).Encode(ev); err != nil {
- // Should never be reached
- if lg != nil {
- lg.Warn("failed to encode event", zap.Error(err))
- } else {
- plog.Warningf("error writing event (%v)", err)
- }
- return
- }
- if !stream {
- return
- }
- w.(http.Flusher).Flush()
- }
- }
-}
-
-func trimEventPrefix(ev *v2store.Event, prefix string) *v2store.Event {
- if ev == nil {
- return nil
- }
- // Since the *Event may reference one in the store history
- // history, we must copy it before modifying
- e := ev.Clone()
- trimNodeExternPrefix(e.Node, prefix)
- trimNodeExternPrefix(e.PrevNode, prefix)
- return e
-}
-
-func trimNodeExternPrefix(n *v2store.NodeExtern, prefix string) {
- if n == nil {
- return
- }
- n.Key = strings.TrimPrefix(n.Key, prefix)
- for _, nn := range n.Nodes {
- trimNodeExternPrefix(nn, prefix)
- }
-}
-
-func trimErrorPrefix(err error, prefix string) error {
- if e, ok := err.(*v2error.Error); ok {
- e.Cause = strings.TrimPrefix(e.Cause, prefix)
- }
- return err
-}
-
-func unmarshalRequest(lg *zap.Logger, r *http.Request, req json.Unmarshaler, w http.ResponseWriter) bool {
- ctype := r.Header.Get("Content-Type")
- semicolonPosition := strings.Index(ctype, ";")
- if semicolonPosition != -1 {
- ctype = strings.TrimSpace(strings.ToLower(ctype[0:semicolonPosition]))
- }
- if ctype != "application/json" {
- writeError(lg, w, r, httptypes.NewHTTPError(http.StatusUnsupportedMediaType, fmt.Sprintf("Bad Content-Type %s, accept application/json", ctype)))
- return false
- }
- b, err := ioutil.ReadAll(r.Body)
- if err != nil {
- writeError(lg, w, r, httptypes.NewHTTPError(http.StatusBadRequest, err.Error()))
- return false
- }
- if err := req.UnmarshalJSON(b); err != nil {
- writeError(lg, w, r, httptypes.NewHTTPError(http.StatusBadRequest, err.Error()))
- return false
- }
- return true
-}
-
-func getID(lg *zap.Logger, p string, w http.ResponseWriter) (types.ID, bool) {
- idStr := trimPrefix(p, membersPrefix)
- if idStr == "" {
- http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
- return 0, false
- }
- id, err := types.IDFromString(idStr)
- if err != nil {
- writeError(lg, w, nil, httptypes.NewHTTPError(http.StatusNotFound, fmt.Sprintf("No such member: %s", idStr)))
- return 0, false
- }
- return id, true
-}
-
-// getUint64 extracts a uint64 by the given key from a Form. If the key does
-// not exist in the form, 0 is returned. If the key exists but the value is
-// badly formed, an error is returned. If multiple values are present only the
-// first is considered.
-func getUint64(form url.Values, key string) (i uint64, err error) {
- if vals, ok := form[key]; ok {
- i, err = strconv.ParseUint(vals[0], 10, 64)
- }
- return
-}
-
-// getBool extracts a bool by the given key from a Form. If the key does not
-// exist in the form, false is returned. If the key exists but the value is
-// badly formed, an error is returned. If multiple values are present only the
-// first is considered.
-func getBool(form url.Values, key string) (b bool, err error) {
- if vals, ok := form[key]; ok {
- b, err = strconv.ParseBool(vals[0])
- }
- return
-}
-
-// trimPrefix removes a given prefix and any slash following the prefix
-// e.g.: trimPrefix("foo", "foo") == trimPrefix("foo/", "foo") == ""
-func trimPrefix(p, prefix string) (s string) {
- s = strings.TrimPrefix(p, prefix)
- s = strings.TrimPrefix(s, "/")
- return
-}
-
-func newMemberCollection(ms []*membership.Member) *httptypes.MemberCollection {
- c := httptypes.MemberCollection(make([]httptypes.Member, len(ms)))
-
- for i, m := range ms {
- c[i] = newMember(m)
- }
-
- return &c
-}
-
-func newMember(m *membership.Member) httptypes.Member {
- tm := httptypes.Member{
- ID: m.ID.String(),
- Name: m.Name,
- PeerURLs: make([]string, len(m.PeerURLs)),
- ClientURLs: make([]string, len(m.ClientURLs)),
- }
-
- copy(tm.PeerURLs, m.PeerURLs)
- copy(tm.ClientURLs, m.ClientURLs)
-
- return tm
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2http/client_auth.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2http/client_auth.go
deleted file mode 100644
index d8d6a88..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2http/client_auth.go
+++ /dev/null
@@ -1,664 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v2http
-
-import (
- "encoding/json"
- "net/http"
- "path"
- "strings"
-
- "go.etcd.io/etcd/etcdserver/api"
- "go.etcd.io/etcd/etcdserver/api/v2auth"
- "go.etcd.io/etcd/etcdserver/api/v2http/httptypes"
-
- "go.uber.org/zap"
-)
-
-type authHandler struct {
- lg *zap.Logger
- sec v2auth.Store
- cluster api.Cluster
- clientCertAuthEnabled bool
-}
-
-func hasWriteRootAccess(lg *zap.Logger, sec v2auth.Store, r *http.Request, clientCertAuthEnabled bool) bool {
- if r.Method == "GET" || r.Method == "HEAD" {
- return true
- }
- return hasRootAccess(lg, sec, r, clientCertAuthEnabled)
-}
-
-func userFromBasicAuth(lg *zap.Logger, sec v2auth.Store, r *http.Request) *v2auth.User {
- username, password, ok := r.BasicAuth()
- if !ok {
- if lg != nil {
- lg.Warn("malformed basic auth encoding")
- } else {
- plog.Warningf("auth: malformed basic auth encoding")
- }
- return nil
- }
- user, err := sec.GetUser(username)
- if err != nil {
- return nil
- }
-
- ok = sec.CheckPassword(user, password)
- if !ok {
- if lg != nil {
- lg.Warn("incorrect password", zap.String("user-name", username))
- } else {
- plog.Warningf("auth: incorrect password for user: %s", username)
- }
- return nil
- }
- return &user
-}
-
-func userFromClientCertificate(lg *zap.Logger, sec v2auth.Store, r *http.Request) *v2auth.User {
- if r.TLS == nil {
- return nil
- }
-
- for _, chains := range r.TLS.VerifiedChains {
- for _, chain := range chains {
- if lg != nil {
- lg.Debug("found common name", zap.String("common-name", chain.Subject.CommonName))
- } else {
- plog.Debugf("auth: found common name %s.\n", chain.Subject.CommonName)
- }
- user, err := sec.GetUser(chain.Subject.CommonName)
- if err == nil {
- if lg != nil {
- lg.Debug(
- "authenticated a user via common name",
- zap.String("user-name", user.User),
- zap.String("common-name", chain.Subject.CommonName),
- )
- } else {
- plog.Debugf("auth: authenticated user %s by cert common name.", user.User)
- }
- return &user
- }
- }
- }
- return nil
-}
-
-func hasRootAccess(lg *zap.Logger, sec v2auth.Store, r *http.Request, clientCertAuthEnabled bool) bool {
- if sec == nil {
- // No store means no auth available, eg, tests.
- return true
- }
- if !sec.AuthEnabled() {
- return true
- }
-
- var rootUser *v2auth.User
- if r.Header.Get("Authorization") == "" && clientCertAuthEnabled {
- rootUser = userFromClientCertificate(lg, sec, r)
- if rootUser == nil {
- return false
- }
- } else {
- rootUser = userFromBasicAuth(lg, sec, r)
- if rootUser == nil {
- return false
- }
- }
-
- for _, role := range rootUser.Roles {
- if role == v2auth.RootRoleName {
- return true
- }
- }
-
- if lg != nil {
- lg.Warn(
- "a user does not have root role for resource",
- zap.String("root-user", rootUser.User),
- zap.String("root-role-name", v2auth.RootRoleName),
- zap.String("resource-path", r.URL.Path),
- )
- } else {
- plog.Warningf("auth: user %s does not have the %s role for resource %s.", rootUser.User, v2auth.RootRoleName, r.URL.Path)
- }
- return false
-}
-
-func hasKeyPrefixAccess(lg *zap.Logger, sec v2auth.Store, r *http.Request, key string, recursive, clientCertAuthEnabled bool) bool {
- if sec == nil {
- // No store means no auth available, eg, tests.
- return true
- }
- if !sec.AuthEnabled() {
- return true
- }
-
- var user *v2auth.User
- if r.Header.Get("Authorization") == "" {
- if clientCertAuthEnabled {
- user = userFromClientCertificate(lg, sec, r)
- }
- if user == nil {
- return hasGuestAccess(lg, sec, r, key)
- }
- } else {
- user = userFromBasicAuth(lg, sec, r)
- if user == nil {
- return false
- }
- }
-
- writeAccess := r.Method != "GET" && r.Method != "HEAD"
- for _, roleName := range user.Roles {
- role, err := sec.GetRole(roleName)
- if err != nil {
- continue
- }
- if recursive {
- if role.HasRecursiveAccess(key, writeAccess) {
- return true
- }
- } else if role.HasKeyAccess(key, writeAccess) {
- return true
- }
- }
-
- if lg != nil {
- lg.Warn(
- "invalid access for user on key",
- zap.String("user-name", user.User),
- zap.String("key", key),
- )
- } else {
- plog.Warningf("auth: invalid access for user %s on key %s.", user.User, key)
- }
- return false
-}
-
-func hasGuestAccess(lg *zap.Logger, sec v2auth.Store, r *http.Request, key string) bool {
- writeAccess := r.Method != "GET" && r.Method != "HEAD"
- role, err := sec.GetRole(v2auth.GuestRoleName)
- if err != nil {
- return false
- }
- if role.HasKeyAccess(key, writeAccess) {
- return true
- }
-
- if lg != nil {
- lg.Warn(
- "invalid access for a guest role on key",
- zap.String("role-name", v2auth.GuestRoleName),
- zap.String("key", key),
- )
- } else {
- plog.Warningf("auth: invalid access for unauthenticated user on resource %s.", key)
- }
- return false
-}
-
-func writeNoAuth(lg *zap.Logger, w http.ResponseWriter, r *http.Request) {
- herr := httptypes.NewHTTPError(http.StatusUnauthorized, "Insufficient credentials")
- if err := herr.WriteTo(w); err != nil {
- if lg != nil {
- lg.Debug(
- "failed to write v2 HTTP error",
- zap.String("remote-addr", r.RemoteAddr),
- zap.Error(err),
- )
- } else {
- plog.Debugf("error writing HTTPError (%v) to %s", err, r.RemoteAddr)
- }
- }
-}
-
-func handleAuth(mux *http.ServeMux, sh *authHandler) {
- mux.HandleFunc(authPrefix+"/roles", authCapabilityHandler(sh.baseRoles))
- mux.HandleFunc(authPrefix+"/roles/", authCapabilityHandler(sh.handleRoles))
- mux.HandleFunc(authPrefix+"/users", authCapabilityHandler(sh.baseUsers))
- mux.HandleFunc(authPrefix+"/users/", authCapabilityHandler(sh.handleUsers))
- mux.HandleFunc(authPrefix+"/enable", authCapabilityHandler(sh.enableDisable))
-}
-
-func (sh *authHandler) baseRoles(w http.ResponseWriter, r *http.Request) {
- if !allowMethod(w, r.Method, "GET") {
- return
- }
- if !hasRootAccess(sh.lg, sh.sec, r, sh.clientCertAuthEnabled) {
- writeNoAuth(sh.lg, w, r)
- return
- }
-
- w.Header().Set("X-Etcd-Cluster-ID", sh.cluster.ID().String())
- w.Header().Set("Content-Type", "application/json")
-
- roles, err := sh.sec.AllRoles()
- if err != nil {
- writeError(sh.lg, w, r, err)
- return
- }
- if roles == nil {
- roles = make([]string, 0)
- }
-
- err = r.ParseForm()
- if err != nil {
- writeError(sh.lg, w, r, err)
- return
- }
-
- var rolesCollections struct {
- Roles []v2auth.Role `json:"roles"`
- }
- for _, roleName := range roles {
- var role v2auth.Role
- role, err = sh.sec.GetRole(roleName)
- if err != nil {
- writeError(sh.lg, w, r, err)
- return
- }
- rolesCollections.Roles = append(rolesCollections.Roles, role)
- }
- err = json.NewEncoder(w).Encode(rolesCollections)
-
- if err != nil {
- if sh.lg != nil {
- sh.lg.Warn(
- "failed to encode base roles",
- zap.String("url", r.URL.String()),
- zap.Error(err),
- )
- } else {
- plog.Warningf("baseRoles error encoding on %s", r.URL)
- }
- writeError(sh.lg, w, r, err)
- return
- }
-}
-
-func (sh *authHandler) handleRoles(w http.ResponseWriter, r *http.Request) {
- subpath := path.Clean(r.URL.Path[len(authPrefix):])
- // Split "/roles/rolename/command".
- // First item is an empty string, second is "roles"
- pieces := strings.Split(subpath, "/")
- if len(pieces) == 2 {
- sh.baseRoles(w, r)
- return
- }
- if len(pieces) != 3 {
- writeError(sh.lg, w, r, httptypes.NewHTTPError(http.StatusBadRequest, "Invalid path"))
- return
- }
- sh.forRole(w, r, pieces[2])
-}
-
-func (sh *authHandler) forRole(w http.ResponseWriter, r *http.Request, role string) {
- if !allowMethod(w, r.Method, "GET", "PUT", "DELETE") {
- return
- }
- if !hasRootAccess(sh.lg, sh.sec, r, sh.clientCertAuthEnabled) {
- writeNoAuth(sh.lg, w, r)
- return
- }
- w.Header().Set("X-Etcd-Cluster-ID", sh.cluster.ID().String())
- w.Header().Set("Content-Type", "application/json")
-
- switch r.Method {
- case "GET":
- data, err := sh.sec.GetRole(role)
- if err != nil {
- writeError(sh.lg, w, r, err)
- return
- }
- err = json.NewEncoder(w).Encode(data)
- if err != nil {
- if sh.lg != nil {
- sh.lg.Warn(
- "failed to encode a role",
- zap.String("url", r.URL.String()),
- zap.Error(err),
- )
- } else {
- plog.Warningf("forRole error encoding on %s", r.URL)
- }
- return
- }
- return
-
- case "PUT":
- var in v2auth.Role
- err := json.NewDecoder(r.Body).Decode(&in)
- if err != nil {
- writeError(sh.lg, w, r, httptypes.NewHTTPError(http.StatusBadRequest, "Invalid JSON in request body."))
- return
- }
- if in.Role != role {
- writeError(sh.lg, w, r, httptypes.NewHTTPError(http.StatusBadRequest, "Role JSON name does not match the name in the URL"))
- return
- }
-
- var out v2auth.Role
-
- // create
- if in.Grant.IsEmpty() && in.Revoke.IsEmpty() {
- err = sh.sec.CreateRole(in)
- if err != nil {
- writeError(sh.lg, w, r, err)
- return
- }
- w.WriteHeader(http.StatusCreated)
- out = in
- } else {
- if !in.Permissions.IsEmpty() {
- writeError(sh.lg, w, r, httptypes.NewHTTPError(http.StatusBadRequest, "Role JSON contains both permissions and grant/revoke"))
- return
- }
- out, err = sh.sec.UpdateRole(in)
- if err != nil {
- writeError(sh.lg, w, r, err)
- return
- }
- w.WriteHeader(http.StatusOK)
- }
-
- err = json.NewEncoder(w).Encode(out)
- if err != nil {
- if sh.lg != nil {
- sh.lg.Warn(
- "failed to encode a role",
- zap.String("url", r.URL.String()),
- zap.Error(err),
- )
- } else {
- plog.Warningf("forRole error encoding on %s", r.URL)
- }
- return
- }
- return
-
- case "DELETE":
- err := sh.sec.DeleteRole(role)
- if err != nil {
- writeError(sh.lg, w, r, err)
- return
- }
- }
-}
-
-type userWithRoles struct {
- User string `json:"user"`
- Roles []v2auth.Role `json:"roles,omitempty"`
-}
-
-type usersCollections struct {
- Users []userWithRoles `json:"users"`
-}
-
-func (sh *authHandler) baseUsers(w http.ResponseWriter, r *http.Request) {
- if !allowMethod(w, r.Method, "GET") {
- return
- }
- if !hasRootAccess(sh.lg, sh.sec, r, sh.clientCertAuthEnabled) {
- writeNoAuth(sh.lg, w, r)
- return
- }
- w.Header().Set("X-Etcd-Cluster-ID", sh.cluster.ID().String())
- w.Header().Set("Content-Type", "application/json")
-
- users, err := sh.sec.AllUsers()
- if err != nil {
- writeError(sh.lg, w, r, err)
- return
- }
- if users == nil {
- users = make([]string, 0)
- }
-
- err = r.ParseForm()
- if err != nil {
- writeError(sh.lg, w, r, err)
- return
- }
-
- ucs := usersCollections{}
- for _, userName := range users {
- var user v2auth.User
- user, err = sh.sec.GetUser(userName)
- if err != nil {
- writeError(sh.lg, w, r, err)
- return
- }
-
- uwr := userWithRoles{User: user.User}
- for _, roleName := range user.Roles {
- var role v2auth.Role
- role, err = sh.sec.GetRole(roleName)
- if err != nil {
- continue
- }
- uwr.Roles = append(uwr.Roles, role)
- }
-
- ucs.Users = append(ucs.Users, uwr)
- }
- err = json.NewEncoder(w).Encode(ucs)
-
- if err != nil {
- if sh.lg != nil {
- sh.lg.Warn(
- "failed to encode users",
- zap.String("url", r.URL.String()),
- zap.Error(err),
- )
- } else {
- plog.Warningf("baseUsers error encoding on %s", r.URL)
- }
- writeError(sh.lg, w, r, err)
- return
- }
-}
-
-func (sh *authHandler) handleUsers(w http.ResponseWriter, r *http.Request) {
- subpath := path.Clean(r.URL.Path[len(authPrefix):])
- // Split "/users/username".
- // First item is an empty string, second is "users"
- pieces := strings.Split(subpath, "/")
- if len(pieces) == 2 {
- sh.baseUsers(w, r)
- return
- }
- if len(pieces) != 3 {
- writeError(sh.lg, w, r, httptypes.NewHTTPError(http.StatusBadRequest, "Invalid path"))
- return
- }
- sh.forUser(w, r, pieces[2])
-}
-
-func (sh *authHandler) forUser(w http.ResponseWriter, r *http.Request, user string) {
- if !allowMethod(w, r.Method, "GET", "PUT", "DELETE") {
- return
- }
- if !hasRootAccess(sh.lg, sh.sec, r, sh.clientCertAuthEnabled) {
- writeNoAuth(sh.lg, w, r)
- return
- }
- w.Header().Set("X-Etcd-Cluster-ID", sh.cluster.ID().String())
- w.Header().Set("Content-Type", "application/json")
-
- switch r.Method {
- case "GET":
- u, err := sh.sec.GetUser(user)
- if err != nil {
- writeError(sh.lg, w, r, err)
- return
- }
-
- err = r.ParseForm()
- if err != nil {
- writeError(sh.lg, w, r, err)
- return
- }
-
- uwr := userWithRoles{User: u.User}
- for _, roleName := range u.Roles {
- var role v2auth.Role
- role, err = sh.sec.GetRole(roleName)
- if err != nil {
- writeError(sh.lg, w, r, err)
- return
- }
- uwr.Roles = append(uwr.Roles, role)
- }
- err = json.NewEncoder(w).Encode(uwr)
-
- if err != nil {
- if sh.lg != nil {
- sh.lg.Warn(
- "failed to encode roles",
- zap.String("url", r.URL.String()),
- zap.Error(err),
- )
- } else {
- plog.Warningf("forUser error encoding on %s", r.URL)
- }
- return
- }
- return
-
- case "PUT":
- var u v2auth.User
- err := json.NewDecoder(r.Body).Decode(&u)
- if err != nil {
- writeError(sh.lg, w, r, httptypes.NewHTTPError(http.StatusBadRequest, "Invalid JSON in request body."))
- return
- }
- if u.User != user {
- writeError(sh.lg, w, r, httptypes.NewHTTPError(http.StatusBadRequest, "User JSON name does not match the name in the URL"))
- return
- }
-
- var (
- out v2auth.User
- created bool
- )
-
- if len(u.Grant) == 0 && len(u.Revoke) == 0 {
- // create or update
- if len(u.Roles) != 0 {
- out, err = sh.sec.CreateUser(u)
- } else {
- // if user passes in both password and roles, we are unsure about his/her
- // intention.
- out, created, err = sh.sec.CreateOrUpdateUser(u)
- }
-
- if err != nil {
- writeError(sh.lg, w, r, err)
- return
- }
- } else {
- // update case
- if len(u.Roles) != 0 {
- writeError(sh.lg, w, r, httptypes.NewHTTPError(http.StatusBadRequest, "User JSON contains both roles and grant/revoke"))
- return
- }
- out, err = sh.sec.UpdateUser(u)
- if err != nil {
- writeError(sh.lg, w, r, err)
- return
- }
- }
-
- if created {
- w.WriteHeader(http.StatusCreated)
- } else {
- w.WriteHeader(http.StatusOK)
- }
-
- out.Password = ""
-
- err = json.NewEncoder(w).Encode(out)
- if err != nil {
- if sh.lg != nil {
- sh.lg.Warn(
- "failed to encode a user",
- zap.String("url", r.URL.String()),
- zap.Error(err),
- )
- } else {
- plog.Warningf("forUser error encoding on %s", r.URL)
- }
- return
- }
- return
-
- case "DELETE":
- err := sh.sec.DeleteUser(user)
- if err != nil {
- writeError(sh.lg, w, r, err)
- return
- }
- }
-}
-
-type enabled struct {
- Enabled bool `json:"enabled"`
-}
-
-func (sh *authHandler) enableDisable(w http.ResponseWriter, r *http.Request) {
- if !allowMethod(w, r.Method, "GET", "PUT", "DELETE") {
- return
- }
- if !hasWriteRootAccess(sh.lg, sh.sec, r, sh.clientCertAuthEnabled) {
- writeNoAuth(sh.lg, w, r)
- return
- }
- w.Header().Set("X-Etcd-Cluster-ID", sh.cluster.ID().String())
- w.Header().Set("Content-Type", "application/json")
- isEnabled := sh.sec.AuthEnabled()
- switch r.Method {
- case "GET":
- jsonDict := enabled{isEnabled}
- err := json.NewEncoder(w).Encode(jsonDict)
- if err != nil {
- if sh.lg != nil {
- sh.lg.Warn(
- "failed to encode a auth state",
- zap.String("url", r.URL.String()),
- zap.Error(err),
- )
- } else {
- plog.Warningf("error encoding auth state on %s", r.URL)
- }
- }
-
- case "PUT":
- err := sh.sec.EnableAuth()
- if err != nil {
- writeError(sh.lg, w, r, err)
- return
- }
-
- case "DELETE":
- err := sh.sec.DisableAuth()
- if err != nil {
- writeError(sh.lg, w, r, err)
- return
- }
- }
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2http/doc.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2http/doc.go
deleted file mode 100644
index 475c4b1..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2http/doc.go
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package v2http provides etcd client and server implementations.
-package v2http
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2http/http.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2http/http.go
deleted file mode 100644
index c695689..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2http/http.go
+++ /dev/null
@@ -1,93 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v2http
-
-import (
- "math"
- "net/http"
- "strings"
- "time"
-
- "go.etcd.io/etcd/etcdserver/api/etcdhttp"
- "go.etcd.io/etcd/etcdserver/api/v2auth"
- "go.etcd.io/etcd/etcdserver/api/v2http/httptypes"
- "go.etcd.io/etcd/pkg/logutil"
-
- "github.com/coreos/pkg/capnslog"
- "go.uber.org/zap"
-)
-
-const (
- // time to wait for a Watch request
- defaultWatchTimeout = time.Duration(math.MaxInt64)
-)
-
-var (
- plog = capnslog.NewPackageLogger("go.etcd.io/etcd", "etcdserver/api/v2http")
- mlog = logutil.NewMergeLogger(plog)
-)
-
-func writeError(lg *zap.Logger, w http.ResponseWriter, r *http.Request, err error) {
- if err == nil {
- return
- }
- if e, ok := err.(v2auth.Error); ok {
- herr := httptypes.NewHTTPError(e.HTTPStatus(), e.Error())
- if et := herr.WriteTo(w); et != nil {
- if lg != nil {
- lg.Debug(
- "failed to write v2 HTTP error",
- zap.String("remote-addr", r.RemoteAddr),
- zap.String("v2auth-error", e.Error()),
- zap.Error(et),
- )
- } else {
- plog.Debugf("error writing HTTPError (%v) to %s", et, r.RemoteAddr)
- }
- }
- return
- }
- etcdhttp.WriteError(lg, w, r, err)
-}
-
-// allowMethod verifies that the given method is one of the allowed methods,
-// and if not, it writes an error to w. A boolean is returned indicating
-// whether or not the method is allowed.
-func allowMethod(w http.ResponseWriter, m string, ms ...string) bool {
- for _, meth := range ms {
- if m == meth {
- return true
- }
- }
- w.Header().Set("Allow", strings.Join(ms, ","))
- http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
- return false
-}
-
-func requestLogger(lg *zap.Logger, handler http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- if lg != nil {
- lg.Debug(
- "handling HTTP request",
- zap.String("method", r.Method),
- zap.String("request-uri", r.RequestURI),
- zap.String("remote-addr", r.RemoteAddr),
- )
- } else {
- plog.Debugf("[%s] %s remote:%s", r.Method, r.RequestURI, r.RemoteAddr)
- }
- handler.ServeHTTP(w, r)
- })
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2http/httptypes/errors.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2http/httptypes/errors.go
deleted file mode 100644
index 245c089..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2http/httptypes/errors.go
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package httptypes
-
-import (
- "encoding/json"
- "net/http"
-
- "github.com/coreos/pkg/capnslog"
-)
-
-var (
- plog = capnslog.NewPackageLogger("go.etcd.io/etcd", "etcdserver/api/v2http/httptypes")
-)
-
-type HTTPError struct {
- Message string `json:"message"`
- // Code is the HTTP status code
- Code int `json:"-"`
-}
-
-func (e HTTPError) Error() string {
- return e.Message
-}
-
-func (e HTTPError) WriteTo(w http.ResponseWriter) error {
- w.Header().Set("Content-Type", "application/json")
- w.WriteHeader(e.Code)
- b, err := json.Marshal(e)
- if err != nil {
- plog.Panicf("marshal HTTPError should never fail (%v)", err)
- }
- if _, err := w.Write(b); err != nil {
- return err
- }
- return nil
-}
-
-func NewHTTPError(code int, m string) *HTTPError {
- return &HTTPError{
- Message: m,
- Code: code,
- }
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2http/httptypes/member.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2http/httptypes/member.go
deleted file mode 100644
index 95fd443..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2http/httptypes/member.go
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package httptypes defines how etcd's HTTP API entities are serialized to and
-// deserialized from JSON.
-package httptypes
-
-import (
- "encoding/json"
-
- "go.etcd.io/etcd/pkg/types"
-)
-
-type Member struct {
- ID string `json:"id"`
- Name string `json:"name"`
- PeerURLs []string `json:"peerURLs"`
- ClientURLs []string `json:"clientURLs"`
-}
-
-type MemberCreateRequest struct {
- PeerURLs types.URLs
-}
-
-type MemberUpdateRequest struct {
- MemberCreateRequest
-}
-
-func (m *MemberCreateRequest) UnmarshalJSON(data []byte) error {
- s := struct {
- PeerURLs []string `json:"peerURLs"`
- }{}
-
- err := json.Unmarshal(data, &s)
- if err != nil {
- return err
- }
-
- urls, err := types.NewURLs(s.PeerURLs)
- if err != nil {
- return err
- }
-
- m.PeerURLs = urls
- return nil
-}
-
-type MemberCollection []Member
-
-func (c *MemberCollection) MarshalJSON() ([]byte, error) {
- d := struct {
- Members []Member `json:"members"`
- }{
- Members: []Member(*c),
- }
-
- return json.Marshal(d)
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2http/metrics.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2http/metrics.go
deleted file mode 100644
index 14f7da0..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2http/metrics.go
+++ /dev/null
@@ -1,99 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v2http
-
-import (
- "strconv"
- "time"
-
- "net/http"
-
- "go.etcd.io/etcd/etcdserver/api/v2error"
- "go.etcd.io/etcd/etcdserver/api/v2http/httptypes"
- "go.etcd.io/etcd/etcdserver/etcdserverpb"
-
- "github.com/prometheus/client_golang/prometheus"
-)
-
-var (
- incomingEvents = prometheus.NewCounterVec(
- prometheus.CounterOpts{
- Namespace: "etcd",
- Subsystem: "http",
- Name: "received_total",
- Help: "Counter of requests received into the system (successfully parsed and authd).",
- }, []string{"method"})
-
- failedEvents = prometheus.NewCounterVec(
- prometheus.CounterOpts{
- Namespace: "etcd",
- Subsystem: "http",
- Name: "failed_total",
- Help: "Counter of handle failures of requests (non-watches), by method (GET/PUT etc.) and code (400, 500 etc.).",
- }, []string{"method", "code"})
-
- successfulEventsHandlingSec = prometheus.NewHistogramVec(
- prometheus.HistogramOpts{
- Namespace: "etcd",
- Subsystem: "http",
- Name: "successful_duration_seconds",
- Help: "Bucketed histogram of processing time (s) of successfully handled requests (non-watches), by method (GET/PUT etc.).",
-
- // lowest bucket start of upper bound 0.0005 sec (0.5 ms) with factor 2
- // highest bucket start of 0.0005 sec * 2^12 == 2.048 sec
- Buckets: prometheus.ExponentialBuckets(0.0005, 2, 13),
- }, []string{"method"})
-)
-
-func init() {
- prometheus.MustRegister(incomingEvents)
- prometheus.MustRegister(failedEvents)
- prometheus.MustRegister(successfulEventsHandlingSec)
-}
-
-func reportRequestReceived(request etcdserverpb.Request) {
- incomingEvents.WithLabelValues(methodFromRequest(request)).Inc()
-}
-
-func reportRequestCompleted(request etcdserverpb.Request, startTime time.Time) {
- method := methodFromRequest(request)
- successfulEventsHandlingSec.WithLabelValues(method).Observe(time.Since(startTime).Seconds())
-}
-
-func reportRequestFailed(request etcdserverpb.Request, err error) {
- method := methodFromRequest(request)
- failedEvents.WithLabelValues(method, strconv.Itoa(codeFromError(err))).Inc()
-}
-
-func methodFromRequest(request etcdserverpb.Request) string {
- if request.Method == "GET" && request.Quorum {
- return "QGET"
- }
- return request.Method
-}
-
-func codeFromError(err error) int {
- if err == nil {
- return http.StatusInternalServerError
- }
- switch e := err.(type) {
- case *v2error.Error:
- return e.StatusCode()
- case *httptypes.HTTPError:
- return e.Code
- default:
- return http.StatusInternalServerError
- }
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2stats/leader.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2stats/leader.go
deleted file mode 100644
index ca47f0f..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2stats/leader.go
+++ /dev/null
@@ -1,128 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v2stats
-
-import (
- "encoding/json"
- "math"
- "sync"
- "time"
-)
-
-// LeaderStats is used by the leader in an etcd cluster, and encapsulates
-// statistics about communication with its followers
-type LeaderStats struct {
- leaderStats
- sync.Mutex
-}
-
-type leaderStats struct {
- // Leader is the ID of the leader in the etcd cluster.
- // TODO(jonboulle): clarify that these are IDs, not names
- Leader string `json:"leader"`
- Followers map[string]*FollowerStats `json:"followers"`
-}
-
-// NewLeaderStats generates a new LeaderStats with the given id as leader
-func NewLeaderStats(id string) *LeaderStats {
- return &LeaderStats{
- leaderStats: leaderStats{
- Leader: id,
- Followers: make(map[string]*FollowerStats),
- },
- }
-}
-
-func (ls *LeaderStats) JSON() []byte {
- ls.Lock()
- stats := ls.leaderStats
- ls.Unlock()
- b, err := json.Marshal(stats)
- // TODO(jonboulle): appropriate error handling?
- if err != nil {
- plog.Errorf("error marshalling leader stats (%v)", err)
- }
- return b
-}
-
-func (ls *LeaderStats) Follower(name string) *FollowerStats {
- ls.Lock()
- defer ls.Unlock()
- fs, ok := ls.Followers[name]
- if !ok {
- fs = &FollowerStats{}
- fs.Latency.Minimum = 1 << 63
- ls.Followers[name] = fs
- }
- return fs
-}
-
-// FollowerStats encapsulates various statistics about a follower in an etcd cluster
-type FollowerStats struct {
- Latency LatencyStats `json:"latency"`
- Counts CountsStats `json:"counts"`
-
- sync.Mutex
-}
-
-// LatencyStats encapsulates latency statistics.
-type LatencyStats struct {
- Current float64 `json:"current"`
- Average float64 `json:"average"`
- averageSquare float64
- StandardDeviation float64 `json:"standardDeviation"`
- Minimum float64 `json:"minimum"`
- Maximum float64 `json:"maximum"`
-}
-
-// CountsStats encapsulates raft statistics.
-type CountsStats struct {
- Fail uint64 `json:"fail"`
- Success uint64 `json:"success"`
-}
-
-// Succ updates the FollowerStats with a successful send
-func (fs *FollowerStats) Succ(d time.Duration) {
- fs.Lock()
- defer fs.Unlock()
-
- total := float64(fs.Counts.Success) * fs.Latency.Average
- totalSquare := float64(fs.Counts.Success) * fs.Latency.averageSquare
-
- fs.Counts.Success++
-
- fs.Latency.Current = float64(d) / (1000000.0)
-
- if fs.Latency.Current > fs.Latency.Maximum {
- fs.Latency.Maximum = fs.Latency.Current
- }
-
- if fs.Latency.Current < fs.Latency.Minimum {
- fs.Latency.Minimum = fs.Latency.Current
- }
-
- fs.Latency.Average = (total + fs.Latency.Current) / float64(fs.Counts.Success)
- fs.Latency.averageSquare = (totalSquare + fs.Latency.Current*fs.Latency.Current) / float64(fs.Counts.Success)
-
- // sdv = sqrt(avg(x^2) - avg(x)^2)
- fs.Latency.StandardDeviation = math.Sqrt(fs.Latency.averageSquare - fs.Latency.Average*fs.Latency.Average)
-}
-
-// Fail updates the FollowerStats with an unsuccessful send
-func (fs *FollowerStats) Fail() {
- fs.Lock()
- defer fs.Unlock()
- fs.Counts.Fail++
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2stats/queue.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2stats/queue.go
deleted file mode 100644
index 2c3dff3..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2stats/queue.go
+++ /dev/null
@@ -1,110 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v2stats
-
-import (
- "sync"
- "time"
-)
-
-const (
- queueCapacity = 200
-)
-
-// RequestStats represent the stats for a request.
-// It encapsulates the sending time and the size of the request.
-type RequestStats struct {
- SendingTime time.Time
- Size int
-}
-
-type statsQueue struct {
- items [queueCapacity]*RequestStats
- size int
- front int
- back int
- totalReqSize int
- rwl sync.RWMutex
-}
-
-func (q *statsQueue) Len() int {
- return q.size
-}
-
-func (q *statsQueue) ReqSize() int {
- return q.totalReqSize
-}
-
-// FrontAndBack gets the front and back elements in the queue
-// We must grab front and back together with the protection of the lock
-func (q *statsQueue) frontAndBack() (*RequestStats, *RequestStats) {
- q.rwl.RLock()
- defer q.rwl.RUnlock()
- if q.size != 0 {
- return q.items[q.front], q.items[q.back]
- }
- return nil, nil
-}
-
-// Insert function insert a RequestStats into the queue and update the records
-func (q *statsQueue) Insert(p *RequestStats) {
- q.rwl.Lock()
- defer q.rwl.Unlock()
-
- q.back = (q.back + 1) % queueCapacity
-
- if q.size == queueCapacity { //dequeue
- q.totalReqSize -= q.items[q.front].Size
- q.front = (q.back + 1) % queueCapacity
- } else {
- q.size++
- }
-
- q.items[q.back] = p
- q.totalReqSize += q.items[q.back].Size
-
-}
-
-// Rate function returns the package rate and byte rate
-func (q *statsQueue) Rate() (float64, float64) {
- front, back := q.frontAndBack()
-
- if front == nil || back == nil {
- return 0, 0
- }
-
- if time.Since(back.SendingTime) > time.Second {
- q.Clear()
- return 0, 0
- }
-
- sampleDuration := back.SendingTime.Sub(front.SendingTime)
-
- pr := float64(q.Len()) / float64(sampleDuration) * float64(time.Second)
-
- br := float64(q.ReqSize()) / float64(sampleDuration) * float64(time.Second)
-
- return pr, br
-}
-
-// Clear function clear up the statsQueue
-func (q *statsQueue) Clear() {
- q.rwl.Lock()
- defer q.rwl.Unlock()
- q.back = -1
- q.front = 0
- q.size = 0
- q.totalReqSize = 0
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2stats/server.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2stats/server.go
deleted file mode 100644
index c4accc7..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2stats/server.go
+++ /dev/null
@@ -1,142 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v2stats
-
-import (
- "encoding/json"
- "log"
- "sync"
- "time"
-
- "go.etcd.io/etcd/raft"
-)
-
-// ServerStats encapsulates various statistics about an EtcdServer and its
-// communication with other members of the cluster
-type ServerStats struct {
- serverStats
- sync.Mutex
-}
-
-func NewServerStats(name, id string) *ServerStats {
- ss := &ServerStats{
- serverStats: serverStats{
- Name: name,
- ID: id,
- },
- }
- now := time.Now()
- ss.StartTime = now
- ss.LeaderInfo.StartTime = now
- ss.sendRateQueue = &statsQueue{back: -1}
- ss.recvRateQueue = &statsQueue{back: -1}
- return ss
-}
-
-type serverStats struct {
- Name string `json:"name"`
- // ID is the raft ID of the node.
- // TODO(jonboulle): use ID instead of name?
- ID string `json:"id"`
- State raft.StateType `json:"state"`
- StartTime time.Time `json:"startTime"`
-
- LeaderInfo struct {
- Name string `json:"leader"`
- Uptime string `json:"uptime"`
- StartTime time.Time `json:"startTime"`
- } `json:"leaderInfo"`
-
- RecvAppendRequestCnt uint64 `json:"recvAppendRequestCnt,"`
- RecvingPkgRate float64 `json:"recvPkgRate,omitempty"`
- RecvingBandwidthRate float64 `json:"recvBandwidthRate,omitempty"`
-
- SendAppendRequestCnt uint64 `json:"sendAppendRequestCnt"`
- SendingPkgRate float64 `json:"sendPkgRate,omitempty"`
- SendingBandwidthRate float64 `json:"sendBandwidthRate,omitempty"`
-
- sendRateQueue *statsQueue
- recvRateQueue *statsQueue
-}
-
-func (ss *ServerStats) JSON() []byte {
- ss.Lock()
- stats := ss.serverStats
- stats.SendingPkgRate, stats.SendingBandwidthRate = stats.sendRateQueue.Rate()
- stats.RecvingPkgRate, stats.RecvingBandwidthRate = stats.recvRateQueue.Rate()
- stats.LeaderInfo.Uptime = time.Since(stats.LeaderInfo.StartTime).String()
- ss.Unlock()
- b, err := json.Marshal(stats)
- // TODO(jonboulle): appropriate error handling?
- if err != nil {
- log.Printf("stats: error marshalling server stats: %v", err)
- }
- return b
-}
-
-// RecvAppendReq updates the ServerStats in response to an AppendRequest
-// from the given leader being received
-func (ss *ServerStats) RecvAppendReq(leader string, reqSize int) {
- ss.Lock()
- defer ss.Unlock()
-
- now := time.Now()
-
- ss.State = raft.StateFollower
- if leader != ss.LeaderInfo.Name {
- ss.LeaderInfo.Name = leader
- ss.LeaderInfo.StartTime = now
- }
-
- ss.recvRateQueue.Insert(
- &RequestStats{
- SendingTime: now,
- Size: reqSize,
- },
- )
- ss.RecvAppendRequestCnt++
-}
-
-// SendAppendReq updates the ServerStats in response to an AppendRequest
-// being sent by this server
-func (ss *ServerStats) SendAppendReq(reqSize int) {
- ss.Lock()
- defer ss.Unlock()
-
- ss.becomeLeader()
-
- ss.sendRateQueue.Insert(
- &RequestStats{
- SendingTime: time.Now(),
- Size: reqSize,
- },
- )
-
- ss.SendAppendRequestCnt++
-}
-
-func (ss *ServerStats) BecomeLeader() {
- ss.Lock()
- defer ss.Unlock()
- ss.becomeLeader()
-}
-
-func (ss *ServerStats) becomeLeader() {
- if ss.State != raft.StateLeader {
- ss.State = raft.StateLeader
- ss.LeaderInfo.Name = ss.ID
- ss.LeaderInfo.StartTime = time.Now()
- }
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2stats/stats.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2stats/stats.go
deleted file mode 100644
index c50a200..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2stats/stats.go
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package v2stats defines a standard interface for etcd cluster statistics.
-package v2stats
-
-import "github.com/coreos/pkg/capnslog"
-
-var plog = capnslog.NewPackageLogger("go.etcd.io/etcd", "etcdserver/stats")
-
-type Stats interface {
- // SelfStats returns the struct representing statistics of this server
- SelfStats() []byte
- // LeaderStats returns the statistics of all followers in the cluster
- // if this server is leader. Otherwise, nil is returned.
- LeaderStats() []byte
- // StoreStats returns statistics of the store backing this EtcdServer
- StoreStats() []byte
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2store/doc.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2store/doc.go
deleted file mode 100644
index 1933e4c..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2store/doc.go
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package v2store defines etcd's in-memory key/value store in v2 API.
-// To be deprecated in favor of v3 storage.
-package v2store
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2store/event.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2store/event.go
deleted file mode 100644
index 33e9017..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2store/event.go
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v2store
-
-const (
- Get = "get"
- Create = "create"
- Set = "set"
- Update = "update"
- Delete = "delete"
- CompareAndSwap = "compareAndSwap"
- CompareAndDelete = "compareAndDelete"
- Expire = "expire"
-)
-
-type Event struct {
- Action string `json:"action"`
- Node *NodeExtern `json:"node,omitempty"`
- PrevNode *NodeExtern `json:"prevNode,omitempty"`
- EtcdIndex uint64 `json:"-"`
- Refresh bool `json:"refresh,omitempty"`
-}
-
-func newEvent(action string, key string, modifiedIndex, createdIndex uint64) *Event {
- n := &NodeExtern{
- Key: key,
- ModifiedIndex: modifiedIndex,
- CreatedIndex: createdIndex,
- }
-
- return &Event{
- Action: action,
- Node: n,
- }
-}
-
-func (e *Event) IsCreated() bool {
- if e.Action == Create {
- return true
- }
- return e.Action == Set && e.PrevNode == nil
-}
-
-func (e *Event) Index() uint64 {
- return e.Node.ModifiedIndex
-}
-
-func (e *Event) Clone() *Event {
- return &Event{
- Action: e.Action,
- EtcdIndex: e.EtcdIndex,
- Node: e.Node.Clone(),
- PrevNode: e.PrevNode.Clone(),
- }
-}
-
-func (e *Event) SetRefresh() {
- e.Refresh = true
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2store/event_history.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2store/event_history.go
deleted file mode 100644
index e4a969f..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2store/event_history.go
+++ /dev/null
@@ -1,129 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v2store
-
-import (
- "fmt"
- "path"
- "strings"
- "sync"
-
- "go.etcd.io/etcd/etcdserver/api/v2error"
-)
-
-type EventHistory struct {
- Queue eventQueue
- StartIndex uint64
- LastIndex uint64
- rwl sync.RWMutex
-}
-
-func newEventHistory(capacity int) *EventHistory {
- return &EventHistory{
- Queue: eventQueue{
- Capacity: capacity,
- Events: make([]*Event, capacity),
- },
- }
-}
-
-// addEvent function adds event into the eventHistory
-func (eh *EventHistory) addEvent(e *Event) *Event {
- eh.rwl.Lock()
- defer eh.rwl.Unlock()
-
- eh.Queue.insert(e)
-
- eh.LastIndex = e.Index()
-
- eh.StartIndex = eh.Queue.Events[eh.Queue.Front].Index()
-
- return e
-}
-
-// scan enumerates events from the index history and stops at the first point
-// where the key matches.
-func (eh *EventHistory) scan(key string, recursive bool, index uint64) (*Event, *v2error.Error) {
- eh.rwl.RLock()
- defer eh.rwl.RUnlock()
-
- // index should be after the event history's StartIndex
- if index < eh.StartIndex {
- return nil,
- v2error.NewError(v2error.EcodeEventIndexCleared,
- fmt.Sprintf("the requested history has been cleared [%v/%v]",
- eh.StartIndex, index), 0)
- }
-
- // the index should come before the size of the queue minus the duplicate count
- if index > eh.LastIndex { // future index
- return nil, nil
- }
-
- offset := index - eh.StartIndex
- i := (eh.Queue.Front + int(offset)) % eh.Queue.Capacity
-
- for {
- e := eh.Queue.Events[i]
-
- if !e.Refresh {
- ok := e.Node.Key == key
-
- if recursive {
- // add tailing slash
- nkey := path.Clean(key)
- if nkey[len(nkey)-1] != '/' {
- nkey = nkey + "/"
- }
-
- ok = ok || strings.HasPrefix(e.Node.Key, nkey)
- }
-
- if (e.Action == Delete || e.Action == Expire) && e.PrevNode != nil && e.PrevNode.Dir {
- ok = ok || strings.HasPrefix(key, e.PrevNode.Key)
- }
-
- if ok {
- return e, nil
- }
- }
-
- i = (i + 1) % eh.Queue.Capacity
-
- if i == eh.Queue.Back {
- return nil, nil
- }
- }
-}
-
-// clone will be protected by a stop-world lock
-// do not need to obtain internal lock
-func (eh *EventHistory) clone() *EventHistory {
- clonedQueue := eventQueue{
- Capacity: eh.Queue.Capacity,
- Events: make([]*Event, eh.Queue.Capacity),
- Size: eh.Queue.Size,
- Front: eh.Queue.Front,
- Back: eh.Queue.Back,
- }
-
- copy(clonedQueue.Events, eh.Queue.Events)
- return &EventHistory{
- StartIndex: eh.StartIndex,
- Queue: clonedQueue,
- LastIndex: eh.LastIndex,
- }
-
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2store/event_queue.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2store/event_queue.go
deleted file mode 100644
index 7ea03de..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2store/event_queue.go
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v2store
-
-type eventQueue struct {
- Events []*Event
- Size int
- Front int
- Back int
- Capacity int
-}
-
-func (eq *eventQueue) insert(e *Event) {
- eq.Events[eq.Back] = e
- eq.Back = (eq.Back + 1) % eq.Capacity
-
- if eq.Size == eq.Capacity { //dequeue
- eq.Front = (eq.Front + 1) % eq.Capacity
- } else {
- eq.Size++
- }
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2store/metrics.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2store/metrics.go
deleted file mode 100644
index 5adea1e..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2store/metrics.go
+++ /dev/null
@@ -1,130 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v2store
-
-import "github.com/prometheus/client_golang/prometheus"
-
-// Set of raw Prometheus metrics.
-// Labels
-// * action = declared in event.go
-// * outcome = Outcome
-// Do not increment directly, use Report* methods.
-var (
- readCounter = prometheus.NewCounterVec(
- prometheus.CounterOpts{
- Namespace: "etcd_debugging",
- Subsystem: "store",
- Name: "reads_total",
- Help: "Total number of reads action by (get/getRecursive), local to this member.",
- }, []string{"action"})
-
- writeCounter = prometheus.NewCounterVec(
- prometheus.CounterOpts{
- Namespace: "etcd_debugging",
- Subsystem: "store",
- Name: "writes_total",
- Help: "Total number of writes (e.g. set/compareAndDelete) seen by this member.",
- }, []string{"action"})
-
- readFailedCounter = prometheus.NewCounterVec(
- prometheus.CounterOpts{
- Namespace: "etcd_debugging",
- Subsystem: "store",
- Name: "reads_failed_total",
- Help: "Failed read actions by (get/getRecursive), local to this member.",
- }, []string{"action"})
-
- writeFailedCounter = prometheus.NewCounterVec(
- prometheus.CounterOpts{
- Namespace: "etcd_debugging",
- Subsystem: "store",
- Name: "writes_failed_total",
- Help: "Failed write actions (e.g. set/compareAndDelete), seen by this member.",
- }, []string{"action"})
-
- expireCounter = prometheus.NewCounter(
- prometheus.CounterOpts{
- Namespace: "etcd_debugging",
- Subsystem: "store",
- Name: "expires_total",
- Help: "Total number of expired keys.",
- })
-
- watchRequests = prometheus.NewCounter(
- prometheus.CounterOpts{
- Namespace: "etcd_debugging",
- Subsystem: "store",
- Name: "watch_requests_total",
- Help: "Total number of incoming watch requests (new or reestablished).",
- })
-
- watcherCount = prometheus.NewGauge(
- prometheus.GaugeOpts{
- Namespace: "etcd_debugging",
- Subsystem: "store",
- Name: "watchers",
- Help: "Count of currently active watchers.",
- })
-)
-
-const (
- GetRecursive = "getRecursive"
-)
-
-func init() {
- if prometheus.Register(readCounter) != nil {
- // Tests will try to double register since the tests use both
- // store and store_test packages; ignore second attempts.
- return
- }
- prometheus.MustRegister(writeCounter)
- prometheus.MustRegister(expireCounter)
- prometheus.MustRegister(watchRequests)
- prometheus.MustRegister(watcherCount)
-}
-
-func reportReadSuccess(readAction string) {
- readCounter.WithLabelValues(readAction).Inc()
-}
-
-func reportReadFailure(readAction string) {
- readCounter.WithLabelValues(readAction).Inc()
- readFailedCounter.WithLabelValues(readAction).Inc()
-}
-
-func reportWriteSuccess(writeAction string) {
- writeCounter.WithLabelValues(writeAction).Inc()
-}
-
-func reportWriteFailure(writeAction string) {
- writeCounter.WithLabelValues(writeAction).Inc()
- writeFailedCounter.WithLabelValues(writeAction).Inc()
-}
-
-func reportExpiredKey() {
- expireCounter.Inc()
-}
-
-func reportWatchRequest() {
- watchRequests.Inc()
-}
-
-func reportWatcherAdded() {
- watcherCount.Inc()
-}
-
-func reportWatcherRemoved() {
- watcherCount.Dec()
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2store/node.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2store/node.go
deleted file mode 100644
index 38a6984..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2store/node.go
+++ /dev/null
@@ -1,396 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v2store
-
-import (
- "path"
- "sort"
- "time"
-
- "go.etcd.io/etcd/etcdserver/api/v2error"
-
- "github.com/jonboulle/clockwork"
-)
-
-// explanations of Compare function result
-const (
- CompareMatch = iota
- CompareIndexNotMatch
- CompareValueNotMatch
- CompareNotMatch
-)
-
-var Permanent time.Time
-
-// node is the basic element in the store system.
-// A key-value pair will have a string value
-// A directory will have a children map
-type node struct {
- Path string
-
- CreatedIndex uint64
- ModifiedIndex uint64
-
- Parent *node `json:"-"` // should not encode this field! avoid circular dependency.
-
- ExpireTime time.Time
- Value string // for key-value pair
- Children map[string]*node // for directory
-
- // A reference to the store this node is attached to.
- store *store
-}
-
-// newKV creates a Key-Value pair
-func newKV(store *store, nodePath string, value string, createdIndex uint64, parent *node, expireTime time.Time) *node {
- return &node{
- Path: nodePath,
- CreatedIndex: createdIndex,
- ModifiedIndex: createdIndex,
- Parent: parent,
- store: store,
- ExpireTime: expireTime,
- Value: value,
- }
-}
-
-// newDir creates a directory
-func newDir(store *store, nodePath string, createdIndex uint64, parent *node, expireTime time.Time) *node {
- return &node{
- Path: nodePath,
- CreatedIndex: createdIndex,
- ModifiedIndex: createdIndex,
- Parent: parent,
- ExpireTime: expireTime,
- Children: make(map[string]*node),
- store: store,
- }
-}
-
-// IsHidden function checks if the node is a hidden node. A hidden node
-// will begin with '_'
-// A hidden node will not be shown via get command under a directory
-// For example if we have /foo/_hidden and /foo/notHidden, get "/foo"
-// will only return /foo/notHidden
-func (n *node) IsHidden() bool {
- _, name := path.Split(n.Path)
-
- return name[0] == '_'
-}
-
-// IsPermanent function checks if the node is a permanent one.
-func (n *node) IsPermanent() bool {
- // we use a uninitialized time.Time to indicate the node is a
- // permanent one.
- // the uninitialized time.Time should equal zero.
- return n.ExpireTime.IsZero()
-}
-
-// IsDir function checks whether the node is a directory.
-// If the node is a directory, the function will return true.
-// Otherwise the function will return false.
-func (n *node) IsDir() bool {
- return n.Children != nil
-}
-
-// Read function gets the value of the node.
-// If the receiver node is not a key-value pair, a "Not A File" error will be returned.
-func (n *node) Read() (string, *v2error.Error) {
- if n.IsDir() {
- return "", v2error.NewError(v2error.EcodeNotFile, "", n.store.CurrentIndex)
- }
-
- return n.Value, nil
-}
-
-// Write function set the value of the node to the given value.
-// If the receiver node is a directory, a "Not A File" error will be returned.
-func (n *node) Write(value string, index uint64) *v2error.Error {
- if n.IsDir() {
- return v2error.NewError(v2error.EcodeNotFile, "", n.store.CurrentIndex)
- }
-
- n.Value = value
- n.ModifiedIndex = index
-
- return nil
-}
-
-func (n *node) expirationAndTTL(clock clockwork.Clock) (*time.Time, int64) {
- if !n.IsPermanent() {
- /* compute ttl as:
- ceiling( (expireTime - timeNow) / nanosecondsPerSecond )
- which ranges from 1..n
- rather than as:
- ( (expireTime - timeNow) / nanosecondsPerSecond ) + 1
- which ranges 1..n+1
- */
- ttlN := n.ExpireTime.Sub(clock.Now())
- ttl := ttlN / time.Second
- if (ttlN % time.Second) > 0 {
- ttl++
- }
- t := n.ExpireTime.UTC()
- return &t, int64(ttl)
- }
- return nil, 0
-}
-
-// List function return a slice of nodes under the receiver node.
-// If the receiver node is not a directory, a "Not A Directory" error will be returned.
-func (n *node) List() ([]*node, *v2error.Error) {
- if !n.IsDir() {
- return nil, v2error.NewError(v2error.EcodeNotDir, "", n.store.CurrentIndex)
- }
-
- nodes := make([]*node, len(n.Children))
-
- i := 0
- for _, node := range n.Children {
- nodes[i] = node
- i++
- }
-
- return nodes, nil
-}
-
-// GetChild function returns the child node under the directory node.
-// On success, it returns the file node
-func (n *node) GetChild(name string) (*node, *v2error.Error) {
- if !n.IsDir() {
- return nil, v2error.NewError(v2error.EcodeNotDir, n.Path, n.store.CurrentIndex)
- }
-
- child, ok := n.Children[name]
-
- if ok {
- return child, nil
- }
-
- return nil, nil
-}
-
-// Add function adds a node to the receiver node.
-// If the receiver is not a directory, a "Not A Directory" error will be returned.
-// If there is an existing node with the same name under the directory, a "Already Exist"
-// error will be returned
-func (n *node) Add(child *node) *v2error.Error {
- if !n.IsDir() {
- return v2error.NewError(v2error.EcodeNotDir, "", n.store.CurrentIndex)
- }
-
- _, name := path.Split(child.Path)
-
- if _, ok := n.Children[name]; ok {
- return v2error.NewError(v2error.EcodeNodeExist, "", n.store.CurrentIndex)
- }
-
- n.Children[name] = child
-
- return nil
-}
-
-// Remove function remove the node.
-func (n *node) Remove(dir, recursive bool, callback func(path string)) *v2error.Error {
- if !n.IsDir() { // key-value pair
- _, name := path.Split(n.Path)
-
- // find its parent and remove the node from the map
- if n.Parent != nil && n.Parent.Children[name] == n {
- delete(n.Parent.Children, name)
- }
-
- if callback != nil {
- callback(n.Path)
- }
-
- if !n.IsPermanent() {
- n.store.ttlKeyHeap.remove(n)
- }
-
- return nil
- }
-
- if !dir {
- // cannot delete a directory without dir set to true
- return v2error.NewError(v2error.EcodeNotFile, n.Path, n.store.CurrentIndex)
- }
-
- if len(n.Children) != 0 && !recursive {
- // cannot delete a directory if it is not empty and the operation
- // is not recursive
- return v2error.NewError(v2error.EcodeDirNotEmpty, n.Path, n.store.CurrentIndex)
- }
-
- for _, child := range n.Children { // delete all children
- child.Remove(true, true, callback)
- }
-
- // delete self
- _, name := path.Split(n.Path)
- if n.Parent != nil && n.Parent.Children[name] == n {
- delete(n.Parent.Children, name)
-
- if callback != nil {
- callback(n.Path)
- }
-
- if !n.IsPermanent() {
- n.store.ttlKeyHeap.remove(n)
- }
- }
-
- return nil
-}
-
-func (n *node) Repr(recursive, sorted bool, clock clockwork.Clock) *NodeExtern {
- if n.IsDir() {
- node := &NodeExtern{
- Key: n.Path,
- Dir: true,
- ModifiedIndex: n.ModifiedIndex,
- CreatedIndex: n.CreatedIndex,
- }
- node.Expiration, node.TTL = n.expirationAndTTL(clock)
-
- if !recursive {
- return node
- }
-
- children, _ := n.List()
- node.Nodes = make(NodeExterns, len(children))
-
- // we do not use the index in the children slice directly
- // we need to skip the hidden one
- i := 0
-
- for _, child := range children {
-
- if child.IsHidden() { // get will not list hidden node
- continue
- }
-
- node.Nodes[i] = child.Repr(recursive, sorted, clock)
-
- i++
- }
-
- // eliminate hidden nodes
- node.Nodes = node.Nodes[:i]
- if sorted {
- sort.Sort(node.Nodes)
- }
-
- return node
- }
-
- // since n.Value could be changed later, so we need to copy the value out
- value := n.Value
- node := &NodeExtern{
- Key: n.Path,
- Value: &value,
- ModifiedIndex: n.ModifiedIndex,
- CreatedIndex: n.CreatedIndex,
- }
- node.Expiration, node.TTL = n.expirationAndTTL(clock)
- return node
-}
-
-func (n *node) UpdateTTL(expireTime time.Time) {
- if !n.IsPermanent() {
- if expireTime.IsZero() {
- // from ttl to permanent
- n.ExpireTime = expireTime
- // remove from ttl heap
- n.store.ttlKeyHeap.remove(n)
- return
- }
-
- // update ttl
- n.ExpireTime = expireTime
- // update ttl heap
- n.store.ttlKeyHeap.update(n)
- return
- }
-
- if expireTime.IsZero() {
- return
- }
-
- // from permanent to ttl
- n.ExpireTime = expireTime
- // push into ttl heap
- n.store.ttlKeyHeap.push(n)
-}
-
-// Compare function compares node index and value with provided ones.
-// second result value explains result and equals to one of Compare.. constants
-func (n *node) Compare(prevValue string, prevIndex uint64) (ok bool, which int) {
- indexMatch := prevIndex == 0 || n.ModifiedIndex == prevIndex
- valueMatch := prevValue == "" || n.Value == prevValue
- ok = valueMatch && indexMatch
- switch {
- case valueMatch && indexMatch:
- which = CompareMatch
- case indexMatch && !valueMatch:
- which = CompareValueNotMatch
- case valueMatch && !indexMatch:
- which = CompareIndexNotMatch
- default:
- which = CompareNotMatch
- }
- return ok, which
-}
-
-// Clone function clone the node recursively and return the new node.
-// If the node is a directory, it will clone all the content under this directory.
-// If the node is a key-value pair, it will clone the pair.
-func (n *node) Clone() *node {
- if !n.IsDir() {
- newkv := newKV(n.store, n.Path, n.Value, n.CreatedIndex, n.Parent, n.ExpireTime)
- newkv.ModifiedIndex = n.ModifiedIndex
- return newkv
- }
-
- clone := newDir(n.store, n.Path, n.CreatedIndex, n.Parent, n.ExpireTime)
- clone.ModifiedIndex = n.ModifiedIndex
-
- for key, child := range n.Children {
- clone.Children[key] = child.Clone()
- }
-
- return clone
-}
-
-// recoverAndclean function help to do recovery.
-// Two things need to be done: 1. recovery structure; 2. delete expired nodes
-//
-// If the node is a directory, it will help recover children's parent pointer and recursively
-// call this function on its children.
-// We check the expire last since we need to recover the whole structure first and add all the
-// notifications into the event history.
-func (n *node) recoverAndclean() {
- if n.IsDir() {
- for _, child := range n.Children {
- child.Parent = n
- child.store = n.store
- child.recoverAndclean()
- }
- }
-
- if !n.ExpireTime.IsZero() {
- n.store.ttlKeyHeap.push(n)
- }
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2store/node_extern.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2store/node_extern.go
deleted file mode 100644
index b3bf5f3..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2store/node_extern.go
+++ /dev/null
@@ -1,116 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v2store
-
-import (
- "sort"
- "time"
-
- "github.com/jonboulle/clockwork"
-)
-
-// NodeExtern is the external representation of the
-// internal node with additional fields
-// PrevValue is the previous value of the node
-// TTL is time to live in second
-type NodeExtern struct {
- Key string `json:"key,omitempty"`
- Value *string `json:"value,omitempty"`
- Dir bool `json:"dir,omitempty"`
- Expiration *time.Time `json:"expiration,omitempty"`
- TTL int64 `json:"ttl,omitempty"`
- Nodes NodeExterns `json:"nodes,omitempty"`
- ModifiedIndex uint64 `json:"modifiedIndex,omitempty"`
- CreatedIndex uint64 `json:"createdIndex,omitempty"`
-}
-
-func (eNode *NodeExtern) loadInternalNode(n *node, recursive, sorted bool, clock clockwork.Clock) {
- if n.IsDir() { // node is a directory
- eNode.Dir = true
-
- children, _ := n.List()
- eNode.Nodes = make(NodeExterns, len(children))
-
- // we do not use the index in the children slice directly
- // we need to skip the hidden one
- i := 0
-
- for _, child := range children {
- if child.IsHidden() { // get will not return hidden nodes
- continue
- }
-
- eNode.Nodes[i] = child.Repr(recursive, sorted, clock)
- i++
- }
-
- // eliminate hidden nodes
- eNode.Nodes = eNode.Nodes[:i]
-
- if sorted {
- sort.Sort(eNode.Nodes)
- }
-
- } else { // node is a file
- value, _ := n.Read()
- eNode.Value = &value
- }
-
- eNode.Expiration, eNode.TTL = n.expirationAndTTL(clock)
-}
-
-func (eNode *NodeExtern) Clone() *NodeExtern {
- if eNode == nil {
- return nil
- }
- nn := &NodeExtern{
- Key: eNode.Key,
- Dir: eNode.Dir,
- TTL: eNode.TTL,
- ModifiedIndex: eNode.ModifiedIndex,
- CreatedIndex: eNode.CreatedIndex,
- }
- if eNode.Value != nil {
- s := *eNode.Value
- nn.Value = &s
- }
- if eNode.Expiration != nil {
- t := *eNode.Expiration
- nn.Expiration = &t
- }
- if eNode.Nodes != nil {
- nn.Nodes = make(NodeExterns, len(eNode.Nodes))
- for i, n := range eNode.Nodes {
- nn.Nodes[i] = n.Clone()
- }
- }
- return nn
-}
-
-type NodeExterns []*NodeExtern
-
-// interfaces for sorting
-
-func (ns NodeExterns) Len() int {
- return len(ns)
-}
-
-func (ns NodeExterns) Less(i, j int) bool {
- return ns[i].Key < ns[j].Key
-}
-
-func (ns NodeExterns) Swap(i, j int) {
- ns[i], ns[j] = ns[j], ns[i]
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2store/stats.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2store/stats.go
deleted file mode 100644
index 45bc97f..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2store/stats.go
+++ /dev/null
@@ -1,145 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v2store
-
-import (
- "encoding/json"
- "sync/atomic"
-)
-
-const (
- SetSuccess = iota
- SetFail
- DeleteSuccess
- DeleteFail
- CreateSuccess
- CreateFail
- UpdateSuccess
- UpdateFail
- CompareAndSwapSuccess
- CompareAndSwapFail
- GetSuccess
- GetFail
- ExpireCount
- CompareAndDeleteSuccess
- CompareAndDeleteFail
-)
-
-type Stats struct {
- // Number of get requests
-
- GetSuccess uint64 `json:"getsSuccess"`
- GetFail uint64 `json:"getsFail"`
-
- // Number of sets requests
-
- SetSuccess uint64 `json:"setsSuccess"`
- SetFail uint64 `json:"setsFail"`
-
- // Number of delete requests
-
- DeleteSuccess uint64 `json:"deleteSuccess"`
- DeleteFail uint64 `json:"deleteFail"`
-
- // Number of update requests
-
- UpdateSuccess uint64 `json:"updateSuccess"`
- UpdateFail uint64 `json:"updateFail"`
-
- // Number of create requests
-
- CreateSuccess uint64 `json:"createSuccess"`
- CreateFail uint64 `json:"createFail"`
-
- // Number of testAndSet requests
-
- CompareAndSwapSuccess uint64 `json:"compareAndSwapSuccess"`
- CompareAndSwapFail uint64 `json:"compareAndSwapFail"`
-
- // Number of compareAndDelete requests
-
- CompareAndDeleteSuccess uint64 `json:"compareAndDeleteSuccess"`
- CompareAndDeleteFail uint64 `json:"compareAndDeleteFail"`
-
- ExpireCount uint64 `json:"expireCount"`
-
- Watchers uint64 `json:"watchers"`
-}
-
-func newStats() *Stats {
- s := new(Stats)
- return s
-}
-
-func (s *Stats) clone() *Stats {
- return &Stats{
- GetSuccess: s.GetSuccess,
- GetFail: s.GetFail,
- SetSuccess: s.SetSuccess,
- SetFail: s.SetFail,
- DeleteSuccess: s.DeleteSuccess,
- DeleteFail: s.DeleteFail,
- UpdateSuccess: s.UpdateSuccess,
- UpdateFail: s.UpdateFail,
- CreateSuccess: s.CreateSuccess,
- CreateFail: s.CreateFail,
- CompareAndSwapSuccess: s.CompareAndSwapSuccess,
- CompareAndSwapFail: s.CompareAndSwapFail,
- CompareAndDeleteSuccess: s.CompareAndDeleteSuccess,
- CompareAndDeleteFail: s.CompareAndDeleteFail,
- ExpireCount: s.ExpireCount,
- Watchers: s.Watchers,
- }
-}
-
-func (s *Stats) toJson() []byte {
- b, _ := json.Marshal(s)
- return b
-}
-
-func (s *Stats) Inc(field int) {
- switch field {
- case SetSuccess:
- atomic.AddUint64(&s.SetSuccess, 1)
- case SetFail:
- atomic.AddUint64(&s.SetFail, 1)
- case CreateSuccess:
- atomic.AddUint64(&s.CreateSuccess, 1)
- case CreateFail:
- atomic.AddUint64(&s.CreateFail, 1)
- case DeleteSuccess:
- atomic.AddUint64(&s.DeleteSuccess, 1)
- case DeleteFail:
- atomic.AddUint64(&s.DeleteFail, 1)
- case GetSuccess:
- atomic.AddUint64(&s.GetSuccess, 1)
- case GetFail:
- atomic.AddUint64(&s.GetFail, 1)
- case UpdateSuccess:
- atomic.AddUint64(&s.UpdateSuccess, 1)
- case UpdateFail:
- atomic.AddUint64(&s.UpdateFail, 1)
- case CompareAndSwapSuccess:
- atomic.AddUint64(&s.CompareAndSwapSuccess, 1)
- case CompareAndSwapFail:
- atomic.AddUint64(&s.CompareAndSwapFail, 1)
- case CompareAndDeleteSuccess:
- atomic.AddUint64(&s.CompareAndDeleteSuccess, 1)
- case CompareAndDeleteFail:
- atomic.AddUint64(&s.CompareAndDeleteFail, 1)
- case ExpireCount:
- atomic.AddUint64(&s.ExpireCount, 1)
- }
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2store/store.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2store/store.go
deleted file mode 100644
index ce94043..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2store/store.go
+++ /dev/null
@@ -1,791 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v2store
-
-import (
- "encoding/json"
- "fmt"
- "path"
- "strconv"
- "strings"
- "sync"
- "time"
-
- "go.etcd.io/etcd/etcdserver/api/v2error"
- "go.etcd.io/etcd/pkg/types"
-
- "github.com/jonboulle/clockwork"
-)
-
-// The default version to set when the store is first initialized.
-const defaultVersion = 2
-
-var minExpireTime time.Time
-
-func init() {
- minExpireTime, _ = time.Parse(time.RFC3339, "2000-01-01T00:00:00Z")
-}
-
-type Store interface {
- Version() int
- Index() uint64
-
- Get(nodePath string, recursive, sorted bool) (*Event, error)
- Set(nodePath string, dir bool, value string, expireOpts TTLOptionSet) (*Event, error)
- Update(nodePath string, newValue string, expireOpts TTLOptionSet) (*Event, error)
- Create(nodePath string, dir bool, value string, unique bool,
- expireOpts TTLOptionSet) (*Event, error)
- CompareAndSwap(nodePath string, prevValue string, prevIndex uint64,
- value string, expireOpts TTLOptionSet) (*Event, error)
- Delete(nodePath string, dir, recursive bool) (*Event, error)
- CompareAndDelete(nodePath string, prevValue string, prevIndex uint64) (*Event, error)
-
- Watch(prefix string, recursive, stream bool, sinceIndex uint64) (Watcher, error)
-
- Save() ([]byte, error)
- Recovery(state []byte) error
-
- Clone() Store
- SaveNoCopy() ([]byte, error)
-
- JsonStats() []byte
- DeleteExpiredKeys(cutoff time.Time)
-
- HasTTLKeys() bool
-}
-
-type TTLOptionSet struct {
- ExpireTime time.Time
- Refresh bool
-}
-
-type store struct {
- Root *node
- WatcherHub *watcherHub
- CurrentIndex uint64
- Stats *Stats
- CurrentVersion int
- ttlKeyHeap *ttlKeyHeap // need to recovery manually
- worldLock sync.RWMutex // stop the world lock
- clock clockwork.Clock
- readonlySet types.Set
-}
-
-// New creates a store where the given namespaces will be created as initial directories.
-func New(namespaces ...string) Store {
- s := newStore(namespaces...)
- s.clock = clockwork.NewRealClock()
- return s
-}
-
-func newStore(namespaces ...string) *store {
- s := new(store)
- s.CurrentVersion = defaultVersion
- s.Root = newDir(s, "/", s.CurrentIndex, nil, Permanent)
- for _, namespace := range namespaces {
- s.Root.Add(newDir(s, namespace, s.CurrentIndex, s.Root, Permanent))
- }
- s.Stats = newStats()
- s.WatcherHub = newWatchHub(1000)
- s.ttlKeyHeap = newTtlKeyHeap()
- s.readonlySet = types.NewUnsafeSet(append(namespaces, "/")...)
- return s
-}
-
-// Version retrieves current version of the store.
-func (s *store) Version() int {
- return s.CurrentVersion
-}
-
-// Index retrieves the current index of the store.
-func (s *store) Index() uint64 {
- s.worldLock.RLock()
- defer s.worldLock.RUnlock()
- return s.CurrentIndex
-}
-
-// Get returns a get event.
-// If recursive is true, it will return all the content under the node path.
-// If sorted is true, it will sort the content by keys.
-func (s *store) Get(nodePath string, recursive, sorted bool) (*Event, error) {
- var err *v2error.Error
-
- s.worldLock.RLock()
- defer s.worldLock.RUnlock()
-
- defer func() {
- if err == nil {
- s.Stats.Inc(GetSuccess)
- if recursive {
- reportReadSuccess(GetRecursive)
- } else {
- reportReadSuccess(Get)
- }
- return
- }
-
- s.Stats.Inc(GetFail)
- if recursive {
- reportReadFailure(GetRecursive)
- } else {
- reportReadFailure(Get)
- }
- }()
-
- n, err := s.internalGet(nodePath)
- if err != nil {
- return nil, err
- }
-
- e := newEvent(Get, nodePath, n.ModifiedIndex, n.CreatedIndex)
- e.EtcdIndex = s.CurrentIndex
- e.Node.loadInternalNode(n, recursive, sorted, s.clock)
-
- return e, nil
-}
-
-// Create creates the node at nodePath. Create will help to create intermediate directories with no ttl.
-// If the node has already existed, create will fail.
-// If any node on the path is a file, create will fail.
-func (s *store) Create(nodePath string, dir bool, value string, unique bool, expireOpts TTLOptionSet) (*Event, error) {
- var err *v2error.Error
-
- s.worldLock.Lock()
- defer s.worldLock.Unlock()
-
- defer func() {
- if err == nil {
- s.Stats.Inc(CreateSuccess)
- reportWriteSuccess(Create)
- return
- }
-
- s.Stats.Inc(CreateFail)
- reportWriteFailure(Create)
- }()
-
- e, err := s.internalCreate(nodePath, dir, value, unique, false, expireOpts.ExpireTime, Create)
- if err != nil {
- return nil, err
- }
-
- e.EtcdIndex = s.CurrentIndex
- s.WatcherHub.notify(e)
-
- return e, nil
-}
-
-// Set creates or replace the node at nodePath.
-func (s *store) Set(nodePath string, dir bool, value string, expireOpts TTLOptionSet) (*Event, error) {
- var err *v2error.Error
-
- s.worldLock.Lock()
- defer s.worldLock.Unlock()
-
- defer func() {
- if err == nil {
- s.Stats.Inc(SetSuccess)
- reportWriteSuccess(Set)
- return
- }
-
- s.Stats.Inc(SetFail)
- reportWriteFailure(Set)
- }()
-
- // Get prevNode value
- n, getErr := s.internalGet(nodePath)
- if getErr != nil && getErr.ErrorCode != v2error.EcodeKeyNotFound {
- err = getErr
- return nil, err
- }
-
- if expireOpts.Refresh {
- if getErr != nil {
- err = getErr
- return nil, err
- }
- value = n.Value
- }
-
- // Set new value
- e, err := s.internalCreate(nodePath, dir, value, false, true, expireOpts.ExpireTime, Set)
- if err != nil {
- return nil, err
- }
- e.EtcdIndex = s.CurrentIndex
-
- // Put prevNode into event
- if getErr == nil {
- prev := newEvent(Get, nodePath, n.ModifiedIndex, n.CreatedIndex)
- prev.Node.loadInternalNode(n, false, false, s.clock)
- e.PrevNode = prev.Node
- }
-
- if !expireOpts.Refresh {
- s.WatcherHub.notify(e)
- } else {
- e.SetRefresh()
- s.WatcherHub.add(e)
- }
-
- return e, nil
-}
-
-// returns user-readable cause of failed comparison
-func getCompareFailCause(n *node, which int, prevValue string, prevIndex uint64) string {
- switch which {
- case CompareIndexNotMatch:
- return fmt.Sprintf("[%v != %v]", prevIndex, n.ModifiedIndex)
- case CompareValueNotMatch:
- return fmt.Sprintf("[%v != %v]", prevValue, n.Value)
- default:
- return fmt.Sprintf("[%v != %v] [%v != %v]", prevValue, n.Value, prevIndex, n.ModifiedIndex)
- }
-}
-
-func (s *store) CompareAndSwap(nodePath string, prevValue string, prevIndex uint64,
- value string, expireOpts TTLOptionSet) (*Event, error) {
-
- var err *v2error.Error
-
- s.worldLock.Lock()
- defer s.worldLock.Unlock()
-
- defer func() {
- if err == nil {
- s.Stats.Inc(CompareAndSwapSuccess)
- reportWriteSuccess(CompareAndSwap)
- return
- }
-
- s.Stats.Inc(CompareAndSwapFail)
- reportWriteFailure(CompareAndSwap)
- }()
-
- nodePath = path.Clean(path.Join("/", nodePath))
- // we do not allow the user to change "/"
- if s.readonlySet.Contains(nodePath) {
- return nil, v2error.NewError(v2error.EcodeRootROnly, "/", s.CurrentIndex)
- }
-
- n, err := s.internalGet(nodePath)
- if err != nil {
- return nil, err
- }
- if n.IsDir() { // can only compare and swap file
- err = v2error.NewError(v2error.EcodeNotFile, nodePath, s.CurrentIndex)
- return nil, err
- }
-
- // If both of the prevValue and prevIndex are given, we will test both of them.
- // Command will be executed, only if both of the tests are successful.
- if ok, which := n.Compare(prevValue, prevIndex); !ok {
- cause := getCompareFailCause(n, which, prevValue, prevIndex)
- err = v2error.NewError(v2error.EcodeTestFailed, cause, s.CurrentIndex)
- return nil, err
- }
-
- if expireOpts.Refresh {
- value = n.Value
- }
-
- // update etcd index
- s.CurrentIndex++
-
- e := newEvent(CompareAndSwap, nodePath, s.CurrentIndex, n.CreatedIndex)
- e.EtcdIndex = s.CurrentIndex
- e.PrevNode = n.Repr(false, false, s.clock)
- eNode := e.Node
-
- // if test succeed, write the value
- n.Write(value, s.CurrentIndex)
- n.UpdateTTL(expireOpts.ExpireTime)
-
- // copy the value for safety
- valueCopy := value
- eNode.Value = &valueCopy
- eNode.Expiration, eNode.TTL = n.expirationAndTTL(s.clock)
-
- if !expireOpts.Refresh {
- s.WatcherHub.notify(e)
- } else {
- e.SetRefresh()
- s.WatcherHub.add(e)
- }
-
- return e, nil
-}
-
-// Delete deletes the node at the given path.
-// If the node is a directory, recursive must be true to delete it.
-func (s *store) Delete(nodePath string, dir, recursive bool) (*Event, error) {
- var err *v2error.Error
-
- s.worldLock.Lock()
- defer s.worldLock.Unlock()
-
- defer func() {
- if err == nil {
- s.Stats.Inc(DeleteSuccess)
- reportWriteSuccess(Delete)
- return
- }
-
- s.Stats.Inc(DeleteFail)
- reportWriteFailure(Delete)
- }()
-
- nodePath = path.Clean(path.Join("/", nodePath))
- // we do not allow the user to change "/"
- if s.readonlySet.Contains(nodePath) {
- return nil, v2error.NewError(v2error.EcodeRootROnly, "/", s.CurrentIndex)
- }
-
- // recursive implies dir
- if recursive {
- dir = true
- }
-
- n, err := s.internalGet(nodePath)
- if err != nil { // if the node does not exist, return error
- return nil, err
- }
-
- nextIndex := s.CurrentIndex + 1
- e := newEvent(Delete, nodePath, nextIndex, n.CreatedIndex)
- e.EtcdIndex = nextIndex
- e.PrevNode = n.Repr(false, false, s.clock)
- eNode := e.Node
-
- if n.IsDir() {
- eNode.Dir = true
- }
-
- callback := func(path string) { // notify function
- // notify the watchers with deleted set true
- s.WatcherHub.notifyWatchers(e, path, true)
- }
-
- err = n.Remove(dir, recursive, callback)
- if err != nil {
- return nil, err
- }
-
- // update etcd index
- s.CurrentIndex++
-
- s.WatcherHub.notify(e)
-
- return e, nil
-}
-
-func (s *store) CompareAndDelete(nodePath string, prevValue string, prevIndex uint64) (*Event, error) {
- var err *v2error.Error
-
- s.worldLock.Lock()
- defer s.worldLock.Unlock()
-
- defer func() {
- if err == nil {
- s.Stats.Inc(CompareAndDeleteSuccess)
- reportWriteSuccess(CompareAndDelete)
- return
- }
-
- s.Stats.Inc(CompareAndDeleteFail)
- reportWriteFailure(CompareAndDelete)
- }()
-
- nodePath = path.Clean(path.Join("/", nodePath))
-
- n, err := s.internalGet(nodePath)
- if err != nil { // if the node does not exist, return error
- return nil, err
- }
- if n.IsDir() { // can only compare and delete file
- return nil, v2error.NewError(v2error.EcodeNotFile, nodePath, s.CurrentIndex)
- }
-
- // If both of the prevValue and prevIndex are given, we will test both of them.
- // Command will be executed, only if both of the tests are successful.
- if ok, which := n.Compare(prevValue, prevIndex); !ok {
- cause := getCompareFailCause(n, which, prevValue, prevIndex)
- return nil, v2error.NewError(v2error.EcodeTestFailed, cause, s.CurrentIndex)
- }
-
- // update etcd index
- s.CurrentIndex++
-
- e := newEvent(CompareAndDelete, nodePath, s.CurrentIndex, n.CreatedIndex)
- e.EtcdIndex = s.CurrentIndex
- e.PrevNode = n.Repr(false, false, s.clock)
-
- callback := func(path string) { // notify function
- // notify the watchers with deleted set true
- s.WatcherHub.notifyWatchers(e, path, true)
- }
-
- err = n.Remove(false, false, callback)
- if err != nil {
- return nil, err
- }
-
- s.WatcherHub.notify(e)
-
- return e, nil
-}
-
-func (s *store) Watch(key string, recursive, stream bool, sinceIndex uint64) (Watcher, error) {
- s.worldLock.RLock()
- defer s.worldLock.RUnlock()
-
- key = path.Clean(path.Join("/", key))
- if sinceIndex == 0 {
- sinceIndex = s.CurrentIndex + 1
- }
- // WatcherHub does not know about the current index, so we need to pass it in
- w, err := s.WatcherHub.watch(key, recursive, stream, sinceIndex, s.CurrentIndex)
- if err != nil {
- return nil, err
- }
-
- return w, nil
-}
-
-// walk walks all the nodePath and apply the walkFunc on each directory
-func (s *store) walk(nodePath string, walkFunc func(prev *node, component string) (*node, *v2error.Error)) (*node, *v2error.Error) {
- components := strings.Split(nodePath, "/")
-
- curr := s.Root
- var err *v2error.Error
-
- for i := 1; i < len(components); i++ {
- if len(components[i]) == 0 { // ignore empty string
- return curr, nil
- }
-
- curr, err = walkFunc(curr, components[i])
- if err != nil {
- return nil, err
- }
- }
-
- return curr, nil
-}
-
-// Update updates the value/ttl of the node.
-// If the node is a file, the value and the ttl can be updated.
-// If the node is a directory, only the ttl can be updated.
-func (s *store) Update(nodePath string, newValue string, expireOpts TTLOptionSet) (*Event, error) {
- var err *v2error.Error
-
- s.worldLock.Lock()
- defer s.worldLock.Unlock()
-
- defer func() {
- if err == nil {
- s.Stats.Inc(UpdateSuccess)
- reportWriteSuccess(Update)
- return
- }
-
- s.Stats.Inc(UpdateFail)
- reportWriteFailure(Update)
- }()
-
- nodePath = path.Clean(path.Join("/", nodePath))
- // we do not allow the user to change "/"
- if s.readonlySet.Contains(nodePath) {
- return nil, v2error.NewError(v2error.EcodeRootROnly, "/", s.CurrentIndex)
- }
-
- currIndex, nextIndex := s.CurrentIndex, s.CurrentIndex+1
-
- n, err := s.internalGet(nodePath)
- if err != nil { // if the node does not exist, return error
- return nil, err
- }
- if n.IsDir() && len(newValue) != 0 {
- // if the node is a directory, we cannot update value to non-empty
- return nil, v2error.NewError(v2error.EcodeNotFile, nodePath, currIndex)
- }
-
- if expireOpts.Refresh {
- newValue = n.Value
- }
-
- e := newEvent(Update, nodePath, nextIndex, n.CreatedIndex)
- e.EtcdIndex = nextIndex
- e.PrevNode = n.Repr(false, false, s.clock)
- eNode := e.Node
-
- n.Write(newValue, nextIndex)
-
- if n.IsDir() {
- eNode.Dir = true
- } else {
- // copy the value for safety
- newValueCopy := newValue
- eNode.Value = &newValueCopy
- }
-
- // update ttl
- n.UpdateTTL(expireOpts.ExpireTime)
-
- eNode.Expiration, eNode.TTL = n.expirationAndTTL(s.clock)
-
- if !expireOpts.Refresh {
- s.WatcherHub.notify(e)
- } else {
- e.SetRefresh()
- s.WatcherHub.add(e)
- }
-
- s.CurrentIndex = nextIndex
-
- return e, nil
-}
-
-func (s *store) internalCreate(nodePath string, dir bool, value string, unique, replace bool,
- expireTime time.Time, action string) (*Event, *v2error.Error) {
-
- currIndex, nextIndex := s.CurrentIndex, s.CurrentIndex+1
-
- if unique { // append unique item under the node path
- nodePath += "/" + fmt.Sprintf("%020s", strconv.FormatUint(nextIndex, 10))
- }
-
- nodePath = path.Clean(path.Join("/", nodePath))
-
- // we do not allow the user to change "/"
- if s.readonlySet.Contains(nodePath) {
- return nil, v2error.NewError(v2error.EcodeRootROnly, "/", currIndex)
- }
-
- // Assume expire times that are way in the past are
- // This can occur when the time is serialized to JS
- if expireTime.Before(minExpireTime) {
- expireTime = Permanent
- }
-
- dirName, nodeName := path.Split(nodePath)
-
- // walk through the nodePath, create dirs and get the last directory node
- d, err := s.walk(dirName, s.checkDir)
-
- if err != nil {
- s.Stats.Inc(SetFail)
- reportWriteFailure(action)
- err.Index = currIndex
- return nil, err
- }
-
- e := newEvent(action, nodePath, nextIndex, nextIndex)
- eNode := e.Node
-
- n, _ := d.GetChild(nodeName)
-
- // force will try to replace an existing file
- if n != nil {
- if replace {
- if n.IsDir() {
- return nil, v2error.NewError(v2error.EcodeNotFile, nodePath, currIndex)
- }
- e.PrevNode = n.Repr(false, false, s.clock)
-
- n.Remove(false, false, nil)
- } else {
- return nil, v2error.NewError(v2error.EcodeNodeExist, nodePath, currIndex)
- }
- }
-
- if !dir { // create file
- // copy the value for safety
- valueCopy := value
- eNode.Value = &valueCopy
-
- n = newKV(s, nodePath, value, nextIndex, d, expireTime)
-
- } else { // create directory
- eNode.Dir = true
-
- n = newDir(s, nodePath, nextIndex, d, expireTime)
- }
-
- // we are sure d is a directory and does not have the children with name n.Name
- d.Add(n)
-
- // node with TTL
- if !n.IsPermanent() {
- s.ttlKeyHeap.push(n)
-
- eNode.Expiration, eNode.TTL = n.expirationAndTTL(s.clock)
- }
-
- s.CurrentIndex = nextIndex
-
- return e, nil
-}
-
-// InternalGet gets the node of the given nodePath.
-func (s *store) internalGet(nodePath string) (*node, *v2error.Error) {
- nodePath = path.Clean(path.Join("/", nodePath))
-
- walkFunc := func(parent *node, name string) (*node, *v2error.Error) {
-
- if !parent.IsDir() {
- err := v2error.NewError(v2error.EcodeNotDir, parent.Path, s.CurrentIndex)
- return nil, err
- }
-
- child, ok := parent.Children[name]
- if ok {
- return child, nil
- }
-
- return nil, v2error.NewError(v2error.EcodeKeyNotFound, path.Join(parent.Path, name), s.CurrentIndex)
- }
-
- f, err := s.walk(nodePath, walkFunc)
-
- if err != nil {
- return nil, err
- }
- return f, nil
-}
-
-// DeleteExpiredKeys will delete all expired keys
-func (s *store) DeleteExpiredKeys(cutoff time.Time) {
- s.worldLock.Lock()
- defer s.worldLock.Unlock()
-
- for {
- node := s.ttlKeyHeap.top()
- if node == nil || node.ExpireTime.After(cutoff) {
- break
- }
-
- s.CurrentIndex++
- e := newEvent(Expire, node.Path, s.CurrentIndex, node.CreatedIndex)
- e.EtcdIndex = s.CurrentIndex
- e.PrevNode = node.Repr(false, false, s.clock)
- if node.IsDir() {
- e.Node.Dir = true
- }
-
- callback := func(path string) { // notify function
- // notify the watchers with deleted set true
- s.WatcherHub.notifyWatchers(e, path, true)
- }
-
- s.ttlKeyHeap.pop()
- node.Remove(true, true, callback)
-
- reportExpiredKey()
- s.Stats.Inc(ExpireCount)
-
- s.WatcherHub.notify(e)
- }
-
-}
-
-// checkDir will check whether the component is a directory under parent node.
-// If it is a directory, this function will return the pointer to that node.
-// If it does not exist, this function will create a new directory and return the pointer to that node.
-// If it is a file, this function will return error.
-func (s *store) checkDir(parent *node, dirName string) (*node, *v2error.Error) {
- node, ok := parent.Children[dirName]
-
- if ok {
- if node.IsDir() {
- return node, nil
- }
-
- return nil, v2error.NewError(v2error.EcodeNotDir, node.Path, s.CurrentIndex)
- }
-
- n := newDir(s, path.Join(parent.Path, dirName), s.CurrentIndex+1, parent, Permanent)
-
- parent.Children[dirName] = n
-
- return n, nil
-}
-
-// Save saves the static state of the store system.
-// It will not be able to save the state of watchers.
-// It will not save the parent field of the node. Or there will
-// be cyclic dependencies issue for the json package.
-func (s *store) Save() ([]byte, error) {
- b, err := json.Marshal(s.Clone())
- if err != nil {
- return nil, err
- }
-
- return b, nil
-}
-
-func (s *store) SaveNoCopy() ([]byte, error) {
- b, err := json.Marshal(s)
- if err != nil {
- return nil, err
- }
-
- return b, nil
-}
-
-func (s *store) Clone() Store {
- s.worldLock.Lock()
-
- clonedStore := newStore()
- clonedStore.CurrentIndex = s.CurrentIndex
- clonedStore.Root = s.Root.Clone()
- clonedStore.WatcherHub = s.WatcherHub.clone()
- clonedStore.Stats = s.Stats.clone()
- clonedStore.CurrentVersion = s.CurrentVersion
-
- s.worldLock.Unlock()
- return clonedStore
-}
-
-// Recovery recovers the store system from a static state
-// It needs to recover the parent field of the nodes.
-// It needs to delete the expired nodes since the saved time and also
-// needs to create monitoring go routines.
-func (s *store) Recovery(state []byte) error {
- s.worldLock.Lock()
- defer s.worldLock.Unlock()
- err := json.Unmarshal(state, s)
-
- if err != nil {
- return err
- }
-
- s.ttlKeyHeap = newTtlKeyHeap()
-
- s.Root.recoverAndclean()
- return nil
-}
-
-func (s *store) JsonStats() []byte {
- s.Stats.Watchers = uint64(s.WatcherHub.count)
- return s.Stats.toJson()
-}
-
-func (s *store) HasTTLKeys() bool {
- s.worldLock.RLock()
- defer s.worldLock.RUnlock()
- return s.ttlKeyHeap.Len() != 0
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2store/ttl_key_heap.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2store/ttl_key_heap.go
deleted file mode 100644
index 477d2b9..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2store/ttl_key_heap.go
+++ /dev/null
@@ -1,97 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v2store
-
-import "container/heap"
-
-// An TTLKeyHeap is a min-heap of TTLKeys order by expiration time
-type ttlKeyHeap struct {
- array []*node
- keyMap map[*node]int
-}
-
-func newTtlKeyHeap() *ttlKeyHeap {
- h := &ttlKeyHeap{keyMap: make(map[*node]int)}
- heap.Init(h)
- return h
-}
-
-func (h ttlKeyHeap) Len() int {
- return len(h.array)
-}
-
-func (h ttlKeyHeap) Less(i, j int) bool {
- return h.array[i].ExpireTime.Before(h.array[j].ExpireTime)
-}
-
-func (h ttlKeyHeap) Swap(i, j int) {
- // swap node
- h.array[i], h.array[j] = h.array[j], h.array[i]
-
- // update map
- h.keyMap[h.array[i]] = i
- h.keyMap[h.array[j]] = j
-}
-
-func (h *ttlKeyHeap) Push(x interface{}) {
- n, _ := x.(*node)
- h.keyMap[n] = len(h.array)
- h.array = append(h.array, n)
-}
-
-func (h *ttlKeyHeap) Pop() interface{} {
- old := h.array
- n := len(old)
- x := old[n-1]
- // Set slice element to nil, so GC can recycle the node.
- // This is due to golang GC doesn't support partial recycling:
- // https://github.com/golang/go/issues/9618
- old[n-1] = nil
- h.array = old[0 : n-1]
- delete(h.keyMap, x)
- return x
-}
-
-func (h *ttlKeyHeap) top() *node {
- if h.Len() != 0 {
- return h.array[0]
- }
- return nil
-}
-
-func (h *ttlKeyHeap) pop() *node {
- x := heap.Pop(h)
- n, _ := x.(*node)
- return n
-}
-
-func (h *ttlKeyHeap) push(x interface{}) {
- heap.Push(h, x)
-}
-
-func (h *ttlKeyHeap) update(n *node) {
- index, ok := h.keyMap[n]
- if ok {
- heap.Remove(h, index)
- heap.Push(h, n)
- }
-}
-
-func (h *ttlKeyHeap) remove(n *node) {
- index, ok := h.keyMap[n]
- if ok {
- heap.Remove(h, index)
- }
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2store/watcher.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2store/watcher.go
deleted file mode 100644
index 4b1e846..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2store/watcher.go
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v2store
-
-type Watcher interface {
- EventChan() chan *Event
- StartIndex() uint64 // The EtcdIndex at which the Watcher was created
- Remove()
-}
-
-type watcher struct {
- eventChan chan *Event
- stream bool
- recursive bool
- sinceIndex uint64
- startIndex uint64
- hub *watcherHub
- removed bool
- remove func()
-}
-
-func (w *watcher) EventChan() chan *Event {
- return w.eventChan
-}
-
-func (w *watcher) StartIndex() uint64 {
- return w.startIndex
-}
-
-// notify function notifies the watcher. If the watcher interests in the given path,
-// the function will return true.
-func (w *watcher) notify(e *Event, originalPath bool, deleted bool) bool {
- // watcher is interested the path in three cases and under one condition
- // the condition is that the event happens after the watcher's sinceIndex
-
- // 1. the path at which the event happens is the path the watcher is watching at.
- // For example if the watcher is watching at "/foo" and the event happens at "/foo",
- // the watcher must be interested in that event.
-
- // 2. the watcher is a recursive watcher, it interests in the event happens after
- // its watching path. For example if watcher A watches at "/foo" and it is a recursive
- // one, it will interest in the event happens at "/foo/bar".
-
- // 3. when we delete a directory, we need to force notify all the watchers who watches
- // at the file we need to delete.
- // For example a watcher is watching at "/foo/bar". And we deletes "/foo". The watcher
- // should get notified even if "/foo" is not the path it is watching.
- if (w.recursive || originalPath || deleted) && e.Index() >= w.sinceIndex {
- // We cannot block here if the eventChan capacity is full, otherwise
- // etcd will hang. eventChan capacity is full when the rate of
- // notifications are higher than our send rate.
- // If this happens, we close the channel.
- select {
- case w.eventChan <- e:
- default:
- // We have missed a notification. Remove the watcher.
- // Removing the watcher also closes the eventChan.
- w.remove()
- }
- return true
- }
- return false
-}
-
-// Remove removes the watcher from watcherHub
-// The actual remove function is guaranteed to only be executed once
-func (w *watcher) Remove() {
- w.hub.mutex.Lock()
- defer w.hub.mutex.Unlock()
-
- close(w.eventChan)
- if w.remove != nil {
- w.remove()
- }
-}
-
-// nopWatcher is a watcher that receives nothing, always blocking.
-type nopWatcher struct{}
-
-func NewNopWatcher() Watcher { return &nopWatcher{} }
-func (w *nopWatcher) EventChan() chan *Event { return nil }
-func (w *nopWatcher) StartIndex() uint64 { return 0 }
-func (w *nopWatcher) Remove() {}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2store/watcher_hub.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2store/watcher_hub.go
deleted file mode 100644
index a452e7e..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2store/watcher_hub.go
+++ /dev/null
@@ -1,200 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v2store
-
-import (
- "container/list"
- "path"
- "strings"
- "sync"
- "sync/atomic"
-
- "go.etcd.io/etcd/etcdserver/api/v2error"
-)
-
-// A watcherHub contains all subscribed watchers
-// watchers is a map with watched path as key and watcher as value
-// EventHistory keeps the old events for watcherHub. It is used to help
-// watcher to get a continuous event history. Or a watcher might miss the
-// event happens between the end of the first watch command and the start
-// of the second command.
-type watcherHub struct {
- // count must be the first element to keep 64-bit alignment for atomic
- // access
-
- count int64 // current number of watchers.
-
- mutex sync.Mutex
- watchers map[string]*list.List
- EventHistory *EventHistory
-}
-
-// newWatchHub creates a watcherHub. The capacity determines how many events we will
-// keep in the eventHistory.
-// Typically, we only need to keep a small size of history[smaller than 20K].
-// Ideally, it should smaller than 20K/s[max throughput] * 2 * 50ms[RTT] = 2000
-func newWatchHub(capacity int) *watcherHub {
- return &watcherHub{
- watchers: make(map[string]*list.List),
- EventHistory: newEventHistory(capacity),
- }
-}
-
-// Watch function returns a Watcher.
-// If recursive is true, the first change after index under key will be sent to the event channel of the watcher.
-// If recursive is false, the first change after index at key will be sent to the event channel of the watcher.
-// If index is zero, watch will start from the current index + 1.
-func (wh *watcherHub) watch(key string, recursive, stream bool, index, storeIndex uint64) (Watcher, *v2error.Error) {
- reportWatchRequest()
- event, err := wh.EventHistory.scan(key, recursive, index)
-
- if err != nil {
- err.Index = storeIndex
- return nil, err
- }
-
- w := &watcher{
- eventChan: make(chan *Event, 100), // use a buffered channel
- recursive: recursive,
- stream: stream,
- sinceIndex: index,
- startIndex: storeIndex,
- hub: wh,
- }
-
- wh.mutex.Lock()
- defer wh.mutex.Unlock()
- // If the event exists in the known history, append the EtcdIndex and return immediately
- if event != nil {
- ne := event.Clone()
- ne.EtcdIndex = storeIndex
- w.eventChan <- ne
- return w, nil
- }
-
- l, ok := wh.watchers[key]
-
- var elem *list.Element
-
- if ok { // add the new watcher to the back of the list
- elem = l.PushBack(w)
- } else { // create a new list and add the new watcher
- l = list.New()
- elem = l.PushBack(w)
- wh.watchers[key] = l
- }
-
- w.remove = func() {
- if w.removed { // avoid removing it twice
- return
- }
- w.removed = true
- l.Remove(elem)
- atomic.AddInt64(&wh.count, -1)
- reportWatcherRemoved()
- if l.Len() == 0 {
- delete(wh.watchers, key)
- }
- }
-
- atomic.AddInt64(&wh.count, 1)
- reportWatcherAdded()
-
- return w, nil
-}
-
-func (wh *watcherHub) add(e *Event) {
- wh.EventHistory.addEvent(e)
-}
-
-// notify function accepts an event and notify to the watchers.
-func (wh *watcherHub) notify(e *Event) {
- e = wh.EventHistory.addEvent(e) // add event into the eventHistory
-
- segments := strings.Split(e.Node.Key, "/")
-
- currPath := "/"
-
- // walk through all the segments of the path and notify the watchers
- // if the path is "/foo/bar", it will notify watchers with path "/",
- // "/foo" and "/foo/bar"
-
- for _, segment := range segments {
- currPath = path.Join(currPath, segment)
- // notify the watchers who interests in the changes of current path
- wh.notifyWatchers(e, currPath, false)
- }
-}
-
-func (wh *watcherHub) notifyWatchers(e *Event, nodePath string, deleted bool) {
- wh.mutex.Lock()
- defer wh.mutex.Unlock()
-
- l, ok := wh.watchers[nodePath]
- if ok {
- curr := l.Front()
-
- for curr != nil {
- next := curr.Next() // save reference to the next one in the list
-
- w, _ := curr.Value.(*watcher)
-
- originalPath := e.Node.Key == nodePath
- if (originalPath || !isHidden(nodePath, e.Node.Key)) && w.notify(e, originalPath, deleted) {
- if !w.stream { // do not remove the stream watcher
- // if we successfully notify a watcher
- // we need to remove the watcher from the list
- // and decrease the counter
- w.removed = true
- l.Remove(curr)
- atomic.AddInt64(&wh.count, -1)
- reportWatcherRemoved()
- }
- }
-
- curr = next // update current to the next element in the list
- }
-
- if l.Len() == 0 {
- // if we have notified all watcher in the list
- // we can delete the list
- delete(wh.watchers, nodePath)
- }
- }
-}
-
-// clone function clones the watcherHub and return the cloned one.
-// only clone the static content. do not clone the current watchers.
-func (wh *watcherHub) clone() *watcherHub {
- clonedHistory := wh.EventHistory.clone()
-
- return &watcherHub{
- EventHistory: clonedHistory,
- }
-}
-
-// isHidden checks to see if key path is considered hidden to watch path i.e. the
-// last element is hidden or it's within a hidden directory
-func isHidden(watchPath, keyPath string) bool {
- // When deleting a directory, watchPath might be deeper than the actual keyPath
- // For example, when deleting /foo we also need to notify watchers on /foo/bar.
- if len(watchPath) > len(keyPath) {
- return false
- }
- // if watch path is just a "/", after path will start without "/"
- // add a "/" to deal with the special case when watchPath is "/"
- afterPath := path.Clean("/" + keyPath[len(watchPath):])
- return strings.Contains(afterPath, "/_")
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2v3/cluster.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2v3/cluster.go
deleted file mode 100644
index a22e4af..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2v3/cluster.go
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2017 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v2v3
-
-import (
- "go.etcd.io/etcd/etcdserver/api/membership"
- "go.etcd.io/etcd/pkg/types"
-
- "github.com/coreos/go-semver/semver"
-)
-
-func (s *v2v3Server) ID() types.ID {
- // TODO: use an actual member ID
- return types.ID(0xe7cd2f00d)
-}
-func (s *v2v3Server) ClientURLs() []string { panic("STUB") }
-func (s *v2v3Server) Members() []*membership.Member { panic("STUB") }
-func (s *v2v3Server) Member(id types.ID) *membership.Member { panic("STUB") }
-func (s *v2v3Server) Version() *semver.Version { panic("STUB") }
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2v3/doc.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2v3/doc.go
deleted file mode 100644
index 2ff372f..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2v3/doc.go
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2017 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package v2v3 provides a ServerV2 implementation backed by clientv3.Client.
-package v2v3
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2v3/server.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2v3/server.go
deleted file mode 100644
index 5ff9b96..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2v3/server.go
+++ /dev/null
@@ -1,129 +0,0 @@
-// Copyright 2017 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v2v3
-
-import (
- "context"
- "net/http"
- "time"
-
- "go.etcd.io/etcd/clientv3"
- "go.etcd.io/etcd/etcdserver"
- "go.etcd.io/etcd/etcdserver/api"
- "go.etcd.io/etcd/etcdserver/api/membership"
- pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
- "go.etcd.io/etcd/pkg/types"
-
- "github.com/coreos/go-semver/semver"
- "go.uber.org/zap"
-)
-
-type fakeStats struct{}
-
-func (s *fakeStats) SelfStats() []byte { return nil }
-func (s *fakeStats) LeaderStats() []byte { return nil }
-func (s *fakeStats) StoreStats() []byte { return nil }
-
-type v2v3Server struct {
- lg *zap.Logger
- c *clientv3.Client
- store *v2v3Store
- fakeStats
-}
-
-func NewServer(lg *zap.Logger, c *clientv3.Client, pfx string) etcdserver.ServerPeer {
- return &v2v3Server{lg: lg, c: c, store: newStore(c, pfx)}
-}
-
-func (s *v2v3Server) ClientCertAuthEnabled() bool { return false }
-
-func (s *v2v3Server) LeaseHandler() http.Handler { panic("STUB: lease handler") }
-func (s *v2v3Server) RaftHandler() http.Handler { panic("STUB: raft handler") }
-
-func (s *v2v3Server) Leader() types.ID {
- ctx, cancel := context.WithTimeout(context.TODO(), 5*time.Second)
- defer cancel()
- resp, err := s.c.Status(ctx, s.c.Endpoints()[0])
- if err != nil {
- return 0
- }
- return types.ID(resp.Leader)
-}
-
-func (s *v2v3Server) AddMember(ctx context.Context, memb membership.Member) ([]*membership.Member, error) {
- // adding member as learner is not supported by V2 Server.
- resp, err := s.c.MemberAdd(ctx, memb.PeerURLs)
- if err != nil {
- return nil, err
- }
- return v3MembersToMembership(resp.Members), nil
-}
-
-func (s *v2v3Server) RemoveMember(ctx context.Context, id uint64) ([]*membership.Member, error) {
- resp, err := s.c.MemberRemove(ctx, id)
- if err != nil {
- return nil, err
- }
- return v3MembersToMembership(resp.Members), nil
-}
-
-func (s *v2v3Server) PromoteMember(ctx context.Context, id uint64) ([]*membership.Member, error) {
- resp, err := s.c.MemberPromote(ctx, id)
- if err != nil {
- return nil, err
- }
- return v3MembersToMembership(resp.Members), nil
-}
-
-func (s *v2v3Server) UpdateMember(ctx context.Context, m membership.Member) ([]*membership.Member, error) {
- resp, err := s.c.MemberUpdate(ctx, uint64(m.ID), m.PeerURLs)
- if err != nil {
- return nil, err
- }
- return v3MembersToMembership(resp.Members), nil
-}
-
-func v3MembersToMembership(v3membs []*pb.Member) []*membership.Member {
- membs := make([]*membership.Member, len(v3membs))
- for i, m := range v3membs {
- membs[i] = &membership.Member{
- ID: types.ID(m.ID),
- RaftAttributes: membership.RaftAttributes{
- PeerURLs: m.PeerURLs,
- IsLearner: m.IsLearner,
- },
- Attributes: membership.Attributes{
- Name: m.Name,
- ClientURLs: m.ClientURLs,
- },
- }
- }
- return membs
-}
-
-func (s *v2v3Server) ClusterVersion() *semver.Version { return s.Version() }
-func (s *v2v3Server) Cluster() api.Cluster { return s }
-func (s *v2v3Server) Alarms() []*pb.AlarmMember { return nil }
-
-func (s *v2v3Server) Do(ctx context.Context, r pb.Request) (etcdserver.Response, error) {
- applier := etcdserver.NewApplierV2(s.lg, s.store, nil)
- reqHandler := etcdserver.NewStoreRequestV2Handler(s.store, applier)
- req := (*etcdserver.RequestV2)(&r)
- resp, err := req.Handle(ctx, reqHandler)
- if resp.Err != nil {
- return resp, resp.Err
- }
- return resp, err
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2v3/store.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2v3/store.go
deleted file mode 100644
index f1c7ab3..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2v3/store.go
+++ /dev/null
@@ -1,638 +0,0 @@
-// Copyright 2017 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v2v3
-
-import (
- "context"
- "fmt"
- "path"
- "sort"
- "strings"
- "time"
-
- "go.etcd.io/etcd/clientv3"
- "go.etcd.io/etcd/clientv3/concurrency"
- "go.etcd.io/etcd/etcdserver/api/v2error"
- "go.etcd.io/etcd/etcdserver/api/v2store"
- "go.etcd.io/etcd/mvcc/mvccpb"
-)
-
-// store implements the Store interface for V2 using
-// a v3 client.
-type v2v3Store struct {
- c *clientv3.Client
- // pfx is the v3 prefix where keys should be stored.
- pfx string
- ctx context.Context
-}
-
-const maxPathDepth = 63
-
-var errUnsupported = fmt.Errorf("TTLs are unsupported")
-
-func NewStore(c *clientv3.Client, pfx string) v2store.Store { return newStore(c, pfx) }
-
-func newStore(c *clientv3.Client, pfx string) *v2v3Store { return &v2v3Store{c, pfx, c.Ctx()} }
-
-func (s *v2v3Store) Index() uint64 { panic("STUB") }
-
-func (s *v2v3Store) Get(nodePath string, recursive, sorted bool) (*v2store.Event, error) {
- key := s.mkPath(nodePath)
- resp, err := s.c.Txn(s.ctx).Then(
- clientv3.OpGet(key+"/"),
- clientv3.OpGet(key),
- ).Commit()
- if err != nil {
- return nil, err
- }
-
- if kvs := resp.Responses[0].GetResponseRange().Kvs; len(kvs) != 0 || isRoot(nodePath) {
- nodes, err := s.getDir(nodePath, recursive, sorted, resp.Header.Revision)
- if err != nil {
- return nil, err
- }
- cidx, midx := uint64(0), uint64(0)
- if len(kvs) > 0 {
- cidx, midx = mkV2Rev(kvs[0].CreateRevision), mkV2Rev(kvs[0].ModRevision)
- }
- return &v2store.Event{
- Action: v2store.Get,
- Node: &v2store.NodeExtern{
- Key: nodePath,
- Dir: true,
- Nodes: nodes,
- CreatedIndex: cidx,
- ModifiedIndex: midx,
- },
- EtcdIndex: mkV2Rev(resp.Header.Revision),
- }, nil
- }
-
- kvs := resp.Responses[1].GetResponseRange().Kvs
- if len(kvs) == 0 {
- return nil, v2error.NewError(v2error.EcodeKeyNotFound, nodePath, mkV2Rev(resp.Header.Revision))
- }
-
- return &v2store.Event{
- Action: v2store.Get,
- Node: s.mkV2Node(kvs[0]),
- EtcdIndex: mkV2Rev(resp.Header.Revision),
- }, nil
-}
-
-func (s *v2v3Store) getDir(nodePath string, recursive, sorted bool, rev int64) ([]*v2store.NodeExtern, error) {
- rootNodes, err := s.getDirDepth(nodePath, 1, rev)
- if err != nil || !recursive {
- if sorted {
- sort.Sort(v2store.NodeExterns(rootNodes))
- }
- return rootNodes, err
- }
- nextNodes := rootNodes
- nodes := make(map[string]*v2store.NodeExtern)
- // Breadth walk the subdirectories
- for i := 2; len(nextNodes) > 0; i++ {
- for _, n := range nextNodes {
- nodes[n.Key] = n
- if parent := nodes[path.Dir(n.Key)]; parent != nil {
- parent.Nodes = append(parent.Nodes, n)
- }
- }
- if nextNodes, err = s.getDirDepth(nodePath, i, rev); err != nil {
- return nil, err
- }
- }
-
- if sorted {
- sort.Sort(v2store.NodeExterns(rootNodes))
- }
- return rootNodes, nil
-}
-
-func (s *v2v3Store) getDirDepth(nodePath string, depth int, rev int64) ([]*v2store.NodeExtern, error) {
- pd := s.mkPathDepth(nodePath, depth)
- resp, err := s.c.Get(s.ctx, pd, clientv3.WithPrefix(), clientv3.WithRev(rev))
- if err != nil {
- return nil, err
- }
-
- nodes := make([]*v2store.NodeExtern, len(resp.Kvs))
- for i, kv := range resp.Kvs {
- nodes[i] = s.mkV2Node(kv)
- }
- return nodes, nil
-}
-
-func (s *v2v3Store) Set(
- nodePath string,
- dir bool,
- value string,
- expireOpts v2store.TTLOptionSet,
-) (*v2store.Event, error) {
- if expireOpts.Refresh || !expireOpts.ExpireTime.IsZero() {
- return nil, errUnsupported
- }
-
- if isRoot(nodePath) {
- return nil, v2error.NewError(v2error.EcodeRootROnly, nodePath, 0)
- }
-
- ecode := 0
- applyf := func(stm concurrency.STM) error {
- // build path if any directories in path do not exist
- dirs := []string{}
- for p := path.Dir(nodePath); !isRoot(p); p = path.Dir(p) {
- pp := s.mkPath(p)
- if stm.Rev(pp) > 0 {
- ecode = v2error.EcodeNotDir
- return nil
- }
- if stm.Rev(pp+"/") == 0 {
- dirs = append(dirs, pp+"/")
- }
- }
- for _, d := range dirs {
- stm.Put(d, "")
- }
-
- key := s.mkPath(nodePath)
- if dir {
- if stm.Rev(key) != 0 {
- // exists as non-dir
- ecode = v2error.EcodeNotDir
- return nil
- }
- key = key + "/"
- } else if stm.Rev(key+"/") != 0 {
- ecode = v2error.EcodeNotFile
- return nil
- }
- stm.Put(key, value, clientv3.WithPrevKV())
- stm.Put(s.mkActionKey(), v2store.Set)
- return nil
- }
-
- resp, err := s.newSTM(applyf)
- if err != nil {
- return nil, err
- }
- if ecode != 0 {
- return nil, v2error.NewError(ecode, nodePath, mkV2Rev(resp.Header.Revision))
- }
-
- createRev := resp.Header.Revision
- var pn *v2store.NodeExtern
- if pkv := prevKeyFromPuts(resp); pkv != nil {
- pn = s.mkV2Node(pkv)
- createRev = pkv.CreateRevision
- }
-
- vp := &value
- if dir {
- vp = nil
- }
- return &v2store.Event{
- Action: v2store.Set,
- Node: &v2store.NodeExtern{
- Key: nodePath,
- Value: vp,
- Dir: dir,
- ModifiedIndex: mkV2Rev(resp.Header.Revision),
- CreatedIndex: mkV2Rev(createRev),
- },
- PrevNode: pn,
- EtcdIndex: mkV2Rev(resp.Header.Revision),
- }, nil
-}
-
-func (s *v2v3Store) Update(nodePath, newValue string, expireOpts v2store.TTLOptionSet) (*v2store.Event, error) {
- if isRoot(nodePath) {
- return nil, v2error.NewError(v2error.EcodeRootROnly, nodePath, 0)
- }
-
- if expireOpts.Refresh || !expireOpts.ExpireTime.IsZero() {
- return nil, errUnsupported
- }
-
- key := s.mkPath(nodePath)
- ecode := 0
- applyf := func(stm concurrency.STM) error {
- if rev := stm.Rev(key + "/"); rev != 0 {
- ecode = v2error.EcodeNotFile
- return nil
- }
- if rev := stm.Rev(key); rev == 0 {
- ecode = v2error.EcodeKeyNotFound
- return nil
- }
- stm.Put(key, newValue, clientv3.WithPrevKV())
- stm.Put(s.mkActionKey(), v2store.Update)
- return nil
- }
-
- resp, err := s.newSTM(applyf)
- if err != nil {
- return nil, err
- }
- if ecode != 0 {
- return nil, v2error.NewError(v2error.EcodeNotFile, nodePath, mkV2Rev(resp.Header.Revision))
- }
-
- pkv := prevKeyFromPuts(resp)
- return &v2store.Event{
- Action: v2store.Update,
- Node: &v2store.NodeExtern{
- Key: nodePath,
- Value: &newValue,
- ModifiedIndex: mkV2Rev(resp.Header.Revision),
- CreatedIndex: mkV2Rev(pkv.CreateRevision),
- },
- PrevNode: s.mkV2Node(pkv),
- EtcdIndex: mkV2Rev(resp.Header.Revision),
- }, nil
-}
-
-func (s *v2v3Store) Create(
- nodePath string,
- dir bool,
- value string,
- unique bool,
- expireOpts v2store.TTLOptionSet,
-) (*v2store.Event, error) {
- if isRoot(nodePath) {
- return nil, v2error.NewError(v2error.EcodeRootROnly, nodePath, 0)
- }
- if expireOpts.Refresh || !expireOpts.ExpireTime.IsZero() {
- return nil, errUnsupported
- }
- ecode := 0
- applyf := func(stm concurrency.STM) error {
- ecode = 0
- key := s.mkPath(nodePath)
- if unique {
- // append unique item under the node path
- for {
- key = nodePath + "/" + fmt.Sprintf("%020s", time.Now())
- key = path.Clean(path.Join("/", key))
- key = s.mkPath(key)
- if stm.Rev(key) == 0 {
- break
- }
- }
- }
- if stm.Rev(key) > 0 || stm.Rev(key+"/") > 0 {
- ecode = v2error.EcodeNodeExist
- return nil
- }
- // build path if any directories in path do not exist
- dirs := []string{}
- for p := path.Dir(nodePath); !isRoot(p); p = path.Dir(p) {
- pp := s.mkPath(p)
- if stm.Rev(pp) > 0 {
- ecode = v2error.EcodeNotDir
- return nil
- }
- if stm.Rev(pp+"/") == 0 {
- dirs = append(dirs, pp+"/")
- }
- }
- for _, d := range dirs {
- stm.Put(d, "")
- }
-
- if dir {
- // directories marked with extra slash in key name
- key += "/"
- }
- stm.Put(key, value)
- stm.Put(s.mkActionKey(), v2store.Create)
- return nil
- }
-
- resp, err := s.newSTM(applyf)
- if err != nil {
- return nil, err
- }
- if ecode != 0 {
- return nil, v2error.NewError(ecode, nodePath, mkV2Rev(resp.Header.Revision))
- }
-
- var v *string
- if !dir {
- v = &value
- }
-
- return &v2store.Event{
- Action: v2store.Create,
- Node: &v2store.NodeExtern{
- Key: nodePath,
- Value: v,
- Dir: dir,
- ModifiedIndex: mkV2Rev(resp.Header.Revision),
- CreatedIndex: mkV2Rev(resp.Header.Revision),
- },
- EtcdIndex: mkV2Rev(resp.Header.Revision),
- }, nil
-}
-
-func (s *v2v3Store) CompareAndSwap(
- nodePath string,
- prevValue string,
- prevIndex uint64,
- value string,
- expireOpts v2store.TTLOptionSet,
-) (*v2store.Event, error) {
- if isRoot(nodePath) {
- return nil, v2error.NewError(v2error.EcodeRootROnly, nodePath, 0)
- }
- if expireOpts.Refresh || !expireOpts.ExpireTime.IsZero() {
- return nil, errUnsupported
- }
-
- key := s.mkPath(nodePath)
- resp, err := s.c.Txn(s.ctx).If(
- s.mkCompare(nodePath, prevValue, prevIndex)...,
- ).Then(
- clientv3.OpPut(key, value, clientv3.WithPrevKV()),
- clientv3.OpPut(s.mkActionKey(), v2store.CompareAndSwap),
- ).Else(
- clientv3.OpGet(key),
- clientv3.OpGet(key+"/"),
- ).Commit()
-
- if err != nil {
- return nil, err
- }
- if !resp.Succeeded {
- return nil, compareFail(nodePath, prevValue, prevIndex, resp)
- }
-
- pkv := resp.Responses[0].GetResponsePut().PrevKv
- return &v2store.Event{
- Action: v2store.CompareAndSwap,
- Node: &v2store.NodeExtern{
- Key: nodePath,
- Value: &value,
- CreatedIndex: mkV2Rev(pkv.CreateRevision),
- ModifiedIndex: mkV2Rev(resp.Header.Revision),
- },
- PrevNode: s.mkV2Node(pkv),
- EtcdIndex: mkV2Rev(resp.Header.Revision),
- }, nil
-}
-
-func (s *v2v3Store) Delete(nodePath string, dir, recursive bool) (*v2store.Event, error) {
- if isRoot(nodePath) {
- return nil, v2error.NewError(v2error.EcodeRootROnly, nodePath, 0)
- }
- if !dir && !recursive {
- return s.deleteNode(nodePath)
- }
- if !recursive {
- return s.deleteEmptyDir(nodePath)
- }
-
- dels := make([]clientv3.Op, maxPathDepth+1)
- dels[0] = clientv3.OpDelete(s.mkPath(nodePath)+"/", clientv3.WithPrevKV())
- for i := 1; i < maxPathDepth; i++ {
- dels[i] = clientv3.OpDelete(s.mkPathDepth(nodePath, i), clientv3.WithPrefix())
- }
- dels[maxPathDepth] = clientv3.OpPut(s.mkActionKey(), v2store.Delete)
-
- resp, err := s.c.Txn(s.ctx).If(
- clientv3.Compare(clientv3.Version(s.mkPath(nodePath)+"/"), ">", 0),
- clientv3.Compare(clientv3.Version(s.mkPathDepth(nodePath, maxPathDepth)+"/"), "=", 0),
- ).Then(
- dels...,
- ).Commit()
- if err != nil {
- return nil, err
- }
- if !resp.Succeeded {
- return nil, v2error.NewError(v2error.EcodeNodeExist, nodePath, mkV2Rev(resp.Header.Revision))
- }
- dresp := resp.Responses[0].GetResponseDeleteRange()
- return &v2store.Event{
- Action: v2store.Delete,
- PrevNode: s.mkV2Node(dresp.PrevKvs[0]),
- EtcdIndex: mkV2Rev(resp.Header.Revision),
- }, nil
-}
-
-func (s *v2v3Store) deleteEmptyDir(nodePath string) (*v2store.Event, error) {
- resp, err := s.c.Txn(s.ctx).If(
- clientv3.Compare(clientv3.Version(s.mkPathDepth(nodePath, 1)), "=", 0).WithPrefix(),
- ).Then(
- clientv3.OpDelete(s.mkPath(nodePath)+"/", clientv3.WithPrevKV()),
- clientv3.OpPut(s.mkActionKey(), v2store.Delete),
- ).Commit()
- if err != nil {
- return nil, err
- }
- if !resp.Succeeded {
- return nil, v2error.NewError(v2error.EcodeDirNotEmpty, nodePath, mkV2Rev(resp.Header.Revision))
- }
- dresp := resp.Responses[0].GetResponseDeleteRange()
- if len(dresp.PrevKvs) == 0 {
- return nil, v2error.NewError(v2error.EcodeNodeExist, nodePath, mkV2Rev(resp.Header.Revision))
- }
- return &v2store.Event{
- Action: v2store.Delete,
- PrevNode: s.mkV2Node(dresp.PrevKvs[0]),
- EtcdIndex: mkV2Rev(resp.Header.Revision),
- }, nil
-}
-
-func (s *v2v3Store) deleteNode(nodePath string) (*v2store.Event, error) {
- resp, err := s.c.Txn(s.ctx).If(
- clientv3.Compare(clientv3.Version(s.mkPath(nodePath)+"/"), "=", 0),
- ).Then(
- clientv3.OpDelete(s.mkPath(nodePath), clientv3.WithPrevKV()),
- clientv3.OpPut(s.mkActionKey(), v2store.Delete),
- ).Commit()
- if err != nil {
- return nil, err
- }
- if !resp.Succeeded {
- return nil, v2error.NewError(v2error.EcodeNotFile, nodePath, mkV2Rev(resp.Header.Revision))
- }
- pkvs := resp.Responses[0].GetResponseDeleteRange().PrevKvs
- if len(pkvs) == 0 {
- return nil, v2error.NewError(v2error.EcodeKeyNotFound, nodePath, mkV2Rev(resp.Header.Revision))
- }
- pkv := pkvs[0]
- return &v2store.Event{
- Action: v2store.Delete,
- Node: &v2store.NodeExtern{
- Key: nodePath,
- CreatedIndex: mkV2Rev(pkv.CreateRevision),
- ModifiedIndex: mkV2Rev(resp.Header.Revision),
- },
- PrevNode: s.mkV2Node(pkv),
- EtcdIndex: mkV2Rev(resp.Header.Revision),
- }, nil
-}
-
-func (s *v2v3Store) CompareAndDelete(nodePath, prevValue string, prevIndex uint64) (*v2store.Event, error) {
- if isRoot(nodePath) {
- return nil, v2error.NewError(v2error.EcodeRootROnly, nodePath, 0)
- }
-
- key := s.mkPath(nodePath)
- resp, err := s.c.Txn(s.ctx).If(
- s.mkCompare(nodePath, prevValue, prevIndex)...,
- ).Then(
- clientv3.OpDelete(key, clientv3.WithPrevKV()),
- clientv3.OpPut(s.mkActionKey(), v2store.CompareAndDelete),
- ).Else(
- clientv3.OpGet(key),
- clientv3.OpGet(key+"/"),
- ).Commit()
-
- if err != nil {
- return nil, err
- }
- if !resp.Succeeded {
- return nil, compareFail(nodePath, prevValue, prevIndex, resp)
- }
-
- // len(pkvs) > 1 since txn only succeeds when key exists
- pkv := resp.Responses[0].GetResponseDeleteRange().PrevKvs[0]
- return &v2store.Event{
- Action: v2store.CompareAndDelete,
- Node: &v2store.NodeExtern{
- Key: nodePath,
- CreatedIndex: mkV2Rev(pkv.CreateRevision),
- ModifiedIndex: mkV2Rev(resp.Header.Revision),
- },
- PrevNode: s.mkV2Node(pkv),
- EtcdIndex: mkV2Rev(resp.Header.Revision),
- }, nil
-}
-
-func compareFail(nodePath, prevValue string, prevIndex uint64, resp *clientv3.TxnResponse) error {
- if dkvs := resp.Responses[1].GetResponseRange().Kvs; len(dkvs) > 0 {
- return v2error.NewError(v2error.EcodeNotFile, nodePath, mkV2Rev(resp.Header.Revision))
- }
- kvs := resp.Responses[0].GetResponseRange().Kvs
- if len(kvs) == 0 {
- return v2error.NewError(v2error.EcodeKeyNotFound, nodePath, mkV2Rev(resp.Header.Revision))
- }
- kv := kvs[0]
- indexMatch := prevIndex == 0 || kv.ModRevision == int64(prevIndex)
- valueMatch := prevValue == "" || string(kv.Value) == prevValue
- var cause string
- switch {
- case indexMatch && !valueMatch:
- cause = fmt.Sprintf("[%v != %v]", prevValue, string(kv.Value))
- case valueMatch && !indexMatch:
- cause = fmt.Sprintf("[%v != %v]", prevIndex, kv.ModRevision)
- default:
- cause = fmt.Sprintf("[%v != %v] [%v != %v]", prevValue, string(kv.Value), prevIndex, kv.ModRevision)
- }
- return v2error.NewError(v2error.EcodeTestFailed, cause, mkV2Rev(resp.Header.Revision))
-}
-
-func (s *v2v3Store) mkCompare(nodePath, prevValue string, prevIndex uint64) []clientv3.Cmp {
- key := s.mkPath(nodePath)
- cmps := []clientv3.Cmp{clientv3.Compare(clientv3.Version(key), ">", 0)}
- if prevIndex != 0 {
- cmps = append(cmps, clientv3.Compare(clientv3.ModRevision(key), "=", mkV3Rev(prevIndex)))
- }
- if prevValue != "" {
- cmps = append(cmps, clientv3.Compare(clientv3.Value(key), "=", prevValue))
- }
- return cmps
-}
-
-func (s *v2v3Store) JsonStats() []byte { panic("STUB") }
-func (s *v2v3Store) DeleteExpiredKeys(cutoff time.Time) { panic("STUB") }
-
-func (s *v2v3Store) Version() int { return 2 }
-
-// TODO: move this out of the Store interface?
-
-func (s *v2v3Store) Save() ([]byte, error) { panic("STUB") }
-func (s *v2v3Store) Recovery(state []byte) error { panic("STUB") }
-func (s *v2v3Store) Clone() v2store.Store { panic("STUB") }
-func (s *v2v3Store) SaveNoCopy() ([]byte, error) { panic("STUB") }
-func (s *v2v3Store) HasTTLKeys() bool { panic("STUB") }
-
-func (s *v2v3Store) mkPath(nodePath string) string { return s.mkPathDepth(nodePath, 0) }
-
-func (s *v2v3Store) mkNodePath(p string) string {
- return path.Clean(p[len(s.pfx)+len("/k/000/"):])
-}
-
-// mkPathDepth makes a path to a key that encodes its directory depth
-// for fast directory listing. If a depth is provided, it is added
-// to the computed depth.
-func (s *v2v3Store) mkPathDepth(nodePath string, depth int) string {
- normalForm := path.Clean(path.Join("/", nodePath))
- n := strings.Count(normalForm, "/") + depth
- return fmt.Sprintf("%s/%03d/k/%s", s.pfx, n, normalForm)
-}
-
-func (s *v2v3Store) mkActionKey() string { return s.pfx + "/act" }
-
-func isRoot(s string) bool { return len(s) == 0 || s == "/" || s == "/0" || s == "/1" }
-
-func mkV2Rev(v3Rev int64) uint64 {
- if v3Rev == 0 {
- return 0
- }
- return uint64(v3Rev - 1)
-}
-
-func mkV3Rev(v2Rev uint64) int64 {
- if v2Rev == 0 {
- return 0
- }
- return int64(v2Rev + 1)
-}
-
-// mkV2Node creates a V2 NodeExtern from a V3 KeyValue
-func (s *v2v3Store) mkV2Node(kv *mvccpb.KeyValue) *v2store.NodeExtern {
- if kv == nil {
- return nil
- }
- n := &v2store.NodeExtern{
- Key: s.mkNodePath(string(kv.Key)),
- Dir: kv.Key[len(kv.Key)-1] == '/',
- CreatedIndex: mkV2Rev(kv.CreateRevision),
- ModifiedIndex: mkV2Rev(kv.ModRevision),
- }
- if !n.Dir {
- v := string(kv.Value)
- n.Value = &v
- }
- return n
-}
-
-// prevKeyFromPuts gets the prev key that is being put; ignores
-// the put action response.
-func prevKeyFromPuts(resp *clientv3.TxnResponse) *mvccpb.KeyValue {
- for _, r := range resp.Responses {
- pkv := r.GetResponsePut().PrevKv
- if pkv != nil && pkv.CreateRevision > 0 {
- return pkv
- }
- }
- return nil
-}
-
-func (s *v2v3Store) newSTM(applyf func(concurrency.STM) error) (*clientv3.TxnResponse, error) {
- return concurrency.NewSTM(s.c, applyf, concurrency.WithIsolation(concurrency.Serializable))
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v2v3/watcher.go b/vendor/go.etcd.io/etcd/etcdserver/api/v2v3/watcher.go
deleted file mode 100644
index e8a3557..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v2v3/watcher.go
+++ /dev/null
@@ -1,140 +0,0 @@
-// Copyright 2017 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v2v3
-
-import (
- "context"
- "strings"
-
- "go.etcd.io/etcd/clientv3"
- "go.etcd.io/etcd/etcdserver/api/v2error"
- "go.etcd.io/etcd/etcdserver/api/v2store"
-)
-
-func (s *v2v3Store) Watch(prefix string, recursive, stream bool, sinceIndex uint64) (v2store.Watcher, error) {
- ctx, cancel := context.WithCancel(s.ctx)
- wch := s.c.Watch(
- ctx,
- // TODO: very pricey; use a single store-wide watch in future
- s.pfx,
- clientv3.WithPrefix(),
- clientv3.WithRev(int64(sinceIndex)),
- clientv3.WithCreatedNotify(),
- clientv3.WithPrevKV())
- resp, ok := <-wch
- if err := resp.Err(); err != nil || !ok {
- cancel()
- return nil, v2error.NewError(v2error.EcodeRaftInternal, prefix, 0)
- }
-
- evc, donec := make(chan *v2store.Event), make(chan struct{})
- go func() {
- defer func() {
- close(evc)
- close(donec)
- }()
- for resp := range wch {
- for _, ev := range s.mkV2Events(resp) {
- k := ev.Node.Key
- if recursive {
- if !strings.HasPrefix(k, prefix) {
- continue
- }
- // accept events on hidden keys given in prefix
- k = strings.Replace(k, prefix, "/", 1)
- // ignore hidden keys deeper than prefix
- if strings.Contains(k, "/_") {
- continue
- }
- }
- if !recursive && k != prefix {
- continue
- }
- select {
- case evc <- ev:
- case <-ctx.Done():
- return
- }
- if !stream {
- return
- }
- }
- }
- }()
-
- return &v2v3Watcher{
- startRev: resp.Header.Revision,
- evc: evc,
- donec: donec,
- cancel: cancel,
- }, nil
-}
-
-func (s *v2v3Store) mkV2Events(wr clientv3.WatchResponse) (evs []*v2store.Event) {
- ak := s.mkActionKey()
- for _, rev := range mkRevs(wr) {
- var act, key *clientv3.Event
- for _, ev := range rev {
- if string(ev.Kv.Key) == ak {
- act = ev
- } else if key != nil && len(key.Kv.Key) < len(ev.Kv.Key) {
- // use longest key to ignore intermediate new
- // directories from Create.
- key = ev
- } else if key == nil {
- key = ev
- }
- }
- v2ev := &v2store.Event{
- Action: string(act.Kv.Value),
- Node: s.mkV2Node(key.Kv),
- PrevNode: s.mkV2Node(key.PrevKv),
- EtcdIndex: mkV2Rev(wr.Header.Revision),
- }
- evs = append(evs, v2ev)
- }
- return evs
-}
-
-func mkRevs(wr clientv3.WatchResponse) (revs [][]*clientv3.Event) {
- var curRev []*clientv3.Event
- for _, ev := range wr.Events {
- if curRev != nil && ev.Kv.ModRevision != curRev[0].Kv.ModRevision {
- revs = append(revs, curRev)
- curRev = nil
- }
- curRev = append(curRev, ev)
- }
- if curRev != nil {
- revs = append(revs, curRev)
- }
- return revs
-}
-
-type v2v3Watcher struct {
- startRev int64
- evc chan *v2store.Event
- donec chan struct{}
- cancel context.CancelFunc
-}
-
-func (w *v2v3Watcher) StartIndex() uint64 { return mkV2Rev(w.startRev) }
-
-func (w *v2v3Watcher) Remove() {
- w.cancel()
- <-w.donec
-}
-
-func (w *v2v3Watcher) EventChan() chan *v2store.Event { return w.evc }
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3alarm/alarms.go b/vendor/go.etcd.io/etcd/etcdserver/api/v3alarm/alarms.go
deleted file mode 100644
index 2b085a8..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3alarm/alarms.go
+++ /dev/null
@@ -1,153 +0,0 @@
-// Copyright 2016 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package v3alarm manages health status alarms in etcd.
-package v3alarm
-
-import (
- "sync"
-
- pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
- "go.etcd.io/etcd/mvcc/backend"
- "go.etcd.io/etcd/pkg/types"
-
- "github.com/coreos/pkg/capnslog"
-)
-
-var (
- alarmBucketName = []byte("alarm")
- plog = capnslog.NewPackageLogger("go.etcd.io/etcd", "alarm")
-)
-
-type BackendGetter interface {
- Backend() backend.Backend
-}
-
-type alarmSet map[types.ID]*pb.AlarmMember
-
-// AlarmStore persists alarms to the backend.
-type AlarmStore struct {
- mu sync.Mutex
- types map[pb.AlarmType]alarmSet
-
- bg BackendGetter
-}
-
-func NewAlarmStore(bg BackendGetter) (*AlarmStore, error) {
- ret := &AlarmStore{types: make(map[pb.AlarmType]alarmSet), bg: bg}
- err := ret.restore()
- return ret, err
-}
-
-func (a *AlarmStore) Activate(id types.ID, at pb.AlarmType) *pb.AlarmMember {
- a.mu.Lock()
- defer a.mu.Unlock()
-
- newAlarm := &pb.AlarmMember{MemberID: uint64(id), Alarm: at}
- if m := a.addToMap(newAlarm); m != newAlarm {
- return m
- }
-
- v, err := newAlarm.Marshal()
- if err != nil {
- plog.Panicf("failed to marshal alarm member")
- }
-
- b := a.bg.Backend()
- b.BatchTx().Lock()
- b.BatchTx().UnsafePut(alarmBucketName, v, nil)
- b.BatchTx().Unlock()
-
- return newAlarm
-}
-
-func (a *AlarmStore) Deactivate(id types.ID, at pb.AlarmType) *pb.AlarmMember {
- a.mu.Lock()
- defer a.mu.Unlock()
-
- t := a.types[at]
- if t == nil {
- t = make(alarmSet)
- a.types[at] = t
- }
- m := t[id]
- if m == nil {
- return nil
- }
-
- delete(t, id)
-
- v, err := m.Marshal()
- if err != nil {
- plog.Panicf("failed to marshal alarm member")
- }
-
- b := a.bg.Backend()
- b.BatchTx().Lock()
- b.BatchTx().UnsafeDelete(alarmBucketName, v)
- b.BatchTx().Unlock()
-
- return m
-}
-
-func (a *AlarmStore) Get(at pb.AlarmType) (ret []*pb.AlarmMember) {
- a.mu.Lock()
- defer a.mu.Unlock()
- if at == pb.AlarmType_NONE {
- for _, t := range a.types {
- for _, m := range t {
- ret = append(ret, m)
- }
- }
- return ret
- }
- for _, m := range a.types[at] {
- ret = append(ret, m)
- }
- return ret
-}
-
-func (a *AlarmStore) restore() error {
- b := a.bg.Backend()
- tx := b.BatchTx()
-
- tx.Lock()
- tx.UnsafeCreateBucket(alarmBucketName)
- err := tx.UnsafeForEach(alarmBucketName, func(k, v []byte) error {
- var m pb.AlarmMember
- if err := m.Unmarshal(k); err != nil {
- return err
- }
- a.addToMap(&m)
- return nil
- })
- tx.Unlock()
-
- b.ForceCommit()
- return err
-}
-
-func (a *AlarmStore) addToMap(newAlarm *pb.AlarmMember) *pb.AlarmMember {
- t := a.types[newAlarm.Alarm]
- if t == nil {
- t = make(alarmSet)
- a.types[newAlarm.Alarm] = t
- }
- m := t[types.ID(newAlarm.MemberID)]
- if m != nil {
- return m
- }
- t[types.ID(newAlarm.MemberID)] = newAlarm
- return newAlarm
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3client/doc.go b/vendor/go.etcd.io/etcd/etcdserver/api/v3client/doc.go
deleted file mode 100644
index 47922c4..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3client/doc.go
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2017 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package v3client provides clientv3 interfaces from an etcdserver.
-//
-// Use v3client by creating an EtcdServer instance, then wrapping it with v3client.New:
-//
-// import (
-// "context"
-//
-// "go.etcd.io/etcd/embed"
-// "go.etcd.io/etcd/etcdserver/api/v3client"
-// )
-//
-// ...
-//
-// // create an embedded EtcdServer from the default configuration
-// cfg := embed.NewConfig()
-// cfg.Dir = "default.etcd"
-// e, err := embed.StartEtcd(cfg)
-// if err != nil {
-// // handle error!
-// }
-//
-// // wrap the EtcdServer with v3client
-// cli := v3client.New(e.Server)
-//
-// // use like an ordinary clientv3
-// resp, err := cli.Put(context.TODO(), "some-key", "it works!")
-// if err != nil {
-// // handle error!
-// }
-//
-package v3client
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3client/v3client.go b/vendor/go.etcd.io/etcd/etcdserver/api/v3client/v3client.go
deleted file mode 100644
index d203121..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3client/v3client.go
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright 2017 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v3client
-
-import (
- "context"
- "time"
-
- "go.etcd.io/etcd/clientv3"
- "go.etcd.io/etcd/etcdserver"
- "go.etcd.io/etcd/etcdserver/api/v3rpc"
- "go.etcd.io/etcd/proxy/grpcproxy/adapter"
-)
-
-// New creates a clientv3 client that wraps an in-process EtcdServer. Instead
-// of making gRPC calls through sockets, the client makes direct function calls
-// to the etcd server through its api/v3rpc function interfaces.
-func New(s *etcdserver.EtcdServer) *clientv3.Client {
- c := clientv3.NewCtxClient(context.Background())
-
- kvc := adapter.KvServerToKvClient(v3rpc.NewQuotaKVServer(s))
- c.KV = clientv3.NewKVFromKVClient(kvc, c)
-
- lc := adapter.LeaseServerToLeaseClient(v3rpc.NewQuotaLeaseServer(s))
- c.Lease = clientv3.NewLeaseFromLeaseClient(lc, c, time.Second)
-
- wc := adapter.WatchServerToWatchClient(v3rpc.NewWatchServer(s))
- c.Watcher = &watchWrapper{clientv3.NewWatchFromWatchClient(wc, c)}
-
- mc := adapter.MaintenanceServerToMaintenanceClient(v3rpc.NewMaintenanceServer(s))
- c.Maintenance = clientv3.NewMaintenanceFromMaintenanceClient(mc, c)
-
- clc := adapter.ClusterServerToClusterClient(v3rpc.NewClusterServer(s))
- c.Cluster = clientv3.NewClusterFromClusterClient(clc, c)
-
- // TODO: implement clientv3.Auth interface?
-
- return c
-}
-
-// BlankContext implements Stringer on a context so the ctx string doesn't
-// depend on the context's WithValue data, which tends to be unsynchronized
-// (e.g., x/net/trace), causing ctx.String() to throw data races.
-type blankContext struct{ context.Context }
-
-func (*blankContext) String() string { return "(blankCtx)" }
-
-// watchWrapper wraps clientv3 watch calls to blank out the context
-// to avoid races on trace data.
-type watchWrapper struct{ clientv3.Watcher }
-
-func (ww *watchWrapper) Watch(ctx context.Context, key string, opts ...clientv3.OpOption) clientv3.WatchChan {
- return ww.Watcher.Watch(&blankContext{ctx}, key, opts...)
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3compactor/compactor.go b/vendor/go.etcd.io/etcd/etcdserver/api/v3compactor/compactor.go
deleted file mode 100644
index 73a9684..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3compactor/compactor.go
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright 2016 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v3compactor
-
-import (
- "context"
- "fmt"
- "time"
-
- pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
-
- "github.com/coreos/pkg/capnslog"
- "github.com/jonboulle/clockwork"
- "go.uber.org/zap"
-)
-
-var (
- plog = capnslog.NewPackageLogger("go.etcd.io/etcd", "compactor")
-)
-
-const (
- ModePeriodic = "periodic"
- ModeRevision = "revision"
-)
-
-// Compactor purges old log from the storage periodically.
-type Compactor interface {
- // Run starts the main loop of the compactor in background.
- // Use Stop() to halt the loop and release the resource.
- Run()
- // Stop halts the main loop of the compactor.
- Stop()
- // Pause temporally suspend the compactor not to run compaction. Resume() to unpose.
- Pause()
- // Resume restarts the compactor suspended by Pause().
- Resume()
-}
-
-type Compactable interface {
- Compact(ctx context.Context, r *pb.CompactionRequest) (*pb.CompactionResponse, error)
-}
-
-type RevGetter interface {
- Rev() int64
-}
-
-// New returns a new Compactor based on given "mode".
-func New(
- lg *zap.Logger,
- mode string,
- retention time.Duration,
- rg RevGetter,
- c Compactable,
-) (Compactor, error) {
- switch mode {
- case ModePeriodic:
- return newPeriodic(lg, clockwork.NewRealClock(), retention, rg, c), nil
- case ModeRevision:
- return newRevision(lg, clockwork.NewRealClock(), int64(retention), rg, c), nil
- default:
- return nil, fmt.Errorf("unsupported compaction mode %s", mode)
- }
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3compactor/doc.go b/vendor/go.etcd.io/etcd/etcdserver/api/v3compactor/doc.go
deleted file mode 100644
index bb28046..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3compactor/doc.go
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2016 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package v3compactor implements automated policies for compacting etcd's mvcc storage.
-package v3compactor
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3compactor/periodic.go b/vendor/go.etcd.io/etcd/etcdserver/api/v3compactor/periodic.go
deleted file mode 100644
index ab64cb7..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3compactor/periodic.go
+++ /dev/null
@@ -1,217 +0,0 @@
-// Copyright 2017 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v3compactor
-
-import (
- "context"
- "sync"
- "time"
-
- pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
- "go.etcd.io/etcd/mvcc"
-
- "github.com/jonboulle/clockwork"
- "go.uber.org/zap"
-)
-
-// Periodic compacts the log by purging revisions older than
-// the configured retention time.
-type Periodic struct {
- lg *zap.Logger
- clock clockwork.Clock
- period time.Duration
-
- rg RevGetter
- c Compactable
-
- revs []int64
- ctx context.Context
- cancel context.CancelFunc
-
- // mu protects paused
- mu sync.RWMutex
- paused bool
-}
-
-// newPeriodic creates a new instance of Periodic compactor that purges
-// the log older than h Duration.
-func newPeriodic(lg *zap.Logger, clock clockwork.Clock, h time.Duration, rg RevGetter, c Compactable) *Periodic {
- pc := &Periodic{
- lg: lg,
- clock: clock,
- period: h,
- rg: rg,
- c: c,
- revs: make([]int64, 0),
- }
- pc.ctx, pc.cancel = context.WithCancel(context.Background())
- return pc
-}
-
-/*
-Compaction period 1-hour:
- 1. compute compaction period, which is 1-hour
- 2. record revisions for every 1/10 of 1-hour (6-minute)
- 3. keep recording revisions with no compaction for first 1-hour
- 4. do compact with revs[0]
- - success? contiue on for-loop and move sliding window; revs = revs[1:]
- - failure? update revs, and retry after 1/10 of 1-hour (6-minute)
-
-Compaction period 24-hour:
- 1. compute compaction period, which is 1-hour
- 2. record revisions for every 1/10 of 1-hour (6-minute)
- 3. keep recording revisions with no compaction for first 24-hour
- 4. do compact with revs[0]
- - success? contiue on for-loop and move sliding window; revs = revs[1:]
- - failure? update revs, and retry after 1/10 of 1-hour (6-minute)
-
-Compaction period 59-min:
- 1. compute compaction period, which is 59-min
- 2. record revisions for every 1/10 of 59-min (5.9-min)
- 3. keep recording revisions with no compaction for first 59-min
- 4. do compact with revs[0]
- - success? contiue on for-loop and move sliding window; revs = revs[1:]
- - failure? update revs, and retry after 1/10 of 59-min (5.9-min)
-
-Compaction period 5-sec:
- 1. compute compaction period, which is 5-sec
- 2. record revisions for every 1/10 of 5-sec (0.5-sec)
- 3. keep recording revisions with no compaction for first 5-sec
- 4. do compact with revs[0]
- - success? contiue on for-loop and move sliding window; revs = revs[1:]
- - failure? update revs, and retry after 1/10 of 5-sec (0.5-sec)
-*/
-
-// Run runs periodic compactor.
-func (pc *Periodic) Run() {
- compactInterval := pc.getCompactInterval()
- retryInterval := pc.getRetryInterval()
- retentions := pc.getRetentions()
-
- go func() {
- lastSuccess := pc.clock.Now()
- baseInterval := pc.period
- for {
- pc.revs = append(pc.revs, pc.rg.Rev())
- if len(pc.revs) > retentions {
- pc.revs = pc.revs[1:] // pc.revs[0] is always the rev at pc.period ago
- }
-
- select {
- case <-pc.ctx.Done():
- return
- case <-pc.clock.After(retryInterval):
- pc.mu.Lock()
- p := pc.paused
- pc.mu.Unlock()
- if p {
- continue
- }
- }
-
- if pc.clock.Now().Sub(lastSuccess) < baseInterval {
- continue
- }
-
- // wait up to initial given period
- if baseInterval == pc.period {
- baseInterval = compactInterval
- }
- rev := pc.revs[0]
-
- if pc.lg != nil {
- pc.lg.Info(
- "starting auto periodic compaction",
- zap.Int64("revision", rev),
- zap.Duration("compact-period", pc.period),
- )
- } else {
- plog.Noticef("Starting auto-compaction at revision %d (retention: %v)", rev, pc.period)
- }
- _, err := pc.c.Compact(pc.ctx, &pb.CompactionRequest{Revision: rev})
- if err == nil || err == mvcc.ErrCompacted {
- if pc.lg != nil {
- pc.lg.Info(
- "completed auto periodic compaction",
- zap.Int64("revision", rev),
- zap.Duration("compact-period", pc.period),
- zap.Duration("took", time.Since(lastSuccess)),
- )
- } else {
- plog.Noticef("Finished auto-compaction at revision %d", rev)
- }
- lastSuccess = pc.clock.Now()
- } else {
- if pc.lg != nil {
- pc.lg.Warn(
- "failed auto periodic compaction",
- zap.Int64("revision", rev),
- zap.Duration("compact-period", pc.period),
- zap.Duration("retry-interval", retryInterval),
- zap.Error(err),
- )
- } else {
- plog.Noticef("Failed auto-compaction at revision %d (%v)", rev, err)
- plog.Noticef("Retry after %v", retryInterval)
- }
- }
- }
- }()
-}
-
-// if given compaction period x is <1-hour, compact every x duration.
-// (e.g. --auto-compaction-mode 'periodic' --auto-compaction-retention='10m', then compact every 10-minute)
-// if given compaction period x is >1-hour, compact every hour.
-// (e.g. --auto-compaction-mode 'periodic' --auto-compaction-retention='2h', then compact every 1-hour)
-func (pc *Periodic) getCompactInterval() time.Duration {
- itv := pc.period
- if itv > time.Hour {
- itv = time.Hour
- }
- return itv
-}
-
-func (pc *Periodic) getRetentions() int {
- return int(pc.period/pc.getRetryInterval()) + 1
-}
-
-const retryDivisor = 10
-
-func (pc *Periodic) getRetryInterval() time.Duration {
- itv := pc.period
- if itv > time.Hour {
- itv = time.Hour
- }
- return itv / retryDivisor
-}
-
-// Stop stops periodic compactor.
-func (pc *Periodic) Stop() {
- pc.cancel()
-}
-
-// Pause pauses periodic compactor.
-func (pc *Periodic) Pause() {
- pc.mu.Lock()
- pc.paused = true
- pc.mu.Unlock()
-}
-
-// Resume resumes periodic compactor.
-func (pc *Periodic) Resume() {
- pc.mu.Lock()
- pc.paused = false
- pc.mu.Unlock()
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3compactor/revision.go b/vendor/go.etcd.io/etcd/etcdserver/api/v3compactor/revision.go
deleted file mode 100644
index cf8ac43..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3compactor/revision.go
+++ /dev/null
@@ -1,143 +0,0 @@
-// Copyright 2017 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v3compactor
-
-import (
- "context"
- "sync"
- "time"
-
- pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
- "go.etcd.io/etcd/mvcc"
-
- "github.com/jonboulle/clockwork"
- "go.uber.org/zap"
-)
-
-// Revision compacts the log by purging revisions older than
-// the configured reivison number. Compaction happens every 5 minutes.
-type Revision struct {
- lg *zap.Logger
-
- clock clockwork.Clock
- retention int64
-
- rg RevGetter
- c Compactable
-
- ctx context.Context
- cancel context.CancelFunc
-
- mu sync.Mutex
- paused bool
-}
-
-// newRevision creates a new instance of Revisonal compactor that purges
-// the log older than retention revisions from the current revision.
-func newRevision(lg *zap.Logger, clock clockwork.Clock, retention int64, rg RevGetter, c Compactable) *Revision {
- rc := &Revision{
- lg: lg,
- clock: clock,
- retention: retention,
- rg: rg,
- c: c,
- }
- rc.ctx, rc.cancel = context.WithCancel(context.Background())
- return rc
-}
-
-const revInterval = 5 * time.Minute
-
-// Run runs revision-based compactor.
-func (rc *Revision) Run() {
- prev := int64(0)
- go func() {
- for {
- select {
- case <-rc.ctx.Done():
- return
- case <-rc.clock.After(revInterval):
- rc.mu.Lock()
- p := rc.paused
- rc.mu.Unlock()
- if p {
- continue
- }
- }
-
- rev := rc.rg.Rev() - rc.retention
- if rev <= 0 || rev == prev {
- continue
- }
-
- now := time.Now()
- if rc.lg != nil {
- rc.lg.Info(
- "starting auto revision compaction",
- zap.Int64("revision", rev),
- zap.Int64("revision-compaction-retention", rc.retention),
- )
- } else {
- plog.Noticef("Starting auto-compaction at revision %d (retention: %d revisions)", rev, rc.retention)
- }
- _, err := rc.c.Compact(rc.ctx, &pb.CompactionRequest{Revision: rev})
- if err == nil || err == mvcc.ErrCompacted {
- prev = rev
- if rc.lg != nil {
- rc.lg.Info(
- "completed auto revision compaction",
- zap.Int64("revision", rev),
- zap.Int64("revision-compaction-retention", rc.retention),
- zap.Duration("took", time.Since(now)),
- )
- } else {
- plog.Noticef("Finished auto-compaction at revision %d", rev)
- }
- } else {
- if rc.lg != nil {
- rc.lg.Warn(
- "failed auto revision compaction",
- zap.Int64("revision", rev),
- zap.Int64("revision-compaction-retention", rc.retention),
- zap.Duration("retry-interval", revInterval),
- zap.Error(err),
- )
- } else {
- plog.Noticef("Failed auto-compaction at revision %d (%v)", rev, err)
- plog.Noticef("Retry after %v", revInterval)
- }
- }
- }
- }()
-}
-
-// Stop stops revision-based compactor.
-func (rc *Revision) Stop() {
- rc.cancel()
-}
-
-// Pause pauses revision-based compactor.
-func (rc *Revision) Pause() {
- rc.mu.Lock()
- rc.paused = true
- rc.mu.Unlock()
-}
-
-// Resume resumes revision-based compactor.
-func (rc *Revision) Resume() {
- rc.mu.Lock()
- rc.paused = false
- rc.mu.Unlock()
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3election/doc.go b/vendor/go.etcd.io/etcd/etcdserver/api/v3election/doc.go
deleted file mode 100644
index d6fefd7..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3election/doc.go
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2017 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package v3election provides a v3 election service from an etcdserver.
-package v3election
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3election/election.go b/vendor/go.etcd.io/etcd/etcdserver/api/v3election/election.go
deleted file mode 100644
index f5a3be3..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3election/election.go
+++ /dev/null
@@ -1,134 +0,0 @@
-// Copyright 2017 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v3election
-
-import (
- "context"
- "errors"
-
- "go.etcd.io/etcd/clientv3"
- "go.etcd.io/etcd/clientv3/concurrency"
- epb "go.etcd.io/etcd/etcdserver/api/v3election/v3electionpb"
-)
-
-// ErrMissingLeaderKey is returned when election API request
-// is missing the "leader" field.
-var ErrMissingLeaderKey = errors.New(`"leader" field must be provided`)
-
-type electionServer struct {
- c *clientv3.Client
-}
-
-func NewElectionServer(c *clientv3.Client) epb.ElectionServer {
- return &electionServer{c}
-}
-
-func (es *electionServer) Campaign(ctx context.Context, req *epb.CampaignRequest) (*epb.CampaignResponse, error) {
- s, err := es.session(ctx, req.Lease)
- if err != nil {
- return nil, err
- }
- e := concurrency.NewElection(s, string(req.Name))
- if err = e.Campaign(ctx, string(req.Value)); err != nil {
- return nil, err
- }
- return &epb.CampaignResponse{
- Header: e.Header(),
- Leader: &epb.LeaderKey{
- Name: req.Name,
- Key: []byte(e.Key()),
- Rev: e.Rev(),
- Lease: int64(s.Lease()),
- },
- }, nil
-}
-
-func (es *electionServer) Proclaim(ctx context.Context, req *epb.ProclaimRequest) (*epb.ProclaimResponse, error) {
- if req.Leader == nil {
- return nil, ErrMissingLeaderKey
- }
- s, err := es.session(ctx, req.Leader.Lease)
- if err != nil {
- return nil, err
- }
- e := concurrency.ResumeElection(s, string(req.Leader.Name), string(req.Leader.Key), req.Leader.Rev)
- if err := e.Proclaim(ctx, string(req.Value)); err != nil {
- return nil, err
- }
- return &epb.ProclaimResponse{Header: e.Header()}, nil
-}
-
-func (es *electionServer) Observe(req *epb.LeaderRequest, stream epb.Election_ObserveServer) error {
- s, err := es.session(stream.Context(), -1)
- if err != nil {
- return err
- }
- e := concurrency.NewElection(s, string(req.Name))
- ch := e.Observe(stream.Context())
- for stream.Context().Err() == nil {
- select {
- case <-stream.Context().Done():
- case resp, ok := <-ch:
- if !ok {
- return nil
- }
- lresp := &epb.LeaderResponse{Header: resp.Header, Kv: resp.Kvs[0]}
- if err := stream.Send(lresp); err != nil {
- return err
- }
- }
- }
- return stream.Context().Err()
-}
-
-func (es *electionServer) Leader(ctx context.Context, req *epb.LeaderRequest) (*epb.LeaderResponse, error) {
- s, err := es.session(ctx, -1)
- if err != nil {
- return nil, err
- }
- l, lerr := concurrency.NewElection(s, string(req.Name)).Leader(ctx)
- if lerr != nil {
- return nil, lerr
- }
- return &epb.LeaderResponse{Header: l.Header, Kv: l.Kvs[0]}, nil
-}
-
-func (es *electionServer) Resign(ctx context.Context, req *epb.ResignRequest) (*epb.ResignResponse, error) {
- if req.Leader == nil {
- return nil, ErrMissingLeaderKey
- }
- s, err := es.session(ctx, req.Leader.Lease)
- if err != nil {
- return nil, err
- }
- e := concurrency.ResumeElection(s, string(req.Leader.Name), string(req.Leader.Key), req.Leader.Rev)
- if err := e.Resign(ctx); err != nil {
- return nil, err
- }
- return &epb.ResignResponse{Header: e.Header()}, nil
-}
-
-func (es *electionServer) session(ctx context.Context, lease int64) (*concurrency.Session, error) {
- s, err := concurrency.NewSession(
- es.c,
- concurrency.WithLease(clientv3.LeaseID(lease)),
- concurrency.WithContext(ctx),
- )
- if err != nil {
- return nil, err
- }
- s.Orphan()
- return s, nil
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3election/v3electionpb/gw/v3election.pb.gw.go b/vendor/go.etcd.io/etcd/etcdserver/api/v3election/v3electionpb/gw/v3election.pb.gw.go
deleted file mode 100644
index 23551b5..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3election/v3electionpb/gw/v3election.pb.gw.go
+++ /dev/null
@@ -1,313 +0,0 @@
-// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
-// source: etcdserver/api/v3election/v3electionpb/v3election.proto
-
-/*
-Package v3electionpb is a reverse proxy.
-
-It translates gRPC into RESTful JSON APIs.
-*/
-package gw
-
-import (
- "go.etcd.io/etcd/etcdserver/api/v3election/v3electionpb"
- "io"
- "net/http"
-
- "github.com/golang/protobuf/proto"
- "github.com/grpc-ecosystem/grpc-gateway/runtime"
- "github.com/grpc-ecosystem/grpc-gateway/utilities"
- "golang.org/x/net/context"
- "google.golang.org/grpc"
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/grpclog"
- "google.golang.org/grpc/status"
-)
-
-var _ codes.Code
-var _ io.Reader
-var _ status.Status
-var _ = runtime.String
-var _ = utilities.NewDoubleArray
-
-func request_Election_Campaign_0(ctx context.Context, marshaler runtime.Marshaler, client v3electionpb.ElectionClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq v3electionpb.CampaignRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.Campaign(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Election_Proclaim_0(ctx context.Context, marshaler runtime.Marshaler, client v3electionpb.ElectionClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq v3electionpb.ProclaimRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.Proclaim(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Election_Leader_0(ctx context.Context, marshaler runtime.Marshaler, client v3electionpb.ElectionClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq v3electionpb.LeaderRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.Leader(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Election_Observe_0(ctx context.Context, marshaler runtime.Marshaler, client v3electionpb.ElectionClient, req *http.Request, pathParams map[string]string) (v3electionpb.Election_ObserveClient, runtime.ServerMetadata, error) {
- var protoReq v3electionpb.LeaderRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- stream, err := client.Observe(ctx, &protoReq)
- if err != nil {
- return nil, metadata, err
- }
- header, err := stream.Header()
- if err != nil {
- return nil, metadata, err
- }
- metadata.HeaderMD = header
- return stream, metadata, nil
-
-}
-
-func request_Election_Resign_0(ctx context.Context, marshaler runtime.Marshaler, client v3electionpb.ElectionClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq v3electionpb.ResignRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.Resign(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-// RegisterElectionHandlerFromEndpoint is same as RegisterElectionHandler but
-// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
-func RegisterElectionHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
- conn, err := grpc.Dial(endpoint, opts...)
- if err != nil {
- return err
- }
- defer func() {
- if err != nil {
- if cerr := conn.Close(); cerr != nil {
- grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
- }
- return
- }
- go func() {
- <-ctx.Done()
- if cerr := conn.Close(); cerr != nil {
- grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
- }
- }()
- }()
-
- return RegisterElectionHandler(ctx, mux, conn)
-}
-
-// RegisterElectionHandler registers the http handlers for service Election to "mux".
-// The handlers forward requests to the grpc endpoint over "conn".
-func RegisterElectionHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
- return RegisterElectionHandlerClient(ctx, mux, v3electionpb.NewElectionClient(conn))
-}
-
-// RegisterElectionHandler registers the http handlers for service Election to "mux".
-// The handlers forward requests to the grpc endpoint over the given implementation of "ElectionClient".
-// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ElectionClient"
-// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
-// "ElectionClient" to call the correct interceptors.
-func RegisterElectionHandlerClient(ctx context.Context, mux *runtime.ServeMux, client v3electionpb.ElectionClient) error {
-
- mux.Handle("POST", pattern_Election_Campaign_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Election_Campaign_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Election_Campaign_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Election_Proclaim_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Election_Proclaim_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Election_Proclaim_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Election_Leader_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Election_Leader_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Election_Leader_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Election_Observe_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Election_Observe_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Election_Observe_0(ctx, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Election_Resign_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Election_Resign_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Election_Resign_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-var (
- pattern_Election_Campaign_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3", "election", "campaign"}, ""))
-
- pattern_Election_Proclaim_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3", "election", "proclaim"}, ""))
-
- pattern_Election_Leader_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3", "election", "leader"}, ""))
-
- pattern_Election_Observe_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3", "election", "observe"}, ""))
-
- pattern_Election_Resign_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3", "election", "resign"}, ""))
-)
-
-var (
- forward_Election_Campaign_0 = runtime.ForwardResponseMessage
-
- forward_Election_Proclaim_0 = runtime.ForwardResponseMessage
-
- forward_Election_Leader_0 = runtime.ForwardResponseMessage
-
- forward_Election_Observe_0 = runtime.ForwardResponseStream
-
- forward_Election_Resign_0 = runtime.ForwardResponseMessage
-)
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3election/v3electionpb/v3election.pb.go b/vendor/go.etcd.io/etcd/etcdserver/api/v3election/v3electionpb/v3election.pb.go
deleted file mode 100644
index 1fc1bce..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3election/v3electionpb/v3election.pb.go
+++ /dev/null
@@ -1,2079 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: v3election.proto
-
-/*
- Package v3electionpb is a generated protocol buffer package.
-
- It is generated from these files:
- v3election.proto
-
- It has these top-level messages:
- CampaignRequest
- CampaignResponse
- LeaderKey
- LeaderRequest
- LeaderResponse
- ResignRequest
- ResignResponse
- ProclaimRequest
- ProclaimResponse
-*/
-package v3electionpb
-
-import (
- "fmt"
-
- proto "github.com/golang/protobuf/proto"
-
- math "math"
-
- _ "github.com/gogo/protobuf/gogoproto"
-
- etcdserverpb "go.etcd.io/etcd/etcdserver/etcdserverpb"
-
- mvccpb "go.etcd.io/etcd/mvcc/mvccpb"
-
- context "golang.org/x/net/context"
-
- grpc "google.golang.org/grpc"
-
- io "io"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
-
-type CampaignRequest struct {
- // name is the election's identifier for the campaign.
- Name []byte `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
- // lease is the ID of the lease attached to leadership of the election. If the
- // lease expires or is revoked before resigning leadership, then the
- // leadership is transferred to the next campaigner, if any.
- Lease int64 `protobuf:"varint,2,opt,name=lease,proto3" json:"lease,omitempty"`
- // value is the initial proclaimed value set when the campaigner wins the
- // election.
- Value []byte `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"`
-}
-
-func (m *CampaignRequest) Reset() { *m = CampaignRequest{} }
-func (m *CampaignRequest) String() string { return proto.CompactTextString(m) }
-func (*CampaignRequest) ProtoMessage() {}
-func (*CampaignRequest) Descriptor() ([]byte, []int) { return fileDescriptorV3Election, []int{0} }
-
-func (m *CampaignRequest) GetName() []byte {
- if m != nil {
- return m.Name
- }
- return nil
-}
-
-func (m *CampaignRequest) GetLease() int64 {
- if m != nil {
- return m.Lease
- }
- return 0
-}
-
-func (m *CampaignRequest) GetValue() []byte {
- if m != nil {
- return m.Value
- }
- return nil
-}
-
-type CampaignResponse struct {
- Header *etcdserverpb.ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
- // leader describes the resources used for holding leadereship of the election.
- Leader *LeaderKey `protobuf:"bytes,2,opt,name=leader" json:"leader,omitempty"`
-}
-
-func (m *CampaignResponse) Reset() { *m = CampaignResponse{} }
-func (m *CampaignResponse) String() string { return proto.CompactTextString(m) }
-func (*CampaignResponse) ProtoMessage() {}
-func (*CampaignResponse) Descriptor() ([]byte, []int) { return fileDescriptorV3Election, []int{1} }
-
-func (m *CampaignResponse) GetHeader() *etcdserverpb.ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-func (m *CampaignResponse) GetLeader() *LeaderKey {
- if m != nil {
- return m.Leader
- }
- return nil
-}
-
-type LeaderKey struct {
- // name is the election identifier that correponds to the leadership key.
- Name []byte `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
- // key is an opaque key representing the ownership of the election. If the key
- // is deleted, then leadership is lost.
- Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"`
- // rev is the creation revision of the key. It can be used to test for ownership
- // of an election during transactions by testing the key's creation revision
- // matches rev.
- Rev int64 `protobuf:"varint,3,opt,name=rev,proto3" json:"rev,omitempty"`
- // lease is the lease ID of the election leader.
- Lease int64 `protobuf:"varint,4,opt,name=lease,proto3" json:"lease,omitempty"`
-}
-
-func (m *LeaderKey) Reset() { *m = LeaderKey{} }
-func (m *LeaderKey) String() string { return proto.CompactTextString(m) }
-func (*LeaderKey) ProtoMessage() {}
-func (*LeaderKey) Descriptor() ([]byte, []int) { return fileDescriptorV3Election, []int{2} }
-
-func (m *LeaderKey) GetName() []byte {
- if m != nil {
- return m.Name
- }
- return nil
-}
-
-func (m *LeaderKey) GetKey() []byte {
- if m != nil {
- return m.Key
- }
- return nil
-}
-
-func (m *LeaderKey) GetRev() int64 {
- if m != nil {
- return m.Rev
- }
- return 0
-}
-
-func (m *LeaderKey) GetLease() int64 {
- if m != nil {
- return m.Lease
- }
- return 0
-}
-
-type LeaderRequest struct {
- // name is the election identifier for the leadership information.
- Name []byte `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
-}
-
-func (m *LeaderRequest) Reset() { *m = LeaderRequest{} }
-func (m *LeaderRequest) String() string { return proto.CompactTextString(m) }
-func (*LeaderRequest) ProtoMessage() {}
-func (*LeaderRequest) Descriptor() ([]byte, []int) { return fileDescriptorV3Election, []int{3} }
-
-func (m *LeaderRequest) GetName() []byte {
- if m != nil {
- return m.Name
- }
- return nil
-}
-
-type LeaderResponse struct {
- Header *etcdserverpb.ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
- // kv is the key-value pair representing the latest leader update.
- Kv *mvccpb.KeyValue `protobuf:"bytes,2,opt,name=kv" json:"kv,omitempty"`
-}
-
-func (m *LeaderResponse) Reset() { *m = LeaderResponse{} }
-func (m *LeaderResponse) String() string { return proto.CompactTextString(m) }
-func (*LeaderResponse) ProtoMessage() {}
-func (*LeaderResponse) Descriptor() ([]byte, []int) { return fileDescriptorV3Election, []int{4} }
-
-func (m *LeaderResponse) GetHeader() *etcdserverpb.ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-func (m *LeaderResponse) GetKv() *mvccpb.KeyValue {
- if m != nil {
- return m.Kv
- }
- return nil
-}
-
-type ResignRequest struct {
- // leader is the leadership to relinquish by resignation.
- Leader *LeaderKey `protobuf:"bytes,1,opt,name=leader" json:"leader,omitempty"`
-}
-
-func (m *ResignRequest) Reset() { *m = ResignRequest{} }
-func (m *ResignRequest) String() string { return proto.CompactTextString(m) }
-func (*ResignRequest) ProtoMessage() {}
-func (*ResignRequest) Descriptor() ([]byte, []int) { return fileDescriptorV3Election, []int{5} }
-
-func (m *ResignRequest) GetLeader() *LeaderKey {
- if m != nil {
- return m.Leader
- }
- return nil
-}
-
-type ResignResponse struct {
- Header *etcdserverpb.ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
-}
-
-func (m *ResignResponse) Reset() { *m = ResignResponse{} }
-func (m *ResignResponse) String() string { return proto.CompactTextString(m) }
-func (*ResignResponse) ProtoMessage() {}
-func (*ResignResponse) Descriptor() ([]byte, []int) { return fileDescriptorV3Election, []int{6} }
-
-func (m *ResignResponse) GetHeader() *etcdserverpb.ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-type ProclaimRequest struct {
- // leader is the leadership hold on the election.
- Leader *LeaderKey `protobuf:"bytes,1,opt,name=leader" json:"leader,omitempty"`
- // value is an update meant to overwrite the leader's current value.
- Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
-}
-
-func (m *ProclaimRequest) Reset() { *m = ProclaimRequest{} }
-func (m *ProclaimRequest) String() string { return proto.CompactTextString(m) }
-func (*ProclaimRequest) ProtoMessage() {}
-func (*ProclaimRequest) Descriptor() ([]byte, []int) { return fileDescriptorV3Election, []int{7} }
-
-func (m *ProclaimRequest) GetLeader() *LeaderKey {
- if m != nil {
- return m.Leader
- }
- return nil
-}
-
-func (m *ProclaimRequest) GetValue() []byte {
- if m != nil {
- return m.Value
- }
- return nil
-}
-
-type ProclaimResponse struct {
- Header *etcdserverpb.ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
-}
-
-func (m *ProclaimResponse) Reset() { *m = ProclaimResponse{} }
-func (m *ProclaimResponse) String() string { return proto.CompactTextString(m) }
-func (*ProclaimResponse) ProtoMessage() {}
-func (*ProclaimResponse) Descriptor() ([]byte, []int) { return fileDescriptorV3Election, []int{8} }
-
-func (m *ProclaimResponse) GetHeader() *etcdserverpb.ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-func init() {
- proto.RegisterType((*CampaignRequest)(nil), "v3electionpb.CampaignRequest")
- proto.RegisterType((*CampaignResponse)(nil), "v3electionpb.CampaignResponse")
- proto.RegisterType((*LeaderKey)(nil), "v3electionpb.LeaderKey")
- proto.RegisterType((*LeaderRequest)(nil), "v3electionpb.LeaderRequest")
- proto.RegisterType((*LeaderResponse)(nil), "v3electionpb.LeaderResponse")
- proto.RegisterType((*ResignRequest)(nil), "v3electionpb.ResignRequest")
- proto.RegisterType((*ResignResponse)(nil), "v3electionpb.ResignResponse")
- proto.RegisterType((*ProclaimRequest)(nil), "v3electionpb.ProclaimRequest")
- proto.RegisterType((*ProclaimResponse)(nil), "v3electionpb.ProclaimResponse")
-}
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ context.Context
-var _ grpc.ClientConn
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the grpc package it is being compiled against.
-const _ = grpc.SupportPackageIsVersion4
-
-// Client API for Election service
-
-type ElectionClient interface {
- // Campaign waits to acquire leadership in an election, returning a LeaderKey
- // representing the leadership if successful. The LeaderKey can then be used
- // to issue new values on the election, transactionally guard API requests on
- // leadership still being held, and resign from the election.
- Campaign(ctx context.Context, in *CampaignRequest, opts ...grpc.CallOption) (*CampaignResponse, error)
- // Proclaim updates the leader's posted value with a new value.
- Proclaim(ctx context.Context, in *ProclaimRequest, opts ...grpc.CallOption) (*ProclaimResponse, error)
- // Leader returns the current election proclamation, if any.
- Leader(ctx context.Context, in *LeaderRequest, opts ...grpc.CallOption) (*LeaderResponse, error)
- // Observe streams election proclamations in-order as made by the election's
- // elected leaders.
- Observe(ctx context.Context, in *LeaderRequest, opts ...grpc.CallOption) (Election_ObserveClient, error)
- // Resign releases election leadership so other campaigners may acquire
- // leadership on the election.
- Resign(ctx context.Context, in *ResignRequest, opts ...grpc.CallOption) (*ResignResponse, error)
-}
-
-type electionClient struct {
- cc *grpc.ClientConn
-}
-
-func NewElectionClient(cc *grpc.ClientConn) ElectionClient {
- return &electionClient{cc}
-}
-
-func (c *electionClient) Campaign(ctx context.Context, in *CampaignRequest, opts ...grpc.CallOption) (*CampaignResponse, error) {
- out := new(CampaignResponse)
- err := grpc.Invoke(ctx, "/v3electionpb.Election/Campaign", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *electionClient) Proclaim(ctx context.Context, in *ProclaimRequest, opts ...grpc.CallOption) (*ProclaimResponse, error) {
- out := new(ProclaimResponse)
- err := grpc.Invoke(ctx, "/v3electionpb.Election/Proclaim", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *electionClient) Leader(ctx context.Context, in *LeaderRequest, opts ...grpc.CallOption) (*LeaderResponse, error) {
- out := new(LeaderResponse)
- err := grpc.Invoke(ctx, "/v3electionpb.Election/Leader", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *electionClient) Observe(ctx context.Context, in *LeaderRequest, opts ...grpc.CallOption) (Election_ObserveClient, error) {
- stream, err := grpc.NewClientStream(ctx, &_Election_serviceDesc.Streams[0], c.cc, "/v3electionpb.Election/Observe", opts...)
- if err != nil {
- return nil, err
- }
- x := &electionObserveClient{stream}
- if err := x.ClientStream.SendMsg(in); err != nil {
- return nil, err
- }
- if err := x.ClientStream.CloseSend(); err != nil {
- return nil, err
- }
- return x, nil
-}
-
-type Election_ObserveClient interface {
- Recv() (*LeaderResponse, error)
- grpc.ClientStream
-}
-
-type electionObserveClient struct {
- grpc.ClientStream
-}
-
-func (x *electionObserveClient) Recv() (*LeaderResponse, error) {
- m := new(LeaderResponse)
- if err := x.ClientStream.RecvMsg(m); err != nil {
- return nil, err
- }
- return m, nil
-}
-
-func (c *electionClient) Resign(ctx context.Context, in *ResignRequest, opts ...grpc.CallOption) (*ResignResponse, error) {
- out := new(ResignResponse)
- err := grpc.Invoke(ctx, "/v3electionpb.Election/Resign", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-// Server API for Election service
-
-type ElectionServer interface {
- // Campaign waits to acquire leadership in an election, returning a LeaderKey
- // representing the leadership if successful. The LeaderKey can then be used
- // to issue new values on the election, transactionally guard API requests on
- // leadership still being held, and resign from the election.
- Campaign(context.Context, *CampaignRequest) (*CampaignResponse, error)
- // Proclaim updates the leader's posted value with a new value.
- Proclaim(context.Context, *ProclaimRequest) (*ProclaimResponse, error)
- // Leader returns the current election proclamation, if any.
- Leader(context.Context, *LeaderRequest) (*LeaderResponse, error)
- // Observe streams election proclamations in-order as made by the election's
- // elected leaders.
- Observe(*LeaderRequest, Election_ObserveServer) error
- // Resign releases election leadership so other campaigners may acquire
- // leadership on the election.
- Resign(context.Context, *ResignRequest) (*ResignResponse, error)
-}
-
-func RegisterElectionServer(s *grpc.Server, srv ElectionServer) {
- s.RegisterService(&_Election_serviceDesc, srv)
-}
-
-func _Election_Campaign_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(CampaignRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(ElectionServer).Campaign(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/v3electionpb.Election/Campaign",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(ElectionServer).Campaign(ctx, req.(*CampaignRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Election_Proclaim_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(ProclaimRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(ElectionServer).Proclaim(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/v3electionpb.Election/Proclaim",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(ElectionServer).Proclaim(ctx, req.(*ProclaimRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Election_Leader_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(LeaderRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(ElectionServer).Leader(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/v3electionpb.Election/Leader",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(ElectionServer).Leader(ctx, req.(*LeaderRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Election_Observe_Handler(srv interface{}, stream grpc.ServerStream) error {
- m := new(LeaderRequest)
- if err := stream.RecvMsg(m); err != nil {
- return err
- }
- return srv.(ElectionServer).Observe(m, &electionObserveServer{stream})
-}
-
-type Election_ObserveServer interface {
- Send(*LeaderResponse) error
- grpc.ServerStream
-}
-
-type electionObserveServer struct {
- grpc.ServerStream
-}
-
-func (x *electionObserveServer) Send(m *LeaderResponse) error {
- return x.ServerStream.SendMsg(m)
-}
-
-func _Election_Resign_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(ResignRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(ElectionServer).Resign(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/v3electionpb.Election/Resign",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(ElectionServer).Resign(ctx, req.(*ResignRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-var _Election_serviceDesc = grpc.ServiceDesc{
- ServiceName: "v3electionpb.Election",
- HandlerType: (*ElectionServer)(nil),
- Methods: []grpc.MethodDesc{
- {
- MethodName: "Campaign",
- Handler: _Election_Campaign_Handler,
- },
- {
- MethodName: "Proclaim",
- Handler: _Election_Proclaim_Handler,
- },
- {
- MethodName: "Leader",
- Handler: _Election_Leader_Handler,
- },
- {
- MethodName: "Resign",
- Handler: _Election_Resign_Handler,
- },
- },
- Streams: []grpc.StreamDesc{
- {
- StreamName: "Observe",
- Handler: _Election_Observe_Handler,
- ServerStreams: true,
- },
- },
- Metadata: "v3election.proto",
-}
-
-func (m *CampaignRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *CampaignRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if len(m.Name) > 0 {
- dAtA[i] = 0xa
- i++
- i = encodeVarintV3Election(dAtA, i, uint64(len(m.Name)))
- i += copy(dAtA[i:], m.Name)
- }
- if m.Lease != 0 {
- dAtA[i] = 0x10
- i++
- i = encodeVarintV3Election(dAtA, i, uint64(m.Lease))
- }
- if len(m.Value) > 0 {
- dAtA[i] = 0x1a
- i++
- i = encodeVarintV3Election(dAtA, i, uint64(len(m.Value)))
- i += copy(dAtA[i:], m.Value)
- }
- return i, nil
-}
-
-func (m *CampaignResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *CampaignResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintV3Election(dAtA, i, uint64(m.Header.Size()))
- n1, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n1
- }
- if m.Leader != nil {
- dAtA[i] = 0x12
- i++
- i = encodeVarintV3Election(dAtA, i, uint64(m.Leader.Size()))
- n2, err := m.Leader.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n2
- }
- return i, nil
-}
-
-func (m *LeaderKey) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *LeaderKey) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if len(m.Name) > 0 {
- dAtA[i] = 0xa
- i++
- i = encodeVarintV3Election(dAtA, i, uint64(len(m.Name)))
- i += copy(dAtA[i:], m.Name)
- }
- if len(m.Key) > 0 {
- dAtA[i] = 0x12
- i++
- i = encodeVarintV3Election(dAtA, i, uint64(len(m.Key)))
- i += copy(dAtA[i:], m.Key)
- }
- if m.Rev != 0 {
- dAtA[i] = 0x18
- i++
- i = encodeVarintV3Election(dAtA, i, uint64(m.Rev))
- }
- if m.Lease != 0 {
- dAtA[i] = 0x20
- i++
- i = encodeVarintV3Election(dAtA, i, uint64(m.Lease))
- }
- return i, nil
-}
-
-func (m *LeaderRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *LeaderRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if len(m.Name) > 0 {
- dAtA[i] = 0xa
- i++
- i = encodeVarintV3Election(dAtA, i, uint64(len(m.Name)))
- i += copy(dAtA[i:], m.Name)
- }
- return i, nil
-}
-
-func (m *LeaderResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *LeaderResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintV3Election(dAtA, i, uint64(m.Header.Size()))
- n3, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n3
- }
- if m.Kv != nil {
- dAtA[i] = 0x12
- i++
- i = encodeVarintV3Election(dAtA, i, uint64(m.Kv.Size()))
- n4, err := m.Kv.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n4
- }
- return i, nil
-}
-
-func (m *ResignRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *ResignRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Leader != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintV3Election(dAtA, i, uint64(m.Leader.Size()))
- n5, err := m.Leader.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n5
- }
- return i, nil
-}
-
-func (m *ResignResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *ResignResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintV3Election(dAtA, i, uint64(m.Header.Size()))
- n6, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n6
- }
- return i, nil
-}
-
-func (m *ProclaimRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *ProclaimRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Leader != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintV3Election(dAtA, i, uint64(m.Leader.Size()))
- n7, err := m.Leader.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n7
- }
- if len(m.Value) > 0 {
- dAtA[i] = 0x12
- i++
- i = encodeVarintV3Election(dAtA, i, uint64(len(m.Value)))
- i += copy(dAtA[i:], m.Value)
- }
- return i, nil
-}
-
-func (m *ProclaimResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *ProclaimResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintV3Election(dAtA, i, uint64(m.Header.Size()))
- n8, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n8
- }
- return i, nil
-}
-
-func encodeVarintV3Election(dAtA []byte, offset int, v uint64) int {
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return offset + 1
-}
-func (m *CampaignRequest) Size() (n int) {
- var l int
- _ = l
- l = len(m.Name)
- if l > 0 {
- n += 1 + l + sovV3Election(uint64(l))
- }
- if m.Lease != 0 {
- n += 1 + sovV3Election(uint64(m.Lease))
- }
- l = len(m.Value)
- if l > 0 {
- n += 1 + l + sovV3Election(uint64(l))
- }
- return n
-}
-
-func (m *CampaignResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovV3Election(uint64(l))
- }
- if m.Leader != nil {
- l = m.Leader.Size()
- n += 1 + l + sovV3Election(uint64(l))
- }
- return n
-}
-
-func (m *LeaderKey) Size() (n int) {
- var l int
- _ = l
- l = len(m.Name)
- if l > 0 {
- n += 1 + l + sovV3Election(uint64(l))
- }
- l = len(m.Key)
- if l > 0 {
- n += 1 + l + sovV3Election(uint64(l))
- }
- if m.Rev != 0 {
- n += 1 + sovV3Election(uint64(m.Rev))
- }
- if m.Lease != 0 {
- n += 1 + sovV3Election(uint64(m.Lease))
- }
- return n
-}
-
-func (m *LeaderRequest) Size() (n int) {
- var l int
- _ = l
- l = len(m.Name)
- if l > 0 {
- n += 1 + l + sovV3Election(uint64(l))
- }
- return n
-}
-
-func (m *LeaderResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovV3Election(uint64(l))
- }
- if m.Kv != nil {
- l = m.Kv.Size()
- n += 1 + l + sovV3Election(uint64(l))
- }
- return n
-}
-
-func (m *ResignRequest) Size() (n int) {
- var l int
- _ = l
- if m.Leader != nil {
- l = m.Leader.Size()
- n += 1 + l + sovV3Election(uint64(l))
- }
- return n
-}
-
-func (m *ResignResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovV3Election(uint64(l))
- }
- return n
-}
-
-func (m *ProclaimRequest) Size() (n int) {
- var l int
- _ = l
- if m.Leader != nil {
- l = m.Leader.Size()
- n += 1 + l + sovV3Election(uint64(l))
- }
- l = len(m.Value)
- if l > 0 {
- n += 1 + l + sovV3Election(uint64(l))
- }
- return n
-}
-
-func (m *ProclaimResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovV3Election(uint64(l))
- }
- return n
-}
-
-func sovV3Election(x uint64) (n int) {
- for {
- n++
- x >>= 7
- if x == 0 {
- break
- }
- }
- return n
-}
-func sozV3Election(x uint64) (n int) {
- return sovV3Election(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *CampaignRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Election
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: CampaignRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: CampaignRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Election
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthV3Election
- }
- postIndex := iNdEx + byteLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Name = append(m.Name[:0], dAtA[iNdEx:postIndex]...)
- if m.Name == nil {
- m.Name = []byte{}
- }
- iNdEx = postIndex
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Lease", wireType)
- }
- m.Lease = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Election
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Lease |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Election
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthV3Election
- }
- postIndex := iNdEx + byteLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...)
- if m.Value == nil {
- m.Value = []byte{}
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipV3Election(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthV3Election
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *CampaignResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Election
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: CampaignResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: CampaignResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Election
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthV3Election
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &etcdserverpb.ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Leader", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Election
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthV3Election
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Leader == nil {
- m.Leader = &LeaderKey{}
- }
- if err := m.Leader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipV3Election(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthV3Election
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *LeaderKey) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Election
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: LeaderKey: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: LeaderKey: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Election
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthV3Election
- }
- postIndex := iNdEx + byteLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Name = append(m.Name[:0], dAtA[iNdEx:postIndex]...)
- if m.Name == nil {
- m.Name = []byte{}
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Election
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthV3Election
- }
- postIndex := iNdEx + byteLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...)
- if m.Key == nil {
- m.Key = []byte{}
- }
- iNdEx = postIndex
- case 3:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Rev", wireType)
- }
- m.Rev = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Election
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Rev |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 4:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Lease", wireType)
- }
- m.Lease = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Election
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Lease |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipV3Election(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthV3Election
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *LeaderRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Election
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: LeaderRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: LeaderRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Election
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthV3Election
- }
- postIndex := iNdEx + byteLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Name = append(m.Name[:0], dAtA[iNdEx:postIndex]...)
- if m.Name == nil {
- m.Name = []byte{}
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipV3Election(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthV3Election
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *LeaderResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Election
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: LeaderResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: LeaderResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Election
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthV3Election
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &etcdserverpb.ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Kv", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Election
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthV3Election
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Kv == nil {
- m.Kv = &mvccpb.KeyValue{}
- }
- if err := m.Kv.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipV3Election(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthV3Election
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *ResignRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Election
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: ResignRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: ResignRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Leader", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Election
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthV3Election
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Leader == nil {
- m.Leader = &LeaderKey{}
- }
- if err := m.Leader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipV3Election(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthV3Election
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *ResignResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Election
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: ResignResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: ResignResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Election
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthV3Election
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &etcdserverpb.ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipV3Election(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthV3Election
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *ProclaimRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Election
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: ProclaimRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: ProclaimRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Leader", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Election
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthV3Election
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Leader == nil {
- m.Leader = &LeaderKey{}
- }
- if err := m.Leader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Election
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthV3Election
- }
- postIndex := iNdEx + byteLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...)
- if m.Value == nil {
- m.Value = []byte{}
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipV3Election(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthV3Election
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *ProclaimResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Election
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: ProclaimResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: ProclaimResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Election
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthV3Election
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &etcdserverpb.ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipV3Election(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthV3Election
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipV3Election(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowV3Election
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowV3Election
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- return iNdEx, nil
- case 1:
- iNdEx += 8
- return iNdEx, nil
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowV3Election
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- iNdEx += length
- if length < 0 {
- return 0, ErrInvalidLengthV3Election
- }
- return iNdEx, nil
- case 3:
- for {
- var innerWire uint64
- var start int = iNdEx
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowV3Election
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- innerWire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- innerWireType := int(innerWire & 0x7)
- if innerWireType == 4 {
- break
- }
- next, err := skipV3Election(dAtA[start:])
- if err != nil {
- return 0, err
- }
- iNdEx = start + next
- }
- return iNdEx, nil
- case 4:
- return iNdEx, nil
- case 5:
- iNdEx += 4
- return iNdEx, nil
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- }
- panic("unreachable")
-}
-
-var (
- ErrInvalidLengthV3Election = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowV3Election = fmt.Errorf("proto: integer overflow")
-)
-
-func init() { proto.RegisterFile("v3election.proto", fileDescriptorV3Election) }
-
-var fileDescriptorV3Election = []byte{
- // 535 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x94, 0xcf, 0x6e, 0xd3, 0x40,
- 0x10, 0xc6, 0x59, 0x27, 0x84, 0x32, 0xa4, 0xad, 0x65, 0x82, 0x48, 0x43, 0x30, 0xd1, 0x22, 0xa1,
- 0x2a, 0x07, 0x2f, 0x6a, 0x38, 0xe5, 0x84, 0x40, 0xa0, 0x4a, 0x45, 0x02, 0x7c, 0x40, 0x70, 0xdc,
- 0xb8, 0x23, 0x37, 0x8a, 0xe3, 0x35, 0xb6, 0x6b, 0x29, 0x57, 0x5e, 0x81, 0x03, 0x3c, 0x12, 0x47,
- 0x24, 0x5e, 0x00, 0x05, 0x1e, 0x04, 0xed, 0xae, 0x8d, 0xff, 0x28, 0x41, 0xa8, 0xb9, 0x58, 0xe3,
- 0x9d, 0xcf, 0xf3, 0x9b, 0x6f, 0x76, 0x12, 0x30, 0xb3, 0x09, 0x06, 0xe8, 0xa5, 0x73, 0x11, 0x3a,
- 0x51, 0x2c, 0x52, 0x61, 0x75, 0xcb, 0x93, 0x68, 0x36, 0xe8, 0xf9, 0xc2, 0x17, 0x2a, 0xc1, 0x64,
- 0xa4, 0x35, 0x83, 0x47, 0x98, 0x7a, 0xe7, 0x4c, 0x3e, 0x12, 0x8c, 0x33, 0x8c, 0x2b, 0x61, 0x34,
- 0x63, 0x71, 0xe4, 0xe5, 0xba, 0x23, 0xa5, 0x5b, 0x66, 0x9e, 0xa7, 0x1e, 0xd1, 0x8c, 0x2d, 0xb2,
- 0x3c, 0x35, 0xf4, 0x85, 0xf0, 0x03, 0x64, 0x3c, 0x9a, 0x33, 0x1e, 0x86, 0x22, 0xe5, 0x92, 0x98,
- 0xe8, 0x2c, 0x7d, 0x0b, 0x87, 0xcf, 0xf9, 0x32, 0xe2, 0x73, 0x3f, 0x74, 0xf1, 0xe3, 0x25, 0x26,
- 0xa9, 0x65, 0x41, 0x3b, 0xe4, 0x4b, 0xec, 0x93, 0x11, 0x39, 0xee, 0xba, 0x2a, 0xb6, 0x7a, 0x70,
- 0x3d, 0x40, 0x9e, 0x60, 0xdf, 0x18, 0x91, 0xe3, 0x96, 0xab, 0x5f, 0xe4, 0x69, 0xc6, 0x83, 0x4b,
- 0xec, 0xb7, 0x94, 0x54, 0xbf, 0xd0, 0x15, 0x98, 0x65, 0xc9, 0x24, 0x12, 0x61, 0x82, 0xd6, 0x13,
- 0xe8, 0x5c, 0x20, 0x3f, 0xc7, 0x58, 0x55, 0xbd, 0x75, 0x32, 0x74, 0xaa, 0x46, 0x9c, 0x42, 0x77,
- 0xaa, 0x34, 0x6e, 0xae, 0xb5, 0x18, 0x74, 0x02, 0xfd, 0x95, 0xa1, 0xbe, 0xba, 0xeb, 0x54, 0x47,
- 0xe6, 0xbc, 0x52, 0xb9, 0x33, 0x5c, 0xb9, 0xb9, 0x8c, 0x7e, 0x80, 0x9b, 0x7f, 0x0f, 0x37, 0xfa,
- 0x30, 0xa1, 0xb5, 0xc0, 0x95, 0x2a, 0xd7, 0x75, 0x65, 0x28, 0x4f, 0x62, 0xcc, 0x94, 0x83, 0x96,
- 0x2b, 0xc3, 0xd2, 0x6b, 0xbb, 0xe2, 0x95, 0x3e, 0x84, 0x7d, 0x5d, 0xfa, 0x1f, 0x63, 0xa2, 0x17,
- 0x70, 0x50, 0x88, 0x76, 0x32, 0x3e, 0x02, 0x63, 0x91, 0xe5, 0xa6, 0x4d, 0x47, 0xdf, 0xa8, 0x73,
- 0x86, 0xab, 0x77, 0x72, 0xc0, 0xae, 0xb1, 0xc8, 0xe8, 0x53, 0xd8, 0x77, 0x31, 0xa9, 0xdc, 0x5a,
- 0x39, 0x2b, 0xf2, 0x7f, 0xb3, 0x7a, 0x09, 0x07, 0x45, 0x85, 0x5d, 0x7a, 0xa5, 0xef, 0xe1, 0xf0,
- 0x4d, 0x2c, 0xbc, 0x80, 0xcf, 0x97, 0x57, 0xed, 0xa5, 0x5c, 0x24, 0xa3, 0xba, 0x48, 0xa7, 0x60,
- 0x96, 0x95, 0x77, 0xe9, 0xf1, 0xe4, 0x4b, 0x1b, 0xf6, 0x5e, 0xe4, 0x0d, 0x58, 0x0b, 0xd8, 0x2b,
- 0xf6, 0xd3, 0xba, 0x5f, 0xef, 0xac, 0xf1, 0x53, 0x18, 0xd8, 0xdb, 0xd2, 0x9a, 0x42, 0x47, 0x9f,
- 0x7e, 0xfc, 0xfe, 0x6c, 0x0c, 0xe8, 0x1d, 0x96, 0x4d, 0x58, 0x21, 0x64, 0x5e, 0x2e, 0x9b, 0x92,
- 0xb1, 0x84, 0x15, 0x1e, 0x9a, 0xb0, 0xc6, 0xd4, 0x9a, 0xb0, 0xa6, 0xf5, 0x2d, 0xb0, 0x28, 0x97,
- 0x49, 0x98, 0x07, 0x1d, 0x3d, 0x5b, 0xeb, 0xde, 0xa6, 0x89, 0x17, 0xa0, 0xe1, 0xe6, 0x64, 0x8e,
- 0xb1, 0x15, 0xa6, 0x4f, 0x6f, 0xd7, 0x30, 0xfa, 0xa2, 0x24, 0xc4, 0x87, 0x1b, 0xaf, 0x67, 0x6a,
- 0xe0, 0xbb, 0x50, 0x1e, 0x28, 0xca, 0x11, 0xed, 0xd5, 0x28, 0x42, 0x17, 0x9e, 0x92, 0xf1, 0x63,
- 0x22, 0xdd, 0xe8, 0x05, 0x6d, 0x72, 0x6a, 0x8b, 0xdf, 0xe4, 0xd4, 0x77, 0x7a, 0x8b, 0x9b, 0x58,
- 0x89, 0xa6, 0x64, 0xfc, 0xcc, 0xfc, 0xb6, 0xb6, 0xc9, 0xf7, 0xb5, 0x4d, 0x7e, 0xae, 0x6d, 0xf2,
- 0xf5, 0x97, 0x7d, 0x6d, 0xd6, 0x51, 0x7f, 0x8c, 0x93, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x2f,
- 0x1d, 0xfa, 0x11, 0xb1, 0x05, 0x00, 0x00,
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3election/v3electionpb/v3election.proto b/vendor/go.etcd.io/etcd/etcdserver/api/v3election/v3electionpb/v3election.proto
deleted file mode 100644
index 918f39f..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3election/v3electionpb/v3election.proto
+++ /dev/null
@@ -1,119 +0,0 @@
-syntax = "proto3";
-package v3electionpb;
-
-import "gogoproto/gogo.proto";
-import "etcd/etcdserver/etcdserverpb/rpc.proto";
-import "etcd/mvcc/mvccpb/kv.proto";
-
-// for grpc-gateway
-import "google/api/annotations.proto";
-
-option (gogoproto.marshaler_all) = true;
-option (gogoproto.unmarshaler_all) = true;
-
-// The election service exposes client-side election facilities as a gRPC interface.
-service Election {
- // Campaign waits to acquire leadership in an election, returning a LeaderKey
- // representing the leadership if successful. The LeaderKey can then be used
- // to issue new values on the election, transactionally guard API requests on
- // leadership still being held, and resign from the election.
- rpc Campaign(CampaignRequest) returns (CampaignResponse) {
- option (google.api.http) = {
- post: "/v3/election/campaign"
- body: "*"
- };
- }
- // Proclaim updates the leader's posted value with a new value.
- rpc Proclaim(ProclaimRequest) returns (ProclaimResponse) {
- option (google.api.http) = {
- post: "/v3/election/proclaim"
- body: "*"
- };
- }
- // Leader returns the current election proclamation, if any.
- rpc Leader(LeaderRequest) returns (LeaderResponse) {
- option (google.api.http) = {
- post: "/v3/election/leader"
- body: "*"
- };
- }
- // Observe streams election proclamations in-order as made by the election's
- // elected leaders.
- rpc Observe(LeaderRequest) returns (stream LeaderResponse) {
- option (google.api.http) = {
- post: "/v3/election/observe"
- body: "*"
- };
- }
- // Resign releases election leadership so other campaigners may acquire
- // leadership on the election.
- rpc Resign(ResignRequest) returns (ResignResponse) {
- option (google.api.http) = {
- post: "/v3/election/resign"
- body: "*"
- };
- }
-}
-
-message CampaignRequest {
- // name is the election's identifier for the campaign.
- bytes name = 1;
- // lease is the ID of the lease attached to leadership of the election. If the
- // lease expires or is revoked before resigning leadership, then the
- // leadership is transferred to the next campaigner, if any.
- int64 lease = 2;
- // value is the initial proclaimed value set when the campaigner wins the
- // election.
- bytes value = 3;
-}
-
-message CampaignResponse {
- etcdserverpb.ResponseHeader header = 1;
- // leader describes the resources used for holding leadereship of the election.
- LeaderKey leader = 2;
-}
-
-message LeaderKey {
- // name is the election identifier that correponds to the leadership key.
- bytes name = 1;
- // key is an opaque key representing the ownership of the election. If the key
- // is deleted, then leadership is lost.
- bytes key = 2;
- // rev is the creation revision of the key. It can be used to test for ownership
- // of an election during transactions by testing the key's creation revision
- // matches rev.
- int64 rev = 3;
- // lease is the lease ID of the election leader.
- int64 lease = 4;
-}
-
-message LeaderRequest {
- // name is the election identifier for the leadership information.
- bytes name = 1;
-}
-
-message LeaderResponse {
- etcdserverpb.ResponseHeader header = 1;
- // kv is the key-value pair representing the latest leader update.
- mvccpb.KeyValue kv = 2;
-}
-
-message ResignRequest {
- // leader is the leadership to relinquish by resignation.
- LeaderKey leader = 1;
-}
-
-message ResignResponse {
- etcdserverpb.ResponseHeader header = 1;
-}
-
-message ProclaimRequest {
- // leader is the leadership hold on the election.
- LeaderKey leader = 1;
- // value is an update meant to overwrite the leader's current value.
- bytes value = 2;
-}
-
-message ProclaimResponse {
- etcdserverpb.ResponseHeader header = 1;
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3lock/doc.go b/vendor/go.etcd.io/etcd/etcdserver/api/v3lock/doc.go
deleted file mode 100644
index e0a1008..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3lock/doc.go
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2017 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package v3lock provides a v3 locking service from an etcdserver.
-package v3lock
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3lock/lock.go b/vendor/go.etcd.io/etcd/etcdserver/api/v3lock/lock.go
deleted file mode 100644
index 5a17c86..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3lock/lock.go
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2017 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v3lock
-
-import (
- "context"
-
- "go.etcd.io/etcd/clientv3"
- "go.etcd.io/etcd/clientv3/concurrency"
- "go.etcd.io/etcd/etcdserver/api/v3lock/v3lockpb"
-)
-
-type lockServer struct {
- c *clientv3.Client
-}
-
-func NewLockServer(c *clientv3.Client) v3lockpb.LockServer {
- return &lockServer{c}
-}
-
-func (ls *lockServer) Lock(ctx context.Context, req *v3lockpb.LockRequest) (*v3lockpb.LockResponse, error) {
- s, err := concurrency.NewSession(
- ls.c,
- concurrency.WithLease(clientv3.LeaseID(req.Lease)),
- concurrency.WithContext(ctx),
- )
- if err != nil {
- return nil, err
- }
- s.Orphan()
- m := concurrency.NewMutex(s, string(req.Name))
- if err = m.Lock(ctx); err != nil {
- return nil, err
- }
- return &v3lockpb.LockResponse{Header: m.Header(), Key: []byte(m.Key())}, nil
-}
-
-func (ls *lockServer) Unlock(ctx context.Context, req *v3lockpb.UnlockRequest) (*v3lockpb.UnlockResponse, error) {
- resp, err := ls.c.Delete(ctx, string(req.Key))
- if err != nil {
- return nil, err
- }
- return &v3lockpb.UnlockResponse{Header: resp.Header}, nil
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3lock/v3lockpb/gw/v3lock.pb.gw.go b/vendor/go.etcd.io/etcd/etcdserver/api/v3lock/v3lockpb/gw/v3lock.pb.gw.go
deleted file mode 100644
index 1eeeff1..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3lock/v3lockpb/gw/v3lock.pb.gw.go
+++ /dev/null
@@ -1,167 +0,0 @@
-// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
-// source: etcdserver/api/v3lock/v3lockpb/v3lock.proto
-
-/*
-Package v3lockpb is a reverse proxy.
-
-It translates gRPC into RESTful JSON APIs.
-*/
-package gw
-
-import (
- "go.etcd.io/etcd/etcdserver/api/v3lock/v3lockpb"
- "io"
- "net/http"
-
- "github.com/golang/protobuf/proto"
- "github.com/grpc-ecosystem/grpc-gateway/runtime"
- "github.com/grpc-ecosystem/grpc-gateway/utilities"
- "golang.org/x/net/context"
- "google.golang.org/grpc"
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/grpclog"
- "google.golang.org/grpc/status"
-)
-
-var _ codes.Code
-var _ io.Reader
-var _ status.Status
-var _ = runtime.String
-var _ = utilities.NewDoubleArray
-
-func request_Lock_Lock_0(ctx context.Context, marshaler runtime.Marshaler, client v3lockpb.LockClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq v3lockpb.LockRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.Lock(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Lock_Unlock_0(ctx context.Context, marshaler runtime.Marshaler, client v3lockpb.LockClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq v3lockpb.UnlockRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.Unlock(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-// RegisterLockHandlerFromEndpoint is same as RegisterLockHandler but
-// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
-func RegisterLockHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
- conn, err := grpc.Dial(endpoint, opts...)
- if err != nil {
- return err
- }
- defer func() {
- if err != nil {
- if cerr := conn.Close(); cerr != nil {
- grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
- }
- return
- }
- go func() {
- <-ctx.Done()
- if cerr := conn.Close(); cerr != nil {
- grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
- }
- }()
- }()
-
- return RegisterLockHandler(ctx, mux, conn)
-}
-
-// RegisterLockHandler registers the http handlers for service Lock to "mux".
-// The handlers forward requests to the grpc endpoint over "conn".
-func RegisterLockHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
- return RegisterLockHandlerClient(ctx, mux, v3lockpb.NewLockClient(conn))
-}
-
-// RegisterLockHandler registers the http handlers for service Lock to "mux".
-// The handlers forward requests to the grpc endpoint over the given implementation of "LockClient".
-// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "LockClient"
-// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
-// "LockClient" to call the correct interceptors.
-func RegisterLockHandlerClient(ctx context.Context, mux *runtime.ServeMux, client v3lockpb.LockClient) error {
-
- mux.Handle("POST", pattern_Lock_Lock_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Lock_Lock_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Lock_Lock_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Lock_Unlock_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Lock_Unlock_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Lock_Unlock_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-var (
- pattern_Lock_Lock_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 1}, []string{"v3", "lock"}, ""))
-
- pattern_Lock_Unlock_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3", "lock", "unlock"}, ""))
-)
-
-var (
- forward_Lock_Lock_0 = runtime.ForwardResponseMessage
-
- forward_Lock_Unlock_0 = runtime.ForwardResponseMessage
-)
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3lock/v3lockpb/v3lock.pb.go b/vendor/go.etcd.io/etcd/etcdserver/api/v3lock/v3lockpb/v3lock.pb.go
deleted file mode 100644
index 36ebdd9..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3lock/v3lockpb/v3lock.pb.go
+++ /dev/null
@@ -1,959 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: v3lock.proto
-
-/*
- Package v3lockpb is a generated protocol buffer package.
-
- It is generated from these files:
- v3lock.proto
-
- It has these top-level messages:
- LockRequest
- LockResponse
- UnlockRequest
- UnlockResponse
-*/
-package v3lockpb
-
-import (
- "fmt"
-
- proto "github.com/golang/protobuf/proto"
-
- math "math"
-
- _ "github.com/gogo/protobuf/gogoproto"
-
- etcdserverpb "go.etcd.io/etcd/etcdserver/etcdserverpb"
-
- context "golang.org/x/net/context"
-
- grpc "google.golang.org/grpc"
-
- io "io"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
-
-type LockRequest struct {
- // name is the identifier for the distributed shared lock to be acquired.
- Name []byte `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
- // lease is the ID of the lease that will be attached to ownership of the
- // lock. If the lease expires or is revoked and currently holds the lock,
- // the lock is automatically released. Calls to Lock with the same lease will
- // be treated as a single acquisition; locking twice with the same lease is a
- // no-op.
- Lease int64 `protobuf:"varint,2,opt,name=lease,proto3" json:"lease,omitempty"`
-}
-
-func (m *LockRequest) Reset() { *m = LockRequest{} }
-func (m *LockRequest) String() string { return proto.CompactTextString(m) }
-func (*LockRequest) ProtoMessage() {}
-func (*LockRequest) Descriptor() ([]byte, []int) { return fileDescriptorV3Lock, []int{0} }
-
-func (m *LockRequest) GetName() []byte {
- if m != nil {
- return m.Name
- }
- return nil
-}
-
-func (m *LockRequest) GetLease() int64 {
- if m != nil {
- return m.Lease
- }
- return 0
-}
-
-type LockResponse struct {
- Header *etcdserverpb.ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
- // key is a key that will exist on etcd for the duration that the Lock caller
- // owns the lock. Users should not modify this key or the lock may exhibit
- // undefined behavior.
- Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"`
-}
-
-func (m *LockResponse) Reset() { *m = LockResponse{} }
-func (m *LockResponse) String() string { return proto.CompactTextString(m) }
-func (*LockResponse) ProtoMessage() {}
-func (*LockResponse) Descriptor() ([]byte, []int) { return fileDescriptorV3Lock, []int{1} }
-
-func (m *LockResponse) GetHeader() *etcdserverpb.ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-func (m *LockResponse) GetKey() []byte {
- if m != nil {
- return m.Key
- }
- return nil
-}
-
-type UnlockRequest struct {
- // key is the lock ownership key granted by Lock.
- Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
-}
-
-func (m *UnlockRequest) Reset() { *m = UnlockRequest{} }
-func (m *UnlockRequest) String() string { return proto.CompactTextString(m) }
-func (*UnlockRequest) ProtoMessage() {}
-func (*UnlockRequest) Descriptor() ([]byte, []int) { return fileDescriptorV3Lock, []int{2} }
-
-func (m *UnlockRequest) GetKey() []byte {
- if m != nil {
- return m.Key
- }
- return nil
-}
-
-type UnlockResponse struct {
- Header *etcdserverpb.ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
-}
-
-func (m *UnlockResponse) Reset() { *m = UnlockResponse{} }
-func (m *UnlockResponse) String() string { return proto.CompactTextString(m) }
-func (*UnlockResponse) ProtoMessage() {}
-func (*UnlockResponse) Descriptor() ([]byte, []int) { return fileDescriptorV3Lock, []int{3} }
-
-func (m *UnlockResponse) GetHeader() *etcdserverpb.ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-func init() {
- proto.RegisterType((*LockRequest)(nil), "v3lockpb.LockRequest")
- proto.RegisterType((*LockResponse)(nil), "v3lockpb.LockResponse")
- proto.RegisterType((*UnlockRequest)(nil), "v3lockpb.UnlockRequest")
- proto.RegisterType((*UnlockResponse)(nil), "v3lockpb.UnlockResponse")
-}
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ context.Context
-var _ grpc.ClientConn
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the grpc package it is being compiled against.
-const _ = grpc.SupportPackageIsVersion4
-
-// Client API for Lock service
-
-type LockClient interface {
- // Lock acquires a distributed shared lock on a given named lock.
- // On success, it will return a unique key that exists so long as the
- // lock is held by the caller. This key can be used in conjunction with
- // transactions to safely ensure updates to etcd only occur while holding
- // lock ownership. The lock is held until Unlock is called on the key or the
- // lease associate with the owner expires.
- Lock(ctx context.Context, in *LockRequest, opts ...grpc.CallOption) (*LockResponse, error)
- // Unlock takes a key returned by Lock and releases the hold on lock. The
- // next Lock caller waiting for the lock will then be woken up and given
- // ownership of the lock.
- Unlock(ctx context.Context, in *UnlockRequest, opts ...grpc.CallOption) (*UnlockResponse, error)
-}
-
-type lockClient struct {
- cc *grpc.ClientConn
-}
-
-func NewLockClient(cc *grpc.ClientConn) LockClient {
- return &lockClient{cc}
-}
-
-func (c *lockClient) Lock(ctx context.Context, in *LockRequest, opts ...grpc.CallOption) (*LockResponse, error) {
- out := new(LockResponse)
- err := grpc.Invoke(ctx, "/v3lockpb.Lock/Lock", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *lockClient) Unlock(ctx context.Context, in *UnlockRequest, opts ...grpc.CallOption) (*UnlockResponse, error) {
- out := new(UnlockResponse)
- err := grpc.Invoke(ctx, "/v3lockpb.Lock/Unlock", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-// Server API for Lock service
-
-type LockServer interface {
- // Lock acquires a distributed shared lock on a given named lock.
- // On success, it will return a unique key that exists so long as the
- // lock is held by the caller. This key can be used in conjunction with
- // transactions to safely ensure updates to etcd only occur while holding
- // lock ownership. The lock is held until Unlock is called on the key or the
- // lease associate with the owner expires.
- Lock(context.Context, *LockRequest) (*LockResponse, error)
- // Unlock takes a key returned by Lock and releases the hold on lock. The
- // next Lock caller waiting for the lock will then be woken up and given
- // ownership of the lock.
- Unlock(context.Context, *UnlockRequest) (*UnlockResponse, error)
-}
-
-func RegisterLockServer(s *grpc.Server, srv LockServer) {
- s.RegisterService(&_Lock_serviceDesc, srv)
-}
-
-func _Lock_Lock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(LockRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(LockServer).Lock(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/v3lockpb.Lock/Lock",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(LockServer).Lock(ctx, req.(*LockRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Lock_Unlock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(UnlockRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(LockServer).Unlock(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/v3lockpb.Lock/Unlock",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(LockServer).Unlock(ctx, req.(*UnlockRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-var _Lock_serviceDesc = grpc.ServiceDesc{
- ServiceName: "v3lockpb.Lock",
- HandlerType: (*LockServer)(nil),
- Methods: []grpc.MethodDesc{
- {
- MethodName: "Lock",
- Handler: _Lock_Lock_Handler,
- },
- {
- MethodName: "Unlock",
- Handler: _Lock_Unlock_Handler,
- },
- },
- Streams: []grpc.StreamDesc{},
- Metadata: "v3lock.proto",
-}
-
-func (m *LockRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *LockRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if len(m.Name) > 0 {
- dAtA[i] = 0xa
- i++
- i = encodeVarintV3Lock(dAtA, i, uint64(len(m.Name)))
- i += copy(dAtA[i:], m.Name)
- }
- if m.Lease != 0 {
- dAtA[i] = 0x10
- i++
- i = encodeVarintV3Lock(dAtA, i, uint64(m.Lease))
- }
- return i, nil
-}
-
-func (m *LockResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *LockResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintV3Lock(dAtA, i, uint64(m.Header.Size()))
- n1, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n1
- }
- if len(m.Key) > 0 {
- dAtA[i] = 0x12
- i++
- i = encodeVarintV3Lock(dAtA, i, uint64(len(m.Key)))
- i += copy(dAtA[i:], m.Key)
- }
- return i, nil
-}
-
-func (m *UnlockRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *UnlockRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if len(m.Key) > 0 {
- dAtA[i] = 0xa
- i++
- i = encodeVarintV3Lock(dAtA, i, uint64(len(m.Key)))
- i += copy(dAtA[i:], m.Key)
- }
- return i, nil
-}
-
-func (m *UnlockResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *UnlockResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintV3Lock(dAtA, i, uint64(m.Header.Size()))
- n2, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n2
- }
- return i, nil
-}
-
-func encodeVarintV3Lock(dAtA []byte, offset int, v uint64) int {
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return offset + 1
-}
-func (m *LockRequest) Size() (n int) {
- var l int
- _ = l
- l = len(m.Name)
- if l > 0 {
- n += 1 + l + sovV3Lock(uint64(l))
- }
- if m.Lease != 0 {
- n += 1 + sovV3Lock(uint64(m.Lease))
- }
- return n
-}
-
-func (m *LockResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovV3Lock(uint64(l))
- }
- l = len(m.Key)
- if l > 0 {
- n += 1 + l + sovV3Lock(uint64(l))
- }
- return n
-}
-
-func (m *UnlockRequest) Size() (n int) {
- var l int
- _ = l
- l = len(m.Key)
- if l > 0 {
- n += 1 + l + sovV3Lock(uint64(l))
- }
- return n
-}
-
-func (m *UnlockResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovV3Lock(uint64(l))
- }
- return n
-}
-
-func sovV3Lock(x uint64) (n int) {
- for {
- n++
- x >>= 7
- if x == 0 {
- break
- }
- }
- return n
-}
-func sozV3Lock(x uint64) (n int) {
- return sovV3Lock(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *LockRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Lock
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: LockRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: LockRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Lock
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthV3Lock
- }
- postIndex := iNdEx + byteLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Name = append(m.Name[:0], dAtA[iNdEx:postIndex]...)
- if m.Name == nil {
- m.Name = []byte{}
- }
- iNdEx = postIndex
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Lease", wireType)
- }
- m.Lease = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Lock
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Lease |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipV3Lock(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthV3Lock
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *LockResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Lock
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: LockResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: LockResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Lock
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthV3Lock
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &etcdserverpb.ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Lock
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthV3Lock
- }
- postIndex := iNdEx + byteLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...)
- if m.Key == nil {
- m.Key = []byte{}
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipV3Lock(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthV3Lock
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *UnlockRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Lock
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: UnlockRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: UnlockRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Lock
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthV3Lock
- }
- postIndex := iNdEx + byteLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...)
- if m.Key == nil {
- m.Key = []byte{}
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipV3Lock(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthV3Lock
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *UnlockResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Lock
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: UnlockResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: UnlockResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowV3Lock
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthV3Lock
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &etcdserverpb.ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipV3Lock(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthV3Lock
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipV3Lock(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowV3Lock
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowV3Lock
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- return iNdEx, nil
- case 1:
- iNdEx += 8
- return iNdEx, nil
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowV3Lock
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- iNdEx += length
- if length < 0 {
- return 0, ErrInvalidLengthV3Lock
- }
- return iNdEx, nil
- case 3:
- for {
- var innerWire uint64
- var start int = iNdEx
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowV3Lock
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- innerWire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- innerWireType := int(innerWire & 0x7)
- if innerWireType == 4 {
- break
- }
- next, err := skipV3Lock(dAtA[start:])
- if err != nil {
- return 0, err
- }
- iNdEx = start + next
- }
- return iNdEx, nil
- case 4:
- return iNdEx, nil
- case 5:
- iNdEx += 4
- return iNdEx, nil
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- }
- panic("unreachable")
-}
-
-var (
- ErrInvalidLengthV3Lock = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowV3Lock = fmt.Errorf("proto: integer overflow")
-)
-
-func init() { proto.RegisterFile("v3lock.proto", fileDescriptorV3Lock) }
-
-var fileDescriptorV3Lock = []byte{
- // 331 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x29, 0x33, 0xce, 0xc9,
- 0x4f, 0xce, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x80, 0xf0, 0x0a, 0x92, 0xa4, 0x44,
- 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x82, 0xfa, 0x20, 0x16, 0x44, 0x5e, 0x4a, 0x2d, 0xb5, 0x24, 0x39,
- 0x45, 0x1f, 0x44, 0x14, 0xa7, 0x16, 0x95, 0xa5, 0x16, 0x21, 0x31, 0x0b, 0x92, 0xf4, 0x8b, 0x0a,
- 0x92, 0xa1, 0xea, 0x64, 0xd2, 0xf3, 0xf3, 0xd3, 0x73, 0x52, 0xf5, 0x13, 0x0b, 0x32, 0xf5, 0x13,
- 0xf3, 0xf2, 0xf2, 0x4b, 0x12, 0x4b, 0x32, 0xf3, 0xf3, 0x8a, 0x21, 0xb2, 0x4a, 0xe6, 0x5c, 0xdc,
- 0x3e, 0xf9, 0xc9, 0xd9, 0x41, 0xa9, 0x85, 0xa5, 0xa9, 0xc5, 0x25, 0x42, 0x42, 0x5c, 0x2c, 0x79,
- 0x89, 0xb9, 0xa9, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x3c, 0x41, 0x60, 0xb6, 0x90, 0x08, 0x17, 0x6b,
- 0x4e, 0x6a, 0x62, 0x71, 0xaa, 0x04, 0x93, 0x02, 0xa3, 0x06, 0x73, 0x10, 0x84, 0xa3, 0x14, 0xc6,
- 0xc5, 0x03, 0xd1, 0x58, 0x5c, 0x90, 0x9f, 0x57, 0x9c, 0x2a, 0x64, 0xc2, 0xc5, 0x96, 0x91, 0x9a,
- 0x98, 0x92, 0x5a, 0x04, 0xd6, 0xcb, 0x6d, 0x24, 0xa3, 0x87, 0xec, 0x1e, 0x3d, 0x98, 0x3a, 0x0f,
- 0xb0, 0x9a, 0x20, 0xa8, 0x5a, 0x21, 0x01, 0x2e, 0xe6, 0xec, 0xd4, 0x4a, 0xb0, 0xc9, 0x3c, 0x41,
- 0x20, 0xa6, 0x92, 0x22, 0x17, 0x6f, 0x68, 0x5e, 0x0e, 0x92, 0x93, 0xa0, 0x4a, 0x18, 0x11, 0x4a,
- 0xdc, 0xb8, 0xf8, 0x60, 0x4a, 0x28, 0xb1, 0xdc, 0x68, 0x03, 0x23, 0x17, 0x0b, 0xc8, 0x0f, 0x42,
- 0xfe, 0x50, 0x5a, 0x54, 0x0f, 0x16, 0xe6, 0x7a, 0x48, 0x81, 0x22, 0x25, 0x86, 0x2e, 0x0c, 0x31,
- 0x4d, 0x49, 0xa2, 0xe9, 0xf2, 0x93, 0xc9, 0x4c, 0x42, 0x4a, 0xbc, 0xfa, 0x65, 0xc6, 0xfa, 0x20,
- 0x05, 0x60, 0xc2, 0x8a, 0x51, 0x4b, 0x28, 0x9c, 0x8b, 0x0d, 0xe2, 0x42, 0x21, 0x71, 0x84, 0x5e,
- 0x14, 0x6f, 0x49, 0x49, 0x60, 0x4a, 0x40, 0x8d, 0x95, 0x02, 0x1b, 0x2b, 0xa2, 0xc4, 0x0f, 0x37,
- 0xb6, 0x34, 0x0f, 0x6a, 0xb0, 0x93, 0xc0, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e,
- 0x78, 0x24, 0xc7, 0x38, 0xe3, 0xb1, 0x1c, 0x43, 0x12, 0x1b, 0x38, 0x1e, 0x8d, 0x01, 0x01, 0x00,
- 0x00, 0xff, 0xff, 0x65, 0xa8, 0x61, 0xb1, 0x3d, 0x02, 0x00, 0x00,
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3lock/v3lockpb/v3lock.proto b/vendor/go.etcd.io/etcd/etcdserver/api/v3lock/v3lockpb/v3lock.proto
deleted file mode 100644
index 7220c7f..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3lock/v3lockpb/v3lock.proto
+++ /dev/null
@@ -1,65 +0,0 @@
-syntax = "proto3";
-package v3lockpb;
-
-import "gogoproto/gogo.proto";
-import "etcd/etcdserver/etcdserverpb/rpc.proto";
-
-// for grpc-gateway
-import "google/api/annotations.proto";
-
-option (gogoproto.marshaler_all) = true;
-option (gogoproto.unmarshaler_all) = true;
-
-// The lock service exposes client-side locking facilities as a gRPC interface.
-service Lock {
- // Lock acquires a distributed shared lock on a given named lock.
- // On success, it will return a unique key that exists so long as the
- // lock is held by the caller. This key can be used in conjunction with
- // transactions to safely ensure updates to etcd only occur while holding
- // lock ownership. The lock is held until Unlock is called on the key or the
- // lease associate with the owner expires.
- rpc Lock(LockRequest) returns (LockResponse) {
- option (google.api.http) = {
- post: "/v3/lock/lock"
- body: "*"
- };
- }
-
- // Unlock takes a key returned by Lock and releases the hold on lock. The
- // next Lock caller waiting for the lock will then be woken up and given
- // ownership of the lock.
- rpc Unlock(UnlockRequest) returns (UnlockResponse) {
- option (google.api.http) = {
- post: "/v3/lock/unlock"
- body: "*"
- };
- }
-}
-
-message LockRequest {
- // name is the identifier for the distributed shared lock to be acquired.
- bytes name = 1;
- // lease is the ID of the lease that will be attached to ownership of the
- // lock. If the lease expires or is revoked and currently holds the lock,
- // the lock is automatically released. Calls to Lock with the same lease will
- // be treated as a single acquisition; locking twice with the same lease is a
- // no-op.
- int64 lease = 2;
-}
-
-message LockResponse {
- etcdserverpb.ResponseHeader header = 1;
- // key is a key that will exist on etcd for the duration that the Lock caller
- // owns the lock. Users should not modify this key or the lock may exhibit
- // undefined behavior.
- bytes key = 2;
-}
-
-message UnlockRequest {
- // key is the lock ownership key granted by Lock.
- bytes key = 1;
-}
-
-message UnlockResponse {
- etcdserverpb.ResponseHeader header = 1;
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/auth.go b/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/auth.go
deleted file mode 100644
index 62ce757..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/auth.go
+++ /dev/null
@@ -1,158 +0,0 @@
-// Copyright 2016 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v3rpc
-
-import (
- "context"
-
- "go.etcd.io/etcd/etcdserver"
- pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
-)
-
-type AuthServer struct {
- authenticator etcdserver.Authenticator
-}
-
-func NewAuthServer(s *etcdserver.EtcdServer) *AuthServer {
- return &AuthServer{authenticator: s}
-}
-
-func (as *AuthServer) AuthEnable(ctx context.Context, r *pb.AuthEnableRequest) (*pb.AuthEnableResponse, error) {
- resp, err := as.authenticator.AuthEnable(ctx, r)
- if err != nil {
- return nil, togRPCError(err)
- }
- return resp, nil
-}
-
-func (as *AuthServer) AuthDisable(ctx context.Context, r *pb.AuthDisableRequest) (*pb.AuthDisableResponse, error) {
- resp, err := as.authenticator.AuthDisable(ctx, r)
- if err != nil {
- return nil, togRPCError(err)
- }
- return resp, nil
-}
-
-func (as *AuthServer) Authenticate(ctx context.Context, r *pb.AuthenticateRequest) (*pb.AuthenticateResponse, error) {
- resp, err := as.authenticator.Authenticate(ctx, r)
- if err != nil {
- return nil, togRPCError(err)
- }
- return resp, nil
-}
-
-func (as *AuthServer) RoleAdd(ctx context.Context, r *pb.AuthRoleAddRequest) (*pb.AuthRoleAddResponse, error) {
- resp, err := as.authenticator.RoleAdd(ctx, r)
- if err != nil {
- return nil, togRPCError(err)
- }
- return resp, nil
-}
-
-func (as *AuthServer) RoleDelete(ctx context.Context, r *pb.AuthRoleDeleteRequest) (*pb.AuthRoleDeleteResponse, error) {
- resp, err := as.authenticator.RoleDelete(ctx, r)
- if err != nil {
- return nil, togRPCError(err)
- }
- return resp, nil
-}
-
-func (as *AuthServer) RoleGet(ctx context.Context, r *pb.AuthRoleGetRequest) (*pb.AuthRoleGetResponse, error) {
- resp, err := as.authenticator.RoleGet(ctx, r)
- if err != nil {
- return nil, togRPCError(err)
- }
- return resp, nil
-}
-
-func (as *AuthServer) RoleList(ctx context.Context, r *pb.AuthRoleListRequest) (*pb.AuthRoleListResponse, error) {
- resp, err := as.authenticator.RoleList(ctx, r)
- if err != nil {
- return nil, togRPCError(err)
- }
- return resp, nil
-}
-
-func (as *AuthServer) RoleRevokePermission(ctx context.Context, r *pb.AuthRoleRevokePermissionRequest) (*pb.AuthRoleRevokePermissionResponse, error) {
- resp, err := as.authenticator.RoleRevokePermission(ctx, r)
- if err != nil {
- return nil, togRPCError(err)
- }
- return resp, nil
-}
-
-func (as *AuthServer) RoleGrantPermission(ctx context.Context, r *pb.AuthRoleGrantPermissionRequest) (*pb.AuthRoleGrantPermissionResponse, error) {
- resp, err := as.authenticator.RoleGrantPermission(ctx, r)
- if err != nil {
- return nil, togRPCError(err)
- }
- return resp, nil
-}
-
-func (as *AuthServer) UserAdd(ctx context.Context, r *pb.AuthUserAddRequest) (*pb.AuthUserAddResponse, error) {
- resp, err := as.authenticator.UserAdd(ctx, r)
- if err != nil {
- return nil, togRPCError(err)
- }
- return resp, nil
-}
-
-func (as *AuthServer) UserDelete(ctx context.Context, r *pb.AuthUserDeleteRequest) (*pb.AuthUserDeleteResponse, error) {
- resp, err := as.authenticator.UserDelete(ctx, r)
- if err != nil {
- return nil, togRPCError(err)
- }
- return resp, nil
-}
-
-func (as *AuthServer) UserGet(ctx context.Context, r *pb.AuthUserGetRequest) (*pb.AuthUserGetResponse, error) {
- resp, err := as.authenticator.UserGet(ctx, r)
- if err != nil {
- return nil, togRPCError(err)
- }
- return resp, nil
-}
-
-func (as *AuthServer) UserList(ctx context.Context, r *pb.AuthUserListRequest) (*pb.AuthUserListResponse, error) {
- resp, err := as.authenticator.UserList(ctx, r)
- if err != nil {
- return nil, togRPCError(err)
- }
- return resp, nil
-}
-
-func (as *AuthServer) UserGrantRole(ctx context.Context, r *pb.AuthUserGrantRoleRequest) (*pb.AuthUserGrantRoleResponse, error) {
- resp, err := as.authenticator.UserGrantRole(ctx, r)
- if err != nil {
- return nil, togRPCError(err)
- }
- return resp, nil
-}
-
-func (as *AuthServer) UserRevokeRole(ctx context.Context, r *pb.AuthUserRevokeRoleRequest) (*pb.AuthUserRevokeRoleResponse, error) {
- resp, err := as.authenticator.UserRevokeRole(ctx, r)
- if err != nil {
- return nil, togRPCError(err)
- }
- return resp, nil
-}
-
-func (as *AuthServer) UserChangePassword(ctx context.Context, r *pb.AuthUserChangePasswordRequest) (*pb.AuthUserChangePasswordResponse, error) {
- resp, err := as.authenticator.UserChangePassword(ctx, r)
- if err != nil {
- return nil, togRPCError(err)
- }
- return resp, nil
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/codec.go b/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/codec.go
deleted file mode 100644
index 17a2c87..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/codec.go
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2016 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v3rpc
-
-import "github.com/gogo/protobuf/proto"
-
-type codec struct{}
-
-func (c *codec) Marshal(v interface{}) ([]byte, error) {
- b, err := proto.Marshal(v.(proto.Message))
- sentBytes.Add(float64(len(b)))
- return b, err
-}
-
-func (c *codec) Unmarshal(data []byte, v interface{}) error {
- receivedBytes.Add(float64(len(data)))
- return proto.Unmarshal(data, v.(proto.Message))
-}
-
-func (c *codec) String() string {
- return "proto"
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/grpc.go b/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/grpc.go
deleted file mode 100644
index 3332016..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/grpc.go
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright 2016 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v3rpc
-
-import (
- "crypto/tls"
- "math"
-
- "go.etcd.io/etcd/etcdserver"
- pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
-
- grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
- grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
- "go.etcd.io/etcd/clientv3/credentials"
- "google.golang.org/grpc"
- "google.golang.org/grpc/health"
- healthpb "google.golang.org/grpc/health/grpc_health_v1"
-)
-
-const (
- grpcOverheadBytes = 512 * 1024
- maxStreams = math.MaxUint32
- maxSendBytes = math.MaxInt32
-)
-
-func Server(s *etcdserver.EtcdServer, tls *tls.Config, gopts ...grpc.ServerOption) *grpc.Server {
- var opts []grpc.ServerOption
- opts = append(opts, grpc.CustomCodec(&codec{}))
- if tls != nil {
- bundle := credentials.NewBundle(credentials.Config{TLSConfig: tls})
- opts = append(opts, grpc.Creds(bundle.TransportCredentials()))
- }
- opts = append(opts, grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(
- newLogUnaryInterceptor(s),
- newUnaryInterceptor(s),
- grpc_prometheus.UnaryServerInterceptor,
- )))
- opts = append(opts, grpc.StreamInterceptor(grpc_middleware.ChainStreamServer(
- newStreamInterceptor(s),
- grpc_prometheus.StreamServerInterceptor,
- )))
- opts = append(opts, grpc.MaxRecvMsgSize(int(s.Cfg.MaxRequestBytes+grpcOverheadBytes)))
- opts = append(opts, grpc.MaxSendMsgSize(maxSendBytes))
- opts = append(opts, grpc.MaxConcurrentStreams(maxStreams))
- grpcServer := grpc.NewServer(append(opts, gopts...)...)
-
- pb.RegisterKVServer(grpcServer, NewQuotaKVServer(s))
- pb.RegisterWatchServer(grpcServer, NewWatchServer(s))
- pb.RegisterLeaseServer(grpcServer, NewQuotaLeaseServer(s))
- pb.RegisterClusterServer(grpcServer, NewClusterServer(s))
- pb.RegisterAuthServer(grpcServer, NewAuthServer(s))
- pb.RegisterMaintenanceServer(grpcServer, NewMaintenanceServer(s))
-
- // server should register all the services manually
- // use empty service name for all etcd services' health status,
- // see https://github.com/grpc/grpc/blob/master/doc/health-checking.md for more
- hsrv := health.NewServer()
- hsrv.SetServingStatus("", healthpb.HealthCheckResponse_SERVING)
- healthpb.RegisterHealthServer(grpcServer, hsrv)
-
- // set zero values for metrics registered for this grpc server
- grpc_prometheus.Register(grpcServer)
-
- return grpcServer
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/header.go b/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/header.go
deleted file mode 100644
index f23b6a7..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/header.go
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2016 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v3rpc
-
-import (
- "go.etcd.io/etcd/etcdserver"
- pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
-)
-
-type header struct {
- clusterID int64
- memberID int64
- sg etcdserver.RaftStatusGetter
- rev func() int64
-}
-
-func newHeader(s *etcdserver.EtcdServer) header {
- return header{
- clusterID: int64(s.Cluster().ID()),
- memberID: int64(s.ID()),
- sg: s,
- rev: func() int64 { return s.KV().Rev() },
- }
-}
-
-// fill populates pb.ResponseHeader using etcdserver information
-func (h *header) fill(rh *pb.ResponseHeader) {
- if rh == nil {
- plog.Panic("unexpected nil resp.Header")
- }
- rh.ClusterId = uint64(h.clusterID)
- rh.MemberId = uint64(h.memberID)
- rh.RaftTerm = h.sg.Term()
- if rh.Revision == 0 {
- rh.Revision = h.rev()
- }
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/interceptor.go b/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/interceptor.go
deleted file mode 100644
index ce9047e..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/interceptor.go
+++ /dev/null
@@ -1,276 +0,0 @@
-// Copyright 2016 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v3rpc
-
-import (
- "context"
- "sync"
- "time"
-
- "go.etcd.io/etcd/etcdserver"
- "go.etcd.io/etcd/etcdserver/api"
- "go.etcd.io/etcd/etcdserver/api/v3rpc/rpctypes"
- "go.etcd.io/etcd/pkg/types"
- "go.etcd.io/etcd/raft"
-
- "github.com/coreos/pkg/capnslog"
- pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
- "go.uber.org/zap"
- "google.golang.org/grpc"
- "google.golang.org/grpc/metadata"
- "google.golang.org/grpc/peer"
-)
-
-const (
- maxNoLeaderCnt = 3
-)
-
-type streamsMap struct {
- mu sync.Mutex
- streams map[grpc.ServerStream]struct{}
-}
-
-func newUnaryInterceptor(s *etcdserver.EtcdServer) grpc.UnaryServerInterceptor {
- return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
- if !api.IsCapabilityEnabled(api.V3rpcCapability) {
- return nil, rpctypes.ErrGRPCNotCapable
- }
-
- if s.IsMemberExist(s.ID()) && s.IsLearner() && !isRPCSupportedForLearner(req) {
- return nil, rpctypes.ErrGPRCNotSupportedForLearner
- }
-
- md, ok := metadata.FromIncomingContext(ctx)
- if ok {
- if ks := md[rpctypes.MetadataRequireLeaderKey]; len(ks) > 0 && ks[0] == rpctypes.MetadataHasLeader {
- if s.Leader() == types.ID(raft.None) {
- return nil, rpctypes.ErrGRPCNoLeader
- }
- }
- }
-
- return handler(ctx, req)
- }
-}
-
-func newLogUnaryInterceptor(s *etcdserver.EtcdServer) grpc.UnaryServerInterceptor {
- return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
- startTime := time.Now()
- resp, err := handler(ctx, req)
- lg := s.Logger()
- if (lg != nil && lg.Core().Enabled(zap.DebugLevel)) || // using zap logger and debug level is enabled
- (lg == nil && plog.LevelAt(capnslog.DEBUG)) { // or, using capnslog and debug level is enabled
- defer logUnaryRequestStats(ctx, lg, info, startTime, req, resp)
- }
- return resp, err
- }
-}
-
-func logUnaryRequestStats(ctx context.Context, lg *zap.Logger, info *grpc.UnaryServerInfo, startTime time.Time, req interface{}, resp interface{}) {
- duration := time.Since(startTime)
- remote := "No remote client info."
- peerInfo, ok := peer.FromContext(ctx)
- if ok {
- remote = peerInfo.Addr.String()
- }
- responseType := info.FullMethod
- var reqCount, respCount int64
- var reqSize, respSize int
- var reqContent string
- switch _resp := resp.(type) {
- case *pb.RangeResponse:
- _req, ok := req.(*pb.RangeRequest)
- if ok {
- reqCount = 0
- reqSize = _req.Size()
- reqContent = _req.String()
- }
- if _resp != nil {
- respCount = _resp.GetCount()
- respSize = _resp.Size()
- }
- case *pb.PutResponse:
- _req, ok := req.(*pb.PutRequest)
- if ok {
- reqCount = 1
- reqSize = _req.Size()
- reqContent = pb.NewLoggablePutRequest(_req).String()
- // redact value field from request content, see PR #9821
- }
- if _resp != nil {
- respCount = 0
- respSize = _resp.Size()
- }
- case *pb.DeleteRangeResponse:
- _req, ok := req.(*pb.DeleteRangeRequest)
- if ok {
- reqCount = 0
- reqSize = _req.Size()
- reqContent = _req.String()
- }
- if _resp != nil {
- respCount = _resp.GetDeleted()
- respSize = _resp.Size()
- }
- case *pb.TxnResponse:
- _req, ok := req.(*pb.TxnRequest)
- if ok && _resp != nil {
- if _resp.GetSucceeded() { // determine the 'actual' count and size of request based on success or failure
- reqCount = int64(len(_req.GetSuccess()))
- reqSize = 0
- for _, r := range _req.GetSuccess() {
- reqSize += r.Size()
- }
- } else {
- reqCount = int64(len(_req.GetFailure()))
- reqSize = 0
- for _, r := range _req.GetFailure() {
- reqSize += r.Size()
- }
- }
- reqContent = pb.NewLoggableTxnRequest(_req).String()
- // redact value field from request content, see PR #9821
- }
- if _resp != nil {
- respCount = 0
- respSize = _resp.Size()
- }
- default:
- reqCount = -1
- reqSize = -1
- respCount = -1
- respSize = -1
- }
-
- logGenericRequestStats(lg, startTime, duration, remote, responseType, reqCount, reqSize, respCount, respSize, reqContent)
-}
-
-func logGenericRequestStats(lg *zap.Logger, startTime time.Time, duration time.Duration, remote string, responseType string,
- reqCount int64, reqSize int, respCount int64, respSize int, reqContent string) {
- if lg == nil {
- plog.Debugf("start time = %v, "+
- "time spent = %v, "+
- "remote = %s, "+
- "response type = %s, "+
- "request count = %d, "+
- "request size = %d, "+
- "response count = %d, "+
- "response size = %d, "+
- "request content = %s",
- startTime, duration, remote, responseType, reqCount, reqSize, respCount, respSize, reqContent,
- )
- } else {
- lg.Debug("request stats",
- zap.Time("start time", startTime),
- zap.Duration("time spent", duration),
- zap.String("remote", remote),
- zap.String("response type", responseType),
- zap.Int64("request count", reqCount),
- zap.Int("request size", reqSize),
- zap.Int64("response count", respCount),
- zap.Int("response size", respSize),
- zap.String("request content", reqContent),
- )
- }
-}
-
-func newStreamInterceptor(s *etcdserver.EtcdServer) grpc.StreamServerInterceptor {
- smap := monitorLeader(s)
-
- return func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
- if !api.IsCapabilityEnabled(api.V3rpcCapability) {
- return rpctypes.ErrGRPCNotCapable
- }
-
- if s.IsMemberExist(s.ID()) && s.IsLearner() { // learner does not support stream RPC
- return rpctypes.ErrGPRCNotSupportedForLearner
- }
-
- md, ok := metadata.FromIncomingContext(ss.Context())
- if ok {
- if ks := md[rpctypes.MetadataRequireLeaderKey]; len(ks) > 0 && ks[0] == rpctypes.MetadataHasLeader {
- if s.Leader() == types.ID(raft.None) {
- return rpctypes.ErrGRPCNoLeader
- }
-
- cctx, cancel := context.WithCancel(ss.Context())
- ss = serverStreamWithCtx{ctx: cctx, cancel: &cancel, ServerStream: ss}
-
- smap.mu.Lock()
- smap.streams[ss] = struct{}{}
- smap.mu.Unlock()
-
- defer func() {
- smap.mu.Lock()
- delete(smap.streams, ss)
- smap.mu.Unlock()
- cancel()
- }()
-
- }
- }
-
- return handler(srv, ss)
- }
-}
-
-type serverStreamWithCtx struct {
- grpc.ServerStream
- ctx context.Context
- cancel *context.CancelFunc
-}
-
-func (ssc serverStreamWithCtx) Context() context.Context { return ssc.ctx }
-
-func monitorLeader(s *etcdserver.EtcdServer) *streamsMap {
- smap := &streamsMap{
- streams: make(map[grpc.ServerStream]struct{}),
- }
-
- go func() {
- election := time.Duration(s.Cfg.TickMs) * time.Duration(s.Cfg.ElectionTicks) * time.Millisecond
- noLeaderCnt := 0
-
- for {
- select {
- case <-s.StopNotify():
- return
- case <-time.After(election):
- if s.Leader() == types.ID(raft.None) {
- noLeaderCnt++
- } else {
- noLeaderCnt = 0
- }
-
- // We are more conservative on canceling existing streams. Reconnecting streams
- // cost much more than just rejecting new requests. So we wait until the member
- // cannot find a leader for maxNoLeaderCnt election timeouts to cancel existing streams.
- if noLeaderCnt >= maxNoLeaderCnt {
- smap.mu.Lock()
- for ss := range smap.streams {
- if ssWithCtx, ok := ss.(serverStreamWithCtx); ok {
- (*ssWithCtx.cancel)()
- <-ss.Context().Done()
- }
- }
- smap.streams = make(map[grpc.ServerStream]struct{})
- smap.mu.Unlock()
- }
- }
- }
- }()
-
- return smap
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/key.go b/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/key.go
deleted file mode 100644
index ff59bac..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/key.go
+++ /dev/null
@@ -1,277 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package v3rpc implements etcd v3 RPC system based on gRPC.
-package v3rpc
-
-import (
- "context"
-
- "go.etcd.io/etcd/etcdserver"
- "go.etcd.io/etcd/etcdserver/api/v3rpc/rpctypes"
- pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
- "go.etcd.io/etcd/pkg/adt"
-
- "github.com/coreos/pkg/capnslog"
-)
-
-var (
- plog = capnslog.NewPackageLogger("go.etcd.io/etcd", "etcdserver/api/v3rpc")
-)
-
-type kvServer struct {
- hdr header
- kv etcdserver.RaftKV
- // maxTxnOps is the max operations per txn.
- // e.g suppose maxTxnOps = 128.
- // Txn.Success can have at most 128 operations,
- // and Txn.Failure can have at most 128 operations.
- maxTxnOps uint
-}
-
-func NewKVServer(s *etcdserver.EtcdServer) pb.KVServer {
- return &kvServer{hdr: newHeader(s), kv: s, maxTxnOps: s.Cfg.MaxTxnOps}
-}
-
-func (s *kvServer) Range(ctx context.Context, r *pb.RangeRequest) (*pb.RangeResponse, error) {
- if err := checkRangeRequest(r); err != nil {
- return nil, err
- }
-
- resp, err := s.kv.Range(ctx, r)
- if err != nil {
- return nil, togRPCError(err)
- }
-
- s.hdr.fill(resp.Header)
- return resp, nil
-}
-
-func (s *kvServer) Put(ctx context.Context, r *pb.PutRequest) (*pb.PutResponse, error) {
- if err := checkPutRequest(r); err != nil {
- return nil, err
- }
-
- resp, err := s.kv.Put(ctx, r)
- if err != nil {
- return nil, togRPCError(err)
- }
-
- s.hdr.fill(resp.Header)
- return resp, nil
-}
-
-func (s *kvServer) DeleteRange(ctx context.Context, r *pb.DeleteRangeRequest) (*pb.DeleteRangeResponse, error) {
- if err := checkDeleteRequest(r); err != nil {
- return nil, err
- }
-
- resp, err := s.kv.DeleteRange(ctx, r)
- if err != nil {
- return nil, togRPCError(err)
- }
-
- s.hdr.fill(resp.Header)
- return resp, nil
-}
-
-func (s *kvServer) Txn(ctx context.Context, r *pb.TxnRequest) (*pb.TxnResponse, error) {
- if err := checkTxnRequest(r, int(s.maxTxnOps)); err != nil {
- return nil, err
- }
- // check for forbidden put/del overlaps after checking request to avoid quadratic blowup
- if _, _, err := checkIntervals(r.Success); err != nil {
- return nil, err
- }
- if _, _, err := checkIntervals(r.Failure); err != nil {
- return nil, err
- }
-
- resp, err := s.kv.Txn(ctx, r)
- if err != nil {
- return nil, togRPCError(err)
- }
-
- s.hdr.fill(resp.Header)
- return resp, nil
-}
-
-func (s *kvServer) Compact(ctx context.Context, r *pb.CompactionRequest) (*pb.CompactionResponse, error) {
- resp, err := s.kv.Compact(ctx, r)
- if err != nil {
- return nil, togRPCError(err)
- }
-
- s.hdr.fill(resp.Header)
- return resp, nil
-}
-
-func checkRangeRequest(r *pb.RangeRequest) error {
- if len(r.Key) == 0 {
- return rpctypes.ErrGRPCEmptyKey
- }
- return nil
-}
-
-func checkPutRequest(r *pb.PutRequest) error {
- if len(r.Key) == 0 {
- return rpctypes.ErrGRPCEmptyKey
- }
- if r.IgnoreValue && len(r.Value) != 0 {
- return rpctypes.ErrGRPCValueProvided
- }
- if r.IgnoreLease && r.Lease != 0 {
- return rpctypes.ErrGRPCLeaseProvided
- }
- return nil
-}
-
-func checkDeleteRequest(r *pb.DeleteRangeRequest) error {
- if len(r.Key) == 0 {
- return rpctypes.ErrGRPCEmptyKey
- }
- return nil
-}
-
-func checkTxnRequest(r *pb.TxnRequest, maxTxnOps int) error {
- opc := len(r.Compare)
- if opc < len(r.Success) {
- opc = len(r.Success)
- }
- if opc < len(r.Failure) {
- opc = len(r.Failure)
- }
- if opc > maxTxnOps {
- return rpctypes.ErrGRPCTooManyOps
- }
-
- for _, c := range r.Compare {
- if len(c.Key) == 0 {
- return rpctypes.ErrGRPCEmptyKey
- }
- }
- for _, u := range r.Success {
- if err := checkRequestOp(u, maxTxnOps-opc); err != nil {
- return err
- }
- }
- for _, u := range r.Failure {
- if err := checkRequestOp(u, maxTxnOps-opc); err != nil {
- return err
- }
- }
-
- return nil
-}
-
-// checkIntervals tests whether puts and deletes overlap for a list of ops. If
-// there is an overlap, returns an error. If no overlap, return put and delete
-// sets for recursive evaluation.
-func checkIntervals(reqs []*pb.RequestOp) (map[string]struct{}, adt.IntervalTree, error) {
- dels := adt.NewIntervalTree()
-
- // collect deletes from this level; build first to check lower level overlapped puts
- for _, req := range reqs {
- tv, ok := req.Request.(*pb.RequestOp_RequestDeleteRange)
- if !ok {
- continue
- }
- dreq := tv.RequestDeleteRange
- if dreq == nil {
- continue
- }
- var iv adt.Interval
- if len(dreq.RangeEnd) != 0 {
- iv = adt.NewStringAffineInterval(string(dreq.Key), string(dreq.RangeEnd))
- } else {
- iv = adt.NewStringAffinePoint(string(dreq.Key))
- }
- dels.Insert(iv, struct{}{})
- }
-
- // collect children puts/deletes
- puts := make(map[string]struct{})
- for _, req := range reqs {
- tv, ok := req.Request.(*pb.RequestOp_RequestTxn)
- if !ok {
- continue
- }
- putsThen, delsThen, err := checkIntervals(tv.RequestTxn.Success)
- if err != nil {
- return nil, dels, err
- }
- putsElse, delsElse, err := checkIntervals(tv.RequestTxn.Failure)
- if err != nil {
- return nil, dels, err
- }
- for k := range putsThen {
- if _, ok := puts[k]; ok {
- return nil, dels, rpctypes.ErrGRPCDuplicateKey
- }
- if dels.Intersects(adt.NewStringAffinePoint(k)) {
- return nil, dels, rpctypes.ErrGRPCDuplicateKey
- }
- puts[k] = struct{}{}
- }
- for k := range putsElse {
- if _, ok := puts[k]; ok {
- // if key is from putsThen, overlap is OK since
- // either then/else are mutually exclusive
- if _, isSafe := putsThen[k]; !isSafe {
- return nil, dels, rpctypes.ErrGRPCDuplicateKey
- }
- }
- if dels.Intersects(adt.NewStringAffinePoint(k)) {
- return nil, dels, rpctypes.ErrGRPCDuplicateKey
- }
- puts[k] = struct{}{}
- }
- dels.Union(delsThen, adt.NewStringAffineInterval("\x00", ""))
- dels.Union(delsElse, adt.NewStringAffineInterval("\x00", ""))
- }
-
- // collect and check this level's puts
- for _, req := range reqs {
- tv, ok := req.Request.(*pb.RequestOp_RequestPut)
- if !ok || tv.RequestPut == nil {
- continue
- }
- k := string(tv.RequestPut.Key)
- if _, ok := puts[k]; ok {
- return nil, dels, rpctypes.ErrGRPCDuplicateKey
- }
- if dels.Intersects(adt.NewStringAffinePoint(k)) {
- return nil, dels, rpctypes.ErrGRPCDuplicateKey
- }
- puts[k] = struct{}{}
- }
- return puts, dels, nil
-}
-
-func checkRequestOp(u *pb.RequestOp, maxTxnOps int) error {
- // TODO: ensure only one of the field is set.
- switch uv := u.Request.(type) {
- case *pb.RequestOp_RequestRange:
- return checkRangeRequest(uv.RequestRange)
- case *pb.RequestOp_RequestPut:
- return checkPutRequest(uv.RequestPut)
- case *pb.RequestOp_RequestDeleteRange:
- return checkDeleteRequest(uv.RequestDeleteRange)
- case *pb.RequestOp_RequestTxn:
- return checkTxnRequest(uv.RequestTxn, maxTxnOps)
- default:
- // empty op / nil entry
- return rpctypes.ErrGRPCKeyNotFound
- }
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/lease.go b/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/lease.go
deleted file mode 100644
index 7441bee..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/lease.go
+++ /dev/null
@@ -1,169 +0,0 @@
-// Copyright 2016 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v3rpc
-
-import (
- "context"
- "io"
-
- "go.etcd.io/etcd/etcdserver"
- "go.etcd.io/etcd/etcdserver/api/v3rpc/rpctypes"
- pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
- "go.etcd.io/etcd/lease"
-
- "go.uber.org/zap"
-)
-
-type LeaseServer struct {
- lg *zap.Logger
- hdr header
- le etcdserver.Lessor
-}
-
-func NewLeaseServer(s *etcdserver.EtcdServer) pb.LeaseServer {
- return &LeaseServer{lg: s.Cfg.Logger, le: s, hdr: newHeader(s)}
-}
-
-func (ls *LeaseServer) LeaseGrant(ctx context.Context, cr *pb.LeaseGrantRequest) (*pb.LeaseGrantResponse, error) {
- resp, err := ls.le.LeaseGrant(ctx, cr)
-
- if err != nil {
- return nil, togRPCError(err)
- }
- ls.hdr.fill(resp.Header)
- return resp, nil
-}
-
-func (ls *LeaseServer) LeaseRevoke(ctx context.Context, rr *pb.LeaseRevokeRequest) (*pb.LeaseRevokeResponse, error) {
- resp, err := ls.le.LeaseRevoke(ctx, rr)
- if err != nil {
- return nil, togRPCError(err)
- }
- ls.hdr.fill(resp.Header)
- return resp, nil
-}
-
-func (ls *LeaseServer) LeaseTimeToLive(ctx context.Context, rr *pb.LeaseTimeToLiveRequest) (*pb.LeaseTimeToLiveResponse, error) {
- resp, err := ls.le.LeaseTimeToLive(ctx, rr)
- if err != nil && err != lease.ErrLeaseNotFound {
- return nil, togRPCError(err)
- }
- if err == lease.ErrLeaseNotFound {
- resp = &pb.LeaseTimeToLiveResponse{
- Header: &pb.ResponseHeader{},
- ID: rr.ID,
- TTL: -1,
- }
- }
- ls.hdr.fill(resp.Header)
- return resp, nil
-}
-
-func (ls *LeaseServer) LeaseLeases(ctx context.Context, rr *pb.LeaseLeasesRequest) (*pb.LeaseLeasesResponse, error) {
- resp, err := ls.le.LeaseLeases(ctx, rr)
- if err != nil && err != lease.ErrLeaseNotFound {
- return nil, togRPCError(err)
- }
- if err == lease.ErrLeaseNotFound {
- resp = &pb.LeaseLeasesResponse{
- Header: &pb.ResponseHeader{},
- Leases: []*pb.LeaseStatus{},
- }
- }
- ls.hdr.fill(resp.Header)
- return resp, nil
-}
-
-func (ls *LeaseServer) LeaseKeepAlive(stream pb.Lease_LeaseKeepAliveServer) (err error) {
- errc := make(chan error, 1)
- go func() {
- errc <- ls.leaseKeepAlive(stream)
- }()
- select {
- case err = <-errc:
- case <-stream.Context().Done():
- // the only server-side cancellation is noleader for now.
- err = stream.Context().Err()
- if err == context.Canceled {
- err = rpctypes.ErrGRPCNoLeader
- }
- }
- return err
-}
-
-func (ls *LeaseServer) leaseKeepAlive(stream pb.Lease_LeaseKeepAliveServer) error {
- for {
- req, err := stream.Recv()
- if err == io.EOF {
- return nil
- }
- if err != nil {
- if isClientCtxErr(stream.Context().Err(), err) {
- if ls.lg != nil {
- ls.lg.Debug("failed to receive lease keepalive request from gRPC stream", zap.Error(err))
- } else {
- plog.Debugf("failed to receive lease keepalive request from gRPC stream (%q)", err.Error())
- }
- } else {
- if ls.lg != nil {
- ls.lg.Warn("failed to receive lease keepalive request from gRPC stream", zap.Error(err))
- } else {
- plog.Warningf("failed to receive lease keepalive request from gRPC stream (%q)", err.Error())
- }
- streamFailures.WithLabelValues("receive", "lease-keepalive").Inc()
- }
- return err
- }
-
- // Create header before we sent out the renew request.
- // This can make sure that the revision is strictly smaller or equal to
- // when the keepalive happened at the local server (when the local server is the leader)
- // or remote leader.
- // Without this, a lease might be revoked at rev 3 but client can see the keepalive succeeded
- // at rev 4.
- resp := &pb.LeaseKeepAliveResponse{ID: req.ID, Header: &pb.ResponseHeader{}}
- ls.hdr.fill(resp.Header)
-
- ttl, err := ls.le.LeaseRenew(stream.Context(), lease.LeaseID(req.ID))
- if err == lease.ErrLeaseNotFound {
- err = nil
- ttl = 0
- }
-
- if err != nil {
- return togRPCError(err)
- }
-
- resp.TTL = ttl
- err = stream.Send(resp)
- if err != nil {
- if isClientCtxErr(stream.Context().Err(), err) {
- if ls.lg != nil {
- ls.lg.Debug("failed to send lease keepalive response to gRPC stream", zap.Error(err))
- } else {
- plog.Debugf("failed to send lease keepalive response to gRPC stream (%q)", err.Error())
- }
- } else {
- if ls.lg != nil {
- ls.lg.Warn("failed to send lease keepalive response to gRPC stream", zap.Error(err))
- } else {
- plog.Warningf("failed to send lease keepalive response to gRPC stream (%q)", err.Error())
- }
- streamFailures.WithLabelValues("send", "lease-keepalive").Inc()
- }
- return err
- }
- }
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/maintenance.go b/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/maintenance.go
deleted file mode 100644
index c51271a..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/maintenance.go
+++ /dev/null
@@ -1,260 +0,0 @@
-// Copyright 2016 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v3rpc
-
-import (
- "context"
- "crypto/sha256"
- "io"
-
- "go.etcd.io/etcd/auth"
- "go.etcd.io/etcd/etcdserver"
- "go.etcd.io/etcd/etcdserver/api/v3rpc/rpctypes"
- pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
- "go.etcd.io/etcd/mvcc"
- "go.etcd.io/etcd/mvcc/backend"
- "go.etcd.io/etcd/raft"
- "go.etcd.io/etcd/version"
-
- "go.uber.org/zap"
-)
-
-type KVGetter interface {
- KV() mvcc.ConsistentWatchableKV
-}
-
-type BackendGetter interface {
- Backend() backend.Backend
-}
-
-type Alarmer interface {
- // Alarms is implemented in Server interface located in etcdserver/server.go
- // It returns a list of alarms present in the AlarmStore
- Alarms() []*pb.AlarmMember
- Alarm(ctx context.Context, ar *pb.AlarmRequest) (*pb.AlarmResponse, error)
-}
-
-type LeaderTransferrer interface {
- MoveLeader(ctx context.Context, lead, target uint64) error
-}
-
-type AuthGetter interface {
- AuthInfoFromCtx(ctx context.Context) (*auth.AuthInfo, error)
- AuthStore() auth.AuthStore
-}
-
-type ClusterStatusGetter interface {
- IsLearner() bool
-}
-
-type maintenanceServer struct {
- lg *zap.Logger
- rg etcdserver.RaftStatusGetter
- kg KVGetter
- bg BackendGetter
- a Alarmer
- lt LeaderTransferrer
- hdr header
- cs ClusterStatusGetter
-}
-
-func NewMaintenanceServer(s *etcdserver.EtcdServer) pb.MaintenanceServer {
- srv := &maintenanceServer{lg: s.Cfg.Logger, rg: s, kg: s, bg: s, a: s, lt: s, hdr: newHeader(s), cs: s}
- return &authMaintenanceServer{srv, s}
-}
-
-func (ms *maintenanceServer) Defragment(ctx context.Context, sr *pb.DefragmentRequest) (*pb.DefragmentResponse, error) {
- if ms.lg != nil {
- ms.lg.Info("starting defragment")
- } else {
- plog.Noticef("starting to defragment the storage backend...")
- }
- err := ms.bg.Backend().Defrag()
- if err != nil {
- if ms.lg != nil {
- ms.lg.Warn("failed to defragment", zap.Error(err))
- } else {
- plog.Errorf("failed to defragment the storage backend (%v)", err)
- }
- return nil, err
- }
- if ms.lg != nil {
- ms.lg.Info("finished defragment")
- } else {
- plog.Noticef("finished defragmenting the storage backend")
- }
- return &pb.DefragmentResponse{}, nil
-}
-
-func (ms *maintenanceServer) Snapshot(sr *pb.SnapshotRequest, srv pb.Maintenance_SnapshotServer) error {
- snap := ms.bg.Backend().Snapshot()
- pr, pw := io.Pipe()
-
- defer pr.Close()
-
- go func() {
- snap.WriteTo(pw)
- if err := snap.Close(); err != nil {
- if ms.lg != nil {
- ms.lg.Warn("failed to close snapshot", zap.Error(err))
- } else {
- plog.Errorf("error closing snapshot (%v)", err)
- }
- }
- pw.Close()
- }()
-
- // send file data
- h := sha256.New()
- br := int64(0)
- buf := make([]byte, 32*1024)
- sz := snap.Size()
- for br < sz {
- n, err := io.ReadFull(pr, buf)
- if err != nil && err != io.EOF && err != io.ErrUnexpectedEOF {
- return togRPCError(err)
- }
- br += int64(n)
- resp := &pb.SnapshotResponse{
- RemainingBytes: uint64(sz - br),
- Blob: buf[:n],
- }
- if err = srv.Send(resp); err != nil {
- return togRPCError(err)
- }
- h.Write(buf[:n])
- }
-
- // send sha
- sha := h.Sum(nil)
- hresp := &pb.SnapshotResponse{RemainingBytes: 0, Blob: sha}
- if err := srv.Send(hresp); err != nil {
- return togRPCError(err)
- }
-
- return nil
-}
-
-func (ms *maintenanceServer) Hash(ctx context.Context, r *pb.HashRequest) (*pb.HashResponse, error) {
- h, rev, err := ms.kg.KV().Hash()
- if err != nil {
- return nil, togRPCError(err)
- }
- resp := &pb.HashResponse{Header: &pb.ResponseHeader{Revision: rev}, Hash: h}
- ms.hdr.fill(resp.Header)
- return resp, nil
-}
-
-func (ms *maintenanceServer) HashKV(ctx context.Context, r *pb.HashKVRequest) (*pb.HashKVResponse, error) {
- h, rev, compactRev, err := ms.kg.KV().HashByRev(r.Revision)
- if err != nil {
- return nil, togRPCError(err)
- }
-
- resp := &pb.HashKVResponse{Header: &pb.ResponseHeader{Revision: rev}, Hash: h, CompactRevision: compactRev}
- ms.hdr.fill(resp.Header)
- return resp, nil
-}
-
-func (ms *maintenanceServer) Alarm(ctx context.Context, ar *pb.AlarmRequest) (*pb.AlarmResponse, error) {
- return ms.a.Alarm(ctx, ar)
-}
-
-func (ms *maintenanceServer) Status(ctx context.Context, ar *pb.StatusRequest) (*pb.StatusResponse, error) {
- hdr := &pb.ResponseHeader{}
- ms.hdr.fill(hdr)
- resp := &pb.StatusResponse{
- Header: hdr,
- Version: version.Version,
- Leader: uint64(ms.rg.Leader()),
- RaftIndex: ms.rg.CommittedIndex(),
- RaftAppliedIndex: ms.rg.AppliedIndex(),
- RaftTerm: ms.rg.Term(),
- DbSize: ms.bg.Backend().Size(),
- DbSizeInUse: ms.bg.Backend().SizeInUse(),
- IsLearner: ms.cs.IsLearner(),
- }
- if resp.Leader == raft.None {
- resp.Errors = append(resp.Errors, etcdserver.ErrNoLeader.Error())
- }
- for _, a := range ms.a.Alarms() {
- resp.Errors = append(resp.Errors, a.String())
- }
- return resp, nil
-}
-
-func (ms *maintenanceServer) MoveLeader(ctx context.Context, tr *pb.MoveLeaderRequest) (*pb.MoveLeaderResponse, error) {
- if ms.rg.ID() != ms.rg.Leader() {
- return nil, rpctypes.ErrGRPCNotLeader
- }
-
- if err := ms.lt.MoveLeader(ctx, uint64(ms.rg.Leader()), tr.TargetID); err != nil {
- return nil, togRPCError(err)
- }
- return &pb.MoveLeaderResponse{}, nil
-}
-
-type authMaintenanceServer struct {
- *maintenanceServer
- ag AuthGetter
-}
-
-func (ams *authMaintenanceServer) isAuthenticated(ctx context.Context) error {
- authInfo, err := ams.ag.AuthInfoFromCtx(ctx)
- if err != nil {
- return err
- }
-
- return ams.ag.AuthStore().IsAdminPermitted(authInfo)
-}
-
-func (ams *authMaintenanceServer) Defragment(ctx context.Context, sr *pb.DefragmentRequest) (*pb.DefragmentResponse, error) {
- if err := ams.isAuthenticated(ctx); err != nil {
- return nil, err
- }
-
- return ams.maintenanceServer.Defragment(ctx, sr)
-}
-
-func (ams *authMaintenanceServer) Snapshot(sr *pb.SnapshotRequest, srv pb.Maintenance_SnapshotServer) error {
- if err := ams.isAuthenticated(srv.Context()); err != nil {
- return err
- }
-
- return ams.maintenanceServer.Snapshot(sr, srv)
-}
-
-func (ams *authMaintenanceServer) Hash(ctx context.Context, r *pb.HashRequest) (*pb.HashResponse, error) {
- if err := ams.isAuthenticated(ctx); err != nil {
- return nil, err
- }
-
- return ams.maintenanceServer.Hash(ctx, r)
-}
-
-func (ams *authMaintenanceServer) HashKV(ctx context.Context, r *pb.HashKVRequest) (*pb.HashKVResponse, error) {
- if err := ams.isAuthenticated(ctx); err != nil {
- return nil, err
- }
- return ams.maintenanceServer.HashKV(ctx, r)
-}
-
-func (ams *authMaintenanceServer) Status(ctx context.Context, ar *pb.StatusRequest) (*pb.StatusResponse, error) {
- return ams.maintenanceServer.Status(ctx, ar)
-}
-
-func (ams *authMaintenanceServer) MoveLeader(ctx context.Context, tr *pb.MoveLeaderRequest) (*pb.MoveLeaderResponse, error) {
- return ams.maintenanceServer.MoveLeader(ctx, tr)
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/member.go b/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/member.go
deleted file mode 100644
index b2ebc98..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/member.go
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright 2016 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v3rpc
-
-import (
- "context"
- "time"
-
- "go.etcd.io/etcd/etcdserver"
- "go.etcd.io/etcd/etcdserver/api"
- "go.etcd.io/etcd/etcdserver/api/membership"
- "go.etcd.io/etcd/etcdserver/api/v3rpc/rpctypes"
- pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
- "go.etcd.io/etcd/pkg/types"
-)
-
-type ClusterServer struct {
- cluster api.Cluster
- server etcdserver.ServerV3
-}
-
-func NewClusterServer(s etcdserver.ServerV3) *ClusterServer {
- return &ClusterServer{
- cluster: s.Cluster(),
- server: s,
- }
-}
-
-func (cs *ClusterServer) MemberAdd(ctx context.Context, r *pb.MemberAddRequest) (*pb.MemberAddResponse, error) {
- urls, err := types.NewURLs(r.PeerURLs)
- if err != nil {
- return nil, rpctypes.ErrGRPCMemberBadURLs
- }
-
- now := time.Now()
- var m *membership.Member
- if r.IsLearner {
- m = membership.NewMemberAsLearner("", urls, "", &now)
- } else {
- m = membership.NewMember("", urls, "", &now)
- }
- membs, merr := cs.server.AddMember(ctx, *m)
- if merr != nil {
- return nil, togRPCError(merr)
- }
-
- return &pb.MemberAddResponse{
- Header: cs.header(),
- Member: &pb.Member{
- ID: uint64(m.ID),
- PeerURLs: m.PeerURLs,
- IsLearner: m.IsLearner,
- },
- Members: membersToProtoMembers(membs),
- }, nil
-}
-
-func (cs *ClusterServer) MemberRemove(ctx context.Context, r *pb.MemberRemoveRequest) (*pb.MemberRemoveResponse, error) {
- membs, err := cs.server.RemoveMember(ctx, r.ID)
- if err != nil {
- return nil, togRPCError(err)
- }
- return &pb.MemberRemoveResponse{Header: cs.header(), Members: membersToProtoMembers(membs)}, nil
-}
-
-func (cs *ClusterServer) MemberUpdate(ctx context.Context, r *pb.MemberUpdateRequest) (*pb.MemberUpdateResponse, error) {
- m := membership.Member{
- ID: types.ID(r.ID),
- RaftAttributes: membership.RaftAttributes{PeerURLs: r.PeerURLs},
- }
- membs, err := cs.server.UpdateMember(ctx, m)
- if err != nil {
- return nil, togRPCError(err)
- }
- return &pb.MemberUpdateResponse{Header: cs.header(), Members: membersToProtoMembers(membs)}, nil
-}
-
-func (cs *ClusterServer) MemberList(ctx context.Context, r *pb.MemberListRequest) (*pb.MemberListResponse, error) {
- membs := membersToProtoMembers(cs.cluster.Members())
- return &pb.MemberListResponse{Header: cs.header(), Members: membs}, nil
-}
-
-func (cs *ClusterServer) MemberPromote(ctx context.Context, r *pb.MemberPromoteRequest) (*pb.MemberPromoteResponse, error) {
- membs, err := cs.server.PromoteMember(ctx, r.ID)
- if err != nil {
- return nil, togRPCError(err)
- }
- return &pb.MemberPromoteResponse{Header: cs.header(), Members: membersToProtoMembers(membs)}, nil
-}
-
-func (cs *ClusterServer) header() *pb.ResponseHeader {
- return &pb.ResponseHeader{ClusterId: uint64(cs.cluster.ID()), MemberId: uint64(cs.server.ID()), RaftTerm: cs.server.Term()}
-}
-
-func membersToProtoMembers(membs []*membership.Member) []*pb.Member {
- protoMembs := make([]*pb.Member, len(membs))
- for i := range membs {
- protoMembs[i] = &pb.Member{
- Name: membs[i].Name,
- ID: uint64(membs[i].ID),
- PeerURLs: membs[i].PeerURLs,
- ClientURLs: membs[i].ClientURLs,
- IsLearner: membs[i].IsLearner,
- }
- }
- return protoMembs
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/metrics.go b/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/metrics.go
deleted file mode 100644
index d633d27..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/metrics.go
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright 2016 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v3rpc
-
-import "github.com/prometheus/client_golang/prometheus"
-
-var (
- sentBytes = prometheus.NewCounter(prometheus.CounterOpts{
- Namespace: "etcd",
- Subsystem: "network",
- Name: "client_grpc_sent_bytes_total",
- Help: "The total number of bytes sent to grpc clients.",
- })
-
- receivedBytes = prometheus.NewCounter(prometheus.CounterOpts{
- Namespace: "etcd",
- Subsystem: "network",
- Name: "client_grpc_received_bytes_total",
- Help: "The total number of bytes received from grpc clients.",
- })
-
- streamFailures = prometheus.NewCounterVec(prometheus.CounterOpts{
- Namespace: "etcd",
- Subsystem: "network",
- Name: "server_stream_failures_total",
- Help: "The total number of stream failures from the local server.",
- },
- []string{"Type", "API"},
- )
-)
-
-func init() {
- prometheus.MustRegister(sentBytes)
- prometheus.MustRegister(receivedBytes)
- prometheus.MustRegister(streamFailures)
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/quota.go b/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/quota.go
deleted file mode 100644
index a145b8b..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/quota.go
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright 2016 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v3rpc
-
-import (
- "context"
-
- "go.etcd.io/etcd/etcdserver"
- "go.etcd.io/etcd/etcdserver/api/v3rpc/rpctypes"
- pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
- "go.etcd.io/etcd/pkg/types"
-)
-
-type quotaKVServer struct {
- pb.KVServer
- qa quotaAlarmer
-}
-
-type quotaAlarmer struct {
- q etcdserver.Quota
- a Alarmer
- id types.ID
-}
-
-// check whether request satisfies the quota. If there is not enough space,
-// ignore request and raise the free space alarm.
-func (qa *quotaAlarmer) check(ctx context.Context, r interface{}) error {
- if qa.q.Available(r) {
- return nil
- }
- req := &pb.AlarmRequest{
- MemberID: uint64(qa.id),
- Action: pb.AlarmRequest_ACTIVATE,
- Alarm: pb.AlarmType_NOSPACE,
- }
- qa.a.Alarm(ctx, req)
- return rpctypes.ErrGRPCNoSpace
-}
-
-func NewQuotaKVServer(s *etcdserver.EtcdServer) pb.KVServer {
- return "aKVServer{
- NewKVServer(s),
- quotaAlarmer{etcdserver.NewBackendQuota(s, "kv"), s, s.ID()},
- }
-}
-
-func (s *quotaKVServer) Put(ctx context.Context, r *pb.PutRequest) (*pb.PutResponse, error) {
- if err := s.qa.check(ctx, r); err != nil {
- return nil, err
- }
- return s.KVServer.Put(ctx, r)
-}
-
-func (s *quotaKVServer) Txn(ctx context.Context, r *pb.TxnRequest) (*pb.TxnResponse, error) {
- if err := s.qa.check(ctx, r); err != nil {
- return nil, err
- }
- return s.KVServer.Txn(ctx, r)
-}
-
-type quotaLeaseServer struct {
- pb.LeaseServer
- qa quotaAlarmer
-}
-
-func (s *quotaLeaseServer) LeaseGrant(ctx context.Context, cr *pb.LeaseGrantRequest) (*pb.LeaseGrantResponse, error) {
- if err := s.qa.check(ctx, cr); err != nil {
- return nil, err
- }
- return s.LeaseServer.LeaseGrant(ctx, cr)
-}
-
-func NewQuotaLeaseServer(s *etcdserver.EtcdServer) pb.LeaseServer {
- return "aLeaseServer{
- NewLeaseServer(s),
- quotaAlarmer{etcdserver.NewBackendQuota(s, "lease"), s, s.ID()},
- }
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/rpctypes/error.go b/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/rpctypes/error.go
index e6a2814..bc1ad7b 100644
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/rpctypes/error.go
+++ b/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/rpctypes/error.go
@@ -40,9 +40,6 @@
ErrGRPCMemberNotEnoughStarted = status.New(codes.FailedPrecondition, "etcdserver: re-configuration failed due to not enough started members").Err()
ErrGRPCMemberBadURLs = status.New(codes.InvalidArgument, "etcdserver: given member URLs are invalid").Err()
ErrGRPCMemberNotFound = status.New(codes.NotFound, "etcdserver: member not found").Err()
- ErrGRPCMemberNotLearner = status.New(codes.FailedPrecondition, "etcdserver: can only promote a learner member").Err()
- ErrGRPCLearnerNotReady = status.New(codes.FailedPrecondition, "etcdserver: can only promote a learner member which is in sync with leader").Err()
- ErrGRPCTooManyLearners = status.New(codes.FailedPrecondition, "etcdserver: too many learner members in cluster").Err()
ErrGRPCRequestTooLarge = status.New(codes.InvalidArgument, "etcdserver: request is too large").Err()
ErrGRPCRequestTooManyRequests = status.New(codes.ResourceExhausted, "etcdserver: too many requests").Err()
@@ -54,7 +51,6 @@
ErrGRPCUserNotFound = status.New(codes.FailedPrecondition, "etcdserver: user name not found").Err()
ErrGRPCRoleAlreadyExist = status.New(codes.FailedPrecondition, "etcdserver: role name already exists").Err()
ErrGRPCRoleNotFound = status.New(codes.FailedPrecondition, "etcdserver: role name not found").Err()
- ErrGRPCRoleEmpty = status.New(codes.InvalidArgument, "etcdserver: role name is empty").Err()
ErrGRPCAuthFailed = status.New(codes.InvalidArgument, "etcdserver: authentication failed, invalid user ID or password").Err()
ErrGRPCPermissionDenied = status.New(codes.PermissionDenied, "etcdserver: permission denied").Err()
ErrGRPCRoleNotGranted = status.New(codes.FailedPrecondition, "etcdserver: role is not granted to the user").Err()
@@ -73,8 +69,6 @@
ErrGRPCTimeoutDueToConnectionLost = status.New(codes.Unavailable, "etcdserver: request timed out, possibly due to connection lost").Err()
ErrGRPCUnhealthy = status.New(codes.Unavailable, "etcdserver: unhealthy cluster").Err()
ErrGRPCCorrupt = status.New(codes.DataLoss, "etcdserver: corrupt cluster").Err()
- ErrGPRCNotSupportedForLearner = status.New(codes.Unavailable, "etcdserver: rpc not supported for learner").Err()
- ErrGRPCBadLeaderTransferee = status.New(codes.FailedPrecondition, "etcdserver: bad leader transferee").Err()
errStringToError = map[string]error{
ErrorDesc(ErrGRPCEmptyKey): ErrGRPCEmptyKey,
@@ -97,9 +91,6 @@
ErrorDesc(ErrGRPCMemberNotEnoughStarted): ErrGRPCMemberNotEnoughStarted,
ErrorDesc(ErrGRPCMemberBadURLs): ErrGRPCMemberBadURLs,
ErrorDesc(ErrGRPCMemberNotFound): ErrGRPCMemberNotFound,
- ErrorDesc(ErrGRPCMemberNotLearner): ErrGRPCMemberNotLearner,
- ErrorDesc(ErrGRPCLearnerNotReady): ErrGRPCLearnerNotReady,
- ErrorDesc(ErrGRPCTooManyLearners): ErrGRPCTooManyLearners,
ErrorDesc(ErrGRPCRequestTooLarge): ErrGRPCRequestTooLarge,
ErrorDesc(ErrGRPCRequestTooManyRequests): ErrGRPCRequestTooManyRequests,
@@ -111,7 +102,6 @@
ErrorDesc(ErrGRPCUserNotFound): ErrGRPCUserNotFound,
ErrorDesc(ErrGRPCRoleAlreadyExist): ErrGRPCRoleAlreadyExist,
ErrorDesc(ErrGRPCRoleNotFound): ErrGRPCRoleNotFound,
- ErrorDesc(ErrGRPCRoleEmpty): ErrGRPCRoleEmpty,
ErrorDesc(ErrGRPCAuthFailed): ErrGRPCAuthFailed,
ErrorDesc(ErrGRPCPermissionDenied): ErrGRPCPermissionDenied,
ErrorDesc(ErrGRPCRoleNotGranted): ErrGRPCRoleNotGranted,
@@ -122,7 +112,6 @@
ErrorDesc(ErrGRPCNoLeader): ErrGRPCNoLeader,
ErrorDesc(ErrGRPCNotLeader): ErrGRPCNotLeader,
- ErrorDesc(ErrGRPCLeaderChanged): ErrGRPCLeaderChanged,
ErrorDesc(ErrGRPCNotCapable): ErrGRPCNotCapable,
ErrorDesc(ErrGRPCStopped): ErrGRPCStopped,
ErrorDesc(ErrGRPCTimeout): ErrGRPCTimeout,
@@ -130,8 +119,6 @@
ErrorDesc(ErrGRPCTimeoutDueToConnectionLost): ErrGRPCTimeoutDueToConnectionLost,
ErrorDesc(ErrGRPCUnhealthy): ErrGRPCUnhealthy,
ErrorDesc(ErrGRPCCorrupt): ErrGRPCCorrupt,
- ErrorDesc(ErrGPRCNotSupportedForLearner): ErrGPRCNotSupportedForLearner,
- ErrorDesc(ErrGRPCBadLeaderTransferee): ErrGRPCBadLeaderTransferee,
}
)
@@ -156,9 +143,6 @@
ErrMemberNotEnoughStarted = Error(ErrGRPCMemberNotEnoughStarted)
ErrMemberBadURLs = Error(ErrGRPCMemberBadURLs)
ErrMemberNotFound = Error(ErrGRPCMemberNotFound)
- ErrMemberNotLearner = Error(ErrGRPCMemberNotLearner)
- ErrMemberLearnerNotReady = Error(ErrGRPCLearnerNotReady)
- ErrTooManyLearners = Error(ErrGRPCTooManyLearners)
ErrRequestTooLarge = Error(ErrGRPCRequestTooLarge)
ErrTooManyRequests = Error(ErrGRPCRequestTooManyRequests)
@@ -170,7 +154,6 @@
ErrUserNotFound = Error(ErrGRPCUserNotFound)
ErrRoleAlreadyExist = Error(ErrGRPCRoleAlreadyExist)
ErrRoleNotFound = Error(ErrGRPCRoleNotFound)
- ErrRoleEmpty = Error(ErrGRPCRoleEmpty)
ErrAuthFailed = Error(ErrGRPCAuthFailed)
ErrPermissionDenied = Error(ErrGRPCPermissionDenied)
ErrRoleNotGranted = Error(ErrGRPCRoleNotGranted)
@@ -189,7 +172,6 @@
ErrTimeoutDueToConnectionLost = Error(ErrGRPCTimeoutDueToConnectionLost)
ErrUnhealthy = Error(ErrGRPCUnhealthy)
ErrCorrupt = Error(ErrGRPCCorrupt)
- ErrBadLeaderTransferee = Error(ErrGRPCBadLeaderTransferee)
)
// EtcdError defines gRPC server errors.
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/rpctypes/md.go b/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/rpctypes/md.go
index 5c590e1..90b8b83 100644
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/rpctypes/md.go
+++ b/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/rpctypes/md.go
@@ -17,4 +17,6 @@
var (
MetadataRequireLeaderKey = "hasleader"
MetadataHasLeader = "true"
+
+ MetadataClientAPIVersionKey = "client-api-version"
)
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/util.go b/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/util.go
deleted file mode 100644
index 281ddc7..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/util.go
+++ /dev/null
@@ -1,136 +0,0 @@
-// Copyright 2016 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v3rpc
-
-import (
- "context"
- "strings"
-
- "go.etcd.io/etcd/auth"
- "go.etcd.io/etcd/etcdserver"
- "go.etcd.io/etcd/etcdserver/api/membership"
- "go.etcd.io/etcd/etcdserver/api/v3rpc/rpctypes"
- pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
- "go.etcd.io/etcd/lease"
- "go.etcd.io/etcd/mvcc"
-
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/status"
-)
-
-var toGRPCErrorMap = map[error]error{
- membership.ErrIDRemoved: rpctypes.ErrGRPCMemberNotFound,
- membership.ErrIDNotFound: rpctypes.ErrGRPCMemberNotFound,
- membership.ErrIDExists: rpctypes.ErrGRPCMemberExist,
- membership.ErrPeerURLexists: rpctypes.ErrGRPCPeerURLExist,
- membership.ErrMemberNotLearner: rpctypes.ErrGRPCMemberNotLearner,
- membership.ErrTooManyLearners: rpctypes.ErrGRPCTooManyLearners,
- etcdserver.ErrNotEnoughStartedMembers: rpctypes.ErrMemberNotEnoughStarted,
- etcdserver.ErrLearnerNotReady: rpctypes.ErrGRPCLearnerNotReady,
-
- mvcc.ErrCompacted: rpctypes.ErrGRPCCompacted,
- mvcc.ErrFutureRev: rpctypes.ErrGRPCFutureRev,
- etcdserver.ErrRequestTooLarge: rpctypes.ErrGRPCRequestTooLarge,
- etcdserver.ErrNoSpace: rpctypes.ErrGRPCNoSpace,
- etcdserver.ErrTooManyRequests: rpctypes.ErrTooManyRequests,
-
- etcdserver.ErrNoLeader: rpctypes.ErrGRPCNoLeader,
- etcdserver.ErrNotLeader: rpctypes.ErrGRPCNotLeader,
- etcdserver.ErrLeaderChanged: rpctypes.ErrGRPCLeaderChanged,
- etcdserver.ErrStopped: rpctypes.ErrGRPCStopped,
- etcdserver.ErrTimeout: rpctypes.ErrGRPCTimeout,
- etcdserver.ErrTimeoutDueToLeaderFail: rpctypes.ErrGRPCTimeoutDueToLeaderFail,
- etcdserver.ErrTimeoutDueToConnectionLost: rpctypes.ErrGRPCTimeoutDueToConnectionLost,
- etcdserver.ErrUnhealthy: rpctypes.ErrGRPCUnhealthy,
- etcdserver.ErrKeyNotFound: rpctypes.ErrGRPCKeyNotFound,
- etcdserver.ErrCorrupt: rpctypes.ErrGRPCCorrupt,
- etcdserver.ErrBadLeaderTransferee: rpctypes.ErrGRPCBadLeaderTransferee,
-
- lease.ErrLeaseNotFound: rpctypes.ErrGRPCLeaseNotFound,
- lease.ErrLeaseExists: rpctypes.ErrGRPCLeaseExist,
- lease.ErrLeaseTTLTooLarge: rpctypes.ErrGRPCLeaseTTLTooLarge,
-
- auth.ErrRootUserNotExist: rpctypes.ErrGRPCRootUserNotExist,
- auth.ErrRootRoleNotExist: rpctypes.ErrGRPCRootRoleNotExist,
- auth.ErrUserAlreadyExist: rpctypes.ErrGRPCUserAlreadyExist,
- auth.ErrUserEmpty: rpctypes.ErrGRPCUserEmpty,
- auth.ErrUserNotFound: rpctypes.ErrGRPCUserNotFound,
- auth.ErrRoleAlreadyExist: rpctypes.ErrGRPCRoleAlreadyExist,
- auth.ErrRoleNotFound: rpctypes.ErrGRPCRoleNotFound,
- auth.ErrRoleEmpty: rpctypes.ErrGRPCRoleEmpty,
- auth.ErrAuthFailed: rpctypes.ErrGRPCAuthFailed,
- auth.ErrPermissionDenied: rpctypes.ErrGRPCPermissionDenied,
- auth.ErrRoleNotGranted: rpctypes.ErrGRPCRoleNotGranted,
- auth.ErrPermissionNotGranted: rpctypes.ErrGRPCPermissionNotGranted,
- auth.ErrAuthNotEnabled: rpctypes.ErrGRPCAuthNotEnabled,
- auth.ErrInvalidAuthToken: rpctypes.ErrGRPCInvalidAuthToken,
- auth.ErrInvalidAuthMgmt: rpctypes.ErrGRPCInvalidAuthMgmt,
-}
-
-func togRPCError(err error) error {
- // let gRPC server convert to codes.Canceled, codes.DeadlineExceeded
- if err == context.Canceled || err == context.DeadlineExceeded {
- return err
- }
- grpcErr, ok := toGRPCErrorMap[err]
- if !ok {
- return status.Error(codes.Unknown, err.Error())
- }
- return grpcErr
-}
-
-func isClientCtxErr(ctxErr error, err error) bool {
- if ctxErr != nil {
- return true
- }
-
- ev, ok := status.FromError(err)
- if !ok {
- return false
- }
-
- switch ev.Code() {
- case codes.Canceled, codes.DeadlineExceeded:
- // client-side context cancel or deadline exceeded
- // "rpc error: code = Canceled desc = context canceled"
- // "rpc error: code = DeadlineExceeded desc = context deadline exceeded"
- return true
- case codes.Unavailable:
- msg := ev.Message()
- // client-side context cancel or deadline exceeded with TLS ("http2.errClientDisconnected")
- // "rpc error: code = Unavailable desc = client disconnected"
- if msg == "client disconnected" {
- return true
- }
- // "grpc/transport.ClientTransport.CloseStream" on canceled streams
- // "rpc error: code = Unavailable desc = stream error: stream ID 21; CANCEL")
- if strings.HasPrefix(msg, "stream error: ") && strings.HasSuffix(msg, "; CANCEL") {
- return true
- }
- }
- return false
-}
-
-// in v3.4, learner is allowed to serve serializable read and endpoint status
-func isRPCSupportedForLearner(req interface{}) bool {
- switch r := req.(type) {
- case *pb.StatusRequest:
- return true
- case *pb.RangeRequest:
- return r.Serializable
- default:
- return false
- }
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/watch.go b/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/watch.go
deleted file mode 100644
index f41cb6c..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/api/v3rpc/watch.go
+++ /dev/null
@@ -1,584 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package v3rpc
-
-import (
- "context"
- "io"
- "math/rand"
- "sync"
- "time"
-
- "go.etcd.io/etcd/auth"
- "go.etcd.io/etcd/etcdserver"
- "go.etcd.io/etcd/etcdserver/api/v3rpc/rpctypes"
- pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
- "go.etcd.io/etcd/mvcc"
- "go.etcd.io/etcd/mvcc/mvccpb"
-
- "go.uber.org/zap"
-)
-
-type watchServer struct {
- lg *zap.Logger
-
- clusterID int64
- memberID int64
-
- maxRequestBytes int
-
- sg etcdserver.RaftStatusGetter
- watchable mvcc.WatchableKV
- ag AuthGetter
-}
-
-// NewWatchServer returns a new watch server.
-func NewWatchServer(s *etcdserver.EtcdServer) pb.WatchServer {
- return &watchServer{
- lg: s.Cfg.Logger,
-
- clusterID: int64(s.Cluster().ID()),
- memberID: int64(s.ID()),
-
- maxRequestBytes: int(s.Cfg.MaxRequestBytes + grpcOverheadBytes),
-
- sg: s,
- watchable: s.Watchable(),
- ag: s,
- }
-}
-
-var (
- // External test can read this with GetProgressReportInterval()
- // and change this to a small value to finish fast with
- // SetProgressReportInterval().
- progressReportInterval = 10 * time.Minute
- progressReportIntervalMu sync.RWMutex
-)
-
-// GetProgressReportInterval returns the current progress report interval (for testing).
-func GetProgressReportInterval() time.Duration {
- progressReportIntervalMu.RLock()
- interval := progressReportInterval
- progressReportIntervalMu.RUnlock()
-
- // add rand(1/10*progressReportInterval) as jitter so that etcdserver will not
- // send progress notifications to watchers around the same time even when watchers
- // are created around the same time (which is common when a client restarts itself).
- jitter := time.Duration(rand.Int63n(int64(interval) / 10))
-
- return interval + jitter
-}
-
-// SetProgressReportInterval updates the current progress report interval (for testing).
-func SetProgressReportInterval(newTimeout time.Duration) {
- progressReportIntervalMu.Lock()
- progressReportInterval = newTimeout
- progressReportIntervalMu.Unlock()
-}
-
-// We send ctrl response inside the read loop. We do not want
-// send to block read, but we still want ctrl response we sent to
-// be serialized. Thus we use a buffered chan to solve the problem.
-// A small buffer should be OK for most cases, since we expect the
-// ctrl requests are infrequent.
-const ctrlStreamBufLen = 16
-
-// serverWatchStream is an etcd server side stream. It receives requests
-// from client side gRPC stream. It receives watch events from mvcc.WatchStream,
-// and creates responses that forwarded to gRPC stream.
-// It also forwards control message like watch created and canceled.
-type serverWatchStream struct {
- lg *zap.Logger
-
- clusterID int64
- memberID int64
-
- maxRequestBytes int
-
- sg etcdserver.RaftStatusGetter
- watchable mvcc.WatchableKV
- ag AuthGetter
-
- gRPCStream pb.Watch_WatchServer
- watchStream mvcc.WatchStream
- ctrlStream chan *pb.WatchResponse
-
- // mu protects progress, prevKV, fragment
- mu sync.RWMutex
- // tracks the watchID that stream might need to send progress to
- // TODO: combine progress and prevKV into a single struct?
- progress map[mvcc.WatchID]bool
- // record watch IDs that need return previous key-value pair
- prevKV map[mvcc.WatchID]bool
- // records fragmented watch IDs
- fragment map[mvcc.WatchID]bool
-
- // closec indicates the stream is closed.
- closec chan struct{}
-
- // wg waits for the send loop to complete
- wg sync.WaitGroup
-}
-
-func (ws *watchServer) Watch(stream pb.Watch_WatchServer) (err error) {
- sws := serverWatchStream{
- lg: ws.lg,
-
- clusterID: ws.clusterID,
- memberID: ws.memberID,
-
- maxRequestBytes: ws.maxRequestBytes,
-
- sg: ws.sg,
- watchable: ws.watchable,
- ag: ws.ag,
-
- gRPCStream: stream,
- watchStream: ws.watchable.NewWatchStream(),
- // chan for sending control response like watcher created and canceled.
- ctrlStream: make(chan *pb.WatchResponse, ctrlStreamBufLen),
-
- progress: make(map[mvcc.WatchID]bool),
- prevKV: make(map[mvcc.WatchID]bool),
- fragment: make(map[mvcc.WatchID]bool),
-
- closec: make(chan struct{}),
- }
-
- sws.wg.Add(1)
- go func() {
- sws.sendLoop()
- sws.wg.Done()
- }()
-
- errc := make(chan error, 1)
- // Ideally recvLoop would also use sws.wg to signal its completion
- // but when stream.Context().Done() is closed, the stream's recv
- // may continue to block since it uses a different context, leading to
- // deadlock when calling sws.close().
- go func() {
- if rerr := sws.recvLoop(); rerr != nil {
- if isClientCtxErr(stream.Context().Err(), rerr) {
- if sws.lg != nil {
- sws.lg.Debug("failed to receive watch request from gRPC stream", zap.Error(rerr))
- } else {
- plog.Debugf("failed to receive watch request from gRPC stream (%q)", rerr.Error())
- }
- } else {
- if sws.lg != nil {
- sws.lg.Warn("failed to receive watch request from gRPC stream", zap.Error(rerr))
- } else {
- plog.Warningf("failed to receive watch request from gRPC stream (%q)", rerr.Error())
- }
- streamFailures.WithLabelValues("receive", "watch").Inc()
- }
- errc <- rerr
- }
- }()
-
- select {
- case err = <-errc:
- close(sws.ctrlStream)
-
- case <-stream.Context().Done():
- err = stream.Context().Err()
- // the only server-side cancellation is noleader for now.
- if err == context.Canceled {
- err = rpctypes.ErrGRPCNoLeader
- }
- }
-
- sws.close()
- return err
-}
-
-func (sws *serverWatchStream) isWatchPermitted(wcr *pb.WatchCreateRequest) bool {
- authInfo, err := sws.ag.AuthInfoFromCtx(sws.gRPCStream.Context())
- if err != nil {
- return false
- }
- if authInfo == nil {
- // if auth is enabled, IsRangePermitted() can cause an error
- authInfo = &auth.AuthInfo{}
- }
- return sws.ag.AuthStore().IsRangePermitted(authInfo, wcr.Key, wcr.RangeEnd) == nil
-}
-
-func (sws *serverWatchStream) recvLoop() error {
- for {
- req, err := sws.gRPCStream.Recv()
- if err == io.EOF {
- return nil
- }
- if err != nil {
- return err
- }
-
- switch uv := req.RequestUnion.(type) {
- case *pb.WatchRequest_CreateRequest:
- if uv.CreateRequest == nil {
- break
- }
-
- creq := uv.CreateRequest
- if len(creq.Key) == 0 {
- // \x00 is the smallest key
- creq.Key = []byte{0}
- }
- if len(creq.RangeEnd) == 0 {
- // force nil since watchstream.Watch distinguishes
- // between nil and []byte{} for single key / >=
- creq.RangeEnd = nil
- }
- if len(creq.RangeEnd) == 1 && creq.RangeEnd[0] == 0 {
- // support >= key queries
- creq.RangeEnd = []byte{}
- }
-
- if !sws.isWatchPermitted(creq) {
- wr := &pb.WatchResponse{
- Header: sws.newResponseHeader(sws.watchStream.Rev()),
- WatchId: creq.WatchId,
- Canceled: true,
- Created: true,
- CancelReason: rpctypes.ErrGRPCPermissionDenied.Error(),
- }
-
- select {
- case sws.ctrlStream <- wr:
- case <-sws.closec:
- }
- return nil
- }
-
- filters := FiltersFromRequest(creq)
-
- wsrev := sws.watchStream.Rev()
- rev := creq.StartRevision
- if rev == 0 {
- rev = wsrev + 1
- }
- id, err := sws.watchStream.Watch(mvcc.WatchID(creq.WatchId), creq.Key, creq.RangeEnd, rev, filters...)
- if err == nil {
- sws.mu.Lock()
- if creq.ProgressNotify {
- sws.progress[id] = true
- }
- if creq.PrevKv {
- sws.prevKV[id] = true
- }
- if creq.Fragment {
- sws.fragment[id] = true
- }
- sws.mu.Unlock()
- }
- wr := &pb.WatchResponse{
- Header: sws.newResponseHeader(wsrev),
- WatchId: int64(id),
- Created: true,
- Canceled: err != nil,
- }
- if err != nil {
- wr.CancelReason = err.Error()
- }
- select {
- case sws.ctrlStream <- wr:
- case <-sws.closec:
- return nil
- }
-
- case *pb.WatchRequest_CancelRequest:
- if uv.CancelRequest != nil {
- id := uv.CancelRequest.WatchId
- err := sws.watchStream.Cancel(mvcc.WatchID(id))
- if err == nil {
- sws.ctrlStream <- &pb.WatchResponse{
- Header: sws.newResponseHeader(sws.watchStream.Rev()),
- WatchId: id,
- Canceled: true,
- }
- sws.mu.Lock()
- delete(sws.progress, mvcc.WatchID(id))
- delete(sws.prevKV, mvcc.WatchID(id))
- delete(sws.fragment, mvcc.WatchID(id))
- sws.mu.Unlock()
- }
- }
- case *pb.WatchRequest_ProgressRequest:
- if uv.ProgressRequest != nil {
- sws.ctrlStream <- &pb.WatchResponse{
- Header: sws.newResponseHeader(sws.watchStream.Rev()),
- WatchId: -1, // response is not associated with any WatchId and will be broadcast to all watch channels
- }
- }
- default:
- // we probably should not shutdown the entire stream when
- // receive an valid command.
- // so just do nothing instead.
- continue
- }
- }
-}
-
-func (sws *serverWatchStream) sendLoop() {
- // watch ids that are currently active
- ids := make(map[mvcc.WatchID]struct{})
- // watch responses pending on a watch id creation message
- pending := make(map[mvcc.WatchID][]*pb.WatchResponse)
-
- interval := GetProgressReportInterval()
- progressTicker := time.NewTicker(interval)
-
- defer func() {
- progressTicker.Stop()
- // drain the chan to clean up pending events
- for ws := range sws.watchStream.Chan() {
- mvcc.ReportEventReceived(len(ws.Events))
- }
- for _, wrs := range pending {
- for _, ws := range wrs {
- mvcc.ReportEventReceived(len(ws.Events))
- }
- }
- }()
-
- for {
- select {
- case wresp, ok := <-sws.watchStream.Chan():
- if !ok {
- return
- }
-
- // TODO: evs is []mvccpb.Event type
- // either return []*mvccpb.Event from the mvcc package
- // or define protocol buffer with []mvccpb.Event.
- evs := wresp.Events
- events := make([]*mvccpb.Event, len(evs))
- sws.mu.RLock()
- needPrevKV := sws.prevKV[wresp.WatchID]
- sws.mu.RUnlock()
- for i := range evs {
- events[i] = &evs[i]
- if needPrevKV {
- opt := mvcc.RangeOptions{Rev: evs[i].Kv.ModRevision - 1}
- r, err := sws.watchable.Range(evs[i].Kv.Key, nil, opt)
- if err == nil && len(r.KVs) != 0 {
- events[i].PrevKv = &(r.KVs[0])
- }
- }
- }
-
- canceled := wresp.CompactRevision != 0
- wr := &pb.WatchResponse{
- Header: sws.newResponseHeader(wresp.Revision),
- WatchId: int64(wresp.WatchID),
- Events: events,
- CompactRevision: wresp.CompactRevision,
- Canceled: canceled,
- }
-
- if _, okID := ids[wresp.WatchID]; !okID {
- // buffer if id not yet announced
- wrs := append(pending[wresp.WatchID], wr)
- pending[wresp.WatchID] = wrs
- continue
- }
-
- mvcc.ReportEventReceived(len(evs))
-
- sws.mu.RLock()
- fragmented, ok := sws.fragment[wresp.WatchID]
- sws.mu.RUnlock()
-
- var serr error
- if !fragmented && !ok {
- serr = sws.gRPCStream.Send(wr)
- } else {
- serr = sendFragments(wr, sws.maxRequestBytes, sws.gRPCStream.Send)
- }
-
- if serr != nil {
- if isClientCtxErr(sws.gRPCStream.Context().Err(), serr) {
- if sws.lg != nil {
- sws.lg.Debug("failed to send watch response to gRPC stream", zap.Error(serr))
- } else {
- plog.Debugf("failed to send watch response to gRPC stream (%q)", serr.Error())
- }
- } else {
- if sws.lg != nil {
- sws.lg.Warn("failed to send watch response to gRPC stream", zap.Error(serr))
- } else {
- plog.Warningf("failed to send watch response to gRPC stream (%q)", serr.Error())
- }
- streamFailures.WithLabelValues("send", "watch").Inc()
- }
- return
- }
-
- sws.mu.Lock()
- if len(evs) > 0 && sws.progress[wresp.WatchID] {
- // elide next progress update if sent a key update
- sws.progress[wresp.WatchID] = false
- }
- sws.mu.Unlock()
-
- case c, ok := <-sws.ctrlStream:
- if !ok {
- return
- }
-
- if err := sws.gRPCStream.Send(c); err != nil {
- if isClientCtxErr(sws.gRPCStream.Context().Err(), err) {
- if sws.lg != nil {
- sws.lg.Debug("failed to send watch control response to gRPC stream", zap.Error(err))
- } else {
- plog.Debugf("failed to send watch control response to gRPC stream (%q)", err.Error())
- }
- } else {
- if sws.lg != nil {
- sws.lg.Warn("failed to send watch control response to gRPC stream", zap.Error(err))
- } else {
- plog.Warningf("failed to send watch control response to gRPC stream (%q)", err.Error())
- }
- streamFailures.WithLabelValues("send", "watch").Inc()
- }
- return
- }
-
- // track id creation
- wid := mvcc.WatchID(c.WatchId)
- if c.Canceled {
- delete(ids, wid)
- continue
- }
- if c.Created {
- // flush buffered events
- ids[wid] = struct{}{}
- for _, v := range pending[wid] {
- mvcc.ReportEventReceived(len(v.Events))
- if err := sws.gRPCStream.Send(v); err != nil {
- if isClientCtxErr(sws.gRPCStream.Context().Err(), err) {
- if sws.lg != nil {
- sws.lg.Debug("failed to send pending watch response to gRPC stream", zap.Error(err))
- } else {
- plog.Debugf("failed to send pending watch response to gRPC stream (%q)", err.Error())
- }
- } else {
- if sws.lg != nil {
- sws.lg.Warn("failed to send pending watch response to gRPC stream", zap.Error(err))
- } else {
- plog.Warningf("failed to send pending watch response to gRPC stream (%q)", err.Error())
- }
- streamFailures.WithLabelValues("send", "watch").Inc()
- }
- return
- }
- }
- delete(pending, wid)
- }
-
- case <-progressTicker.C:
- sws.mu.Lock()
- for id, ok := range sws.progress {
- if ok {
- sws.watchStream.RequestProgress(id)
- }
- sws.progress[id] = true
- }
- sws.mu.Unlock()
-
- case <-sws.closec:
- return
- }
- }
-}
-
-func sendFragments(
- wr *pb.WatchResponse,
- maxRequestBytes int,
- sendFunc func(*pb.WatchResponse) error) error {
- // no need to fragment if total request size is smaller
- // than max request limit or response contains only one event
- if wr.Size() < maxRequestBytes || len(wr.Events) < 2 {
- return sendFunc(wr)
- }
-
- ow := *wr
- ow.Events = make([]*mvccpb.Event, 0)
- ow.Fragment = true
-
- var idx int
- for {
- cur := ow
- for _, ev := range wr.Events[idx:] {
- cur.Events = append(cur.Events, ev)
- if len(cur.Events) > 1 && cur.Size() >= maxRequestBytes {
- cur.Events = cur.Events[:len(cur.Events)-1]
- break
- }
- idx++
- }
- if idx == len(wr.Events) {
- // last response has no more fragment
- cur.Fragment = false
- }
- if err := sendFunc(&cur); err != nil {
- return err
- }
- if !cur.Fragment {
- break
- }
- }
- return nil
-}
-
-func (sws *serverWatchStream) close() {
- sws.watchStream.Close()
- close(sws.closec)
- sws.wg.Wait()
-}
-
-func (sws *serverWatchStream) newResponseHeader(rev int64) *pb.ResponseHeader {
- return &pb.ResponseHeader{
- ClusterId: uint64(sws.clusterID),
- MemberId: uint64(sws.memberID),
- Revision: rev,
- RaftTerm: sws.sg.Term(),
- }
-}
-
-func filterNoDelete(e mvccpb.Event) bool {
- return e.Type == mvccpb.DELETE
-}
-
-func filterNoPut(e mvccpb.Event) bool {
- return e.Type == mvccpb.PUT
-}
-
-// FiltersFromRequest returns "mvcc.FilterFunc" from a given watch create request.
-func FiltersFromRequest(creq *pb.WatchCreateRequest) []mvcc.FilterFunc {
- filters := make([]mvcc.FilterFunc, 0, len(creq.Filters))
- for _, ft := range creq.Filters {
- switch ft {
- case pb.WatchCreateRequest_NOPUT:
- filters = append(filters, filterNoPut)
- case pb.WatchCreateRequest_NODELETE:
- filters = append(filters, filterNoDelete)
- default:
- }
- }
- return filters
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/apply.go b/vendor/go.etcd.io/etcd/etcdserver/apply.go
deleted file mode 100644
index 1f06ad0..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/apply.go
+++ /dev/null
@@ -1,1019 +0,0 @@
-// Copyright 2016 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package etcdserver
-
-import (
- "bytes"
- "context"
- "fmt"
- "sort"
- "time"
-
- "go.etcd.io/etcd/auth"
- pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
- "go.etcd.io/etcd/lease"
- "go.etcd.io/etcd/mvcc"
- "go.etcd.io/etcd/mvcc/mvccpb"
- "go.etcd.io/etcd/pkg/types"
-
- "github.com/gogo/protobuf/proto"
- "go.uber.org/zap"
-)
-
-const (
- warnApplyDuration = 100 * time.Millisecond
-)
-
-type applyResult struct {
- resp proto.Message
- err error
- // physc signals the physical effect of the request has completed in addition
- // to being logically reflected by the node. Currently only used for
- // Compaction requests.
- physc <-chan struct{}
-}
-
-// applierV3 is the interface for processing V3 raft messages
-type applierV3 interface {
- Apply(r *pb.InternalRaftRequest) *applyResult
-
- Put(txn mvcc.TxnWrite, p *pb.PutRequest) (*pb.PutResponse, error)
- Range(txn mvcc.TxnRead, r *pb.RangeRequest) (*pb.RangeResponse, error)
- DeleteRange(txn mvcc.TxnWrite, dr *pb.DeleteRangeRequest) (*pb.DeleteRangeResponse, error)
- Txn(rt *pb.TxnRequest) (*pb.TxnResponse, error)
- Compaction(compaction *pb.CompactionRequest) (*pb.CompactionResponse, <-chan struct{}, error)
-
- LeaseGrant(lc *pb.LeaseGrantRequest) (*pb.LeaseGrantResponse, error)
- LeaseRevoke(lc *pb.LeaseRevokeRequest) (*pb.LeaseRevokeResponse, error)
-
- LeaseCheckpoint(lc *pb.LeaseCheckpointRequest) (*pb.LeaseCheckpointResponse, error)
-
- Alarm(*pb.AlarmRequest) (*pb.AlarmResponse, error)
-
- Authenticate(r *pb.InternalAuthenticateRequest) (*pb.AuthenticateResponse, error)
-
- AuthEnable() (*pb.AuthEnableResponse, error)
- AuthDisable() (*pb.AuthDisableResponse, error)
-
- UserAdd(ua *pb.AuthUserAddRequest) (*pb.AuthUserAddResponse, error)
- UserDelete(ua *pb.AuthUserDeleteRequest) (*pb.AuthUserDeleteResponse, error)
- UserChangePassword(ua *pb.AuthUserChangePasswordRequest) (*pb.AuthUserChangePasswordResponse, error)
- UserGrantRole(ua *pb.AuthUserGrantRoleRequest) (*pb.AuthUserGrantRoleResponse, error)
- UserGet(ua *pb.AuthUserGetRequest) (*pb.AuthUserGetResponse, error)
- UserRevokeRole(ua *pb.AuthUserRevokeRoleRequest) (*pb.AuthUserRevokeRoleResponse, error)
- RoleAdd(ua *pb.AuthRoleAddRequest) (*pb.AuthRoleAddResponse, error)
- RoleGrantPermission(ua *pb.AuthRoleGrantPermissionRequest) (*pb.AuthRoleGrantPermissionResponse, error)
- RoleGet(ua *pb.AuthRoleGetRequest) (*pb.AuthRoleGetResponse, error)
- RoleRevokePermission(ua *pb.AuthRoleRevokePermissionRequest) (*pb.AuthRoleRevokePermissionResponse, error)
- RoleDelete(ua *pb.AuthRoleDeleteRequest) (*pb.AuthRoleDeleteResponse, error)
- UserList(ua *pb.AuthUserListRequest) (*pb.AuthUserListResponse, error)
- RoleList(ua *pb.AuthRoleListRequest) (*pb.AuthRoleListResponse, error)
-}
-
-type checkReqFunc func(mvcc.ReadView, *pb.RequestOp) error
-
-type applierV3backend struct {
- s *EtcdServer
-
- checkPut checkReqFunc
- checkRange checkReqFunc
-}
-
-func (s *EtcdServer) newApplierV3Backend() applierV3 {
- base := &applierV3backend{s: s}
- base.checkPut = func(rv mvcc.ReadView, req *pb.RequestOp) error {
- return base.checkRequestPut(rv, req)
- }
- base.checkRange = func(rv mvcc.ReadView, req *pb.RequestOp) error {
- return base.checkRequestRange(rv, req)
- }
- return base
-}
-
-func (s *EtcdServer) newApplierV3() applierV3 {
- return newAuthApplierV3(
- s.AuthStore(),
- newQuotaApplierV3(s, s.newApplierV3Backend()),
- s.lessor,
- )
-}
-
-func (a *applierV3backend) Apply(r *pb.InternalRaftRequest) *applyResult {
- ar := &applyResult{}
- defer func(start time.Time) {
- warnOfExpensiveRequest(a.s.getLogger(), start, &pb.InternalRaftStringer{Request: r}, ar.resp, ar.err)
- }(time.Now())
-
- // call into a.s.applyV3.F instead of a.F so upper appliers can check individual calls
- switch {
- case r.Range != nil:
- ar.resp, ar.err = a.s.applyV3.Range(nil, r.Range)
- case r.Put != nil:
- ar.resp, ar.err = a.s.applyV3.Put(nil, r.Put)
- case r.DeleteRange != nil:
- ar.resp, ar.err = a.s.applyV3.DeleteRange(nil, r.DeleteRange)
- case r.Txn != nil:
- ar.resp, ar.err = a.s.applyV3.Txn(r.Txn)
- case r.Compaction != nil:
- ar.resp, ar.physc, ar.err = a.s.applyV3.Compaction(r.Compaction)
- case r.LeaseGrant != nil:
- ar.resp, ar.err = a.s.applyV3.LeaseGrant(r.LeaseGrant)
- case r.LeaseRevoke != nil:
- ar.resp, ar.err = a.s.applyV3.LeaseRevoke(r.LeaseRevoke)
- case r.LeaseCheckpoint != nil:
- ar.resp, ar.err = a.s.applyV3.LeaseCheckpoint(r.LeaseCheckpoint)
- case r.Alarm != nil:
- ar.resp, ar.err = a.s.applyV3.Alarm(r.Alarm)
- case r.Authenticate != nil:
- ar.resp, ar.err = a.s.applyV3.Authenticate(r.Authenticate)
- case r.AuthEnable != nil:
- ar.resp, ar.err = a.s.applyV3.AuthEnable()
- case r.AuthDisable != nil:
- ar.resp, ar.err = a.s.applyV3.AuthDisable()
- case r.AuthUserAdd != nil:
- ar.resp, ar.err = a.s.applyV3.UserAdd(r.AuthUserAdd)
- case r.AuthUserDelete != nil:
- ar.resp, ar.err = a.s.applyV3.UserDelete(r.AuthUserDelete)
- case r.AuthUserChangePassword != nil:
- ar.resp, ar.err = a.s.applyV3.UserChangePassword(r.AuthUserChangePassword)
- case r.AuthUserGrantRole != nil:
- ar.resp, ar.err = a.s.applyV3.UserGrantRole(r.AuthUserGrantRole)
- case r.AuthUserGet != nil:
- ar.resp, ar.err = a.s.applyV3.UserGet(r.AuthUserGet)
- case r.AuthUserRevokeRole != nil:
- ar.resp, ar.err = a.s.applyV3.UserRevokeRole(r.AuthUserRevokeRole)
- case r.AuthRoleAdd != nil:
- ar.resp, ar.err = a.s.applyV3.RoleAdd(r.AuthRoleAdd)
- case r.AuthRoleGrantPermission != nil:
- ar.resp, ar.err = a.s.applyV3.RoleGrantPermission(r.AuthRoleGrantPermission)
- case r.AuthRoleGet != nil:
- ar.resp, ar.err = a.s.applyV3.RoleGet(r.AuthRoleGet)
- case r.AuthRoleRevokePermission != nil:
- ar.resp, ar.err = a.s.applyV3.RoleRevokePermission(r.AuthRoleRevokePermission)
- case r.AuthRoleDelete != nil:
- ar.resp, ar.err = a.s.applyV3.RoleDelete(r.AuthRoleDelete)
- case r.AuthUserList != nil:
- ar.resp, ar.err = a.s.applyV3.UserList(r.AuthUserList)
- case r.AuthRoleList != nil:
- ar.resp, ar.err = a.s.applyV3.RoleList(r.AuthRoleList)
- default:
- panic("not implemented")
- }
- return ar
-}
-
-func (a *applierV3backend) Put(txn mvcc.TxnWrite, p *pb.PutRequest) (resp *pb.PutResponse, err error) {
- resp = &pb.PutResponse{}
- resp.Header = &pb.ResponseHeader{}
-
- val, leaseID := p.Value, lease.LeaseID(p.Lease)
- if txn == nil {
- if leaseID != lease.NoLease {
- if l := a.s.lessor.Lookup(leaseID); l == nil {
- return nil, lease.ErrLeaseNotFound
- }
- }
- txn = a.s.KV().Write()
- defer txn.End()
- }
-
- var rr *mvcc.RangeResult
- if p.IgnoreValue || p.IgnoreLease || p.PrevKv {
- rr, err = txn.Range(p.Key, nil, mvcc.RangeOptions{})
- if err != nil {
- return nil, err
- }
- }
- if p.IgnoreValue || p.IgnoreLease {
- if rr == nil || len(rr.KVs) == 0 {
- // ignore_{lease,value} flag expects previous key-value pair
- return nil, ErrKeyNotFound
- }
- }
- if p.IgnoreValue {
- val = rr.KVs[0].Value
- }
- if p.IgnoreLease {
- leaseID = lease.LeaseID(rr.KVs[0].Lease)
- }
- if p.PrevKv {
- if rr != nil && len(rr.KVs) != 0 {
- resp.PrevKv = &rr.KVs[0]
- }
- }
-
- resp.Header.Revision = txn.Put(p.Key, val, leaseID)
- return resp, nil
-}
-
-func (a *applierV3backend) DeleteRange(txn mvcc.TxnWrite, dr *pb.DeleteRangeRequest) (*pb.DeleteRangeResponse, error) {
- resp := &pb.DeleteRangeResponse{}
- resp.Header = &pb.ResponseHeader{}
- end := mkGteRange(dr.RangeEnd)
-
- if txn == nil {
- txn = a.s.kv.Write()
- defer txn.End()
- }
-
- if dr.PrevKv {
- rr, err := txn.Range(dr.Key, end, mvcc.RangeOptions{})
- if err != nil {
- return nil, err
- }
- if rr != nil {
- resp.PrevKvs = make([]*mvccpb.KeyValue, len(rr.KVs))
- for i := range rr.KVs {
- resp.PrevKvs[i] = &rr.KVs[i]
- }
- }
- }
-
- resp.Deleted, resp.Header.Revision = txn.DeleteRange(dr.Key, end)
- return resp, nil
-}
-
-func (a *applierV3backend) Range(txn mvcc.TxnRead, r *pb.RangeRequest) (*pb.RangeResponse, error) {
- resp := &pb.RangeResponse{}
- resp.Header = &pb.ResponseHeader{}
-
- if txn == nil {
- txn = a.s.kv.Read()
- defer txn.End()
- }
-
- limit := r.Limit
- if r.SortOrder != pb.RangeRequest_NONE ||
- r.MinModRevision != 0 || r.MaxModRevision != 0 ||
- r.MinCreateRevision != 0 || r.MaxCreateRevision != 0 {
- // fetch everything; sort and truncate afterwards
- limit = 0
- }
- if limit > 0 {
- // fetch one extra for 'more' flag
- limit = limit + 1
- }
-
- ro := mvcc.RangeOptions{
- Limit: limit,
- Rev: r.Revision,
- Count: r.CountOnly,
- }
-
- rr, err := txn.Range(r.Key, mkGteRange(r.RangeEnd), ro)
- if err != nil {
- return nil, err
- }
-
- if r.MaxModRevision != 0 {
- f := func(kv *mvccpb.KeyValue) bool { return kv.ModRevision > r.MaxModRevision }
- pruneKVs(rr, f)
- }
- if r.MinModRevision != 0 {
- f := func(kv *mvccpb.KeyValue) bool { return kv.ModRevision < r.MinModRevision }
- pruneKVs(rr, f)
- }
- if r.MaxCreateRevision != 0 {
- f := func(kv *mvccpb.KeyValue) bool { return kv.CreateRevision > r.MaxCreateRevision }
- pruneKVs(rr, f)
- }
- if r.MinCreateRevision != 0 {
- f := func(kv *mvccpb.KeyValue) bool { return kv.CreateRevision < r.MinCreateRevision }
- pruneKVs(rr, f)
- }
-
- sortOrder := r.SortOrder
- if r.SortTarget != pb.RangeRequest_KEY && sortOrder == pb.RangeRequest_NONE {
- // Since current mvcc.Range implementation returns results
- // sorted by keys in lexiographically ascending order,
- // sort ASCEND by default only when target is not 'KEY'
- sortOrder = pb.RangeRequest_ASCEND
- }
- if sortOrder != pb.RangeRequest_NONE {
- var sorter sort.Interface
- switch {
- case r.SortTarget == pb.RangeRequest_KEY:
- sorter = &kvSortByKey{&kvSort{rr.KVs}}
- case r.SortTarget == pb.RangeRequest_VERSION:
- sorter = &kvSortByVersion{&kvSort{rr.KVs}}
- case r.SortTarget == pb.RangeRequest_CREATE:
- sorter = &kvSortByCreate{&kvSort{rr.KVs}}
- case r.SortTarget == pb.RangeRequest_MOD:
- sorter = &kvSortByMod{&kvSort{rr.KVs}}
- case r.SortTarget == pb.RangeRequest_VALUE:
- sorter = &kvSortByValue{&kvSort{rr.KVs}}
- }
- switch {
- case sortOrder == pb.RangeRequest_ASCEND:
- sort.Sort(sorter)
- case sortOrder == pb.RangeRequest_DESCEND:
- sort.Sort(sort.Reverse(sorter))
- }
- }
-
- if r.Limit > 0 && len(rr.KVs) > int(r.Limit) {
- rr.KVs = rr.KVs[:r.Limit]
- resp.More = true
- }
-
- resp.Header.Revision = rr.Rev
- resp.Count = int64(rr.Count)
- resp.Kvs = make([]*mvccpb.KeyValue, len(rr.KVs))
- for i := range rr.KVs {
- if r.KeysOnly {
- rr.KVs[i].Value = nil
- }
- resp.Kvs[i] = &rr.KVs[i]
- }
- return resp, nil
-}
-
-func (a *applierV3backend) Txn(rt *pb.TxnRequest) (*pb.TxnResponse, error) {
- isWrite := !isTxnReadonly(rt)
- txn := mvcc.NewReadOnlyTxnWrite(a.s.KV().Read())
-
- txnPath := compareToPath(txn, rt)
- if isWrite {
- if _, err := checkRequests(txn, rt, txnPath, a.checkPut); err != nil {
- txn.End()
- return nil, err
- }
- }
- if _, err := checkRequests(txn, rt, txnPath, a.checkRange); err != nil {
- txn.End()
- return nil, err
- }
-
- txnResp, _ := newTxnResp(rt, txnPath)
-
- // When executing mutable txn ops, etcd must hold the txn lock so
- // readers do not see any intermediate results. Since writes are
- // serialized on the raft loop, the revision in the read view will
- // be the revision of the write txn.
- if isWrite {
- txn.End()
- txn = a.s.KV().Write()
- }
- a.applyTxn(txn, rt, txnPath, txnResp)
- rev := txn.Rev()
- if len(txn.Changes()) != 0 {
- rev++
- }
- txn.End()
-
- txnResp.Header.Revision = rev
- return txnResp, nil
-}
-
-// newTxnResp allocates a txn response for a txn request given a path.
-func newTxnResp(rt *pb.TxnRequest, txnPath []bool) (txnResp *pb.TxnResponse, txnCount int) {
- reqs := rt.Success
- if !txnPath[0] {
- reqs = rt.Failure
- }
- resps := make([]*pb.ResponseOp, len(reqs))
- txnResp = &pb.TxnResponse{
- Responses: resps,
- Succeeded: txnPath[0],
- Header: &pb.ResponseHeader{},
- }
- for i, req := range reqs {
- switch tv := req.Request.(type) {
- case *pb.RequestOp_RequestRange:
- resps[i] = &pb.ResponseOp{Response: &pb.ResponseOp_ResponseRange{}}
- case *pb.RequestOp_RequestPut:
- resps[i] = &pb.ResponseOp{Response: &pb.ResponseOp_ResponsePut{}}
- case *pb.RequestOp_RequestDeleteRange:
- resps[i] = &pb.ResponseOp{Response: &pb.ResponseOp_ResponseDeleteRange{}}
- case *pb.RequestOp_RequestTxn:
- resp, txns := newTxnResp(tv.RequestTxn, txnPath[1:])
- resps[i] = &pb.ResponseOp{Response: &pb.ResponseOp_ResponseTxn{ResponseTxn: resp}}
- txnPath = txnPath[1+txns:]
- txnCount += txns + 1
- default:
- }
- }
- return txnResp, txnCount
-}
-
-func compareToPath(rv mvcc.ReadView, rt *pb.TxnRequest) []bool {
- txnPath := make([]bool, 1)
- ops := rt.Success
- if txnPath[0] = applyCompares(rv, rt.Compare); !txnPath[0] {
- ops = rt.Failure
- }
- for _, op := range ops {
- tv, ok := op.Request.(*pb.RequestOp_RequestTxn)
- if !ok || tv.RequestTxn == nil {
- continue
- }
- txnPath = append(txnPath, compareToPath(rv, tv.RequestTxn)...)
- }
- return txnPath
-}
-
-func applyCompares(rv mvcc.ReadView, cmps []*pb.Compare) bool {
- for _, c := range cmps {
- if !applyCompare(rv, c) {
- return false
- }
- }
- return true
-}
-
-// applyCompare applies the compare request.
-// If the comparison succeeds, it returns true. Otherwise, returns false.
-func applyCompare(rv mvcc.ReadView, c *pb.Compare) bool {
- // TODO: possible optimizations
- // * chunk reads for large ranges to conserve memory
- // * rewrite rules for common patterns:
- // ex. "[a, b) createrev > 0" => "limit 1 /\ kvs > 0"
- // * caching
- rr, err := rv.Range(c.Key, mkGteRange(c.RangeEnd), mvcc.RangeOptions{})
- if err != nil {
- return false
- }
- if len(rr.KVs) == 0 {
- if c.Target == pb.Compare_VALUE {
- // Always fail if comparing a value on a key/keys that doesn't exist;
- // nil == empty string in grpc; no way to represent missing value
- return false
- }
- return compareKV(c, mvccpb.KeyValue{})
- }
- for _, kv := range rr.KVs {
- if !compareKV(c, kv) {
- return false
- }
- }
- return true
-}
-
-func compareKV(c *pb.Compare, ckv mvccpb.KeyValue) bool {
- var result int
- rev := int64(0)
- switch c.Target {
- case pb.Compare_VALUE:
- v := []byte{}
- if tv, _ := c.TargetUnion.(*pb.Compare_Value); tv != nil {
- v = tv.Value
- }
- result = bytes.Compare(ckv.Value, v)
- case pb.Compare_CREATE:
- if tv, _ := c.TargetUnion.(*pb.Compare_CreateRevision); tv != nil {
- rev = tv.CreateRevision
- }
- result = compareInt64(ckv.CreateRevision, rev)
- case pb.Compare_MOD:
- if tv, _ := c.TargetUnion.(*pb.Compare_ModRevision); tv != nil {
- rev = tv.ModRevision
- }
- result = compareInt64(ckv.ModRevision, rev)
- case pb.Compare_VERSION:
- if tv, _ := c.TargetUnion.(*pb.Compare_Version); tv != nil {
- rev = tv.Version
- }
- result = compareInt64(ckv.Version, rev)
- case pb.Compare_LEASE:
- if tv, _ := c.TargetUnion.(*pb.Compare_Lease); tv != nil {
- rev = tv.Lease
- }
- result = compareInt64(ckv.Lease, rev)
- }
- switch c.Result {
- case pb.Compare_EQUAL:
- return result == 0
- case pb.Compare_NOT_EQUAL:
- return result != 0
- case pb.Compare_GREATER:
- return result > 0
- case pb.Compare_LESS:
- return result < 0
- }
- return true
-}
-
-func (a *applierV3backend) applyTxn(txn mvcc.TxnWrite, rt *pb.TxnRequest, txnPath []bool, tresp *pb.TxnResponse) (txns int) {
- reqs := rt.Success
- if !txnPath[0] {
- reqs = rt.Failure
- }
-
- lg := a.s.getLogger()
- for i, req := range reqs {
- respi := tresp.Responses[i].Response
- switch tv := req.Request.(type) {
- case *pb.RequestOp_RequestRange:
- resp, err := a.Range(txn, tv.RequestRange)
- if err != nil {
- if lg != nil {
- lg.Panic("unexpected error during txn", zap.Error(err))
- } else {
- plog.Panicf("unexpected error during txn: %v", err)
- }
- }
- respi.(*pb.ResponseOp_ResponseRange).ResponseRange = resp
- case *pb.RequestOp_RequestPut:
- resp, err := a.Put(txn, tv.RequestPut)
- if err != nil {
- if lg != nil {
- lg.Panic("unexpected error during txn", zap.Error(err))
- } else {
- plog.Panicf("unexpected error during txn: %v", err)
- }
- }
- respi.(*pb.ResponseOp_ResponsePut).ResponsePut = resp
- case *pb.RequestOp_RequestDeleteRange:
- resp, err := a.DeleteRange(txn, tv.RequestDeleteRange)
- if err != nil {
- if lg != nil {
- lg.Panic("unexpected error during txn", zap.Error(err))
- } else {
- plog.Panicf("unexpected error during txn: %v", err)
- }
- }
- respi.(*pb.ResponseOp_ResponseDeleteRange).ResponseDeleteRange = resp
- case *pb.RequestOp_RequestTxn:
- resp := respi.(*pb.ResponseOp_ResponseTxn).ResponseTxn
- applyTxns := a.applyTxn(txn, tv.RequestTxn, txnPath[1:], resp)
- txns += applyTxns + 1
- txnPath = txnPath[applyTxns+1:]
- default:
- // empty union
- }
- }
- return txns
-}
-
-func (a *applierV3backend) Compaction(compaction *pb.CompactionRequest) (*pb.CompactionResponse, <-chan struct{}, error) {
- resp := &pb.CompactionResponse{}
- resp.Header = &pb.ResponseHeader{}
- ch, err := a.s.KV().Compact(compaction.Revision)
- if err != nil {
- return nil, ch, err
- }
- // get the current revision. which key to get is not important.
- rr, _ := a.s.KV().Range([]byte("compaction"), nil, mvcc.RangeOptions{})
- resp.Header.Revision = rr.Rev
- return resp, ch, err
-}
-
-func (a *applierV3backend) LeaseGrant(lc *pb.LeaseGrantRequest) (*pb.LeaseGrantResponse, error) {
- l, err := a.s.lessor.Grant(lease.LeaseID(lc.ID), lc.TTL)
- resp := &pb.LeaseGrantResponse{}
- if err == nil {
- resp.ID = int64(l.ID)
- resp.TTL = l.TTL()
- resp.Header = newHeader(a.s)
- }
- return resp, err
-}
-
-func (a *applierV3backend) LeaseRevoke(lc *pb.LeaseRevokeRequest) (*pb.LeaseRevokeResponse, error) {
- err := a.s.lessor.Revoke(lease.LeaseID(lc.ID))
- return &pb.LeaseRevokeResponse{Header: newHeader(a.s)}, err
-}
-
-func (a *applierV3backend) LeaseCheckpoint(lc *pb.LeaseCheckpointRequest) (*pb.LeaseCheckpointResponse, error) {
- for _, c := range lc.Checkpoints {
- err := a.s.lessor.Checkpoint(lease.LeaseID(c.ID), c.Remaining_TTL)
- if err != nil {
- return &pb.LeaseCheckpointResponse{Header: newHeader(a.s)}, err
- }
- }
- return &pb.LeaseCheckpointResponse{Header: newHeader(a.s)}, nil
-}
-
-func (a *applierV3backend) Alarm(ar *pb.AlarmRequest) (*pb.AlarmResponse, error) {
- resp := &pb.AlarmResponse{}
- oldCount := len(a.s.alarmStore.Get(ar.Alarm))
-
- lg := a.s.getLogger()
- switch ar.Action {
- case pb.AlarmRequest_GET:
- resp.Alarms = a.s.alarmStore.Get(ar.Alarm)
- case pb.AlarmRequest_ACTIVATE:
- m := a.s.alarmStore.Activate(types.ID(ar.MemberID), ar.Alarm)
- if m == nil {
- break
- }
- resp.Alarms = append(resp.Alarms, m)
- activated := oldCount == 0 && len(a.s.alarmStore.Get(m.Alarm)) == 1
- if !activated {
- break
- }
-
- if lg != nil {
- lg.Warn("alarm raised", zap.String("alarm", m.Alarm.String()), zap.String("from", types.ID(m.MemberID).String()))
- } else {
- plog.Warningf("alarm %v raised by peer %s", m.Alarm, types.ID(m.MemberID))
- }
- switch m.Alarm {
- case pb.AlarmType_CORRUPT:
- a.s.applyV3 = newApplierV3Corrupt(a)
- case pb.AlarmType_NOSPACE:
- a.s.applyV3 = newApplierV3Capped(a)
- default:
- if lg != nil {
- lg.Warn("unimplemented alarm activation", zap.String("alarm", fmt.Sprintf("%+v", m)))
- } else {
- plog.Errorf("unimplemented alarm activation (%+v)", m)
- }
- }
- case pb.AlarmRequest_DEACTIVATE:
- m := a.s.alarmStore.Deactivate(types.ID(ar.MemberID), ar.Alarm)
- if m == nil {
- break
- }
- resp.Alarms = append(resp.Alarms, m)
- deactivated := oldCount > 0 && len(a.s.alarmStore.Get(ar.Alarm)) == 0
- if !deactivated {
- break
- }
-
- switch m.Alarm {
- case pb.AlarmType_NOSPACE, pb.AlarmType_CORRUPT:
- // TODO: check kv hash before deactivating CORRUPT?
- if lg != nil {
- lg.Warn("alarm disarmed", zap.String("alarm", m.Alarm.String()), zap.String("from", types.ID(m.MemberID).String()))
- } else {
- plog.Infof("alarm disarmed %+v", ar)
- }
- a.s.applyV3 = a.s.newApplierV3()
- default:
- if lg != nil {
- lg.Warn("unimplemented alarm deactivation", zap.String("alarm", fmt.Sprintf("%+v", m)))
- } else {
- plog.Errorf("unimplemented alarm deactivation (%+v)", m)
- }
- }
- default:
- return nil, nil
- }
- return resp, nil
-}
-
-type applierV3Capped struct {
- applierV3
- q backendQuota
-}
-
-// newApplierV3Capped creates an applyV3 that will reject Puts and transactions
-// with Puts so that the number of keys in the store is capped.
-func newApplierV3Capped(base applierV3) applierV3 { return &applierV3Capped{applierV3: base} }
-
-func (a *applierV3Capped) Put(txn mvcc.TxnWrite, p *pb.PutRequest) (*pb.PutResponse, error) {
- return nil, ErrNoSpace
-}
-
-func (a *applierV3Capped) Txn(r *pb.TxnRequest) (*pb.TxnResponse, error) {
- if a.q.Cost(r) > 0 {
- return nil, ErrNoSpace
- }
- return a.applierV3.Txn(r)
-}
-
-func (a *applierV3Capped) LeaseGrant(lc *pb.LeaseGrantRequest) (*pb.LeaseGrantResponse, error) {
- return nil, ErrNoSpace
-}
-
-func (a *applierV3backend) AuthEnable() (*pb.AuthEnableResponse, error) {
- err := a.s.AuthStore().AuthEnable()
- if err != nil {
- return nil, err
- }
- return &pb.AuthEnableResponse{Header: newHeader(a.s)}, nil
-}
-
-func (a *applierV3backend) AuthDisable() (*pb.AuthDisableResponse, error) {
- a.s.AuthStore().AuthDisable()
- return &pb.AuthDisableResponse{Header: newHeader(a.s)}, nil
-}
-
-func (a *applierV3backend) Authenticate(r *pb.InternalAuthenticateRequest) (*pb.AuthenticateResponse, error) {
- ctx := context.WithValue(context.WithValue(a.s.ctx, auth.AuthenticateParamIndex{}, a.s.consistIndex.ConsistentIndex()), auth.AuthenticateParamSimpleTokenPrefix{}, r.SimpleToken)
- resp, err := a.s.AuthStore().Authenticate(ctx, r.Name, r.Password)
- if resp != nil {
- resp.Header = newHeader(a.s)
- }
- return resp, err
-}
-
-func (a *applierV3backend) UserAdd(r *pb.AuthUserAddRequest) (*pb.AuthUserAddResponse, error) {
- resp, err := a.s.AuthStore().UserAdd(r)
- if resp != nil {
- resp.Header = newHeader(a.s)
- }
- return resp, err
-}
-
-func (a *applierV3backend) UserDelete(r *pb.AuthUserDeleteRequest) (*pb.AuthUserDeleteResponse, error) {
- resp, err := a.s.AuthStore().UserDelete(r)
- if resp != nil {
- resp.Header = newHeader(a.s)
- }
- return resp, err
-}
-
-func (a *applierV3backend) UserChangePassword(r *pb.AuthUserChangePasswordRequest) (*pb.AuthUserChangePasswordResponse, error) {
- resp, err := a.s.AuthStore().UserChangePassword(r)
- if resp != nil {
- resp.Header = newHeader(a.s)
- }
- return resp, err
-}
-
-func (a *applierV3backend) UserGrantRole(r *pb.AuthUserGrantRoleRequest) (*pb.AuthUserGrantRoleResponse, error) {
- resp, err := a.s.AuthStore().UserGrantRole(r)
- if resp != nil {
- resp.Header = newHeader(a.s)
- }
- return resp, err
-}
-
-func (a *applierV3backend) UserGet(r *pb.AuthUserGetRequest) (*pb.AuthUserGetResponse, error) {
- resp, err := a.s.AuthStore().UserGet(r)
- if resp != nil {
- resp.Header = newHeader(a.s)
- }
- return resp, err
-}
-
-func (a *applierV3backend) UserRevokeRole(r *pb.AuthUserRevokeRoleRequest) (*pb.AuthUserRevokeRoleResponse, error) {
- resp, err := a.s.AuthStore().UserRevokeRole(r)
- if resp != nil {
- resp.Header = newHeader(a.s)
- }
- return resp, err
-}
-
-func (a *applierV3backend) RoleAdd(r *pb.AuthRoleAddRequest) (*pb.AuthRoleAddResponse, error) {
- resp, err := a.s.AuthStore().RoleAdd(r)
- if resp != nil {
- resp.Header = newHeader(a.s)
- }
- return resp, err
-}
-
-func (a *applierV3backend) RoleGrantPermission(r *pb.AuthRoleGrantPermissionRequest) (*pb.AuthRoleGrantPermissionResponse, error) {
- resp, err := a.s.AuthStore().RoleGrantPermission(r)
- if resp != nil {
- resp.Header = newHeader(a.s)
- }
- return resp, err
-}
-
-func (a *applierV3backend) RoleGet(r *pb.AuthRoleGetRequest) (*pb.AuthRoleGetResponse, error) {
- resp, err := a.s.AuthStore().RoleGet(r)
- if resp != nil {
- resp.Header = newHeader(a.s)
- }
- return resp, err
-}
-
-func (a *applierV3backend) RoleRevokePermission(r *pb.AuthRoleRevokePermissionRequest) (*pb.AuthRoleRevokePermissionResponse, error) {
- resp, err := a.s.AuthStore().RoleRevokePermission(r)
- if resp != nil {
- resp.Header = newHeader(a.s)
- }
- return resp, err
-}
-
-func (a *applierV3backend) RoleDelete(r *pb.AuthRoleDeleteRequest) (*pb.AuthRoleDeleteResponse, error) {
- resp, err := a.s.AuthStore().RoleDelete(r)
- if resp != nil {
- resp.Header = newHeader(a.s)
- }
- return resp, err
-}
-
-func (a *applierV3backend) UserList(r *pb.AuthUserListRequest) (*pb.AuthUserListResponse, error) {
- resp, err := a.s.AuthStore().UserList(r)
- if resp != nil {
- resp.Header = newHeader(a.s)
- }
- return resp, err
-}
-
-func (a *applierV3backend) RoleList(r *pb.AuthRoleListRequest) (*pb.AuthRoleListResponse, error) {
- resp, err := a.s.AuthStore().RoleList(r)
- if resp != nil {
- resp.Header = newHeader(a.s)
- }
- return resp, err
-}
-
-type quotaApplierV3 struct {
- applierV3
- q Quota
-}
-
-func newQuotaApplierV3(s *EtcdServer, app applierV3) applierV3 {
- return "aApplierV3{app, NewBackendQuota(s, "v3-applier")}
-}
-
-func (a *quotaApplierV3) Put(txn mvcc.TxnWrite, p *pb.PutRequest) (*pb.PutResponse, error) {
- ok := a.q.Available(p)
- resp, err := a.applierV3.Put(txn, p)
- if err == nil && !ok {
- err = ErrNoSpace
- }
- return resp, err
-}
-
-func (a *quotaApplierV3) Txn(rt *pb.TxnRequest) (*pb.TxnResponse, error) {
- ok := a.q.Available(rt)
- resp, err := a.applierV3.Txn(rt)
- if err == nil && !ok {
- err = ErrNoSpace
- }
- return resp, err
-}
-
-func (a *quotaApplierV3) LeaseGrant(lc *pb.LeaseGrantRequest) (*pb.LeaseGrantResponse, error) {
- ok := a.q.Available(lc)
- resp, err := a.applierV3.LeaseGrant(lc)
- if err == nil && !ok {
- err = ErrNoSpace
- }
- return resp, err
-}
-
-type kvSort struct{ kvs []mvccpb.KeyValue }
-
-func (s *kvSort) Swap(i, j int) {
- t := s.kvs[i]
- s.kvs[i] = s.kvs[j]
- s.kvs[j] = t
-}
-func (s *kvSort) Len() int { return len(s.kvs) }
-
-type kvSortByKey struct{ *kvSort }
-
-func (s *kvSortByKey) Less(i, j int) bool {
- return bytes.Compare(s.kvs[i].Key, s.kvs[j].Key) < 0
-}
-
-type kvSortByVersion struct{ *kvSort }
-
-func (s *kvSortByVersion) Less(i, j int) bool {
- return (s.kvs[i].Version - s.kvs[j].Version) < 0
-}
-
-type kvSortByCreate struct{ *kvSort }
-
-func (s *kvSortByCreate) Less(i, j int) bool {
- return (s.kvs[i].CreateRevision - s.kvs[j].CreateRevision) < 0
-}
-
-type kvSortByMod struct{ *kvSort }
-
-func (s *kvSortByMod) Less(i, j int) bool {
- return (s.kvs[i].ModRevision - s.kvs[j].ModRevision) < 0
-}
-
-type kvSortByValue struct{ *kvSort }
-
-func (s *kvSortByValue) Less(i, j int) bool {
- return bytes.Compare(s.kvs[i].Value, s.kvs[j].Value) < 0
-}
-
-func checkRequests(rv mvcc.ReadView, rt *pb.TxnRequest, txnPath []bool, f checkReqFunc) (int, error) {
- txnCount := 0
- reqs := rt.Success
- if !txnPath[0] {
- reqs = rt.Failure
- }
- for _, req := range reqs {
- if tv, ok := req.Request.(*pb.RequestOp_RequestTxn); ok && tv.RequestTxn != nil {
- txns, err := checkRequests(rv, tv.RequestTxn, txnPath[1:], f)
- if err != nil {
- return 0, err
- }
- txnCount += txns + 1
- txnPath = txnPath[txns+1:]
- continue
- }
- if err := f(rv, req); err != nil {
- return 0, err
- }
- }
- return txnCount, nil
-}
-
-func (a *applierV3backend) checkRequestPut(rv mvcc.ReadView, reqOp *pb.RequestOp) error {
- tv, ok := reqOp.Request.(*pb.RequestOp_RequestPut)
- if !ok || tv.RequestPut == nil {
- return nil
- }
- req := tv.RequestPut
- if req.IgnoreValue || req.IgnoreLease {
- // expects previous key-value, error if not exist
- rr, err := rv.Range(req.Key, nil, mvcc.RangeOptions{})
- if err != nil {
- return err
- }
- if rr == nil || len(rr.KVs) == 0 {
- return ErrKeyNotFound
- }
- }
- if lease.LeaseID(req.Lease) != lease.NoLease {
- if l := a.s.lessor.Lookup(lease.LeaseID(req.Lease)); l == nil {
- return lease.ErrLeaseNotFound
- }
- }
- return nil
-}
-
-func (a *applierV3backend) checkRequestRange(rv mvcc.ReadView, reqOp *pb.RequestOp) error {
- tv, ok := reqOp.Request.(*pb.RequestOp_RequestRange)
- if !ok || tv.RequestRange == nil {
- return nil
- }
- req := tv.RequestRange
- switch {
- case req.Revision == 0:
- return nil
- case req.Revision > rv.Rev():
- return mvcc.ErrFutureRev
- case req.Revision < rv.FirstRev():
- return mvcc.ErrCompacted
- }
- return nil
-}
-
-func compareInt64(a, b int64) int {
- switch {
- case a < b:
- return -1
- case a > b:
- return 1
- default:
- return 0
- }
-}
-
-// mkGteRange determines if the range end is a >= range. This works around grpc
-// sending empty byte strings as nil; >= is encoded in the range end as '\0'.
-// If it is a GTE range, then []byte{} is returned to indicate the empty byte
-// string (vs nil being no byte string).
-func mkGteRange(rangeEnd []byte) []byte {
- if len(rangeEnd) == 1 && rangeEnd[0] == 0 {
- return []byte{}
- }
- return rangeEnd
-}
-
-func noSideEffect(r *pb.InternalRaftRequest) bool {
- return r.Range != nil || r.AuthUserGet != nil || r.AuthRoleGet != nil
-}
-
-func removeNeedlessRangeReqs(txn *pb.TxnRequest) {
- f := func(ops []*pb.RequestOp) []*pb.RequestOp {
- j := 0
- for i := 0; i < len(ops); i++ {
- if _, ok := ops[i].Request.(*pb.RequestOp_RequestRange); ok {
- continue
- }
- ops[j] = ops[i]
- j++
- }
-
- return ops[:j]
- }
-
- txn.Success = f(txn.Success)
- txn.Failure = f(txn.Failure)
-}
-
-func pruneKVs(rr *mvcc.RangeResult, isPrunable func(*mvccpb.KeyValue) bool) {
- j := 0
- for i := range rr.KVs {
- rr.KVs[j] = rr.KVs[i]
- if !isPrunable(&rr.KVs[i]) {
- j++
- }
- }
- rr.KVs = rr.KVs[:j]
-}
-
-func newHeader(s *EtcdServer) *pb.ResponseHeader {
- return &pb.ResponseHeader{
- ClusterId: uint64(s.Cluster().ID()),
- MemberId: uint64(s.ID()),
- Revision: s.KV().Rev(),
- RaftTerm: s.Term(),
- }
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/apply_auth.go b/vendor/go.etcd.io/etcd/etcdserver/apply_auth.go
deleted file mode 100644
index 4b094ad..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/apply_auth.go
+++ /dev/null
@@ -1,242 +0,0 @@
-// Copyright 2016 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package etcdserver
-
-import (
- "sync"
-
- "go.etcd.io/etcd/auth"
- pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
- "go.etcd.io/etcd/lease"
- "go.etcd.io/etcd/mvcc"
-)
-
-type authApplierV3 struct {
- applierV3
- as auth.AuthStore
- lessor lease.Lessor
-
- // mu serializes Apply so that user isn't corrupted and so that
- // serialized requests don't leak data from TOCTOU errors
- mu sync.Mutex
-
- authInfo auth.AuthInfo
-}
-
-func newAuthApplierV3(as auth.AuthStore, base applierV3, lessor lease.Lessor) *authApplierV3 {
- return &authApplierV3{applierV3: base, as: as, lessor: lessor}
-}
-
-func (aa *authApplierV3) Apply(r *pb.InternalRaftRequest) *applyResult {
- aa.mu.Lock()
- defer aa.mu.Unlock()
- if r.Header != nil {
- // backward-compatible with pre-3.0 releases when internalRaftRequest
- // does not have header field
- aa.authInfo.Username = r.Header.Username
- aa.authInfo.Revision = r.Header.AuthRevision
- }
- if needAdminPermission(r) {
- if err := aa.as.IsAdminPermitted(&aa.authInfo); err != nil {
- aa.authInfo.Username = ""
- aa.authInfo.Revision = 0
- return &applyResult{err: err}
- }
- }
- ret := aa.applierV3.Apply(r)
- aa.authInfo.Username = ""
- aa.authInfo.Revision = 0
- return ret
-}
-
-func (aa *authApplierV3) Put(txn mvcc.TxnWrite, r *pb.PutRequest) (*pb.PutResponse, error) {
- if err := aa.as.IsPutPermitted(&aa.authInfo, r.Key); err != nil {
- return nil, err
- }
-
- if err := aa.checkLeasePuts(lease.LeaseID(r.Lease)); err != nil {
- // The specified lease is already attached with a key that cannot
- // be written by this user. It means the user cannot revoke the
- // lease so attaching the lease to the newly written key should
- // be forbidden.
- return nil, err
- }
-
- if r.PrevKv {
- err := aa.as.IsRangePermitted(&aa.authInfo, r.Key, nil)
- if err != nil {
- return nil, err
- }
- }
- return aa.applierV3.Put(txn, r)
-}
-
-func (aa *authApplierV3) Range(txn mvcc.TxnRead, r *pb.RangeRequest) (*pb.RangeResponse, error) {
- if err := aa.as.IsRangePermitted(&aa.authInfo, r.Key, r.RangeEnd); err != nil {
- return nil, err
- }
- return aa.applierV3.Range(txn, r)
-}
-
-func (aa *authApplierV3) DeleteRange(txn mvcc.TxnWrite, r *pb.DeleteRangeRequest) (*pb.DeleteRangeResponse, error) {
- if err := aa.as.IsDeleteRangePermitted(&aa.authInfo, r.Key, r.RangeEnd); err != nil {
- return nil, err
- }
- if r.PrevKv {
- err := aa.as.IsRangePermitted(&aa.authInfo, r.Key, r.RangeEnd)
- if err != nil {
- return nil, err
- }
- }
-
- return aa.applierV3.DeleteRange(txn, r)
-}
-
-func checkTxnReqsPermission(as auth.AuthStore, ai *auth.AuthInfo, reqs []*pb.RequestOp) error {
- for _, requ := range reqs {
- switch tv := requ.Request.(type) {
- case *pb.RequestOp_RequestRange:
- if tv.RequestRange == nil {
- continue
- }
-
- if err := as.IsRangePermitted(ai, tv.RequestRange.Key, tv.RequestRange.RangeEnd); err != nil {
- return err
- }
-
- case *pb.RequestOp_RequestPut:
- if tv.RequestPut == nil {
- continue
- }
-
- if err := as.IsPutPermitted(ai, tv.RequestPut.Key); err != nil {
- return err
- }
-
- case *pb.RequestOp_RequestDeleteRange:
- if tv.RequestDeleteRange == nil {
- continue
- }
-
- if tv.RequestDeleteRange.PrevKv {
- err := as.IsRangePermitted(ai, tv.RequestDeleteRange.Key, tv.RequestDeleteRange.RangeEnd)
- if err != nil {
- return err
- }
- }
-
- err := as.IsDeleteRangePermitted(ai, tv.RequestDeleteRange.Key, tv.RequestDeleteRange.RangeEnd)
- if err != nil {
- return err
- }
- }
- }
-
- return nil
-}
-
-func checkTxnAuth(as auth.AuthStore, ai *auth.AuthInfo, rt *pb.TxnRequest) error {
- for _, c := range rt.Compare {
- if err := as.IsRangePermitted(ai, c.Key, c.RangeEnd); err != nil {
- return err
- }
- }
- if err := checkTxnReqsPermission(as, ai, rt.Success); err != nil {
- return err
- }
- return checkTxnReqsPermission(as, ai, rt.Failure)
-}
-
-func (aa *authApplierV3) Txn(rt *pb.TxnRequest) (*pb.TxnResponse, error) {
- if err := checkTxnAuth(aa.as, &aa.authInfo, rt); err != nil {
- return nil, err
- }
- return aa.applierV3.Txn(rt)
-}
-
-func (aa *authApplierV3) LeaseRevoke(lc *pb.LeaseRevokeRequest) (*pb.LeaseRevokeResponse, error) {
- if err := aa.checkLeasePuts(lease.LeaseID(lc.ID)); err != nil {
- return nil, err
- }
- return aa.applierV3.LeaseRevoke(lc)
-}
-
-func (aa *authApplierV3) checkLeasePuts(leaseID lease.LeaseID) error {
- lease := aa.lessor.Lookup(leaseID)
- if lease != nil {
- for _, key := range lease.Keys() {
- if err := aa.as.IsPutPermitted(&aa.authInfo, []byte(key)); err != nil {
- return err
- }
- }
- }
-
- return nil
-}
-
-func (aa *authApplierV3) UserGet(r *pb.AuthUserGetRequest) (*pb.AuthUserGetResponse, error) {
- err := aa.as.IsAdminPermitted(&aa.authInfo)
- if err != nil && r.Name != aa.authInfo.Username {
- aa.authInfo.Username = ""
- aa.authInfo.Revision = 0
- return &pb.AuthUserGetResponse{}, err
- }
-
- return aa.applierV3.UserGet(r)
-}
-
-func (aa *authApplierV3) RoleGet(r *pb.AuthRoleGetRequest) (*pb.AuthRoleGetResponse, error) {
- err := aa.as.IsAdminPermitted(&aa.authInfo)
- if err != nil && !aa.as.HasRole(aa.authInfo.Username, r.Role) {
- aa.authInfo.Username = ""
- aa.authInfo.Revision = 0
- return &pb.AuthRoleGetResponse{}, err
- }
-
- return aa.applierV3.RoleGet(r)
-}
-
-func needAdminPermission(r *pb.InternalRaftRequest) bool {
- switch {
- case r.AuthEnable != nil:
- return true
- case r.AuthDisable != nil:
- return true
- case r.AuthUserAdd != nil:
- return true
- case r.AuthUserDelete != nil:
- return true
- case r.AuthUserChangePassword != nil:
- return true
- case r.AuthUserGrantRole != nil:
- return true
- case r.AuthUserRevokeRole != nil:
- return true
- case r.AuthRoleAdd != nil:
- return true
- case r.AuthRoleGrantPermission != nil:
- return true
- case r.AuthRoleRevokePermission != nil:
- return true
- case r.AuthRoleDelete != nil:
- return true
- case r.AuthUserList != nil:
- return true
- case r.AuthRoleList != nil:
- return true
- default:
- return false
- }
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/apply_v2.go b/vendor/go.etcd.io/etcd/etcdserver/apply_v2.go
deleted file mode 100644
index c77df19..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/apply_v2.go
+++ /dev/null
@@ -1,147 +0,0 @@
-// Copyright 2016 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package etcdserver
-
-import (
- "encoding/json"
- "path"
- "time"
-
- "go.etcd.io/etcd/etcdserver/api"
- "go.etcd.io/etcd/etcdserver/api/membership"
- "go.etcd.io/etcd/etcdserver/api/v2store"
- "go.etcd.io/etcd/pkg/pbutil"
-
- "github.com/coreos/go-semver/semver"
- "go.uber.org/zap"
-)
-
-// ApplierV2 is the interface for processing V2 raft messages
-type ApplierV2 interface {
- Delete(r *RequestV2) Response
- Post(r *RequestV2) Response
- Put(r *RequestV2) Response
- QGet(r *RequestV2) Response
- Sync(r *RequestV2) Response
-}
-
-func NewApplierV2(lg *zap.Logger, s v2store.Store, c *membership.RaftCluster) ApplierV2 {
- return &applierV2store{lg: lg, store: s, cluster: c}
-}
-
-type applierV2store struct {
- lg *zap.Logger
- store v2store.Store
- cluster *membership.RaftCluster
-}
-
-func (a *applierV2store) Delete(r *RequestV2) Response {
- switch {
- case r.PrevIndex > 0 || r.PrevValue != "":
- return toResponse(a.store.CompareAndDelete(r.Path, r.PrevValue, r.PrevIndex))
- default:
- return toResponse(a.store.Delete(r.Path, r.Dir, r.Recursive))
- }
-}
-
-func (a *applierV2store) Post(r *RequestV2) Response {
- return toResponse(a.store.Create(r.Path, r.Dir, r.Val, true, r.TTLOptions()))
-}
-
-func (a *applierV2store) Put(r *RequestV2) Response {
- ttlOptions := r.TTLOptions()
- exists, existsSet := pbutil.GetBool(r.PrevExist)
- switch {
- case existsSet:
- if exists {
- if r.PrevIndex == 0 && r.PrevValue == "" {
- return toResponse(a.store.Update(r.Path, r.Val, ttlOptions))
- }
- return toResponse(a.store.CompareAndSwap(r.Path, r.PrevValue, r.PrevIndex, r.Val, ttlOptions))
- }
- return toResponse(a.store.Create(r.Path, r.Dir, r.Val, false, ttlOptions))
- case r.PrevIndex > 0 || r.PrevValue != "":
- return toResponse(a.store.CompareAndSwap(r.Path, r.PrevValue, r.PrevIndex, r.Val, ttlOptions))
- default:
- if storeMemberAttributeRegexp.MatchString(r.Path) {
- id := membership.MustParseMemberIDFromKey(path.Dir(r.Path))
- var attr membership.Attributes
- if err := json.Unmarshal([]byte(r.Val), &attr); err != nil {
- if a.lg != nil {
- a.lg.Panic("failed to unmarshal", zap.String("value", r.Val), zap.Error(err))
- } else {
- plog.Panicf("unmarshal %s should never fail: %v", r.Val, err)
- }
- }
- if a.cluster != nil {
- a.cluster.UpdateAttributes(id, attr)
- }
- // return an empty response since there is no consumer.
- return Response{}
- }
- if r.Path == membership.StoreClusterVersionKey() {
- if a.cluster != nil {
- a.cluster.SetVersion(semver.Must(semver.NewVersion(r.Val)), api.UpdateCapability)
- }
- // return an empty response since there is no consumer.
- return Response{}
- }
- return toResponse(a.store.Set(r.Path, r.Dir, r.Val, ttlOptions))
- }
-}
-
-func (a *applierV2store) QGet(r *RequestV2) Response {
- return toResponse(a.store.Get(r.Path, r.Recursive, r.Sorted))
-}
-
-func (a *applierV2store) Sync(r *RequestV2) Response {
- a.store.DeleteExpiredKeys(time.Unix(0, r.Time))
- return Response{}
-}
-
-// applyV2Request interprets r as a call to v2store.X
-// and returns a Response interpreted from v2store.Event
-func (s *EtcdServer) applyV2Request(r *RequestV2) Response {
- defer warnOfExpensiveRequest(s.getLogger(), time.Now(), r, nil, nil)
-
- switch r.Method {
- case "POST":
- return s.applyV2.Post(r)
- case "PUT":
- return s.applyV2.Put(r)
- case "DELETE":
- return s.applyV2.Delete(r)
- case "QGET":
- return s.applyV2.QGet(r)
- case "SYNC":
- return s.applyV2.Sync(r)
- default:
- // This should never be reached, but just in case:
- return Response{Err: 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
-}
-
-func toResponse(ev *v2store.Event, err error) Response {
- return Response{Event: ev, Err: err}
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/backend.go b/vendor/go.etcd.io/etcd/etcdserver/backend.go
deleted file mode 100644
index 01ba192..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/backend.go
+++ /dev/null
@@ -1,112 +0,0 @@
-// Copyright 2017 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package etcdserver
-
-import (
- "fmt"
- "os"
- "time"
-
- "go.etcd.io/etcd/etcdserver/api/snap"
- "go.etcd.io/etcd/lease"
- "go.etcd.io/etcd/mvcc"
- "go.etcd.io/etcd/mvcc/backend"
- "go.etcd.io/etcd/raft/raftpb"
-
- "go.uber.org/zap"
-)
-
-func newBackend(cfg ServerConfig) backend.Backend {
- bcfg := backend.DefaultBackendConfig()
- bcfg.Path = cfg.backendPath()
- if cfg.BackendBatchLimit != 0 {
- bcfg.BatchLimit = cfg.BackendBatchLimit
- if cfg.Logger != nil {
- cfg.Logger.Info("setting backend batch limit", zap.Int("batch limit", cfg.BackendBatchLimit))
- }
- }
- if cfg.BackendBatchInterval != 0 {
- bcfg.BatchInterval = cfg.BackendBatchInterval
- if cfg.Logger != nil {
- cfg.Logger.Info("setting backend batch interval", zap.Duration("batch interval", cfg.BackendBatchInterval))
- }
- }
- bcfg.BackendFreelistType = cfg.BackendFreelistType
- bcfg.Logger = cfg.Logger
- if cfg.QuotaBackendBytes > 0 && cfg.QuotaBackendBytes != DefaultQuotaBytes {
- // permit 10% excess over quota for disarm
- bcfg.MmapSize = uint64(cfg.QuotaBackendBytes + cfg.QuotaBackendBytes/10)
- }
- return backend.New(bcfg)
-}
-
-// openSnapshotBackend renames a snapshot db to the current etcd db and opens it.
-func openSnapshotBackend(cfg ServerConfig, ss *snap.Snapshotter, snapshot raftpb.Snapshot) (backend.Backend, error) {
- snapPath, err := ss.DBFilePath(snapshot.Metadata.Index)
- if err != nil {
- return nil, fmt.Errorf("failed to find database snapshot file (%v)", err)
- }
- if err := os.Rename(snapPath, cfg.backendPath()); err != nil {
- return nil, fmt.Errorf("failed to rename database snapshot file (%v)", err)
- }
- return openBackend(cfg), nil
-}
-
-// openBackend returns a backend using the current etcd db.
-func openBackend(cfg ServerConfig) backend.Backend {
- fn := cfg.backendPath()
-
- now, beOpened := time.Now(), make(chan backend.Backend)
- go func() {
- beOpened <- newBackend(cfg)
- }()
-
- select {
- case be := <-beOpened:
- if cfg.Logger != nil {
- cfg.Logger.Info("opened backend db", zap.String("path", fn), zap.Duration("took", time.Since(now)))
- }
- return be
-
- case <-time.After(10 * time.Second):
- if cfg.Logger != nil {
- cfg.Logger.Info(
- "db file is flocked by another process, or taking too long",
- zap.String("path", fn),
- zap.Duration("took", time.Since(now)),
- )
- } else {
- plog.Warningf("another etcd process is using %q and holds the file lock, or loading backend file is taking >10 seconds", fn)
- plog.Warningf("waiting for it to exit before starting...")
- }
- }
-
- return <-beOpened
-}
-
-// recoverBackendSnapshot recovers the DB from a snapshot in case etcd crashes
-// before updating the backend db after persisting raft snapshot to disk,
-// violating the invariant snapshot.Metadata.Index < db.consistentIndex. In this
-// case, replace the db with the snapshot db sent by the leader.
-func recoverSnapshotBackend(cfg ServerConfig, oldbe backend.Backend, snapshot raftpb.Snapshot) (backend.Backend, error) {
- var cIndex consistentIndex
- kv := mvcc.New(cfg.Logger, oldbe, &lease.FakeLessor{}, &cIndex, mvcc.StoreConfig{CompactionBatchLimit: cfg.CompactionBatchLimit})
- defer kv.Close()
- if snapshot.Metadata.Index <= kv.ConsistentIndex() {
- return oldbe, nil
- }
- oldbe.Close()
- return openSnapshotBackend(cfg, snap.New(cfg.Logger, cfg.SnapDir()), snapshot)
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/cluster_util.go b/vendor/go.etcd.io/etcd/etcdserver/cluster_util.go
deleted file mode 100644
index f92706c..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/cluster_util.go
+++ /dev/null
@@ -1,407 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package etcdserver
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "io/ioutil"
- "net/http"
- "sort"
- "strings"
- "time"
-
- "go.etcd.io/etcd/etcdserver/api/membership"
- "go.etcd.io/etcd/pkg/types"
- "go.etcd.io/etcd/version"
-
- "github.com/coreos/go-semver/semver"
- "go.uber.org/zap"
-)
-
-// isMemberBootstrapped tries to check if the given member has been bootstrapped
-// in the given cluster.
-func isMemberBootstrapped(lg *zap.Logger, cl *membership.RaftCluster, member string, rt http.RoundTripper, timeout time.Duration) bool {
- rcl, err := getClusterFromRemotePeers(lg, getRemotePeerURLs(cl, member), timeout, false, rt)
- if err != nil {
- return false
- }
- id := cl.MemberByName(member).ID
- m := rcl.Member(id)
- if m == nil {
- return false
- }
- if len(m.ClientURLs) > 0 {
- return true
- }
- return false
-}
-
-// GetClusterFromRemotePeers takes a set of URLs representing etcd peers, and
-// attempts to construct a Cluster by accessing the members endpoint on one of
-// these URLs. The first URL to provide a response is used. If no URLs provide
-// a response, or a Cluster cannot be successfully created from a received
-// response, an error is returned.
-// Each request has a 10-second timeout. Because the upper limit of TTL is 5s,
-// 10 second is enough for building connection and finishing request.
-func GetClusterFromRemotePeers(lg *zap.Logger, urls []string, rt http.RoundTripper) (*membership.RaftCluster, error) {
- return getClusterFromRemotePeers(lg, urls, 10*time.Second, true, rt)
-}
-
-// If logerr is true, it prints out more error messages.
-func getClusterFromRemotePeers(lg *zap.Logger, urls []string, timeout time.Duration, logerr bool, rt http.RoundTripper) (*membership.RaftCluster, error) {
- cc := &http.Client{
- Transport: rt,
- Timeout: timeout,
- }
- for _, u := range urls {
- addr := u + "/members"
- resp, err := cc.Get(addr)
- if err != nil {
- if logerr {
- if lg != nil {
- lg.Warn("failed to get cluster response", zap.String("address", addr), zap.Error(err))
- } else {
- plog.Warningf("could not get cluster response from %s: %v", u, err)
- }
- }
- continue
- }
- b, err := ioutil.ReadAll(resp.Body)
- resp.Body.Close()
- if err != nil {
- if logerr {
- if lg != nil {
- lg.Warn("failed to read body of cluster response", zap.String("address", addr), zap.Error(err))
- } else {
- plog.Warningf("could not read the body of cluster response: %v", err)
- }
- }
- continue
- }
- var membs []*membership.Member
- if err = json.Unmarshal(b, &membs); err != nil {
- if logerr {
- if lg != nil {
- lg.Warn("failed to unmarshal cluster response", zap.String("address", addr), zap.Error(err))
- } else {
- plog.Warningf("could not unmarshal cluster response: %v", err)
- }
- }
- continue
- }
- id, err := types.IDFromString(resp.Header.Get("X-Etcd-Cluster-ID"))
- if err != nil {
- if logerr {
- if lg != nil {
- lg.Warn(
- "failed to parse cluster ID",
- zap.String("address", addr),
- zap.String("header", resp.Header.Get("X-Etcd-Cluster-ID")),
- zap.Error(err),
- )
- } else {
- plog.Warningf("could not parse the cluster ID from cluster res: %v", err)
- }
- }
- continue
- }
-
- // check the length of membership members
- // if the membership members are present then prepare and return raft cluster
- // if membership members are not present then the raft cluster formed will be
- // an invalid empty cluster hence return failed to get raft cluster member(s) from the given urls error
- if len(membs) > 0 {
- return membership.NewClusterFromMembers(lg, "", id, membs), nil
- }
- return nil, fmt.Errorf("failed to get raft cluster member(s) from the given URLs")
- }
- return nil, fmt.Errorf("could not retrieve cluster information from the given URLs")
-}
-
-// getRemotePeerURLs returns peer urls of remote members in the cluster. The
-// returned list is sorted in ascending lexicographical order.
-func getRemotePeerURLs(cl *membership.RaftCluster, local string) []string {
- us := make([]string, 0)
- for _, m := range cl.Members() {
- if m.Name == local {
- continue
- }
- us = append(us, m.PeerURLs...)
- }
- sort.Strings(us)
- return us
-}
-
-// getVersions returns the versions of the members in the given cluster.
-// The key of the returned map is the member's ID. The value of the returned map
-// is the semver versions string, including server and cluster.
-// If it fails to get the version of a member, the key will be nil.
-func getVersions(lg *zap.Logger, cl *membership.RaftCluster, local types.ID, rt http.RoundTripper) map[string]*version.Versions {
- members := cl.Members()
- vers := make(map[string]*version.Versions)
- for _, m := range members {
- if m.ID == local {
- cv := "not_decided"
- if cl.Version() != nil {
- cv = cl.Version().String()
- }
- vers[m.ID.String()] = &version.Versions{Server: version.Version, Cluster: cv}
- continue
- }
- ver, err := getVersion(lg, m, rt)
- if err != nil {
- if lg != nil {
- lg.Warn("failed to get version", zap.String("remote-member-id", m.ID.String()), zap.Error(err))
- } else {
- plog.Warningf("cannot get the version of member %s (%v)", m.ID, err)
- }
- vers[m.ID.String()] = nil
- } else {
- vers[m.ID.String()] = ver
- }
- }
- return vers
-}
-
-// decideClusterVersion decides the cluster version based on the versions map.
-// The returned version is the min server version in the map, or nil if the min
-// version in unknown.
-func decideClusterVersion(lg *zap.Logger, vers map[string]*version.Versions) *semver.Version {
- var cv *semver.Version
- lv := semver.Must(semver.NewVersion(version.Version))
-
- for mid, ver := range vers {
- if ver == nil {
- return nil
- }
- v, err := semver.NewVersion(ver.Server)
- if err != nil {
- if lg != nil {
- lg.Warn(
- "failed to parse server version of remote member",
- zap.String("remote-member-id", mid),
- zap.String("remote-member-version", ver.Server),
- zap.Error(err),
- )
- } else {
- plog.Errorf("cannot understand the version of member %s (%v)", mid, err)
- }
- return nil
- }
- if lv.LessThan(*v) {
- if lg != nil {
- lg.Warn(
- "leader found higher-versioned member",
- zap.String("local-member-version", lv.String()),
- zap.String("remote-member-id", mid),
- zap.String("remote-member-version", ver.Server),
- )
- } else {
- plog.Warningf("the local etcd version %s is not up-to-date", lv.String())
- plog.Warningf("member %s has a higher version %s", mid, ver.Server)
- }
- }
- if cv == nil {
- cv = v
- } else if v.LessThan(*cv) {
- cv = v
- }
- }
- return cv
-}
-
-// isCompatibleWithCluster return true if the local member has a compatible version with
-// the current running cluster.
-// The version is considered as compatible when at least one of the other members in the cluster has a
-// cluster version in the range of [MinClusterVersion, Version] and no known members has a cluster version
-// out of the range.
-// We set this rule since when the local member joins, another member might be offline.
-func isCompatibleWithCluster(lg *zap.Logger, cl *membership.RaftCluster, local types.ID, rt http.RoundTripper) bool {
- vers := getVersions(lg, cl, local, rt)
- minV := semver.Must(semver.NewVersion(version.MinClusterVersion))
- maxV := semver.Must(semver.NewVersion(version.Version))
- maxV = &semver.Version{
- Major: maxV.Major,
- Minor: maxV.Minor,
- }
- return isCompatibleWithVers(lg, vers, local, minV, maxV)
-}
-
-func isCompatibleWithVers(lg *zap.Logger, vers map[string]*version.Versions, local types.ID, minV, maxV *semver.Version) bool {
- var ok bool
- for id, v := range vers {
- // ignore comparison with local version
- if id == local.String() {
- continue
- }
- if v == nil {
- continue
- }
- clusterv, err := semver.NewVersion(v.Cluster)
- if err != nil {
- if lg != nil {
- lg.Warn(
- "failed to parse cluster version of remote member",
- zap.String("remote-member-id", id),
- zap.String("remote-member-cluster-version", v.Cluster),
- zap.Error(err),
- )
- } else {
- plog.Errorf("cannot understand the cluster version of member %s (%v)", id, err)
- }
- continue
- }
- if clusterv.LessThan(*minV) {
- if lg != nil {
- lg.Warn(
- "cluster version of remote member is not compatible; too low",
- zap.String("remote-member-id", id),
- zap.String("remote-member-cluster-version", clusterv.String()),
- zap.String("minimum-cluster-version-supported", minV.String()),
- )
- } else {
- plog.Warningf("the running cluster version(%v) is lower than the minimal cluster version(%v) supported", clusterv.String(), minV.String())
- }
- return false
- }
- if maxV.LessThan(*clusterv) {
- if lg != nil {
- lg.Warn(
- "cluster version of remote member is not compatible; too high",
- zap.String("remote-member-id", id),
- zap.String("remote-member-cluster-version", clusterv.String()),
- zap.String("minimum-cluster-version-supported", minV.String()),
- )
- } else {
- plog.Warningf("the running cluster version(%v) is higher than the maximum cluster version(%v) supported", clusterv.String(), maxV.String())
- }
- return false
- }
- ok = true
- }
- return ok
-}
-
-// getVersion returns the Versions of the given member via its
-// peerURLs. Returns the last error if it fails to get the version.
-func getVersion(lg *zap.Logger, m *membership.Member, rt http.RoundTripper) (*version.Versions, error) {
- cc := &http.Client{
- Transport: rt,
- }
- var (
- err error
- resp *http.Response
- )
-
- for _, u := range m.PeerURLs {
- addr := u + "/version"
- resp, err = cc.Get(addr)
- if err != nil {
- if lg != nil {
- lg.Warn(
- "failed to reach the peer URL",
- zap.String("address", addr),
- zap.String("remote-member-id", m.ID.String()),
- zap.Error(err),
- )
- } else {
- plog.Warningf("failed to reach the peerURL(%s) of member %s (%v)", u, m.ID, err)
- }
- continue
- }
- var b []byte
- b, err = ioutil.ReadAll(resp.Body)
- resp.Body.Close()
- if err != nil {
- if lg != nil {
- lg.Warn(
- "failed to read body of response",
- zap.String("address", addr),
- zap.String("remote-member-id", m.ID.String()),
- zap.Error(err),
- )
- } else {
- plog.Warningf("failed to read out the response body from the peerURL(%s) of member %s (%v)", u, m.ID, err)
- }
- continue
- }
- var vers version.Versions
- if err = json.Unmarshal(b, &vers); err != nil {
- if lg != nil {
- lg.Warn(
- "failed to unmarshal response",
- zap.String("address", addr),
- zap.String("remote-member-id", m.ID.String()),
- zap.Error(err),
- )
- } else {
- plog.Warningf("failed to unmarshal the response body got from the peerURL(%s) of member %s (%v)", u, m.ID, err)
- }
- continue
- }
- return &vers, nil
- }
- return nil, err
-}
-
-func promoteMemberHTTP(ctx context.Context, url string, id uint64, peerRt http.RoundTripper) ([]*membership.Member, error) {
- cc := &http.Client{Transport: peerRt}
- // TODO: refactor member http handler code
- // cannot import etcdhttp, so manually construct url
- requestUrl := url + "/members/promote/" + fmt.Sprintf("%d", id)
- req, err := http.NewRequest("POST", requestUrl, nil)
- if err != nil {
- return nil, err
- }
- req = req.WithContext(ctx)
- resp, err := cc.Do(req)
- if err != nil {
- return nil, err
- }
- defer resp.Body.Close()
- b, err := ioutil.ReadAll(resp.Body)
- if err != nil {
- return nil, err
- }
-
- if resp.StatusCode == http.StatusRequestTimeout {
- return nil, ErrTimeout
- }
- if resp.StatusCode == http.StatusPreconditionFailed {
- // both ErrMemberNotLearner and ErrLearnerNotReady have same http status code
- if strings.Contains(string(b), ErrLearnerNotReady.Error()) {
- return nil, ErrLearnerNotReady
- }
- if strings.Contains(string(b), membership.ErrMemberNotLearner.Error()) {
- return nil, membership.ErrMemberNotLearner
- }
- return nil, fmt.Errorf("member promote: unknown error(%s)", string(b))
- }
- if resp.StatusCode == http.StatusNotFound {
- return nil, membership.ErrIDNotFound
- }
-
- if resp.StatusCode != http.StatusOK { // all other types of errors
- return nil, fmt.Errorf("member promote: unknown error(%s)", string(b))
- }
-
- var membs []*membership.Member
- if err := json.Unmarshal(b, &membs); err != nil {
- return nil, err
- }
- return membs, nil
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/config.go b/vendor/go.etcd.io/etcd/etcdserver/config.go
deleted file mode 100644
index 88cd721..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/config.go
+++ /dev/null
@@ -1,307 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package etcdserver
-
-import (
- "context"
- "fmt"
- "path/filepath"
- "sort"
- "strings"
- "time"
-
- "go.etcd.io/etcd/pkg/netutil"
- "go.etcd.io/etcd/pkg/transport"
- "go.etcd.io/etcd/pkg/types"
-
- bolt "go.etcd.io/bbolt"
- "go.uber.org/zap"
- "go.uber.org/zap/zapcore"
-)
-
-// ServerConfig holds the configuration of etcd as taken from the command line or discovery.
-type ServerConfig struct {
- Name string
- DiscoveryURL string
- DiscoveryProxy string
- ClientURLs types.URLs
- PeerURLs types.URLs
- DataDir string
- // DedicatedWALDir config will make the etcd to write the WAL to the WALDir
- // rather than the dataDir/member/wal.
- DedicatedWALDir string
-
- SnapshotCount uint64
-
- // SnapshotCatchUpEntries is the number of entries for a slow follower
- // to catch-up after compacting the raft storage entries.
- // We expect the follower has a millisecond level latency with the leader.
- // The max throughput is around 10K. Keep a 5K entries is enough for helping
- // follower to catch up.
- // WARNING: only change this for tests. Always use "DefaultSnapshotCatchUpEntries"
- SnapshotCatchUpEntries uint64
-
- MaxSnapFiles uint
- MaxWALFiles uint
-
- // BackendBatchInterval is the maximum time before commit the backend transaction.
- BackendBatchInterval time.Duration
- // BackendBatchLimit is the maximum operations before commit the backend transaction.
- BackendBatchLimit int
-
- // BackendFreelistType is the type of the backend boltdb freelist.
- BackendFreelistType bolt.FreelistType
-
- InitialPeerURLsMap types.URLsMap
- InitialClusterToken string
- NewCluster bool
- PeerTLSInfo transport.TLSInfo
-
- CORS map[string]struct{}
-
- // HostWhitelist lists acceptable hostnames from client requests.
- // If server is insecure (no TLS), server only accepts requests
- // whose Host header value exists in this white list.
- HostWhitelist map[string]struct{}
-
- TickMs uint
- ElectionTicks int
-
- // InitialElectionTickAdvance is true, then local member fast-forwards
- // election ticks to speed up "initial" leader election trigger. This
- // benefits the case of larger election ticks. For instance, cross
- // datacenter deployment may require longer election timeout of 10-second.
- // If true, local node does not need wait up to 10-second. Instead,
- // forwards its election ticks to 8-second, and have only 2-second left
- // before leader election.
- //
- // Major assumptions are that:
- // - cluster has no active leader thus advancing ticks enables faster
- // leader election, or
- // - cluster already has an established leader, and rejoining follower
- // is likely to receive heartbeats from the leader after tick advance
- // and before election timeout.
- //
- // However, when network from leader to rejoining follower is congested,
- // and the follower does not receive leader heartbeat within left election
- // ticks, disruptive election has to happen thus affecting cluster
- // availabilities.
- //
- // Disabling this would slow down initial bootstrap process for cross
- // datacenter deployments. Make your own tradeoffs by configuring
- // --initial-election-tick-advance at the cost of slow initial bootstrap.
- //
- // If single-node, it advances ticks regardless.
- //
- // See https://github.com/etcd-io/etcd/issues/9333 for more detail.
- InitialElectionTickAdvance bool
-
- BootstrapTimeout time.Duration
-
- AutoCompactionRetention time.Duration
- AutoCompactionMode string
- CompactionBatchLimit int
- QuotaBackendBytes int64
- MaxTxnOps uint
-
- // MaxRequestBytes is the maximum request size to send over raft.
- MaxRequestBytes uint
-
- StrictReconfigCheck bool
-
- // ClientCertAuthEnabled is true when cert has been signed by the client CA.
- ClientCertAuthEnabled bool
-
- AuthToken string
- BcryptCost uint
-
- // InitialCorruptCheck is true to check data corruption on boot
- // before serving any peer/client traffic.
- InitialCorruptCheck bool
- CorruptCheckTime time.Duration
-
- // PreVote is true to enable Raft Pre-Vote.
- PreVote bool
-
- // Logger logs server-side operations.
- // If not nil, it disables "capnslog" and uses the given logger.
- Logger *zap.Logger
-
- // LoggerConfig is server logger configuration for Raft logger.
- // Must be either: "LoggerConfig != nil" or "LoggerCore != nil && LoggerWriteSyncer != nil".
- LoggerConfig *zap.Config
- // LoggerCore is "zapcore.Core" for raft logger.
- // Must be either: "LoggerConfig != nil" or "LoggerCore != nil && LoggerWriteSyncer != nil".
- LoggerCore zapcore.Core
- LoggerWriteSyncer zapcore.WriteSyncer
-
- Debug bool
-
- ForceNewCluster bool
-
- // EnableLeaseCheckpoint enables primary lessor to persist lease remainingTTL to prevent indefinite auto-renewal of long lived leases.
- EnableLeaseCheckpoint bool
- // LeaseCheckpointInterval time.Duration is the wait duration between lease checkpoints.
- LeaseCheckpointInterval time.Duration
-
- EnableGRPCGateway bool
-}
-
-// VerifyBootstrap sanity-checks the initial config for bootstrap case
-// and returns an error for things that should never happen.
-func (c *ServerConfig) VerifyBootstrap() error {
- if err := c.hasLocalMember(); err != nil {
- return err
- }
- if err := c.advertiseMatchesCluster(); err != nil {
- return err
- }
- if checkDuplicateURL(c.InitialPeerURLsMap) {
- return fmt.Errorf("initial cluster %s has duplicate url", c.InitialPeerURLsMap)
- }
- if c.InitialPeerURLsMap.String() == "" && c.DiscoveryURL == "" {
- return fmt.Errorf("initial cluster unset and no discovery URL found")
- }
- return nil
-}
-
-// VerifyJoinExisting sanity-checks the initial config for join existing cluster
-// case and returns an error for things that should never happen.
-func (c *ServerConfig) VerifyJoinExisting() error {
- // The member has announced its peer urls to the cluster before starting; no need to
- // set the configuration again.
- if err := c.hasLocalMember(); err != nil {
- return err
- }
- if checkDuplicateURL(c.InitialPeerURLsMap) {
- return fmt.Errorf("initial cluster %s has duplicate url", c.InitialPeerURLsMap)
- }
- if c.DiscoveryURL != "" {
- return fmt.Errorf("discovery URL should not be set when joining existing initial cluster")
- }
- return nil
-}
-
-// hasLocalMember checks that the cluster at least contains the local server.
-func (c *ServerConfig) hasLocalMember() error {
- if urls := c.InitialPeerURLsMap[c.Name]; urls == nil {
- return fmt.Errorf("couldn't find local name %q in the initial cluster configuration", c.Name)
- }
- return nil
-}
-
-// advertiseMatchesCluster confirms peer URLs match those in the cluster peer list.
-func (c *ServerConfig) advertiseMatchesCluster() error {
- urls, apurls := c.InitialPeerURLsMap[c.Name], c.PeerURLs.StringSlice()
- urls.Sort()
- sort.Strings(apurls)
- ctx, cancel := context.WithTimeout(context.TODO(), 30*time.Second)
- defer cancel()
- ok, err := netutil.URLStringsEqual(ctx, c.Logger, apurls, urls.StringSlice())
- if ok {
- return nil
- }
-
- initMap, apMap := make(map[string]struct{}), make(map[string]struct{})
- for _, url := range c.PeerURLs {
- apMap[url.String()] = struct{}{}
- }
- for _, url := range c.InitialPeerURLsMap[c.Name] {
- initMap[url.String()] = struct{}{}
- }
-
- missing := []string{}
- for url := range initMap {
- if _, ok := apMap[url]; !ok {
- missing = append(missing, url)
- }
- }
- if len(missing) > 0 {
- for i := range missing {
- missing[i] = c.Name + "=" + missing[i]
- }
- mstr := strings.Join(missing, ",")
- apStr := strings.Join(apurls, ",")
- return fmt.Errorf("--initial-cluster has %s but missing from --initial-advertise-peer-urls=%s (%v)", mstr, apStr, err)
- }
-
- for url := range apMap {
- if _, ok := initMap[url]; !ok {
- missing = append(missing, url)
- }
- }
- if len(missing) > 0 {
- mstr := strings.Join(missing, ",")
- umap := types.URLsMap(map[string]types.URLs{c.Name: c.PeerURLs})
- return fmt.Errorf("--initial-advertise-peer-urls has %s but missing from --initial-cluster=%s", mstr, umap.String())
- }
-
- // resolved URLs from "--initial-advertise-peer-urls" and "--initial-cluster" did not match or failed
- apStr := strings.Join(apurls, ",")
- umap := types.URLsMap(map[string]types.URLs{c.Name: c.PeerURLs})
- return fmt.Errorf("failed to resolve %s to match --initial-cluster=%s (%v)", apStr, umap.String(), err)
-}
-
-func (c *ServerConfig) MemberDir() string { return filepath.Join(c.DataDir, "member") }
-
-func (c *ServerConfig) WALDir() string {
- if c.DedicatedWALDir != "" {
- return c.DedicatedWALDir
- }
- return filepath.Join(c.MemberDir(), "wal")
-}
-
-func (c *ServerConfig) SnapDir() string { return filepath.Join(c.MemberDir(), "snap") }
-
-func (c *ServerConfig) ShouldDiscover() bool { return c.DiscoveryURL != "" }
-
-// ReqTimeout returns timeout for request to finish.
-func (c *ServerConfig) ReqTimeout() time.Duration {
- // 5s for queue waiting, computation and disk IO delay
- // + 2 * election timeout for possible leader election
- return 5*time.Second + 2*time.Duration(c.ElectionTicks*int(c.TickMs))*time.Millisecond
-}
-
-func (c *ServerConfig) electionTimeout() time.Duration {
- return time.Duration(c.ElectionTicks*int(c.TickMs)) * time.Millisecond
-}
-
-func (c *ServerConfig) peerDialTimeout() time.Duration {
- // 1s for queue wait and election timeout
- return time.Second + time.Duration(c.ElectionTicks*int(c.TickMs))*time.Millisecond
-}
-
-func checkDuplicateURL(urlsmap types.URLsMap) bool {
- um := make(map[string]bool)
- for _, urls := range urlsmap {
- for _, url := range urls {
- u := url.String()
- if um[u] {
- return true
- }
- um[u] = true
- }
- }
- return false
-}
-
-func (c *ServerConfig) bootstrapTimeout() time.Duration {
- if c.BootstrapTimeout != 0 {
- return c.BootstrapTimeout
- }
- return time.Second
-}
-
-func (c *ServerConfig) backendPath() string { return filepath.Join(c.SnapDir(), "db") }
diff --git a/vendor/go.etcd.io/etcd/etcdserver/consistent_index.go b/vendor/go.etcd.io/etcd/etcdserver/consistent_index.go
deleted file mode 100644
index d513f67..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/consistent_index.go
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package etcdserver
-
-import (
- "sync/atomic"
-)
-
-// consistentIndex represents the offset of an entry in a consistent replica log.
-// It implements the mvcc.ConsistentIndexGetter interface.
-// It is always set to the offset of current entry before executing the entry,
-// so ConsistentWatchableKV could get the consistent index from it.
-type consistentIndex uint64
-
-func (i *consistentIndex) setConsistentIndex(v uint64) {
- atomic.StoreUint64((*uint64)(i), v)
-}
-
-func (i *consistentIndex) ConsistentIndex() uint64 {
- return atomic.LoadUint64((*uint64)(i))
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/corrupt.go b/vendor/go.etcd.io/etcd/etcdserver/corrupt.go
deleted file mode 100644
index 32678a7..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/corrupt.go
+++ /dev/null
@@ -1,411 +0,0 @@
-// Copyright 2017 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package etcdserver
-
-import (
- "context"
- "fmt"
- "time"
-
- "go.etcd.io/etcd/clientv3"
- "go.etcd.io/etcd/etcdserver/api/v3rpc/rpctypes"
- pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
- "go.etcd.io/etcd/mvcc"
- "go.etcd.io/etcd/pkg/types"
-
- "go.uber.org/zap"
-)
-
-// CheckInitialHashKV compares initial hash values with its peers
-// before serving any peer/client traffic. Only mismatch when hashes
-// are different at requested revision, with same compact revision.
-func (s *EtcdServer) CheckInitialHashKV() error {
- if !s.Cfg.InitialCorruptCheck {
- return nil
- }
-
- lg := s.getLogger()
-
- if lg != nil {
- lg.Info(
- "starting initial corruption check",
- zap.String("local-member-id", s.ID().String()),
- zap.Duration("timeout", s.Cfg.ReqTimeout()),
- )
- } else {
- plog.Infof("%s starting initial corruption check with timeout %v...", s.ID(), s.Cfg.ReqTimeout())
- }
-
- h, rev, crev, err := s.kv.HashByRev(0)
- if err != nil {
- return fmt.Errorf("%s failed to fetch hash (%v)", s.ID(), err)
- }
- peers := s.getPeerHashKVs(rev)
- mismatch := 0
- for _, p := range peers {
- if p.resp != nil {
- peerID := types.ID(p.resp.Header.MemberId)
- fields := []zap.Field{
- zap.String("local-member-id", s.ID().String()),
- zap.Int64("local-member-revision", rev),
- zap.Int64("local-member-compact-revision", crev),
- zap.Uint32("local-member-hash", h),
- zap.String("remote-peer-id", peerID.String()),
- zap.Strings("remote-peer-endpoints", p.eps),
- zap.Int64("remote-peer-revision", p.resp.Header.Revision),
- zap.Int64("remote-peer-compact-revision", p.resp.CompactRevision),
- zap.Uint32("remote-peer-hash", p.resp.Hash),
- }
-
- if h != p.resp.Hash {
- if crev == p.resp.CompactRevision {
- if lg != nil {
- lg.Warn("found different hash values from remote peer", fields...)
- } else {
- plog.Errorf("%s's hash %d != %s's hash %d (revision %d, peer revision %d, compact revision %d)", s.ID(), h, peerID, p.resp.Hash, rev, p.resp.Header.Revision, crev)
- }
- mismatch++
- } else {
- if lg != nil {
- lg.Warn("found different compact revision values from remote peer", fields...)
- } else {
- plog.Warningf("%s cannot check hash of peer(%s): peer has a different compact revision %d (revision:%d)", s.ID(), peerID, p.resp.CompactRevision, rev)
- }
- }
- }
-
- continue
- }
-
- if p.err != nil {
- switch p.err {
- case rpctypes.ErrFutureRev:
- if lg != nil {
- lg.Warn(
- "cannot fetch hash from slow remote peer",
- zap.String("local-member-id", s.ID().String()),
- zap.Int64("local-member-revision", rev),
- zap.Int64("local-member-compact-revision", crev),
- zap.Uint32("local-member-hash", h),
- zap.String("remote-peer-id", p.id.String()),
- zap.Strings("remote-peer-endpoints", p.eps),
- zap.Error(err),
- )
- } else {
- plog.Warningf("%s cannot check the hash of peer(%q) at revision %d: peer is lagging behind(%q)", s.ID(), p.eps, rev, p.err.Error())
- }
- case rpctypes.ErrCompacted:
- if lg != nil {
- lg.Warn(
- "cannot fetch hash from remote peer; local member is behind",
- zap.String("local-member-id", s.ID().String()),
- zap.Int64("local-member-revision", rev),
- zap.Int64("local-member-compact-revision", crev),
- zap.Uint32("local-member-hash", h),
- zap.String("remote-peer-id", p.id.String()),
- zap.Strings("remote-peer-endpoints", p.eps),
- zap.Error(err),
- )
- } else {
- plog.Warningf("%s cannot check the hash of peer(%q) at revision %d: local node is lagging behind(%q)", s.ID(), p.eps, rev, p.err.Error())
- }
- }
- }
- }
- if mismatch > 0 {
- return fmt.Errorf("%s found data inconsistency with peers", s.ID())
- }
-
- if lg != nil {
- lg.Info(
- "initial corruption checking passed; no corruption",
- zap.String("local-member-id", s.ID().String()),
- )
- } else {
- plog.Infof("%s succeeded on initial corruption checking: no corruption", s.ID())
- }
- return nil
-}
-
-func (s *EtcdServer) monitorKVHash() {
- t := s.Cfg.CorruptCheckTime
- if t == 0 {
- return
- }
-
- lg := s.getLogger()
- if lg != nil {
- lg.Info(
- "enabled corruption checking",
- zap.String("local-member-id", s.ID().String()),
- zap.Duration("interval", t),
- )
- } else {
- plog.Infof("enabled corruption checking with %s interval", t)
- }
-
- for {
- select {
- case <-s.stopping:
- return
- case <-time.After(t):
- }
- if !s.isLeader() {
- continue
- }
- if err := s.checkHashKV(); err != nil {
- if lg != nil {
- lg.Warn("failed to check hash KV", zap.Error(err))
- } else {
- plog.Debugf("check hash kv failed %v", err)
- }
- }
- }
-}
-
-func (s *EtcdServer) checkHashKV() error {
- lg := s.getLogger()
-
- h, rev, crev, err := s.kv.HashByRev(0)
- if err != nil {
- return err
- }
- peers := s.getPeerHashKVs(rev)
-
- ctx, cancel := context.WithTimeout(context.Background(), s.Cfg.ReqTimeout())
- err = s.linearizableReadNotify(ctx)
- cancel()
- if err != nil {
- return err
- }
-
- h2, rev2, crev2, err := s.kv.HashByRev(0)
- if err != nil {
- return err
- }
-
- alarmed := false
- mismatch := func(id uint64) {
- if alarmed {
- return
- }
- alarmed = true
- a := &pb.AlarmRequest{
- MemberID: id,
- Action: pb.AlarmRequest_ACTIVATE,
- Alarm: pb.AlarmType_CORRUPT,
- }
- s.goAttach(func() {
- s.raftRequest(s.ctx, pb.InternalRaftRequest{Alarm: a})
- })
- }
-
- if h2 != h && rev2 == rev && crev == crev2 {
- if lg != nil {
- lg.Warn(
- "found hash mismatch",
- zap.Int64("revision-1", rev),
- zap.Int64("compact-revision-1", crev),
- zap.Uint32("hash-1", h),
- zap.Int64("revision-2", rev2),
- zap.Int64("compact-revision-2", crev2),
- zap.Uint32("hash-2", h2),
- )
- } else {
- plog.Warningf("mismatched hashes %d and %d for revision %d", h, h2, rev)
- }
- mismatch(uint64(s.ID()))
- }
-
- for _, p := range peers {
- if p.resp == nil {
- continue
- }
- id := p.resp.Header.MemberId
-
- // leader expects follower's latest revision less than or equal to leader's
- if p.resp.Header.Revision > rev2 {
- if lg != nil {
- lg.Warn(
- "revision from follower must be less than or equal to leader's",
- zap.Int64("leader-revision", rev2),
- zap.Int64("follower-revision", p.resp.Header.Revision),
- zap.String("follower-peer-id", types.ID(id).String()),
- )
- } else {
- plog.Warningf(
- "revision %d from member %v, expected at most %d",
- p.resp.Header.Revision,
- types.ID(id),
- rev2)
- }
- mismatch(id)
- }
-
- // leader expects follower's latest compact revision less than or equal to leader's
- if p.resp.CompactRevision > crev2 {
- if lg != nil {
- lg.Warn(
- "compact revision from follower must be less than or equal to leader's",
- zap.Int64("leader-compact-revision", crev2),
- zap.Int64("follower-compact-revision", p.resp.CompactRevision),
- zap.String("follower-peer-id", types.ID(id).String()),
- )
- } else {
- plog.Warningf(
- "compact revision %d from member %v, expected at most %d",
- p.resp.CompactRevision,
- types.ID(id),
- crev2,
- )
- }
- mismatch(id)
- }
-
- // follower's compact revision is leader's old one, then hashes must match
- if p.resp.CompactRevision == crev && p.resp.Hash != h {
- if lg != nil {
- lg.Warn(
- "same compact revision then hashes must match",
- zap.Int64("leader-compact-revision", crev2),
- zap.Uint32("leader-hash", h),
- zap.Int64("follower-compact-revision", p.resp.CompactRevision),
- zap.Uint32("follower-hash", p.resp.Hash),
- zap.String("follower-peer-id", types.ID(id).String()),
- )
- } else {
- plog.Warningf(
- "hash %d at revision %d from member %v, expected hash %d",
- p.resp.Hash,
- rev,
- types.ID(id),
- h,
- )
- }
- mismatch(id)
- }
- }
- return nil
-}
-
-type peerHashKVResp struct {
- id types.ID
- eps []string
-
- resp *clientv3.HashKVResponse
- err error
-}
-
-func (s *EtcdServer) getPeerHashKVs(rev int64) (resps []*peerHashKVResp) {
- // TODO: handle the case when "s.cluster.Members" have not
- // been populated (e.g. no snapshot to load from disk)
- mbs := s.cluster.Members()
- pss := make([]peerHashKVResp, len(mbs))
- for _, m := range mbs {
- if m.ID == s.ID() {
- continue
- }
- pss = append(pss, peerHashKVResp{id: m.ID, eps: m.PeerURLs})
- }
-
- lg := s.getLogger()
-
- for _, p := range pss {
- if len(p.eps) == 0 {
- continue
- }
- cli, cerr := clientv3.New(clientv3.Config{
- DialTimeout: s.Cfg.ReqTimeout(),
- Endpoints: p.eps,
- })
- if cerr != nil {
- if lg != nil {
- lg.Warn(
- "failed to create client to peer URL",
- zap.String("local-member-id", s.ID().String()),
- zap.String("remote-peer-id", p.id.String()),
- zap.Strings("remote-peer-endpoints", p.eps),
- zap.Error(cerr),
- )
- } else {
- plog.Warningf("%s failed to create client to peer %q for hash checking (%q)", s.ID(), p.eps, cerr.Error())
- }
- continue
- }
-
- respsLen := len(resps)
- for _, c := range cli.Endpoints() {
- ctx, cancel := context.WithTimeout(context.Background(), s.Cfg.ReqTimeout())
- var resp *clientv3.HashKVResponse
- resp, cerr = cli.HashKV(ctx, c, rev)
- cancel()
- if cerr == nil {
- resps = append(resps, &peerHashKVResp{id: p.id, eps: p.eps, resp: resp, err: nil})
- break
- }
- if lg != nil {
- lg.Warn(
- "failed hash kv request",
- zap.String("local-member-id", s.ID().String()),
- zap.Int64("requested-revision", rev),
- zap.String("remote-peer-endpoint", c),
- zap.Error(cerr),
- )
- } else {
- plog.Warningf("%s hash-kv error %q on peer %q with revision %d", s.ID(), cerr.Error(), c, rev)
- }
- }
- cli.Close()
-
- if respsLen == len(resps) {
- resps = append(resps, &peerHashKVResp{id: p.id, eps: p.eps, resp: nil, err: cerr})
- }
- }
- return resps
-}
-
-type applierV3Corrupt struct {
- applierV3
-}
-
-func newApplierV3Corrupt(a applierV3) *applierV3Corrupt { return &applierV3Corrupt{a} }
-
-func (a *applierV3Corrupt) Put(txn mvcc.TxnWrite, p *pb.PutRequest) (*pb.PutResponse, error) {
- return nil, ErrCorrupt
-}
-
-func (a *applierV3Corrupt) Range(txn mvcc.TxnRead, p *pb.RangeRequest) (*pb.RangeResponse, error) {
- return nil, ErrCorrupt
-}
-
-func (a *applierV3Corrupt) DeleteRange(txn mvcc.TxnWrite, p *pb.DeleteRangeRequest) (*pb.DeleteRangeResponse, error) {
- return nil, ErrCorrupt
-}
-
-func (a *applierV3Corrupt) Txn(rt *pb.TxnRequest) (*pb.TxnResponse, error) {
- return nil, ErrCorrupt
-}
-
-func (a *applierV3Corrupt) Compaction(compaction *pb.CompactionRequest) (*pb.CompactionResponse, <-chan struct{}, error) {
- return nil, nil, ErrCorrupt
-}
-
-func (a *applierV3Corrupt) LeaseGrant(lc *pb.LeaseGrantRequest) (*pb.LeaseGrantResponse, error) {
- return nil, ErrCorrupt
-}
-
-func (a *applierV3Corrupt) LeaseRevoke(lc *pb.LeaseRevokeRequest) (*pb.LeaseRevokeResponse, error) {
- return nil, ErrCorrupt
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/doc.go b/vendor/go.etcd.io/etcd/etcdserver/doc.go
deleted file mode 100644
index b195d2d..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/doc.go
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package etcdserver defines how etcd servers interact and store their states.
-package etcdserver
diff --git a/vendor/go.etcd.io/etcd/etcdserver/errors.go b/vendor/go.etcd.io/etcd/etcdserver/errors.go
deleted file mode 100644
index d0fe289..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/errors.go
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package etcdserver
-
-import (
- "errors"
- "fmt"
-)
-
-var (
- ErrUnknownMethod = errors.New("etcdserver: unknown method")
- ErrStopped = errors.New("etcdserver: server stopped")
- ErrCanceled = errors.New("etcdserver: request cancelled")
- ErrTimeout = errors.New("etcdserver: request timed out")
- ErrTimeoutDueToLeaderFail = errors.New("etcdserver: request timed out, possibly due to previous leader failure")
- ErrTimeoutDueToConnectionLost = errors.New("etcdserver: request timed out, possibly due to connection lost")
- ErrTimeoutLeaderTransfer = errors.New("etcdserver: request timed out, leader transfer took too long")
- ErrLeaderChanged = errors.New("etcdserver: leader changed")
- ErrNotEnoughStartedMembers = errors.New("etcdserver: re-configuration failed due to not enough started members")
- ErrLearnerNotReady = errors.New("etcdserver: can only promote a learner member which is in sync with leader")
- ErrNoLeader = errors.New("etcdserver: no leader")
- ErrNotLeader = errors.New("etcdserver: not leader")
- ErrRequestTooLarge = errors.New("etcdserver: request is too large")
- ErrNoSpace = errors.New("etcdserver: no space")
- ErrTooManyRequests = errors.New("etcdserver: too many requests")
- ErrUnhealthy = errors.New("etcdserver: unhealthy cluster")
- ErrKeyNotFound = errors.New("etcdserver: key not found")
- ErrCorrupt = errors.New("etcdserver: corrupt cluster")
- ErrBadLeaderTransferee = errors.New("etcdserver: bad leader transferee")
-)
-
-type DiscoveryError struct {
- Op string
- Err error
-}
-
-func (e DiscoveryError) Error() string {
- return fmt.Sprintf("failed to %s discovery cluster (%v)", e.Op, e.Err)
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/etcdserverpb/etcdserver.pb.go b/vendor/go.etcd.io/etcd/etcdserver/etcdserverpb/etcdserver.pb.go
deleted file mode 100644
index 9e9b42c..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/etcdserverpb/etcdserver.pb.go
+++ /dev/null
@@ -1,1041 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: etcdserver.proto
-
-/*
- Package etcdserverpb is a generated protocol buffer package.
-
- It is generated from these files:
- etcdserver.proto
- raft_internal.proto
- rpc.proto
-
- It has these top-level messages:
- Request
- Metadata
- RequestHeader
- InternalRaftRequest
- EmptyResponse
- InternalAuthenticateRequest
- ResponseHeader
- RangeRequest
- RangeResponse
- PutRequest
- PutResponse
- DeleteRangeRequest
- DeleteRangeResponse
- RequestOp
- ResponseOp
- Compare
- TxnRequest
- TxnResponse
- CompactionRequest
- CompactionResponse
- HashRequest
- HashKVRequest
- HashKVResponse
- HashResponse
- SnapshotRequest
- SnapshotResponse
- WatchRequest
- WatchCreateRequest
- WatchCancelRequest
- WatchProgressRequest
- WatchResponse
- LeaseGrantRequest
- LeaseGrantResponse
- LeaseRevokeRequest
- LeaseRevokeResponse
- LeaseCheckpoint
- LeaseCheckpointRequest
- LeaseCheckpointResponse
- LeaseKeepAliveRequest
- LeaseKeepAliveResponse
- LeaseTimeToLiveRequest
- LeaseTimeToLiveResponse
- LeaseLeasesRequest
- LeaseStatus
- LeaseLeasesResponse
- Member
- MemberAddRequest
- MemberAddResponse
- MemberRemoveRequest
- MemberRemoveResponse
- MemberUpdateRequest
- MemberUpdateResponse
- MemberListRequest
- MemberListResponse
- MemberPromoteRequest
- MemberPromoteResponse
- DefragmentRequest
- DefragmentResponse
- MoveLeaderRequest
- MoveLeaderResponse
- AlarmRequest
- AlarmMember
- AlarmResponse
- StatusRequest
- StatusResponse
- AuthEnableRequest
- AuthDisableRequest
- AuthenticateRequest
- AuthUserAddRequest
- AuthUserGetRequest
- AuthUserDeleteRequest
- AuthUserChangePasswordRequest
- AuthUserGrantRoleRequest
- AuthUserRevokeRoleRequest
- AuthRoleAddRequest
- AuthRoleGetRequest
- AuthUserListRequest
- AuthRoleListRequest
- AuthRoleDeleteRequest
- AuthRoleGrantPermissionRequest
- AuthRoleRevokePermissionRequest
- AuthEnableResponse
- AuthDisableResponse
- AuthenticateResponse
- AuthUserAddResponse
- AuthUserGetResponse
- AuthUserDeleteResponse
- AuthUserChangePasswordResponse
- AuthUserGrantRoleResponse
- AuthUserRevokeRoleResponse
- AuthRoleAddResponse
- AuthRoleGetResponse
- AuthRoleListResponse
- AuthUserListResponse
- AuthRoleDeleteResponse
- AuthRoleGrantPermissionResponse
- AuthRoleRevokePermissionResponse
-*/
-package etcdserverpb
-
-import (
- "fmt"
-
- proto "github.com/golang/protobuf/proto"
-
- math "math"
-
- _ "github.com/gogo/protobuf/gogoproto"
-
- io "io"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
-
-type Request struct {
- ID uint64 `protobuf:"varint,1,opt,name=ID" json:"ID"`
- Method string `protobuf:"bytes,2,opt,name=Method" json:"Method"`
- Path string `protobuf:"bytes,3,opt,name=Path" json:"Path"`
- Val string `protobuf:"bytes,4,opt,name=Val" json:"Val"`
- Dir bool `protobuf:"varint,5,opt,name=Dir" json:"Dir"`
- PrevValue string `protobuf:"bytes,6,opt,name=PrevValue" json:"PrevValue"`
- PrevIndex uint64 `protobuf:"varint,7,opt,name=PrevIndex" json:"PrevIndex"`
- PrevExist *bool `protobuf:"varint,8,opt,name=PrevExist" json:"PrevExist,omitempty"`
- Expiration int64 `protobuf:"varint,9,opt,name=Expiration" json:"Expiration"`
- Wait bool `protobuf:"varint,10,opt,name=Wait" json:"Wait"`
- Since uint64 `protobuf:"varint,11,opt,name=Since" json:"Since"`
- Recursive bool `protobuf:"varint,12,opt,name=Recursive" json:"Recursive"`
- Sorted bool `protobuf:"varint,13,opt,name=Sorted" json:"Sorted"`
- Quorum bool `protobuf:"varint,14,opt,name=Quorum" json:"Quorum"`
- Time int64 `protobuf:"varint,15,opt,name=Time" json:"Time"`
- Stream bool `protobuf:"varint,16,opt,name=Stream" json:"Stream"`
- Refresh *bool `protobuf:"varint,17,opt,name=Refresh" json:"Refresh,omitempty"`
- XXX_unrecognized []byte `json:"-"`
-}
-
-func (m *Request) Reset() { *m = Request{} }
-func (m *Request) String() string { return proto.CompactTextString(m) }
-func (*Request) ProtoMessage() {}
-func (*Request) Descriptor() ([]byte, []int) { return fileDescriptorEtcdserver, []int{0} }
-
-type Metadata struct {
- NodeID uint64 `protobuf:"varint,1,opt,name=NodeID" json:"NodeID"`
- ClusterID uint64 `protobuf:"varint,2,opt,name=ClusterID" json:"ClusterID"`
- XXX_unrecognized []byte `json:"-"`
-}
-
-func (m *Metadata) Reset() { *m = Metadata{} }
-func (m *Metadata) String() string { return proto.CompactTextString(m) }
-func (*Metadata) ProtoMessage() {}
-func (*Metadata) Descriptor() ([]byte, []int) { return fileDescriptorEtcdserver, []int{1} }
-
-func init() {
- proto.RegisterType((*Request)(nil), "etcdserverpb.Request")
- proto.RegisterType((*Metadata)(nil), "etcdserverpb.Metadata")
-}
-func (m *Request) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *Request) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- dAtA[i] = 0x8
- i++
- i = encodeVarintEtcdserver(dAtA, i, uint64(m.ID))
- dAtA[i] = 0x12
- i++
- i = encodeVarintEtcdserver(dAtA, i, uint64(len(m.Method)))
- i += copy(dAtA[i:], m.Method)
- dAtA[i] = 0x1a
- i++
- i = encodeVarintEtcdserver(dAtA, i, uint64(len(m.Path)))
- i += copy(dAtA[i:], m.Path)
- dAtA[i] = 0x22
- i++
- i = encodeVarintEtcdserver(dAtA, i, uint64(len(m.Val)))
- i += copy(dAtA[i:], m.Val)
- dAtA[i] = 0x28
- i++
- if m.Dir {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i++
- dAtA[i] = 0x32
- i++
- i = encodeVarintEtcdserver(dAtA, i, uint64(len(m.PrevValue)))
- i += copy(dAtA[i:], m.PrevValue)
- dAtA[i] = 0x38
- i++
- i = encodeVarintEtcdserver(dAtA, i, uint64(m.PrevIndex))
- if m.PrevExist != nil {
- dAtA[i] = 0x40
- i++
- if *m.PrevExist {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i++
- }
- dAtA[i] = 0x48
- i++
- i = encodeVarintEtcdserver(dAtA, i, uint64(m.Expiration))
- dAtA[i] = 0x50
- i++
- if m.Wait {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i++
- dAtA[i] = 0x58
- i++
- i = encodeVarintEtcdserver(dAtA, i, uint64(m.Since))
- dAtA[i] = 0x60
- i++
- if m.Recursive {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i++
- dAtA[i] = 0x68
- i++
- if m.Sorted {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i++
- dAtA[i] = 0x70
- i++
- if m.Quorum {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i++
- dAtA[i] = 0x78
- i++
- i = encodeVarintEtcdserver(dAtA, i, uint64(m.Time))
- dAtA[i] = 0x80
- i++
- dAtA[i] = 0x1
- i++
- if m.Stream {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i++
- if m.Refresh != nil {
- dAtA[i] = 0x88
- i++
- dAtA[i] = 0x1
- i++
- if *m.Refresh {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i++
- }
- if m.XXX_unrecognized != nil {
- i += copy(dAtA[i:], m.XXX_unrecognized)
- }
- return i, nil
-}
-
-func (m *Metadata) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *Metadata) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- dAtA[i] = 0x8
- i++
- i = encodeVarintEtcdserver(dAtA, i, uint64(m.NodeID))
- dAtA[i] = 0x10
- i++
- i = encodeVarintEtcdserver(dAtA, i, uint64(m.ClusterID))
- if m.XXX_unrecognized != nil {
- i += copy(dAtA[i:], m.XXX_unrecognized)
- }
- return i, nil
-}
-
-func encodeVarintEtcdserver(dAtA []byte, offset int, v uint64) int {
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return offset + 1
-}
-func (m *Request) Size() (n int) {
- var l int
- _ = l
- n += 1 + sovEtcdserver(uint64(m.ID))
- l = len(m.Method)
- n += 1 + l + sovEtcdserver(uint64(l))
- l = len(m.Path)
- n += 1 + l + sovEtcdserver(uint64(l))
- l = len(m.Val)
- n += 1 + l + sovEtcdserver(uint64(l))
- n += 2
- l = len(m.PrevValue)
- n += 1 + l + sovEtcdserver(uint64(l))
- n += 1 + sovEtcdserver(uint64(m.PrevIndex))
- if m.PrevExist != nil {
- n += 2
- }
- n += 1 + sovEtcdserver(uint64(m.Expiration))
- n += 2
- n += 1 + sovEtcdserver(uint64(m.Since))
- n += 2
- n += 2
- n += 2
- n += 1 + sovEtcdserver(uint64(m.Time))
- n += 3
- if m.Refresh != nil {
- n += 3
- }
- if m.XXX_unrecognized != nil {
- n += len(m.XXX_unrecognized)
- }
- return n
-}
-
-func (m *Metadata) Size() (n int) {
- var l int
- _ = l
- n += 1 + sovEtcdserver(uint64(m.NodeID))
- n += 1 + sovEtcdserver(uint64(m.ClusterID))
- if m.XXX_unrecognized != nil {
- n += len(m.XXX_unrecognized)
- }
- return n
-}
-
-func sovEtcdserver(x uint64) (n int) {
- for {
- n++
- x >>= 7
- if x == 0 {
- break
- }
- }
- return n
-}
-func sozEtcdserver(x uint64) (n int) {
- return sovEtcdserver(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *Request) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEtcdserver
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: Request: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: Request: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
- }
- m.ID = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEtcdserver
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.ID |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Method", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEtcdserver
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEtcdserver
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Method = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Path", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEtcdserver
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEtcdserver
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Path = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 4:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Val", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEtcdserver
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEtcdserver
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Val = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 5:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Dir", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEtcdserver
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.Dir = bool(v != 0)
- case 6:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field PrevValue", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEtcdserver
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthEtcdserver
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.PrevValue = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 7:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field PrevIndex", wireType)
- }
- m.PrevIndex = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEtcdserver
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.PrevIndex |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 8:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field PrevExist", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEtcdserver
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- b := bool(v != 0)
- m.PrevExist = &b
- case 9:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Expiration", wireType)
- }
- m.Expiration = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEtcdserver
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Expiration |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 10:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Wait", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEtcdserver
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.Wait = bool(v != 0)
- case 11:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Since", wireType)
- }
- m.Since = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEtcdserver
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Since |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 12:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Recursive", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEtcdserver
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.Recursive = bool(v != 0)
- case 13:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Sorted", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEtcdserver
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.Sorted = bool(v != 0)
- case 14:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Quorum", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEtcdserver
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.Quorum = bool(v != 0)
- case 15:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Time", wireType)
- }
- m.Time = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEtcdserver
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Time |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 16:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Stream", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEtcdserver
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.Stream = bool(v != 0)
- case 17:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Refresh", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEtcdserver
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- b := bool(v != 0)
- m.Refresh = &b
- default:
- iNdEx = preIndex
- skippy, err := skipEtcdserver(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthEtcdserver
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *Metadata) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEtcdserver
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: Metadata: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: Metadata: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field NodeID", wireType)
- }
- m.NodeID = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEtcdserver
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.NodeID |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field ClusterID", wireType)
- }
- m.ClusterID = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowEtcdserver
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.ClusterID |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipEtcdserver(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthEtcdserver
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipEtcdserver(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowEtcdserver
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowEtcdserver
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- return iNdEx, nil
- case 1:
- iNdEx += 8
- return iNdEx, nil
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowEtcdserver
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- iNdEx += length
- if length < 0 {
- return 0, ErrInvalidLengthEtcdserver
- }
- return iNdEx, nil
- case 3:
- for {
- var innerWire uint64
- var start int = iNdEx
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowEtcdserver
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- innerWire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- innerWireType := int(innerWire & 0x7)
- if innerWireType == 4 {
- break
- }
- next, err := skipEtcdserver(dAtA[start:])
- if err != nil {
- return 0, err
- }
- iNdEx = start + next
- }
- return iNdEx, nil
- case 4:
- return iNdEx, nil
- case 5:
- iNdEx += 4
- return iNdEx, nil
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- }
- panic("unreachable")
-}
-
-var (
- ErrInvalidLengthEtcdserver = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowEtcdserver = fmt.Errorf("proto: integer overflow")
-)
-
-func init() { proto.RegisterFile("etcdserver.proto", fileDescriptorEtcdserver) }
-
-var fileDescriptorEtcdserver = []byte{
- // 380 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0xd2, 0xdd, 0x6e, 0xda, 0x30,
- 0x14, 0x07, 0x70, 0x0c, 0xe1, 0xcb, 0x63, 0x1b, 0xb3, 0xd0, 0x74, 0x84, 0xa6, 0x2c, 0x42, 0xbb,
- 0xc8, 0xd5, 0xf6, 0x0e, 0x2c, 0x5c, 0x44, 0x2a, 0x15, 0x0d, 0x15, 0xbd, 0x76, 0xc9, 0x29, 0x58,
- 0x02, 0x4c, 0x1d, 0x07, 0xf1, 0x06, 0x7d, 0x85, 0x3e, 0x12, 0x97, 0x7d, 0x82, 0xaa, 0xa5, 0x2f,
- 0x52, 0x39, 0x24, 0xc4, 0xed, 0x5d, 0xf4, 0xfb, 0x9f, 0x1c, 0x1f, 0x7f, 0xd0, 0x2e, 0xea, 0x79,
- 0x9c, 0xa0, 0xda, 0xa1, 0xfa, 0xbb, 0x55, 0x52, 0x4b, 0xd6, 0x29, 0x65, 0x7b, 0xdb, 0xef, 0x2d,
- 0xe4, 0x42, 0x66, 0xc1, 0x3f, 0xf3, 0x75, 0xaa, 0x19, 0x3c, 0x38, 0xb4, 0x19, 0xe1, 0x7d, 0x8a,
- 0x89, 0x66, 0x3d, 0x5a, 0x0d, 0x03, 0x20, 0x1e, 0xf1, 0x9d, 0xa1, 0x73, 0x78, 0xfe, 0x5d, 0x89,
- 0xaa, 0x61, 0xc0, 0x7e, 0xd1, 0xc6, 0x18, 0xf5, 0x52, 0xc6, 0x50, 0xf5, 0x88, 0xdf, 0xce, 0x93,
- 0xdc, 0x18, 0x50, 0x67, 0xc2, 0xf5, 0x12, 0x6a, 0x56, 0x96, 0x09, 0xfb, 0x49, 0x6b, 0x33, 0xbe,
- 0x02, 0xc7, 0x0a, 0x0c, 0x18, 0x0f, 0x84, 0x82, 0xba, 0x47, 0xfc, 0x56, 0xe1, 0x81, 0x50, 0x6c,
- 0x40, 0xdb, 0x13, 0x85, 0xbb, 0x19, 0x5f, 0xa5, 0x08, 0x0d, 0xeb, 0xaf, 0x92, 0x8b, 0x9a, 0x70,
- 0x13, 0xe3, 0x1e, 0x9a, 0xd6, 0xa0, 0x25, 0x17, 0x35, 0xa3, 0xbd, 0x48, 0x34, 0xb4, 0xce, 0xab,
- 0x90, 0xa8, 0x64, 0xf6, 0x87, 0xd2, 0xd1, 0x7e, 0x2b, 0x14, 0xd7, 0x42, 0x6e, 0xa0, 0xed, 0x11,
- 0xbf, 0x96, 0x37, 0xb2, 0xdc, 0xec, 0xed, 0x86, 0x0b, 0x0d, 0xd4, 0x1a, 0x35, 0x13, 0xd6, 0xa7,
- 0xf5, 0xa9, 0xd8, 0xcc, 0x11, 0xbe, 0x58, 0x33, 0x9c, 0xc8, 0xac, 0x1f, 0xe1, 0x3c, 0x55, 0x89,
- 0xd8, 0x21, 0x74, 0xac, 0x5f, 0x4b, 0x36, 0x67, 0x3a, 0x95, 0x4a, 0x63, 0x0c, 0x5f, 0xad, 0x82,
- 0xdc, 0x4c, 0x7a, 0x95, 0x4a, 0x95, 0xae, 0xe1, 0x9b, 0x9d, 0x9e, 0xcc, 0x4c, 0x75, 0x2d, 0xd6,
- 0x08, 0xdf, 0xad, 0xa9, 0x33, 0xc9, 0xba, 0x6a, 0x85, 0x7c, 0x0d, 0xdd, 0x0f, 0x5d, 0x33, 0x63,
- 0xae, 0xb9, 0xe8, 0x3b, 0x85, 0xc9, 0x12, 0x7e, 0x58, 0xa7, 0x52, 0xe0, 0xe0, 0x82, 0xb6, 0xc6,
- 0xa8, 0x79, 0xcc, 0x35, 0x37, 0x9d, 0x2e, 0x65, 0x8c, 0x9f, 0x5e, 0x43, 0x6e, 0x66, 0x87, 0xff,
- 0x57, 0x69, 0xa2, 0x51, 0x85, 0x41, 0xf6, 0x28, 0xce, 0xb7, 0x70, 0xe6, 0x61, 0xef, 0xf0, 0xea,
- 0x56, 0x0e, 0x47, 0x97, 0x3c, 0x1d, 0x5d, 0xf2, 0x72, 0x74, 0xc9, 0xe3, 0x9b, 0x5b, 0x79, 0x0f,
- 0x00, 0x00, 0xff, 0xff, 0xee, 0x40, 0xba, 0xd6, 0xa4, 0x02, 0x00, 0x00,
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/etcdserverpb/etcdserver.proto b/vendor/go.etcd.io/etcd/etcdserver/etcdserverpb/etcdserver.proto
deleted file mode 100644
index 25e0aca..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/etcdserverpb/etcdserver.proto
+++ /dev/null
@@ -1,34 +0,0 @@
-syntax = "proto2";
-package etcdserverpb;
-
-import "gogoproto/gogo.proto";
-
-option (gogoproto.marshaler_all) = true;
-option (gogoproto.sizer_all) = true;
-option (gogoproto.unmarshaler_all) = true;
-option (gogoproto.goproto_getters_all) = false;
-
-message Request {
- optional uint64 ID = 1 [(gogoproto.nullable) = false];
- optional string Method = 2 [(gogoproto.nullable) = false];
- optional string Path = 3 [(gogoproto.nullable) = false];
- optional string Val = 4 [(gogoproto.nullable) = false];
- optional bool Dir = 5 [(gogoproto.nullable) = false];
- optional string PrevValue = 6 [(gogoproto.nullable) = false];
- optional uint64 PrevIndex = 7 [(gogoproto.nullable) = false];
- optional bool PrevExist = 8 [(gogoproto.nullable) = true];
- optional int64 Expiration = 9 [(gogoproto.nullable) = false];
- optional bool Wait = 10 [(gogoproto.nullable) = false];
- optional uint64 Since = 11 [(gogoproto.nullable) = false];
- optional bool Recursive = 12 [(gogoproto.nullable) = false];
- optional bool Sorted = 13 [(gogoproto.nullable) = false];
- optional bool Quorum = 14 [(gogoproto.nullable) = false];
- optional int64 Time = 15 [(gogoproto.nullable) = false];
- optional bool Stream = 16 [(gogoproto.nullable) = false];
- optional bool Refresh = 17 [(gogoproto.nullable) = true];
-}
-
-message Metadata {
- optional uint64 NodeID = 1 [(gogoproto.nullable) = false];
- optional uint64 ClusterID = 2 [(gogoproto.nullable) = false];
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/etcdserverpb/gw/rpc.pb.gw.go b/vendor/go.etcd.io/etcd/etcdserver/etcdserverpb/gw/rpc.pb.gw.go
deleted file mode 100644
index 904c321..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/etcdserverpb/gw/rpc.pb.gw.go
+++ /dev/null
@@ -1,2318 +0,0 @@
-// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
-// source: etcdserver/etcdserverpb/rpc.proto
-
-/*
-Package etcdserverpb is a reverse proxy.
-
-It translates gRPC into RESTful JSON APIs.
-*/
-package gw
-
-import (
- "go.etcd.io/etcd/etcdserver/etcdserverpb"
- "io"
- "net/http"
-
- "github.com/golang/protobuf/proto"
- "github.com/grpc-ecosystem/grpc-gateway/runtime"
- "github.com/grpc-ecosystem/grpc-gateway/utilities"
- "golang.org/x/net/context"
- "google.golang.org/grpc"
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/grpclog"
- "google.golang.org/grpc/status"
-)
-
-var _ codes.Code
-var _ io.Reader
-var _ status.Status
-var _ = runtime.String
-var _ = utilities.NewDoubleArray
-
-func request_KV_Range_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.KVClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.RangeRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.Range(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_KV_Put_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.KVClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.PutRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.Put(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_KV_DeleteRange_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.KVClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.DeleteRangeRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.DeleteRange(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_KV_Txn_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.KVClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.TxnRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.Txn(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_KV_Compact_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.KVClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.CompactionRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.Compact(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Watch_Watch_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.WatchClient, req *http.Request, pathParams map[string]string) (etcdserverpb.Watch_WatchClient, runtime.ServerMetadata, error) {
- var metadata runtime.ServerMetadata
- stream, err := client.Watch(ctx)
- if err != nil {
- grpclog.Printf("Failed to start streaming: %v", err)
- return nil, metadata, err
- }
- dec := marshaler.NewDecoder(req.Body)
- handleSend := func() error {
- var protoReq etcdserverpb.WatchRequest
- err := dec.Decode(&protoReq)
- if err == io.EOF {
- return err
- }
- if err != nil {
- grpclog.Printf("Failed to decode request: %v", err)
- return err
- }
- if err := stream.Send(&protoReq); err != nil {
- grpclog.Printf("Failed to send request: %v", err)
- return err
- }
- return nil
- }
- if err := handleSend(); err != nil {
- if cerr := stream.CloseSend(); cerr != nil {
- grpclog.Printf("Failed to terminate client stream: %v", cerr)
- }
- if err == io.EOF {
- return stream, metadata, nil
- }
- return nil, metadata, err
- }
- go func() {
- for {
- if err := handleSend(); err != nil {
- break
- }
- }
- if err := stream.CloseSend(); err != nil {
- grpclog.Printf("Failed to terminate client stream: %v", err)
- }
- }()
- header, err := stream.Header()
- if err != nil {
- grpclog.Printf("Failed to get header from client: %v", err)
- return nil, metadata, err
- }
- metadata.HeaderMD = header
- return stream, metadata, nil
-}
-
-func request_Lease_LeaseGrant_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.LeaseClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.LeaseGrantRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.LeaseGrant(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Lease_LeaseRevoke_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.LeaseClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.LeaseRevokeRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.LeaseRevoke(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Lease_LeaseRevoke_1(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.LeaseClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.LeaseRevokeRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.LeaseRevoke(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Lease_LeaseKeepAlive_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.LeaseClient, req *http.Request, pathParams map[string]string) (etcdserverpb.Lease_LeaseKeepAliveClient, runtime.ServerMetadata, error) {
- var metadata runtime.ServerMetadata
- stream, err := client.LeaseKeepAlive(ctx)
- if err != nil {
- grpclog.Printf("Failed to start streaming: %v", err)
- return nil, metadata, err
- }
- dec := marshaler.NewDecoder(req.Body)
- handleSend := func() error {
- var protoReq etcdserverpb.LeaseKeepAliveRequest
- err := dec.Decode(&protoReq)
- if err == io.EOF {
- return err
- }
- if err != nil {
- grpclog.Printf("Failed to decode request: %v", err)
- return err
- }
- if err := stream.Send(&protoReq); err != nil {
- grpclog.Printf("Failed to send request: %v", err)
- return err
- }
- return nil
- }
- if err := handleSend(); err != nil {
- if cerr := stream.CloseSend(); cerr != nil {
- grpclog.Printf("Failed to terminate client stream: %v", cerr)
- }
- if err == io.EOF {
- return stream, metadata, nil
- }
- return nil, metadata, err
- }
- go func() {
- for {
- if err := handleSend(); err != nil {
- break
- }
- }
- if err := stream.CloseSend(); err != nil {
- grpclog.Printf("Failed to terminate client stream: %v", err)
- }
- }()
- header, err := stream.Header()
- if err != nil {
- grpclog.Printf("Failed to get header from client: %v", err)
- return nil, metadata, err
- }
- metadata.HeaderMD = header
- return stream, metadata, nil
-}
-
-func request_Lease_LeaseTimeToLive_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.LeaseClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.LeaseTimeToLiveRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.LeaseTimeToLive(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Lease_LeaseTimeToLive_1(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.LeaseClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.LeaseTimeToLiveRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.LeaseTimeToLive(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Lease_LeaseLeases_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.LeaseClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.LeaseLeasesRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.LeaseLeases(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Lease_LeaseLeases_1(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.LeaseClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.LeaseLeasesRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.LeaseLeases(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Cluster_MemberAdd_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.ClusterClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.MemberAddRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.MemberAdd(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Cluster_MemberRemove_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.ClusterClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.MemberRemoveRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.MemberRemove(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Cluster_MemberUpdate_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.ClusterClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.MemberUpdateRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.MemberUpdate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Cluster_MemberList_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.ClusterClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.MemberListRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.MemberList(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Cluster_MemberPromote_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.ClusterClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.MemberPromoteRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.MemberPromote(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Maintenance_Alarm_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.MaintenanceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.AlarmRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.Alarm(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Maintenance_Status_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.MaintenanceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.StatusRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.Status(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Maintenance_Defragment_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.MaintenanceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.DefragmentRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.Defragment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Maintenance_Hash_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.MaintenanceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.HashRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.Hash(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Maintenance_HashKV_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.MaintenanceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.HashKVRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.HashKV(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Maintenance_Snapshot_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.MaintenanceClient, req *http.Request, pathParams map[string]string) (etcdserverpb.Maintenance_SnapshotClient, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.SnapshotRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- stream, err := client.Snapshot(ctx, &protoReq)
- if err != nil {
- return nil, metadata, err
- }
- header, err := stream.Header()
- if err != nil {
- return nil, metadata, err
- }
- metadata.HeaderMD = header
- return stream, metadata, nil
-
-}
-
-func request_Maintenance_MoveLeader_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.MaintenanceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.MoveLeaderRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.MoveLeader(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Auth_AuthEnable_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.AuthEnableRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.AuthEnable(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Auth_AuthDisable_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.AuthDisableRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.AuthDisable(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Auth_Authenticate_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.AuthenticateRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.Authenticate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Auth_UserAdd_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.AuthUserAddRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.UserAdd(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Auth_UserGet_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.AuthUserGetRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.UserGet(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Auth_UserList_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.AuthUserListRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.UserList(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Auth_UserDelete_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.AuthUserDeleteRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.UserDelete(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Auth_UserChangePassword_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.AuthUserChangePasswordRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.UserChangePassword(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Auth_UserGrantRole_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.AuthUserGrantRoleRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.UserGrantRole(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Auth_UserRevokeRole_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.AuthUserRevokeRoleRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.UserRevokeRole(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Auth_RoleAdd_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.AuthRoleAddRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.RoleAdd(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Auth_RoleGet_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.AuthRoleGetRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.RoleGet(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Auth_RoleList_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.AuthRoleListRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.RoleList(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Auth_RoleDelete_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.AuthRoleDeleteRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.RoleDelete(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Auth_RoleGrantPermission_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.AuthRoleGrantPermissionRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.RoleGrantPermission(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func request_Auth_RoleRevokePermission_0(ctx context.Context, marshaler runtime.Marshaler, client etcdserverpb.AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq etcdserverpb.AuthRoleRevokePermissionRequest
- var metadata runtime.ServerMetadata
-
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.RoleRevokePermission(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-// RegisterKVHandlerFromEndpoint is same as RegisterKVHandler but
-// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
-func RegisterKVHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
- conn, err := grpc.Dial(endpoint, opts...)
- if err != nil {
- return err
- }
- defer func() {
- if err != nil {
- if cerr := conn.Close(); cerr != nil {
- grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
- }
- return
- }
- go func() {
- <-ctx.Done()
- if cerr := conn.Close(); cerr != nil {
- grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
- }
- }()
- }()
-
- return RegisterKVHandler(ctx, mux, conn)
-}
-
-// RegisterKVHandler registers the http handlers for service KV to "mux".
-// The handlers forward requests to the grpc endpoint over "conn".
-func RegisterKVHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
- return RegisterKVHandlerClient(ctx, mux, etcdserverpb.NewKVClient(conn))
-}
-
-// RegisterKVHandler registers the http handlers for service KV to "mux".
-// The handlers forward requests to the grpc endpoint over the given implementation of "KVClient".
-// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "KVClient"
-// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
-// "KVClient" to call the correct interceptors.
-func RegisterKVHandlerClient(ctx context.Context, mux *runtime.ServeMux, client etcdserverpb.KVClient) error {
-
- mux.Handle("POST", pattern_KV_Range_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_KV_Range_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_KV_Range_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_KV_Put_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_KV_Put_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_KV_Put_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_KV_DeleteRange_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_KV_DeleteRange_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_KV_DeleteRange_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_KV_Txn_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_KV_Txn_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_KV_Txn_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_KV_Compact_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_KV_Compact_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_KV_Compact_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-var (
- pattern_KV_Range_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3", "kv", "range"}, ""))
-
- pattern_KV_Put_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3", "kv", "put"}, ""))
-
- pattern_KV_DeleteRange_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3", "kv", "deleterange"}, ""))
-
- pattern_KV_Txn_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3", "kv", "txn"}, ""))
-
- pattern_KV_Compact_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3", "kv", "compaction"}, ""))
-)
-
-var (
- forward_KV_Range_0 = runtime.ForwardResponseMessage
-
- forward_KV_Put_0 = runtime.ForwardResponseMessage
-
- forward_KV_DeleteRange_0 = runtime.ForwardResponseMessage
-
- forward_KV_Txn_0 = runtime.ForwardResponseMessage
-
- forward_KV_Compact_0 = runtime.ForwardResponseMessage
-)
-
-// RegisterWatchHandlerFromEndpoint is same as RegisterWatchHandler but
-// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
-func RegisterWatchHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
- conn, err := grpc.Dial(endpoint, opts...)
- if err != nil {
- return err
- }
- defer func() {
- if err != nil {
- if cerr := conn.Close(); cerr != nil {
- grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
- }
- return
- }
- go func() {
- <-ctx.Done()
- if cerr := conn.Close(); cerr != nil {
- grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
- }
- }()
- }()
-
- return RegisterWatchHandler(ctx, mux, conn)
-}
-
-// RegisterWatchHandler registers the http handlers for service Watch to "mux".
-// The handlers forward requests to the grpc endpoint over "conn".
-func RegisterWatchHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
- return RegisterWatchHandlerClient(ctx, mux, etcdserverpb.NewWatchClient(conn))
-}
-
-// RegisterWatchHandler registers the http handlers for service Watch to "mux".
-// The handlers forward requests to the grpc endpoint over the given implementation of "WatchClient".
-// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "WatchClient"
-// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
-// "WatchClient" to call the correct interceptors.
-func RegisterWatchHandlerClient(ctx context.Context, mux *runtime.ServeMux, client etcdserverpb.WatchClient) error {
-
- mux.Handle("POST", pattern_Watch_Watch_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Watch_Watch_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Watch_Watch_0(ctx, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-var (
- pattern_Watch_Watch_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v3", "watch"}, ""))
-)
-
-var (
- forward_Watch_Watch_0 = runtime.ForwardResponseStream
-)
-
-// RegisterLeaseHandlerFromEndpoint is same as RegisterLeaseHandler but
-// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
-func RegisterLeaseHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
- conn, err := grpc.Dial(endpoint, opts...)
- if err != nil {
- return err
- }
- defer func() {
- if err != nil {
- if cerr := conn.Close(); cerr != nil {
- grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
- }
- return
- }
- go func() {
- <-ctx.Done()
- if cerr := conn.Close(); cerr != nil {
- grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
- }
- }()
- }()
-
- return RegisterLeaseHandler(ctx, mux, conn)
-}
-
-// RegisterLeaseHandler registers the http handlers for service Lease to "mux".
-// The handlers forward requests to the grpc endpoint over "conn".
-func RegisterLeaseHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
- return RegisterLeaseHandlerClient(ctx, mux, etcdserverpb.NewLeaseClient(conn))
-}
-
-// RegisterLeaseHandler registers the http handlers for service Lease to "mux".
-// The handlers forward requests to the grpc endpoint over the given implementation of "LeaseClient".
-// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "LeaseClient"
-// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
-// "LeaseClient" to call the correct interceptors.
-func RegisterLeaseHandlerClient(ctx context.Context, mux *runtime.ServeMux, client etcdserverpb.LeaseClient) error {
-
- mux.Handle("POST", pattern_Lease_LeaseGrant_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Lease_LeaseGrant_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Lease_LeaseGrant_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Lease_LeaseRevoke_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Lease_LeaseRevoke_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Lease_LeaseRevoke_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Lease_LeaseRevoke_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Lease_LeaseRevoke_1(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Lease_LeaseRevoke_1(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Lease_LeaseKeepAlive_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Lease_LeaseKeepAlive_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Lease_LeaseKeepAlive_0(ctx, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Lease_LeaseTimeToLive_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Lease_LeaseTimeToLive_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Lease_LeaseTimeToLive_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Lease_LeaseTimeToLive_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Lease_LeaseTimeToLive_1(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Lease_LeaseTimeToLive_1(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Lease_LeaseLeases_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Lease_LeaseLeases_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Lease_LeaseLeases_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Lease_LeaseLeases_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Lease_LeaseLeases_1(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Lease_LeaseLeases_1(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-var (
- pattern_Lease_LeaseGrant_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3", "lease", "grant"}, ""))
-
- pattern_Lease_LeaseRevoke_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3", "lease", "revoke"}, ""))
-
- pattern_Lease_LeaseRevoke_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3", "kv", "lease", "revoke"}, ""))
-
- pattern_Lease_LeaseKeepAlive_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3", "lease", "keepalive"}, ""))
-
- pattern_Lease_LeaseTimeToLive_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3", "lease", "timetolive"}, ""))
-
- pattern_Lease_LeaseTimeToLive_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3", "kv", "lease", "timetolive"}, ""))
-
- pattern_Lease_LeaseLeases_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3", "lease", "leases"}, ""))
-
- pattern_Lease_LeaseLeases_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3", "kv", "lease", "leases"}, ""))
-)
-
-var (
- forward_Lease_LeaseGrant_0 = runtime.ForwardResponseMessage
-
- forward_Lease_LeaseRevoke_0 = runtime.ForwardResponseMessage
-
- forward_Lease_LeaseRevoke_1 = runtime.ForwardResponseMessage
-
- forward_Lease_LeaseKeepAlive_0 = runtime.ForwardResponseStream
-
- forward_Lease_LeaseTimeToLive_0 = runtime.ForwardResponseMessage
-
- forward_Lease_LeaseTimeToLive_1 = runtime.ForwardResponseMessage
-
- forward_Lease_LeaseLeases_0 = runtime.ForwardResponseMessage
-
- forward_Lease_LeaseLeases_1 = runtime.ForwardResponseMessage
-)
-
-// RegisterClusterHandlerFromEndpoint is same as RegisterClusterHandler but
-// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
-func RegisterClusterHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
- conn, err := grpc.Dial(endpoint, opts...)
- if err != nil {
- return err
- }
- defer func() {
- if err != nil {
- if cerr := conn.Close(); cerr != nil {
- grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
- }
- return
- }
- go func() {
- <-ctx.Done()
- if cerr := conn.Close(); cerr != nil {
- grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
- }
- }()
- }()
-
- return RegisterClusterHandler(ctx, mux, conn)
-}
-
-// RegisterClusterHandler registers the http handlers for service Cluster to "mux".
-// The handlers forward requests to the grpc endpoint over "conn".
-func RegisterClusterHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
- return RegisterClusterHandlerClient(ctx, mux, etcdserverpb.NewClusterClient(conn))
-}
-
-// RegisterClusterHandler registers the http handlers for service Cluster to "mux".
-// The handlers forward requests to the grpc endpoint over the given implementation of "ClusterClient".
-// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ClusterClient"
-// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
-// "ClusterClient" to call the correct interceptors.
-func RegisterClusterHandlerClient(ctx context.Context, mux *runtime.ServeMux, client etcdserverpb.ClusterClient) error {
-
- mux.Handle("POST", pattern_Cluster_MemberAdd_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Cluster_MemberAdd_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Cluster_MemberAdd_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Cluster_MemberRemove_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Cluster_MemberRemove_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Cluster_MemberRemove_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Cluster_MemberUpdate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Cluster_MemberUpdate_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Cluster_MemberUpdate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Cluster_MemberList_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Cluster_MemberList_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Cluster_MemberList_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Cluster_MemberPromote_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Cluster_MemberPromote_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Cluster_MemberPromote_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-var (
- pattern_Cluster_MemberAdd_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3", "cluster", "member", "add"}, ""))
-
- pattern_Cluster_MemberRemove_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3", "cluster", "member", "remove"}, ""))
-
- pattern_Cluster_MemberUpdate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3", "cluster", "member", "update"}, ""))
-
- pattern_Cluster_MemberList_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3", "cluster", "member", "list"}, ""))
-
- pattern_Cluster_MemberPromote_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3", "cluster", "member", "promote"}, ""))
-)
-
-var (
- forward_Cluster_MemberAdd_0 = runtime.ForwardResponseMessage
-
- forward_Cluster_MemberRemove_0 = runtime.ForwardResponseMessage
-
- forward_Cluster_MemberUpdate_0 = runtime.ForwardResponseMessage
-
- forward_Cluster_MemberList_0 = runtime.ForwardResponseMessage
-
- forward_Cluster_MemberPromote_0 = runtime.ForwardResponseMessage
-)
-
-// RegisterMaintenanceHandlerFromEndpoint is same as RegisterMaintenanceHandler but
-// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
-func RegisterMaintenanceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
- conn, err := grpc.Dial(endpoint, opts...)
- if err != nil {
- return err
- }
- defer func() {
- if err != nil {
- if cerr := conn.Close(); cerr != nil {
- grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
- }
- return
- }
- go func() {
- <-ctx.Done()
- if cerr := conn.Close(); cerr != nil {
- grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
- }
- }()
- }()
-
- return RegisterMaintenanceHandler(ctx, mux, conn)
-}
-
-// RegisterMaintenanceHandler registers the http handlers for service Maintenance to "mux".
-// The handlers forward requests to the grpc endpoint over "conn".
-func RegisterMaintenanceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
- return RegisterMaintenanceHandlerClient(ctx, mux, etcdserverpb.NewMaintenanceClient(conn))
-}
-
-// RegisterMaintenanceHandler registers the http handlers for service Maintenance to "mux".
-// The handlers forward requests to the grpc endpoint over the given implementation of "MaintenanceClient".
-// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MaintenanceClient"
-// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
-// "MaintenanceClient" to call the correct interceptors.
-func RegisterMaintenanceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client etcdserverpb.MaintenanceClient) error {
-
- mux.Handle("POST", pattern_Maintenance_Alarm_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Maintenance_Alarm_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Maintenance_Alarm_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Maintenance_Status_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Maintenance_Status_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Maintenance_Status_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Maintenance_Defragment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Maintenance_Defragment_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Maintenance_Defragment_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Maintenance_Hash_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Maintenance_Hash_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Maintenance_Hash_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Maintenance_HashKV_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Maintenance_HashKV_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Maintenance_HashKV_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Maintenance_Snapshot_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Maintenance_Snapshot_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Maintenance_Snapshot_0(ctx, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Maintenance_MoveLeader_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Maintenance_MoveLeader_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Maintenance_MoveLeader_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-var (
- pattern_Maintenance_Alarm_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3", "maintenance", "alarm"}, ""))
-
- pattern_Maintenance_Status_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3", "maintenance", "status"}, ""))
-
- pattern_Maintenance_Defragment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3", "maintenance", "defragment"}, ""))
-
- pattern_Maintenance_Hash_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3", "maintenance", "hash"}, ""))
-
- pattern_Maintenance_HashKV_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3", "maintenance", "hash"}, ""))
-
- pattern_Maintenance_Snapshot_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3", "maintenance", "snapshot"}, ""))
-
- pattern_Maintenance_MoveLeader_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3", "maintenance", "transfer-leadership"}, ""))
-)
-
-var (
- forward_Maintenance_Alarm_0 = runtime.ForwardResponseMessage
-
- forward_Maintenance_Status_0 = runtime.ForwardResponseMessage
-
- forward_Maintenance_Defragment_0 = runtime.ForwardResponseMessage
-
- forward_Maintenance_Hash_0 = runtime.ForwardResponseMessage
-
- forward_Maintenance_HashKV_0 = runtime.ForwardResponseMessage
-
- forward_Maintenance_Snapshot_0 = runtime.ForwardResponseStream
-
- forward_Maintenance_MoveLeader_0 = runtime.ForwardResponseMessage
-)
-
-// RegisterAuthHandlerFromEndpoint is same as RegisterAuthHandler but
-// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
-func RegisterAuthHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
- conn, err := grpc.Dial(endpoint, opts...)
- if err != nil {
- return err
- }
- defer func() {
- if err != nil {
- if cerr := conn.Close(); cerr != nil {
- grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
- }
- return
- }
- go func() {
- <-ctx.Done()
- if cerr := conn.Close(); cerr != nil {
- grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
- }
- }()
- }()
-
- return RegisterAuthHandler(ctx, mux, conn)
-}
-
-// RegisterAuthHandler registers the http handlers for service Auth to "mux".
-// The handlers forward requests to the grpc endpoint over "conn".
-func RegisterAuthHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
- return RegisterAuthHandlerClient(ctx, mux, etcdserverpb.NewAuthClient(conn))
-}
-
-// RegisterAuthHandler registers the http handlers for service Auth to "mux".
-// The handlers forward requests to the grpc endpoint over the given implementation of "AuthClient".
-// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "AuthClient"
-// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
-// "AuthClient" to call the correct interceptors.
-func RegisterAuthHandlerClient(ctx context.Context, mux *runtime.ServeMux, client etcdserverpb.AuthClient) error {
-
- mux.Handle("POST", pattern_Auth_AuthEnable_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Auth_AuthEnable_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Auth_AuthEnable_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Auth_AuthDisable_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Auth_AuthDisable_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Auth_AuthDisable_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Auth_Authenticate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Auth_Authenticate_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Auth_Authenticate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Auth_UserAdd_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Auth_UserAdd_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Auth_UserAdd_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Auth_UserGet_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Auth_UserGet_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Auth_UserGet_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Auth_UserList_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Auth_UserList_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Auth_UserList_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Auth_UserDelete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Auth_UserDelete_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Auth_UserDelete_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Auth_UserChangePassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Auth_UserChangePassword_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Auth_UserChangePassword_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Auth_UserGrantRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Auth_UserGrantRole_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Auth_UserGrantRole_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Auth_UserRevokeRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Auth_UserRevokeRole_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Auth_UserRevokeRole_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Auth_RoleAdd_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Auth_RoleAdd_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Auth_RoleAdd_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Auth_RoleGet_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Auth_RoleGet_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Auth_RoleGet_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Auth_RoleList_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Auth_RoleList_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Auth_RoleList_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Auth_RoleDelete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Auth_RoleDelete_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Auth_RoleDelete_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Auth_RoleGrantPermission_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Auth_RoleGrantPermission_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Auth_RoleGrantPermission_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("POST", pattern_Auth_RoleRevokePermission_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- if cn, ok := w.(http.CloseNotifier); ok {
- go func(done <-chan struct{}, closed <-chan bool) {
- select {
- case <-done:
- case <-closed:
- cancel()
- }
- }(ctx.Done(), cn.CloseNotify())
- }
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_Auth_RoleRevokePermission_0(rctx, inboundMarshaler, client, req, pathParams)
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Auth_RoleRevokePermission_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-var (
- pattern_Auth_AuthEnable_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3", "auth", "enable"}, ""))
-
- pattern_Auth_AuthDisable_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3", "auth", "disable"}, ""))
-
- pattern_Auth_Authenticate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v3", "auth", "authenticate"}, ""))
-
- pattern_Auth_UserAdd_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3", "auth", "user", "add"}, ""))
-
- pattern_Auth_UserGet_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3", "auth", "user", "get"}, ""))
-
- pattern_Auth_UserList_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3", "auth", "user", "list"}, ""))
-
- pattern_Auth_UserDelete_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3", "auth", "user", "delete"}, ""))
-
- pattern_Auth_UserChangePassword_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3", "auth", "user", "changepw"}, ""))
-
- pattern_Auth_UserGrantRole_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3", "auth", "user", "grant"}, ""))
-
- pattern_Auth_UserRevokeRole_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3", "auth", "user", "revoke"}, ""))
-
- pattern_Auth_RoleAdd_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3", "auth", "role", "add"}, ""))
-
- pattern_Auth_RoleGet_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3", "auth", "role", "get"}, ""))
-
- pattern_Auth_RoleList_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3", "auth", "role", "list"}, ""))
-
- pattern_Auth_RoleDelete_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3", "auth", "role", "delete"}, ""))
-
- pattern_Auth_RoleGrantPermission_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3", "auth", "role", "grant"}, ""))
-
- pattern_Auth_RoleRevokePermission_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v3", "auth", "role", "revoke"}, ""))
-)
-
-var (
- forward_Auth_AuthEnable_0 = runtime.ForwardResponseMessage
-
- forward_Auth_AuthDisable_0 = runtime.ForwardResponseMessage
-
- forward_Auth_Authenticate_0 = runtime.ForwardResponseMessage
-
- forward_Auth_UserAdd_0 = runtime.ForwardResponseMessage
-
- forward_Auth_UserGet_0 = runtime.ForwardResponseMessage
-
- forward_Auth_UserList_0 = runtime.ForwardResponseMessage
-
- forward_Auth_UserDelete_0 = runtime.ForwardResponseMessage
-
- forward_Auth_UserChangePassword_0 = runtime.ForwardResponseMessage
-
- forward_Auth_UserGrantRole_0 = runtime.ForwardResponseMessage
-
- forward_Auth_UserRevokeRole_0 = runtime.ForwardResponseMessage
-
- forward_Auth_RoleAdd_0 = runtime.ForwardResponseMessage
-
- forward_Auth_RoleGet_0 = runtime.ForwardResponseMessage
-
- forward_Auth_RoleList_0 = runtime.ForwardResponseMessage
-
- forward_Auth_RoleDelete_0 = runtime.ForwardResponseMessage
-
- forward_Auth_RoleGrantPermission_0 = runtime.ForwardResponseMessage
-
- forward_Auth_RoleRevokePermission_0 = runtime.ForwardResponseMessage
-)
diff --git a/vendor/go.etcd.io/etcd/etcdserver/etcdserverpb/raft_internal.pb.go b/vendor/go.etcd.io/etcd/etcdserver/etcdserverpb/raft_internal.pb.go
deleted file mode 100644
index b170499..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/etcdserverpb/raft_internal.pb.go
+++ /dev/null
@@ -1,2127 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: raft_internal.proto
-
-package etcdserverpb
-
-import (
- "fmt"
-
- proto "github.com/golang/protobuf/proto"
-
- math "math"
-
- _ "github.com/gogo/protobuf/gogoproto"
-
- io "io"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-type RequestHeader struct {
- ID uint64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"`
- // username is a username that is associated with an auth token of gRPC connection
- Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"`
- // auth_revision is a revision number of auth.authStore. It is not related to mvcc
- AuthRevision uint64 `protobuf:"varint,3,opt,name=auth_revision,json=authRevision,proto3" json:"auth_revision,omitempty"`
-}
-
-func (m *RequestHeader) Reset() { *m = RequestHeader{} }
-func (m *RequestHeader) String() string { return proto.CompactTextString(m) }
-func (*RequestHeader) ProtoMessage() {}
-func (*RequestHeader) Descriptor() ([]byte, []int) { return fileDescriptorRaftInternal, []int{0} }
-
-// An InternalRaftRequest is the union of all requests which can be
-// sent via raft.
-type InternalRaftRequest struct {
- Header *RequestHeader `protobuf:"bytes,100,opt,name=header" json:"header,omitempty"`
- ID uint64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"`
- V2 *Request `protobuf:"bytes,2,opt,name=v2" json:"v2,omitempty"`
- Range *RangeRequest `protobuf:"bytes,3,opt,name=range" json:"range,omitempty"`
- Put *PutRequest `protobuf:"bytes,4,opt,name=put" json:"put,omitempty"`
- DeleteRange *DeleteRangeRequest `protobuf:"bytes,5,opt,name=delete_range,json=deleteRange" json:"delete_range,omitempty"`
- Txn *TxnRequest `protobuf:"bytes,6,opt,name=txn" json:"txn,omitempty"`
- Compaction *CompactionRequest `protobuf:"bytes,7,opt,name=compaction" json:"compaction,omitempty"`
- LeaseGrant *LeaseGrantRequest `protobuf:"bytes,8,opt,name=lease_grant,json=leaseGrant" json:"lease_grant,omitempty"`
- LeaseRevoke *LeaseRevokeRequest `protobuf:"bytes,9,opt,name=lease_revoke,json=leaseRevoke" json:"lease_revoke,omitempty"`
- Alarm *AlarmRequest `protobuf:"bytes,10,opt,name=alarm" json:"alarm,omitempty"`
- LeaseCheckpoint *LeaseCheckpointRequest `protobuf:"bytes,11,opt,name=lease_checkpoint,json=leaseCheckpoint" json:"lease_checkpoint,omitempty"`
- AuthEnable *AuthEnableRequest `protobuf:"bytes,1000,opt,name=auth_enable,json=authEnable" json:"auth_enable,omitempty"`
- AuthDisable *AuthDisableRequest `protobuf:"bytes,1011,opt,name=auth_disable,json=authDisable" json:"auth_disable,omitempty"`
- Authenticate *InternalAuthenticateRequest `protobuf:"bytes,1012,opt,name=authenticate" json:"authenticate,omitempty"`
- AuthUserAdd *AuthUserAddRequest `protobuf:"bytes,1100,opt,name=auth_user_add,json=authUserAdd" json:"auth_user_add,omitempty"`
- AuthUserDelete *AuthUserDeleteRequest `protobuf:"bytes,1101,opt,name=auth_user_delete,json=authUserDelete" json:"auth_user_delete,omitempty"`
- AuthUserGet *AuthUserGetRequest `protobuf:"bytes,1102,opt,name=auth_user_get,json=authUserGet" json:"auth_user_get,omitempty"`
- AuthUserChangePassword *AuthUserChangePasswordRequest `protobuf:"bytes,1103,opt,name=auth_user_change_password,json=authUserChangePassword" json:"auth_user_change_password,omitempty"`
- AuthUserGrantRole *AuthUserGrantRoleRequest `protobuf:"bytes,1104,opt,name=auth_user_grant_role,json=authUserGrantRole" json:"auth_user_grant_role,omitempty"`
- AuthUserRevokeRole *AuthUserRevokeRoleRequest `protobuf:"bytes,1105,opt,name=auth_user_revoke_role,json=authUserRevokeRole" json:"auth_user_revoke_role,omitempty"`
- AuthUserList *AuthUserListRequest `protobuf:"bytes,1106,opt,name=auth_user_list,json=authUserList" json:"auth_user_list,omitempty"`
- AuthRoleList *AuthRoleListRequest `protobuf:"bytes,1107,opt,name=auth_role_list,json=authRoleList" json:"auth_role_list,omitempty"`
- AuthRoleAdd *AuthRoleAddRequest `protobuf:"bytes,1200,opt,name=auth_role_add,json=authRoleAdd" json:"auth_role_add,omitempty"`
- AuthRoleDelete *AuthRoleDeleteRequest `protobuf:"bytes,1201,opt,name=auth_role_delete,json=authRoleDelete" json:"auth_role_delete,omitempty"`
- AuthRoleGet *AuthRoleGetRequest `protobuf:"bytes,1202,opt,name=auth_role_get,json=authRoleGet" json:"auth_role_get,omitempty"`
- AuthRoleGrantPermission *AuthRoleGrantPermissionRequest `protobuf:"bytes,1203,opt,name=auth_role_grant_permission,json=authRoleGrantPermission" json:"auth_role_grant_permission,omitempty"`
- AuthRoleRevokePermission *AuthRoleRevokePermissionRequest `protobuf:"bytes,1204,opt,name=auth_role_revoke_permission,json=authRoleRevokePermission" json:"auth_role_revoke_permission,omitempty"`
-}
-
-func (m *InternalRaftRequest) Reset() { *m = InternalRaftRequest{} }
-func (m *InternalRaftRequest) String() string { return proto.CompactTextString(m) }
-func (*InternalRaftRequest) ProtoMessage() {}
-func (*InternalRaftRequest) Descriptor() ([]byte, []int) { return fileDescriptorRaftInternal, []int{1} }
-
-type EmptyResponse struct {
-}
-
-func (m *EmptyResponse) Reset() { *m = EmptyResponse{} }
-func (m *EmptyResponse) String() string { return proto.CompactTextString(m) }
-func (*EmptyResponse) ProtoMessage() {}
-func (*EmptyResponse) Descriptor() ([]byte, []int) { return fileDescriptorRaftInternal, []int{2} }
-
-// What is the difference between AuthenticateRequest (defined in rpc.proto) and InternalAuthenticateRequest?
-// InternalAuthenticateRequest has a member that is filled by etcdserver and shouldn't be user-facing.
-// For avoiding misusage the field, we have an internal version of AuthenticateRequest.
-type InternalAuthenticateRequest struct {
- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
- Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
- // simple_token is generated in API layer (etcdserver/v3_server.go)
- SimpleToken string `protobuf:"bytes,3,opt,name=simple_token,json=simpleToken,proto3" json:"simple_token,omitempty"`
-}
-
-func (m *InternalAuthenticateRequest) Reset() { *m = InternalAuthenticateRequest{} }
-func (m *InternalAuthenticateRequest) String() string { return proto.CompactTextString(m) }
-func (*InternalAuthenticateRequest) ProtoMessage() {}
-func (*InternalAuthenticateRequest) Descriptor() ([]byte, []int) {
- return fileDescriptorRaftInternal, []int{3}
-}
-
-func init() {
- proto.RegisterType((*RequestHeader)(nil), "etcdserverpb.RequestHeader")
- proto.RegisterType((*InternalRaftRequest)(nil), "etcdserverpb.InternalRaftRequest")
- proto.RegisterType((*EmptyResponse)(nil), "etcdserverpb.EmptyResponse")
- proto.RegisterType((*InternalAuthenticateRequest)(nil), "etcdserverpb.InternalAuthenticateRequest")
-}
-func (m *RequestHeader) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *RequestHeader) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.ID != 0 {
- dAtA[i] = 0x8
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(m.ID))
- }
- if len(m.Username) > 0 {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(len(m.Username)))
- i += copy(dAtA[i:], m.Username)
- }
- if m.AuthRevision != 0 {
- dAtA[i] = 0x18
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthRevision))
- }
- return i, nil
-}
-
-func (m *InternalRaftRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *InternalRaftRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.ID != 0 {
- dAtA[i] = 0x8
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(m.ID))
- }
- if m.V2 != nil {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(m.V2.Size()))
- n1, err := m.V2.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n1
- }
- if m.Range != nil {
- dAtA[i] = 0x1a
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(m.Range.Size()))
- n2, err := m.Range.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n2
- }
- if m.Put != nil {
- dAtA[i] = 0x22
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(m.Put.Size()))
- n3, err := m.Put.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n3
- }
- if m.DeleteRange != nil {
- dAtA[i] = 0x2a
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(m.DeleteRange.Size()))
- n4, err := m.DeleteRange.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n4
- }
- if m.Txn != nil {
- dAtA[i] = 0x32
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(m.Txn.Size()))
- n5, err := m.Txn.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n5
- }
- if m.Compaction != nil {
- dAtA[i] = 0x3a
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(m.Compaction.Size()))
- n6, err := m.Compaction.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n6
- }
- if m.LeaseGrant != nil {
- dAtA[i] = 0x42
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(m.LeaseGrant.Size()))
- n7, err := m.LeaseGrant.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n7
- }
- if m.LeaseRevoke != nil {
- dAtA[i] = 0x4a
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(m.LeaseRevoke.Size()))
- n8, err := m.LeaseRevoke.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n8
- }
- if m.Alarm != nil {
- dAtA[i] = 0x52
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(m.Alarm.Size()))
- n9, err := m.Alarm.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n9
- }
- if m.LeaseCheckpoint != nil {
- dAtA[i] = 0x5a
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(m.LeaseCheckpoint.Size()))
- n10, err := m.LeaseCheckpoint.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n10
- }
- if m.Header != nil {
- dAtA[i] = 0xa2
- i++
- dAtA[i] = 0x6
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(m.Header.Size()))
- n11, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n11
- }
- if m.AuthEnable != nil {
- dAtA[i] = 0xc2
- i++
- dAtA[i] = 0x3e
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthEnable.Size()))
- n12, err := m.AuthEnable.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n12
- }
- if m.AuthDisable != nil {
- dAtA[i] = 0x9a
- i++
- dAtA[i] = 0x3f
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthDisable.Size()))
- n13, err := m.AuthDisable.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n13
- }
- if m.Authenticate != nil {
- dAtA[i] = 0xa2
- i++
- dAtA[i] = 0x3f
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(m.Authenticate.Size()))
- n14, err := m.Authenticate.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n14
- }
- if m.AuthUserAdd != nil {
- dAtA[i] = 0xe2
- i++
- dAtA[i] = 0x44
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthUserAdd.Size()))
- n15, err := m.AuthUserAdd.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n15
- }
- if m.AuthUserDelete != nil {
- dAtA[i] = 0xea
- i++
- dAtA[i] = 0x44
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthUserDelete.Size()))
- n16, err := m.AuthUserDelete.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n16
- }
- if m.AuthUserGet != nil {
- dAtA[i] = 0xf2
- i++
- dAtA[i] = 0x44
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthUserGet.Size()))
- n17, err := m.AuthUserGet.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n17
- }
- if m.AuthUserChangePassword != nil {
- dAtA[i] = 0xfa
- i++
- dAtA[i] = 0x44
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthUserChangePassword.Size()))
- n18, err := m.AuthUserChangePassword.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n18
- }
- if m.AuthUserGrantRole != nil {
- dAtA[i] = 0x82
- i++
- dAtA[i] = 0x45
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthUserGrantRole.Size()))
- n19, err := m.AuthUserGrantRole.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n19
- }
- if m.AuthUserRevokeRole != nil {
- dAtA[i] = 0x8a
- i++
- dAtA[i] = 0x45
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthUserRevokeRole.Size()))
- n20, err := m.AuthUserRevokeRole.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n20
- }
- if m.AuthUserList != nil {
- dAtA[i] = 0x92
- i++
- dAtA[i] = 0x45
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthUserList.Size()))
- n21, err := m.AuthUserList.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n21
- }
- if m.AuthRoleList != nil {
- dAtA[i] = 0x9a
- i++
- dAtA[i] = 0x45
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthRoleList.Size()))
- n22, err := m.AuthRoleList.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n22
- }
- if m.AuthRoleAdd != nil {
- dAtA[i] = 0x82
- i++
- dAtA[i] = 0x4b
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthRoleAdd.Size()))
- n23, err := m.AuthRoleAdd.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n23
- }
- if m.AuthRoleDelete != nil {
- dAtA[i] = 0x8a
- i++
- dAtA[i] = 0x4b
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthRoleDelete.Size()))
- n24, err := m.AuthRoleDelete.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n24
- }
- if m.AuthRoleGet != nil {
- dAtA[i] = 0x92
- i++
- dAtA[i] = 0x4b
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthRoleGet.Size()))
- n25, err := m.AuthRoleGet.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n25
- }
- if m.AuthRoleGrantPermission != nil {
- dAtA[i] = 0x9a
- i++
- dAtA[i] = 0x4b
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthRoleGrantPermission.Size()))
- n26, err := m.AuthRoleGrantPermission.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n26
- }
- if m.AuthRoleRevokePermission != nil {
- dAtA[i] = 0xa2
- i++
- dAtA[i] = 0x4b
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(m.AuthRoleRevokePermission.Size()))
- n27, err := m.AuthRoleRevokePermission.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n27
- }
- return i, nil
-}
-
-func (m *EmptyResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *EmptyResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- return i, nil
-}
-
-func (m *InternalAuthenticateRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *InternalAuthenticateRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if len(m.Name) > 0 {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(len(m.Name)))
- i += copy(dAtA[i:], m.Name)
- }
- if len(m.Password) > 0 {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(len(m.Password)))
- i += copy(dAtA[i:], m.Password)
- }
- if len(m.SimpleToken) > 0 {
- dAtA[i] = 0x1a
- i++
- i = encodeVarintRaftInternal(dAtA, i, uint64(len(m.SimpleToken)))
- i += copy(dAtA[i:], m.SimpleToken)
- }
- return i, nil
-}
-
-func encodeVarintRaftInternal(dAtA []byte, offset int, v uint64) int {
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return offset + 1
-}
-func (m *RequestHeader) Size() (n int) {
- var l int
- _ = l
- if m.ID != 0 {
- n += 1 + sovRaftInternal(uint64(m.ID))
- }
- l = len(m.Username)
- if l > 0 {
- n += 1 + l + sovRaftInternal(uint64(l))
- }
- if m.AuthRevision != 0 {
- n += 1 + sovRaftInternal(uint64(m.AuthRevision))
- }
- return n
-}
-
-func (m *InternalRaftRequest) Size() (n int) {
- var l int
- _ = l
- if m.ID != 0 {
- n += 1 + sovRaftInternal(uint64(m.ID))
- }
- if m.V2 != nil {
- l = m.V2.Size()
- n += 1 + l + sovRaftInternal(uint64(l))
- }
- if m.Range != nil {
- l = m.Range.Size()
- n += 1 + l + sovRaftInternal(uint64(l))
- }
- if m.Put != nil {
- l = m.Put.Size()
- n += 1 + l + sovRaftInternal(uint64(l))
- }
- if m.DeleteRange != nil {
- l = m.DeleteRange.Size()
- n += 1 + l + sovRaftInternal(uint64(l))
- }
- if m.Txn != nil {
- l = m.Txn.Size()
- n += 1 + l + sovRaftInternal(uint64(l))
- }
- if m.Compaction != nil {
- l = m.Compaction.Size()
- n += 1 + l + sovRaftInternal(uint64(l))
- }
- if m.LeaseGrant != nil {
- l = m.LeaseGrant.Size()
- n += 1 + l + sovRaftInternal(uint64(l))
- }
- if m.LeaseRevoke != nil {
- l = m.LeaseRevoke.Size()
- n += 1 + l + sovRaftInternal(uint64(l))
- }
- if m.Alarm != nil {
- l = m.Alarm.Size()
- n += 1 + l + sovRaftInternal(uint64(l))
- }
- if m.LeaseCheckpoint != nil {
- l = m.LeaseCheckpoint.Size()
- n += 1 + l + sovRaftInternal(uint64(l))
- }
- if m.Header != nil {
- l = m.Header.Size()
- n += 2 + l + sovRaftInternal(uint64(l))
- }
- if m.AuthEnable != nil {
- l = m.AuthEnable.Size()
- n += 2 + l + sovRaftInternal(uint64(l))
- }
- if m.AuthDisable != nil {
- l = m.AuthDisable.Size()
- n += 2 + l + sovRaftInternal(uint64(l))
- }
- if m.Authenticate != nil {
- l = m.Authenticate.Size()
- n += 2 + l + sovRaftInternal(uint64(l))
- }
- if m.AuthUserAdd != nil {
- l = m.AuthUserAdd.Size()
- n += 2 + l + sovRaftInternal(uint64(l))
- }
- if m.AuthUserDelete != nil {
- l = m.AuthUserDelete.Size()
- n += 2 + l + sovRaftInternal(uint64(l))
- }
- if m.AuthUserGet != nil {
- l = m.AuthUserGet.Size()
- n += 2 + l + sovRaftInternal(uint64(l))
- }
- if m.AuthUserChangePassword != nil {
- l = m.AuthUserChangePassword.Size()
- n += 2 + l + sovRaftInternal(uint64(l))
- }
- if m.AuthUserGrantRole != nil {
- l = m.AuthUserGrantRole.Size()
- n += 2 + l + sovRaftInternal(uint64(l))
- }
- if m.AuthUserRevokeRole != nil {
- l = m.AuthUserRevokeRole.Size()
- n += 2 + l + sovRaftInternal(uint64(l))
- }
- if m.AuthUserList != nil {
- l = m.AuthUserList.Size()
- n += 2 + l + sovRaftInternal(uint64(l))
- }
- if m.AuthRoleList != nil {
- l = m.AuthRoleList.Size()
- n += 2 + l + sovRaftInternal(uint64(l))
- }
- if m.AuthRoleAdd != nil {
- l = m.AuthRoleAdd.Size()
- n += 2 + l + sovRaftInternal(uint64(l))
- }
- if m.AuthRoleDelete != nil {
- l = m.AuthRoleDelete.Size()
- n += 2 + l + sovRaftInternal(uint64(l))
- }
- if m.AuthRoleGet != nil {
- l = m.AuthRoleGet.Size()
- n += 2 + l + sovRaftInternal(uint64(l))
- }
- if m.AuthRoleGrantPermission != nil {
- l = m.AuthRoleGrantPermission.Size()
- n += 2 + l + sovRaftInternal(uint64(l))
- }
- if m.AuthRoleRevokePermission != nil {
- l = m.AuthRoleRevokePermission.Size()
- n += 2 + l + sovRaftInternal(uint64(l))
- }
- return n
-}
-
-func (m *EmptyResponse) Size() (n int) {
- var l int
- _ = l
- return n
-}
-
-func (m *InternalAuthenticateRequest) Size() (n int) {
- var l int
- _ = l
- l = len(m.Name)
- if l > 0 {
- n += 1 + l + sovRaftInternal(uint64(l))
- }
- l = len(m.Password)
- if l > 0 {
- n += 1 + l + sovRaftInternal(uint64(l))
- }
- l = len(m.SimpleToken)
- if l > 0 {
- n += 1 + l + sovRaftInternal(uint64(l))
- }
- return n
-}
-
-func sovRaftInternal(x uint64) (n int) {
- for {
- n++
- x >>= 7
- if x == 0 {
- break
- }
- }
- return n
-}
-func sozRaftInternal(x uint64) (n int) {
- return sovRaftInternal(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *RequestHeader) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: RequestHeader: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: RequestHeader: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
- }
- m.ID = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.ID |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Username", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Username = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 3:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field AuthRevision", wireType)
- }
- m.AuthRevision = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.AuthRevision |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipRaftInternal(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRaftInternal
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *InternalRaftRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: InternalRaftRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: InternalRaftRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
- }
- m.ID = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.ID |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field V2", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.V2 == nil {
- m.V2 = &Request{}
- }
- if err := m.V2.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Range", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Range == nil {
- m.Range = &RangeRequest{}
- }
- if err := m.Range.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 4:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Put", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Put == nil {
- m.Put = &PutRequest{}
- }
- if err := m.Put.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 5:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field DeleteRange", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.DeleteRange == nil {
- m.DeleteRange = &DeleteRangeRequest{}
- }
- if err := m.DeleteRange.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 6:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Txn", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Txn == nil {
- m.Txn = &TxnRequest{}
- }
- if err := m.Txn.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 7:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Compaction", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Compaction == nil {
- m.Compaction = &CompactionRequest{}
- }
- if err := m.Compaction.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 8:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field LeaseGrant", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.LeaseGrant == nil {
- m.LeaseGrant = &LeaseGrantRequest{}
- }
- if err := m.LeaseGrant.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 9:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field LeaseRevoke", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.LeaseRevoke == nil {
- m.LeaseRevoke = &LeaseRevokeRequest{}
- }
- if err := m.LeaseRevoke.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 10:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Alarm", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Alarm == nil {
- m.Alarm = &AlarmRequest{}
- }
- if err := m.Alarm.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 11:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field LeaseCheckpoint", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.LeaseCheckpoint == nil {
- m.LeaseCheckpoint = &LeaseCheckpointRequest{}
- }
- if err := m.LeaseCheckpoint.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 100:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &RequestHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 1000:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field AuthEnable", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.AuthEnable == nil {
- m.AuthEnable = &AuthEnableRequest{}
- }
- if err := m.AuthEnable.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 1011:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field AuthDisable", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.AuthDisable == nil {
- m.AuthDisable = &AuthDisableRequest{}
- }
- if err := m.AuthDisable.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 1012:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Authenticate", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Authenticate == nil {
- m.Authenticate = &InternalAuthenticateRequest{}
- }
- if err := m.Authenticate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 1100:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field AuthUserAdd", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.AuthUserAdd == nil {
- m.AuthUserAdd = &AuthUserAddRequest{}
- }
- if err := m.AuthUserAdd.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 1101:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field AuthUserDelete", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.AuthUserDelete == nil {
- m.AuthUserDelete = &AuthUserDeleteRequest{}
- }
- if err := m.AuthUserDelete.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 1102:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field AuthUserGet", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.AuthUserGet == nil {
- m.AuthUserGet = &AuthUserGetRequest{}
- }
- if err := m.AuthUserGet.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 1103:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field AuthUserChangePassword", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.AuthUserChangePassword == nil {
- m.AuthUserChangePassword = &AuthUserChangePasswordRequest{}
- }
- if err := m.AuthUserChangePassword.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 1104:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field AuthUserGrantRole", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.AuthUserGrantRole == nil {
- m.AuthUserGrantRole = &AuthUserGrantRoleRequest{}
- }
- if err := m.AuthUserGrantRole.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 1105:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field AuthUserRevokeRole", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.AuthUserRevokeRole == nil {
- m.AuthUserRevokeRole = &AuthUserRevokeRoleRequest{}
- }
- if err := m.AuthUserRevokeRole.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 1106:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field AuthUserList", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.AuthUserList == nil {
- m.AuthUserList = &AuthUserListRequest{}
- }
- if err := m.AuthUserList.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 1107:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field AuthRoleList", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.AuthRoleList == nil {
- m.AuthRoleList = &AuthRoleListRequest{}
- }
- if err := m.AuthRoleList.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 1200:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field AuthRoleAdd", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.AuthRoleAdd == nil {
- m.AuthRoleAdd = &AuthRoleAddRequest{}
- }
- if err := m.AuthRoleAdd.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 1201:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field AuthRoleDelete", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.AuthRoleDelete == nil {
- m.AuthRoleDelete = &AuthRoleDeleteRequest{}
- }
- if err := m.AuthRoleDelete.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 1202:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field AuthRoleGet", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.AuthRoleGet == nil {
- m.AuthRoleGet = &AuthRoleGetRequest{}
- }
- if err := m.AuthRoleGet.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 1203:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field AuthRoleGrantPermission", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.AuthRoleGrantPermission == nil {
- m.AuthRoleGrantPermission = &AuthRoleGrantPermissionRequest{}
- }
- if err := m.AuthRoleGrantPermission.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 1204:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field AuthRoleRevokePermission", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.AuthRoleRevokePermission == nil {
- m.AuthRoleRevokePermission = &AuthRoleRevokePermissionRequest{}
- }
- if err := m.AuthRoleRevokePermission.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRaftInternal(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRaftInternal
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *EmptyResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: EmptyResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: EmptyResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipRaftInternal(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRaftInternal
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *InternalAuthenticateRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: InternalAuthenticateRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: InternalAuthenticateRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Name = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Password", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Password = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field SimpleToken", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRaftInternal
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.SimpleToken = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRaftInternal(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRaftInternal
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipRaftInternal(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- return iNdEx, nil
- case 1:
- iNdEx += 8
- return iNdEx, nil
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- iNdEx += length
- if length < 0 {
- return 0, ErrInvalidLengthRaftInternal
- }
- return iNdEx, nil
- case 3:
- for {
- var innerWire uint64
- var start int = iNdEx
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowRaftInternal
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- innerWire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- innerWireType := int(innerWire & 0x7)
- if innerWireType == 4 {
- break
- }
- next, err := skipRaftInternal(dAtA[start:])
- if err != nil {
- return 0, err
- }
- iNdEx = start + next
- }
- return iNdEx, nil
- case 4:
- return iNdEx, nil
- case 5:
- iNdEx += 4
- return iNdEx, nil
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- }
- panic("unreachable")
-}
-
-var (
- ErrInvalidLengthRaftInternal = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowRaftInternal = fmt.Errorf("proto: integer overflow")
-)
-
-func init() { proto.RegisterFile("raft_internal.proto", fileDescriptorRaftInternal) }
-
-var fileDescriptorRaftInternal = []byte{
- // 867 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x96, 0xcb, 0x52, 0x33, 0x45,
- 0x14, 0xc7, 0x49, 0xb8, 0xa6, 0x13, 0x2e, 0x36, 0xa0, 0x6d, 0xa8, 0x8a, 0x10, 0xbc, 0xe0, 0x0d,
- 0xad, 0xf0, 0x00, 0x1a, 0x13, 0x0a, 0xa8, 0xa2, 0x90, 0x9a, 0xc2, 0x2a, 0xab, 0x5c, 0x8c, 0xcd,
- 0xcc, 0x21, 0x19, 0x99, 0xcc, 0x8c, 0x3d, 0x9d, 0x88, 0x6f, 0xe2, 0x63, 0x78, 0xdb, 0xbb, 0x65,
- 0xe1, 0x05, 0xf5, 0x05, 0x14, 0x37, 0xee, 0xbf, 0xef, 0x01, 0xbe, 0xea, 0xcb, 0xf4, 0x64, 0x92,
- 0x0e, 0xbb, 0xc9, 0x39, 0xff, 0xf3, 0xfb, 0x9f, 0x99, 0x3e, 0x07, 0x1a, 0x6d, 0x32, 0x7a, 0xc3,
- 0xdd, 0x20, 0xe2, 0xc0, 0x22, 0x1a, 0x1e, 0x26, 0x2c, 0xe6, 0x31, 0xae, 0x01, 0xf7, 0xfc, 0x14,
- 0xd8, 0x08, 0x58, 0x72, 0x5d, 0xdf, 0xea, 0xc5, 0xbd, 0x58, 0x26, 0x3e, 0x10, 0x4f, 0x4a, 0x53,
- 0xdf, 0xc8, 0x35, 0x3a, 0x52, 0x61, 0x89, 0xa7, 0x1e, 0x9b, 0x5f, 0xa2, 0x55, 0x07, 0xbe, 0x1e,
- 0x42, 0xca, 0x4f, 0x81, 0xfa, 0xc0, 0xf0, 0x1a, 0x2a, 0x9f, 0x75, 0x49, 0x69, 0xb7, 0x74, 0xb0,
- 0xe0, 0x94, 0xcf, 0xba, 0xb8, 0x8e, 0x56, 0x86, 0xa9, 0xb0, 0x1c, 0x00, 0x29, 0xef, 0x96, 0x0e,
- 0x2a, 0x8e, 0xf9, 0x8d, 0xf7, 0xd1, 0x2a, 0x1d, 0xf2, 0xbe, 0xcb, 0x60, 0x14, 0xa4, 0x41, 0x1c,
- 0x91, 0x79, 0x59, 0x56, 0x13, 0x41, 0x47, 0xc7, 0x9a, 0xbf, 0xac, 0xa3, 0xcd, 0x33, 0xdd, 0xb5,
- 0x43, 0x6f, 0xb8, 0xb6, 0x9b, 0x32, 0x7a, 0x03, 0x95, 0x47, 0x2d, 0x69, 0x51, 0x6d, 0x6d, 0x1f,
- 0x8e, 0xbf, 0xd7, 0xa1, 0x2e, 0x71, 0xca, 0xa3, 0x16, 0xfe, 0x10, 0x2d, 0x32, 0x1a, 0xf5, 0x40,
- 0x7a, 0x55, 0x5b, 0xf5, 0x09, 0xa5, 0x48, 0x65, 0x72, 0x25, 0xc4, 0xef, 0xa0, 0xf9, 0x64, 0xc8,
- 0xc9, 0x82, 0xd4, 0x93, 0xa2, 0xfe, 0x72, 0x98, 0xf5, 0xe3, 0x08, 0x11, 0xee, 0xa0, 0x9a, 0x0f,
- 0x21, 0x70, 0x70, 0x95, 0xc9, 0xa2, 0x2c, 0xda, 0x2d, 0x16, 0x75, 0xa5, 0xa2, 0x60, 0x55, 0xf5,
- 0xf3, 0x98, 0x30, 0xe4, 0x77, 0x11, 0x59, 0xb2, 0x19, 0x5e, 0xdd, 0x45, 0xc6, 0x90, 0xdf, 0x45,
- 0xf8, 0x23, 0x84, 0xbc, 0x78, 0x90, 0x50, 0x8f, 0x8b, 0xef, 0xb7, 0x2c, 0x4b, 0x5e, 0x2b, 0x96,
- 0x74, 0x4c, 0x3e, 0xab, 0x1c, 0x2b, 0xc1, 0x1f, 0xa3, 0x6a, 0x08, 0x34, 0x05, 0xb7, 0xc7, 0x68,
- 0xc4, 0xc9, 0x8a, 0x8d, 0x70, 0x2e, 0x04, 0x27, 0x22, 0x6f, 0x08, 0xa1, 0x09, 0x89, 0x77, 0x56,
- 0x04, 0x06, 0xa3, 0xf8, 0x16, 0x48, 0xc5, 0xf6, 0xce, 0x12, 0xe1, 0x48, 0x81, 0x79, 0xe7, 0x30,
- 0x8f, 0x89, 0x63, 0xa1, 0x21, 0x65, 0x03, 0x82, 0x6c, 0xc7, 0xd2, 0x16, 0x29, 0x73, 0x2c, 0x52,
- 0x88, 0x3f, 0x45, 0x1b, 0xca, 0xd6, 0xeb, 0x83, 0x77, 0x9b, 0xc4, 0x41, 0xc4, 0x49, 0x55, 0x16,
- 0xbf, 0x6e, 0xb1, 0xee, 0x18, 0x51, 0x86, 0x59, 0x0f, 0x8b, 0x71, 0x7c, 0x84, 0x96, 0xfa, 0x72,
- 0x86, 0x89, 0x2f, 0x31, 0x3b, 0xd6, 0x21, 0x52, 0x63, 0xee, 0x68, 0x29, 0x6e, 0xa3, 0xaa, 0x1c,
- 0x61, 0x88, 0xe8, 0x75, 0x08, 0xe4, 0x7f, 0xeb, 0x09, 0xb4, 0x87, 0xbc, 0x7f, 0x2c, 0x05, 0xe6,
- 0xfb, 0x51, 0x13, 0xc2, 0x5d, 0x24, 0x07, 0xde, 0xf5, 0x83, 0x54, 0x32, 0x9e, 0x2d, 0xdb, 0x3e,
- 0xa0, 0x60, 0x74, 0x95, 0xc2, 0x7c, 0x40, 0x9a, 0xc7, 0xf0, 0x85, 0xa2, 0x40, 0xc4, 0x03, 0x8f,
- 0x72, 0x20, 0xcf, 0x15, 0xe5, 0xed, 0x22, 0x25, 0x5b, 0xa4, 0xf6, 0x98, 0x34, 0xc3, 0x15, 0xea,
- 0xf1, 0xb1, 0xde, 0x4d, 0xb1, 0xac, 0x2e, 0xf5, 0x7d, 0xf2, 0xeb, 0xca, 0xac, 0xb6, 0x3e, 0x4b,
- 0x81, 0xb5, 0x7d, 0xbf, 0xd0, 0x96, 0x8e, 0xe1, 0x0b, 0xb4, 0x91, 0x63, 0xd4, 0x90, 0x93, 0xdf,
- 0x14, 0x69, 0xdf, 0x4e, 0xd2, 0xdb, 0xa1, 0x61, 0x6b, 0xb4, 0x10, 0x2e, 0xb6, 0xd5, 0x03, 0x4e,
- 0x7e, 0x7f, 0xb2, 0xad, 0x13, 0xe0, 0x53, 0x6d, 0x9d, 0x00, 0xc7, 0x3d, 0xf4, 0x6a, 0x8e, 0xf1,
- 0xfa, 0x62, 0xed, 0xdc, 0x84, 0xa6, 0xe9, 0x37, 0x31, 0xf3, 0xc9, 0x1f, 0x0a, 0xf9, 0xae, 0x1d,
- 0xd9, 0x91, 0xea, 0x4b, 0x2d, 0xce, 0xe8, 0x2f, 0x53, 0x6b, 0x1a, 0x7f, 0x8e, 0xb6, 0xc6, 0xfa,
- 0x15, 0xfb, 0xe2, 0xb2, 0x38, 0x04, 0xf2, 0xa0, 0x3c, 0xde, 0x9c, 0xd1, 0xb6, 0xdc, 0xb5, 0x38,
- 0x3f, 0xea, 0x97, 0xe8, 0x64, 0x06, 0x7f, 0x81, 0xb6, 0x73, 0xb2, 0x5a, 0x3d, 0x85, 0xfe, 0x53,
- 0xa1, 0xdf, 0xb2, 0xa3, 0xf5, 0x0e, 0x8e, 0xb1, 0x31, 0x9d, 0x4a, 0xe1, 0x53, 0xb4, 0x96, 0xc3,
- 0xc3, 0x20, 0xe5, 0xe4, 0x2f, 0x45, 0xdd, 0xb3, 0x53, 0xcf, 0x83, 0x94, 0x17, 0xe6, 0x28, 0x0b,
- 0x1a, 0x92, 0x68, 0x4d, 0x91, 0xfe, 0x9e, 0x49, 0x12, 0xd6, 0x53, 0xa4, 0x2c, 0x68, 0x8e, 0x5e,
- 0x92, 0xc4, 0x44, 0x7e, 0x5f, 0x99, 0x75, 0xf4, 0xa2, 0x66, 0x72, 0x22, 0x75, 0xcc, 0x4c, 0xa4,
- 0xc4, 0xe8, 0x89, 0xfc, 0xa1, 0x32, 0x6b, 0x22, 0x45, 0x95, 0x65, 0x22, 0xf3, 0x70, 0xb1, 0x2d,
- 0x31, 0x91, 0x3f, 0x3e, 0xd9, 0xd6, 0xe4, 0x44, 0xea, 0x18, 0xfe, 0x0a, 0xd5, 0xc7, 0x30, 0x72,
- 0x50, 0x12, 0x60, 0x83, 0x20, 0x95, 0xff, 0x18, 0x7f, 0x52, 0xcc, 0xf7, 0x66, 0x30, 0x85, 0xfc,
- 0xd2, 0xa8, 0x33, 0xfe, 0x2b, 0xd4, 0x9e, 0xc7, 0x03, 0xb4, 0x93, 0x7b, 0xe9, 0xd1, 0x19, 0x33,
- 0xfb, 0x59, 0x99, 0xbd, 0x6f, 0x37, 0x53, 0x53, 0x32, 0xed, 0x46, 0xe8, 0x0c, 0x41, 0x73, 0x1d,
- 0xad, 0x1e, 0x0f, 0x12, 0xfe, 0xad, 0x03, 0x69, 0x12, 0x47, 0x29, 0x34, 0x13, 0xb4, 0xf3, 0xc4,
- 0x1f, 0x22, 0x8c, 0xd1, 0x82, 0xbc, 0x2e, 0x94, 0xe4, 0x75, 0x41, 0x3e, 0x8b, 0x6b, 0x84, 0xd9,
- 0x4f, 0x7d, 0x8d, 0xc8, 0x7e, 0xe3, 0x3d, 0x54, 0x4b, 0x83, 0x41, 0x12, 0x82, 0xcb, 0xe3, 0x5b,
- 0x50, 0xb7, 0x88, 0x8a, 0x53, 0x55, 0xb1, 0x2b, 0x11, 0xfa, 0x64, 0xeb, 0xfe, 0xdf, 0xc6, 0xdc,
- 0xfd, 0x63, 0xa3, 0xf4, 0xf0, 0xd8, 0x28, 0xfd, 0xf3, 0xd8, 0x28, 0x7d, 0xf7, 0x5f, 0x63, 0xee,
- 0x7a, 0x49, 0xde, 0x61, 0x8e, 0x5e, 0x04, 0x00, 0x00, 0xff, 0xff, 0xed, 0x36, 0xf0, 0x6f, 0x1b,
- 0x09, 0x00, 0x00,
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/etcdserverpb/raft_internal.proto b/vendor/go.etcd.io/etcd/etcdserver/etcdserverpb/raft_internal.proto
deleted file mode 100644
index 7111f45..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/etcdserverpb/raft_internal.proto
+++ /dev/null
@@ -1,75 +0,0 @@
-syntax = "proto3";
-package etcdserverpb;
-
-import "gogoproto/gogo.proto";
-import "etcdserver.proto";
-import "rpc.proto";
-
-option (gogoproto.marshaler_all) = true;
-option (gogoproto.sizer_all) = true;
-option (gogoproto.unmarshaler_all) = true;
-option (gogoproto.goproto_getters_all) = false;
-
-message RequestHeader {
- uint64 ID = 1;
- // username is a username that is associated with an auth token of gRPC connection
- string username = 2;
- // auth_revision is a revision number of auth.authStore. It is not related to mvcc
- uint64 auth_revision = 3;
-}
-
-// An InternalRaftRequest is the union of all requests which can be
-// sent via raft.
-message InternalRaftRequest {
- RequestHeader header = 100;
- uint64 ID = 1;
-
- Request v2 = 2;
-
- RangeRequest range = 3;
- PutRequest put = 4;
- DeleteRangeRequest delete_range = 5;
- TxnRequest txn = 6;
- CompactionRequest compaction = 7;
-
- LeaseGrantRequest lease_grant = 8;
- LeaseRevokeRequest lease_revoke = 9;
-
- AlarmRequest alarm = 10;
-
- LeaseCheckpointRequest lease_checkpoint = 11;
-
- AuthEnableRequest auth_enable = 1000;
- AuthDisableRequest auth_disable = 1011;
-
- InternalAuthenticateRequest authenticate = 1012;
-
- AuthUserAddRequest auth_user_add = 1100;
- AuthUserDeleteRequest auth_user_delete = 1101;
- AuthUserGetRequest auth_user_get = 1102;
- AuthUserChangePasswordRequest auth_user_change_password = 1103;
- AuthUserGrantRoleRequest auth_user_grant_role = 1104;
- AuthUserRevokeRoleRequest auth_user_revoke_role = 1105;
- AuthUserListRequest auth_user_list = 1106;
- AuthRoleListRequest auth_role_list = 1107;
-
- AuthRoleAddRequest auth_role_add = 1200;
- AuthRoleDeleteRequest auth_role_delete = 1201;
- AuthRoleGetRequest auth_role_get = 1202;
- AuthRoleGrantPermissionRequest auth_role_grant_permission = 1203;
- AuthRoleRevokePermissionRequest auth_role_revoke_permission = 1204;
-}
-
-message EmptyResponse {
-}
-
-// What is the difference between AuthenticateRequest (defined in rpc.proto) and InternalAuthenticateRequest?
-// InternalAuthenticateRequest has a member that is filled by etcdserver and shouldn't be user-facing.
-// For avoiding misusage the field, we have an internal version of AuthenticateRequest.
-message InternalAuthenticateRequest {
- string name = 1;
- string password = 2;
-
- // simple_token is generated in API layer (etcdserver/v3_server.go)
- string simple_token = 3;
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/etcdserverpb/raft_internal_stringer.go b/vendor/go.etcd.io/etcd/etcdserver/etcdserverpb/raft_internal_stringer.go
deleted file mode 100644
index 3d3536a..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/etcdserverpb/raft_internal_stringer.go
+++ /dev/null
@@ -1,183 +0,0 @@
-// Copyright 2018 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package etcdserverpb
-
-import (
- "fmt"
- "strings"
-
- proto "github.com/golang/protobuf/proto"
-)
-
-// InternalRaftStringer implements custom proto Stringer:
-// redact password, replace value fields with value_size fields.
-type InternalRaftStringer struct {
- Request *InternalRaftRequest
-}
-
-func (as *InternalRaftStringer) String() string {
- switch {
- case as.Request.LeaseGrant != nil:
- return fmt.Sprintf("header:<%s> lease_grant:<ttl:%d-second id:%016x>",
- as.Request.Header.String(),
- as.Request.LeaseGrant.TTL,
- as.Request.LeaseGrant.ID,
- )
- case as.Request.LeaseRevoke != nil:
- return fmt.Sprintf("header:<%s> lease_revoke:<id:%016x>",
- as.Request.Header.String(),
- as.Request.LeaseRevoke.ID,
- )
- case as.Request.Authenticate != nil:
- return fmt.Sprintf("header:<%s> authenticate:<name:%s simple_token:%s>",
- as.Request.Header.String(),
- as.Request.Authenticate.Name,
- as.Request.Authenticate.SimpleToken,
- )
- case as.Request.AuthUserAdd != nil:
- return fmt.Sprintf("header:<%s> auth_user_add:<name:%s>",
- as.Request.Header.String(),
- as.Request.AuthUserAdd.Name,
- )
- case as.Request.AuthUserChangePassword != nil:
- return fmt.Sprintf("header:<%s> auth_user_change_password:<name:%s>",
- as.Request.Header.String(),
- as.Request.AuthUserChangePassword.Name,
- )
- case as.Request.Put != nil:
- return fmt.Sprintf("header:<%s> put:<%s>",
- as.Request.Header.String(),
- NewLoggablePutRequest(as.Request.Put).String(),
- )
- case as.Request.Txn != nil:
- return fmt.Sprintf("header:<%s> txn:<%s>",
- as.Request.Header.String(),
- NewLoggableTxnRequest(as.Request.Txn).String(),
- )
- default:
- // nothing to redact
- }
- return as.Request.String()
-}
-
-// txnRequestStringer implements a custom proto String to replace value bytes fields with value size
-// fields in any nested txn and put operations.
-type txnRequestStringer struct {
- Request *TxnRequest
-}
-
-func NewLoggableTxnRequest(request *TxnRequest) *txnRequestStringer {
- return &txnRequestStringer{request}
-}
-
-func (as *txnRequestStringer) String() string {
- var compare []string
- for _, c := range as.Request.Compare {
- switch cv := c.TargetUnion.(type) {
- case *Compare_Value:
- compare = append(compare, newLoggableValueCompare(c, cv).String())
- default:
- // nothing to redact
- compare = append(compare, c.String())
- }
- }
- var success []string
- for _, s := range as.Request.Success {
- success = append(success, newLoggableRequestOp(s).String())
- }
- var failure []string
- for _, f := range as.Request.Failure {
- failure = append(failure, newLoggableRequestOp(f).String())
- }
- return fmt.Sprintf("compare:<%s> success:<%s> failure:<%s>",
- strings.Join(compare, " "),
- strings.Join(success, " "),
- strings.Join(failure, " "),
- )
-}
-
-// requestOpStringer implements a custom proto String to replace value bytes fields with value
-// size fields in any nested txn and put operations.
-type requestOpStringer struct {
- Op *RequestOp
-}
-
-func newLoggableRequestOp(op *RequestOp) *requestOpStringer {
- return &requestOpStringer{op}
-}
-
-func (as *requestOpStringer) String() string {
- switch op := as.Op.Request.(type) {
- case *RequestOp_RequestPut:
- return fmt.Sprintf("request_put:<%s>", NewLoggablePutRequest(op.RequestPut).String())
- case *RequestOp_RequestTxn:
- return fmt.Sprintf("request_txn:<%s>", NewLoggableTxnRequest(op.RequestTxn).String())
- default:
- // nothing to redact
- }
- return as.Op.String()
-}
-
-// loggableValueCompare implements a custom proto String for Compare.Value union member types to
-// replace the value bytes field with a value size field.
-// To preserve proto encoding of the key and range_end bytes, a faked out proto type is used here.
-type loggableValueCompare struct {
- Result Compare_CompareResult `protobuf:"varint,1,opt,name=result,proto3,enum=etcdserverpb.Compare_CompareResult"`
- Target Compare_CompareTarget `protobuf:"varint,2,opt,name=target,proto3,enum=etcdserverpb.Compare_CompareTarget"`
- Key []byte `protobuf:"bytes,3,opt,name=key,proto3"`
- ValueSize int `protobuf:"bytes,7,opt,name=value_size,proto3"`
- RangeEnd []byte `protobuf:"bytes,64,opt,name=range_end,proto3"`
-}
-
-func newLoggableValueCompare(c *Compare, cv *Compare_Value) *loggableValueCompare {
- return &loggableValueCompare{
- c.Result,
- c.Target,
- c.Key,
- len(cv.Value),
- c.RangeEnd,
- }
-}
-
-func (m *loggableValueCompare) Reset() { *m = loggableValueCompare{} }
-func (m *loggableValueCompare) String() string { return proto.CompactTextString(m) }
-func (*loggableValueCompare) ProtoMessage() {}
-
-// loggablePutRequest implements a custom proto String to replace value bytes field with a value
-// size field.
-// To preserve proto encoding of the key bytes, a faked out proto type is used here.
-type loggablePutRequest struct {
- Key []byte `protobuf:"bytes,1,opt,name=key,proto3"`
- ValueSize int `protobuf:"varint,2,opt,name=value_size,proto3"`
- Lease int64 `protobuf:"varint,3,opt,name=lease,proto3"`
- PrevKv bool `protobuf:"varint,4,opt,name=prev_kv,proto3"`
- IgnoreValue bool `protobuf:"varint,5,opt,name=ignore_value,proto3"`
- IgnoreLease bool `protobuf:"varint,6,opt,name=ignore_lease,proto3"`
-}
-
-func NewLoggablePutRequest(request *PutRequest) *loggablePutRequest {
- return &loggablePutRequest{
- request.Key,
- len(request.Value),
- request.Lease,
- request.PrevKv,
- request.IgnoreValue,
- request.IgnoreLease,
- }
-}
-
-func (m *loggablePutRequest) Reset() { *m = loggablePutRequest{} }
-func (m *loggablePutRequest) String() string { return proto.CompactTextString(m) }
-func (*loggablePutRequest) ProtoMessage() {}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/etcdserverpb/rpc.pb.go b/vendor/go.etcd.io/etcd/etcdserver/etcdserverpb/rpc.pb.go
deleted file mode 100644
index 199ee62..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/etcdserverpb/rpc.pb.go
+++ /dev/null
@@ -1,20086 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: rpc.proto
-
-package etcdserverpb
-
-import (
- "fmt"
-
- proto "github.com/golang/protobuf/proto"
-
- math "math"
-
- _ "github.com/gogo/protobuf/gogoproto"
-
- mvccpb "go.etcd.io/etcd/mvcc/mvccpb"
-
- authpb "go.etcd.io/etcd/auth/authpb"
-
- context "golang.org/x/net/context"
-
- grpc "google.golang.org/grpc"
-
- io "io"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-type AlarmType int32
-
-const (
- AlarmType_NONE AlarmType = 0
- AlarmType_NOSPACE AlarmType = 1
- AlarmType_CORRUPT AlarmType = 2
-)
-
-var AlarmType_name = map[int32]string{
- 0: "NONE",
- 1: "NOSPACE",
- 2: "CORRUPT",
-}
-var AlarmType_value = map[string]int32{
- "NONE": 0,
- "NOSPACE": 1,
- "CORRUPT": 2,
-}
-
-func (x AlarmType) String() string {
- return proto.EnumName(AlarmType_name, int32(x))
-}
-func (AlarmType) EnumDescriptor() ([]byte, []int) { return fileDescriptorRpc, []int{0} }
-
-type RangeRequest_SortOrder int32
-
-const (
- RangeRequest_NONE RangeRequest_SortOrder = 0
- RangeRequest_ASCEND RangeRequest_SortOrder = 1
- RangeRequest_DESCEND RangeRequest_SortOrder = 2
-)
-
-var RangeRequest_SortOrder_name = map[int32]string{
- 0: "NONE",
- 1: "ASCEND",
- 2: "DESCEND",
-}
-var RangeRequest_SortOrder_value = map[string]int32{
- "NONE": 0,
- "ASCEND": 1,
- "DESCEND": 2,
-}
-
-func (x RangeRequest_SortOrder) String() string {
- return proto.EnumName(RangeRequest_SortOrder_name, int32(x))
-}
-func (RangeRequest_SortOrder) EnumDescriptor() ([]byte, []int) { return fileDescriptorRpc, []int{1, 0} }
-
-type RangeRequest_SortTarget int32
-
-const (
- RangeRequest_KEY RangeRequest_SortTarget = 0
- RangeRequest_VERSION RangeRequest_SortTarget = 1
- RangeRequest_CREATE RangeRequest_SortTarget = 2
- RangeRequest_MOD RangeRequest_SortTarget = 3
- RangeRequest_VALUE RangeRequest_SortTarget = 4
-)
-
-var RangeRequest_SortTarget_name = map[int32]string{
- 0: "KEY",
- 1: "VERSION",
- 2: "CREATE",
- 3: "MOD",
- 4: "VALUE",
-}
-var RangeRequest_SortTarget_value = map[string]int32{
- "KEY": 0,
- "VERSION": 1,
- "CREATE": 2,
- "MOD": 3,
- "VALUE": 4,
-}
-
-func (x RangeRequest_SortTarget) String() string {
- return proto.EnumName(RangeRequest_SortTarget_name, int32(x))
-}
-func (RangeRequest_SortTarget) EnumDescriptor() ([]byte, []int) { return fileDescriptorRpc, []int{1, 1} }
-
-type Compare_CompareResult int32
-
-const (
- Compare_EQUAL Compare_CompareResult = 0
- Compare_GREATER Compare_CompareResult = 1
- Compare_LESS Compare_CompareResult = 2
- Compare_NOT_EQUAL Compare_CompareResult = 3
-)
-
-var Compare_CompareResult_name = map[int32]string{
- 0: "EQUAL",
- 1: "GREATER",
- 2: "LESS",
- 3: "NOT_EQUAL",
-}
-var Compare_CompareResult_value = map[string]int32{
- "EQUAL": 0,
- "GREATER": 1,
- "LESS": 2,
- "NOT_EQUAL": 3,
-}
-
-func (x Compare_CompareResult) String() string {
- return proto.EnumName(Compare_CompareResult_name, int32(x))
-}
-func (Compare_CompareResult) EnumDescriptor() ([]byte, []int) { return fileDescriptorRpc, []int{9, 0} }
-
-type Compare_CompareTarget int32
-
-const (
- Compare_VERSION Compare_CompareTarget = 0
- Compare_CREATE Compare_CompareTarget = 1
- Compare_MOD Compare_CompareTarget = 2
- Compare_VALUE Compare_CompareTarget = 3
- Compare_LEASE Compare_CompareTarget = 4
-)
-
-var Compare_CompareTarget_name = map[int32]string{
- 0: "VERSION",
- 1: "CREATE",
- 2: "MOD",
- 3: "VALUE",
- 4: "LEASE",
-}
-var Compare_CompareTarget_value = map[string]int32{
- "VERSION": 0,
- "CREATE": 1,
- "MOD": 2,
- "VALUE": 3,
- "LEASE": 4,
-}
-
-func (x Compare_CompareTarget) String() string {
- return proto.EnumName(Compare_CompareTarget_name, int32(x))
-}
-func (Compare_CompareTarget) EnumDescriptor() ([]byte, []int) { return fileDescriptorRpc, []int{9, 1} }
-
-type WatchCreateRequest_FilterType int32
-
-const (
- // filter out put event.
- WatchCreateRequest_NOPUT WatchCreateRequest_FilterType = 0
- // filter out delete event.
- WatchCreateRequest_NODELETE WatchCreateRequest_FilterType = 1
-)
-
-var WatchCreateRequest_FilterType_name = map[int32]string{
- 0: "NOPUT",
- 1: "NODELETE",
-}
-var WatchCreateRequest_FilterType_value = map[string]int32{
- "NOPUT": 0,
- "NODELETE": 1,
-}
-
-func (x WatchCreateRequest_FilterType) String() string {
- return proto.EnumName(WatchCreateRequest_FilterType_name, int32(x))
-}
-func (WatchCreateRequest_FilterType) EnumDescriptor() ([]byte, []int) {
- return fileDescriptorRpc, []int{21, 0}
-}
-
-type AlarmRequest_AlarmAction int32
-
-const (
- AlarmRequest_GET AlarmRequest_AlarmAction = 0
- AlarmRequest_ACTIVATE AlarmRequest_AlarmAction = 1
- AlarmRequest_DEACTIVATE AlarmRequest_AlarmAction = 2
-)
-
-var AlarmRequest_AlarmAction_name = map[int32]string{
- 0: "GET",
- 1: "ACTIVATE",
- 2: "DEACTIVATE",
-}
-var AlarmRequest_AlarmAction_value = map[string]int32{
- "GET": 0,
- "ACTIVATE": 1,
- "DEACTIVATE": 2,
-}
-
-func (x AlarmRequest_AlarmAction) String() string {
- return proto.EnumName(AlarmRequest_AlarmAction_name, int32(x))
-}
-func (AlarmRequest_AlarmAction) EnumDescriptor() ([]byte, []int) {
- return fileDescriptorRpc, []int{54, 0}
-}
-
-type ResponseHeader struct {
- // cluster_id is the ID of the cluster which sent the response.
- ClusterId uint64 `protobuf:"varint,1,opt,name=cluster_id,json=clusterId,proto3" json:"cluster_id,omitempty"`
- // member_id is the ID of the member which sent the response.
- MemberId uint64 `protobuf:"varint,2,opt,name=member_id,json=memberId,proto3" json:"member_id,omitempty"`
- // revision is the key-value store revision when the request was applied.
- // For watch progress responses, the header.revision indicates progress. All future events
- // recieved in this stream are guaranteed to have a higher revision number than the
- // header.revision number.
- Revision int64 `protobuf:"varint,3,opt,name=revision,proto3" json:"revision,omitempty"`
- // raft_term is the raft term when the request was applied.
- RaftTerm uint64 `protobuf:"varint,4,opt,name=raft_term,json=raftTerm,proto3" json:"raft_term,omitempty"`
-}
-
-func (m *ResponseHeader) Reset() { *m = ResponseHeader{} }
-func (m *ResponseHeader) String() string { return proto.CompactTextString(m) }
-func (*ResponseHeader) ProtoMessage() {}
-func (*ResponseHeader) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{0} }
-
-func (m *ResponseHeader) GetClusterId() uint64 {
- if m != nil {
- return m.ClusterId
- }
- return 0
-}
-
-func (m *ResponseHeader) GetMemberId() uint64 {
- if m != nil {
- return m.MemberId
- }
- return 0
-}
-
-func (m *ResponseHeader) GetRevision() int64 {
- if m != nil {
- return m.Revision
- }
- return 0
-}
-
-func (m *ResponseHeader) GetRaftTerm() uint64 {
- if m != nil {
- return m.RaftTerm
- }
- return 0
-}
-
-type RangeRequest struct {
- // key is the first key for the range. If range_end is not given, the request only looks up key.
- Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
- // range_end is the upper bound on the requested range [key, range_end).
- // If range_end is '\0', the range is all keys >= key.
- // If range_end is key plus one (e.g., "aa"+1 == "ab", "a\xff"+1 == "b"),
- // then the range request gets all keys prefixed with key.
- // If both key and range_end are '\0', then the range request returns all keys.
- RangeEnd []byte `protobuf:"bytes,2,opt,name=range_end,json=rangeEnd,proto3" json:"range_end,omitempty"`
- // limit is a limit on the number of keys returned for the request. When limit is set to 0,
- // it is treated as no limit.
- Limit int64 `protobuf:"varint,3,opt,name=limit,proto3" json:"limit,omitempty"`
- // revision is the point-in-time of the key-value store to use for the range.
- // If revision is less or equal to zero, the range is over the newest key-value store.
- // If the revision has been compacted, ErrCompacted is returned as a response.
- Revision int64 `protobuf:"varint,4,opt,name=revision,proto3" json:"revision,omitempty"`
- // sort_order is the order for returned sorted results.
- SortOrder RangeRequest_SortOrder `protobuf:"varint,5,opt,name=sort_order,json=sortOrder,proto3,enum=etcdserverpb.RangeRequest_SortOrder" json:"sort_order,omitempty"`
- // sort_target is the key-value field to use for sorting.
- SortTarget RangeRequest_SortTarget `protobuf:"varint,6,opt,name=sort_target,json=sortTarget,proto3,enum=etcdserverpb.RangeRequest_SortTarget" json:"sort_target,omitempty"`
- // serializable sets the range request to use serializable member-local reads.
- // Range requests are linearizable by default; linearizable requests have higher
- // latency and lower throughput than serializable requests but reflect the current
- // consensus of the cluster. For better performance, in exchange for possible stale reads,
- // a serializable range request is served locally without needing to reach consensus
- // with other nodes in the cluster.
- Serializable bool `protobuf:"varint,7,opt,name=serializable,proto3" json:"serializable,omitempty"`
- // keys_only when set returns only the keys and not the values.
- KeysOnly bool `protobuf:"varint,8,opt,name=keys_only,json=keysOnly,proto3" json:"keys_only,omitempty"`
- // count_only when set returns only the count of the keys in the range.
- CountOnly bool `protobuf:"varint,9,opt,name=count_only,json=countOnly,proto3" json:"count_only,omitempty"`
- // min_mod_revision is the lower bound for returned key mod revisions; all keys with
- // lesser mod revisions will be filtered away.
- MinModRevision int64 `protobuf:"varint,10,opt,name=min_mod_revision,json=minModRevision,proto3" json:"min_mod_revision,omitempty"`
- // max_mod_revision is the upper bound for returned key mod revisions; all keys with
- // greater mod revisions will be filtered away.
- MaxModRevision int64 `protobuf:"varint,11,opt,name=max_mod_revision,json=maxModRevision,proto3" json:"max_mod_revision,omitempty"`
- // min_create_revision is the lower bound for returned key create revisions; all keys with
- // lesser create revisions will be filtered away.
- MinCreateRevision int64 `protobuf:"varint,12,opt,name=min_create_revision,json=minCreateRevision,proto3" json:"min_create_revision,omitempty"`
- // max_create_revision is the upper bound for returned key create revisions; all keys with
- // greater create revisions will be filtered away.
- MaxCreateRevision int64 `protobuf:"varint,13,opt,name=max_create_revision,json=maxCreateRevision,proto3" json:"max_create_revision,omitempty"`
-}
-
-func (m *RangeRequest) Reset() { *m = RangeRequest{} }
-func (m *RangeRequest) String() string { return proto.CompactTextString(m) }
-func (*RangeRequest) ProtoMessage() {}
-func (*RangeRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{1} }
-
-func (m *RangeRequest) GetKey() []byte {
- if m != nil {
- return m.Key
- }
- return nil
-}
-
-func (m *RangeRequest) GetRangeEnd() []byte {
- if m != nil {
- return m.RangeEnd
- }
- return nil
-}
-
-func (m *RangeRequest) GetLimit() int64 {
- if m != nil {
- return m.Limit
- }
- return 0
-}
-
-func (m *RangeRequest) GetRevision() int64 {
- if m != nil {
- return m.Revision
- }
- return 0
-}
-
-func (m *RangeRequest) GetSortOrder() RangeRequest_SortOrder {
- if m != nil {
- return m.SortOrder
- }
- return RangeRequest_NONE
-}
-
-func (m *RangeRequest) GetSortTarget() RangeRequest_SortTarget {
- if m != nil {
- return m.SortTarget
- }
- return RangeRequest_KEY
-}
-
-func (m *RangeRequest) GetSerializable() bool {
- if m != nil {
- return m.Serializable
- }
- return false
-}
-
-func (m *RangeRequest) GetKeysOnly() bool {
- if m != nil {
- return m.KeysOnly
- }
- return false
-}
-
-func (m *RangeRequest) GetCountOnly() bool {
- if m != nil {
- return m.CountOnly
- }
- return false
-}
-
-func (m *RangeRequest) GetMinModRevision() int64 {
- if m != nil {
- return m.MinModRevision
- }
- return 0
-}
-
-func (m *RangeRequest) GetMaxModRevision() int64 {
- if m != nil {
- return m.MaxModRevision
- }
- return 0
-}
-
-func (m *RangeRequest) GetMinCreateRevision() int64 {
- if m != nil {
- return m.MinCreateRevision
- }
- return 0
-}
-
-func (m *RangeRequest) GetMaxCreateRevision() int64 {
- if m != nil {
- return m.MaxCreateRevision
- }
- return 0
-}
-
-type RangeResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
- // kvs is the list of key-value pairs matched by the range request.
- // kvs is empty when count is requested.
- Kvs []*mvccpb.KeyValue `protobuf:"bytes,2,rep,name=kvs" json:"kvs,omitempty"`
- // more indicates if there are more keys to return in the requested range.
- More bool `protobuf:"varint,3,opt,name=more,proto3" json:"more,omitempty"`
- // count is set to the number of keys within the range when requested.
- Count int64 `protobuf:"varint,4,opt,name=count,proto3" json:"count,omitempty"`
-}
-
-func (m *RangeResponse) Reset() { *m = RangeResponse{} }
-func (m *RangeResponse) String() string { return proto.CompactTextString(m) }
-func (*RangeResponse) ProtoMessage() {}
-func (*RangeResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{2} }
-
-func (m *RangeResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-func (m *RangeResponse) GetKvs() []*mvccpb.KeyValue {
- if m != nil {
- return m.Kvs
- }
- return nil
-}
-
-func (m *RangeResponse) GetMore() bool {
- if m != nil {
- return m.More
- }
- return false
-}
-
-func (m *RangeResponse) GetCount() int64 {
- if m != nil {
- return m.Count
- }
- return 0
-}
-
-type PutRequest struct {
- // key is the key, in bytes, to put into the key-value store.
- Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
- // value is the value, in bytes, to associate with the key in the key-value store.
- Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
- // lease is the lease ID to associate with the key in the key-value store. A lease
- // value of 0 indicates no lease.
- Lease int64 `protobuf:"varint,3,opt,name=lease,proto3" json:"lease,omitempty"`
- // If prev_kv is set, etcd gets the previous key-value pair before changing it.
- // The previous key-value pair will be returned in the put response.
- PrevKv bool `protobuf:"varint,4,opt,name=prev_kv,json=prevKv,proto3" json:"prev_kv,omitempty"`
- // If ignore_value is set, etcd updates the key using its current value.
- // Returns an error if the key does not exist.
- IgnoreValue bool `protobuf:"varint,5,opt,name=ignore_value,json=ignoreValue,proto3" json:"ignore_value,omitempty"`
- // If ignore_lease is set, etcd updates the key using its current lease.
- // Returns an error if the key does not exist.
- IgnoreLease bool `protobuf:"varint,6,opt,name=ignore_lease,json=ignoreLease,proto3" json:"ignore_lease,omitempty"`
-}
-
-func (m *PutRequest) Reset() { *m = PutRequest{} }
-func (m *PutRequest) String() string { return proto.CompactTextString(m) }
-func (*PutRequest) ProtoMessage() {}
-func (*PutRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{3} }
-
-func (m *PutRequest) GetKey() []byte {
- if m != nil {
- return m.Key
- }
- return nil
-}
-
-func (m *PutRequest) GetValue() []byte {
- if m != nil {
- return m.Value
- }
- return nil
-}
-
-func (m *PutRequest) GetLease() int64 {
- if m != nil {
- return m.Lease
- }
- return 0
-}
-
-func (m *PutRequest) GetPrevKv() bool {
- if m != nil {
- return m.PrevKv
- }
- return false
-}
-
-func (m *PutRequest) GetIgnoreValue() bool {
- if m != nil {
- return m.IgnoreValue
- }
- return false
-}
-
-func (m *PutRequest) GetIgnoreLease() bool {
- if m != nil {
- return m.IgnoreLease
- }
- return false
-}
-
-type PutResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
- // if prev_kv is set in the request, the previous key-value pair will be returned.
- PrevKv *mvccpb.KeyValue `protobuf:"bytes,2,opt,name=prev_kv,json=prevKv" json:"prev_kv,omitempty"`
-}
-
-func (m *PutResponse) Reset() { *m = PutResponse{} }
-func (m *PutResponse) String() string { return proto.CompactTextString(m) }
-func (*PutResponse) ProtoMessage() {}
-func (*PutResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{4} }
-
-func (m *PutResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-func (m *PutResponse) GetPrevKv() *mvccpb.KeyValue {
- if m != nil {
- return m.PrevKv
- }
- return nil
-}
-
-type DeleteRangeRequest struct {
- // key is the first key to delete in the range.
- Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
- // range_end is the key following the last key to delete for the range [key, range_end).
- // If range_end is not given, the range is defined to contain only the key argument.
- // If range_end is one bit larger than the given key, then the range is all the keys
- // with the prefix (the given key).
- // If range_end is '\0', the range is all keys greater than or equal to the key argument.
- RangeEnd []byte `protobuf:"bytes,2,opt,name=range_end,json=rangeEnd,proto3" json:"range_end,omitempty"`
- // If prev_kv is set, etcd gets the previous key-value pairs before deleting it.
- // The previous key-value pairs will be returned in the delete response.
- PrevKv bool `protobuf:"varint,3,opt,name=prev_kv,json=prevKv,proto3" json:"prev_kv,omitempty"`
-}
-
-func (m *DeleteRangeRequest) Reset() { *m = DeleteRangeRequest{} }
-func (m *DeleteRangeRequest) String() string { return proto.CompactTextString(m) }
-func (*DeleteRangeRequest) ProtoMessage() {}
-func (*DeleteRangeRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{5} }
-
-func (m *DeleteRangeRequest) GetKey() []byte {
- if m != nil {
- return m.Key
- }
- return nil
-}
-
-func (m *DeleteRangeRequest) GetRangeEnd() []byte {
- if m != nil {
- return m.RangeEnd
- }
- return nil
-}
-
-func (m *DeleteRangeRequest) GetPrevKv() bool {
- if m != nil {
- return m.PrevKv
- }
- return false
-}
-
-type DeleteRangeResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
- // deleted is the number of keys deleted by the delete range request.
- Deleted int64 `protobuf:"varint,2,opt,name=deleted,proto3" json:"deleted,omitempty"`
- // if prev_kv is set in the request, the previous key-value pairs will be returned.
- PrevKvs []*mvccpb.KeyValue `protobuf:"bytes,3,rep,name=prev_kvs,json=prevKvs" json:"prev_kvs,omitempty"`
-}
-
-func (m *DeleteRangeResponse) Reset() { *m = DeleteRangeResponse{} }
-func (m *DeleteRangeResponse) String() string { return proto.CompactTextString(m) }
-func (*DeleteRangeResponse) ProtoMessage() {}
-func (*DeleteRangeResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{6} }
-
-func (m *DeleteRangeResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-func (m *DeleteRangeResponse) GetDeleted() int64 {
- if m != nil {
- return m.Deleted
- }
- return 0
-}
-
-func (m *DeleteRangeResponse) GetPrevKvs() []*mvccpb.KeyValue {
- if m != nil {
- return m.PrevKvs
- }
- return nil
-}
-
-type RequestOp struct {
- // request is a union of request types accepted by a transaction.
- //
- // Types that are valid to be assigned to Request:
- // *RequestOp_RequestRange
- // *RequestOp_RequestPut
- // *RequestOp_RequestDeleteRange
- // *RequestOp_RequestTxn
- Request isRequestOp_Request `protobuf_oneof:"request"`
-}
-
-func (m *RequestOp) Reset() { *m = RequestOp{} }
-func (m *RequestOp) String() string { return proto.CompactTextString(m) }
-func (*RequestOp) ProtoMessage() {}
-func (*RequestOp) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{7} }
-
-type isRequestOp_Request interface {
- isRequestOp_Request()
- MarshalTo([]byte) (int, error)
- Size() int
-}
-
-type RequestOp_RequestRange struct {
- RequestRange *RangeRequest `protobuf:"bytes,1,opt,name=request_range,json=requestRange,oneof"`
-}
-type RequestOp_RequestPut struct {
- RequestPut *PutRequest `protobuf:"bytes,2,opt,name=request_put,json=requestPut,oneof"`
-}
-type RequestOp_RequestDeleteRange struct {
- RequestDeleteRange *DeleteRangeRequest `protobuf:"bytes,3,opt,name=request_delete_range,json=requestDeleteRange,oneof"`
-}
-type RequestOp_RequestTxn struct {
- RequestTxn *TxnRequest `protobuf:"bytes,4,opt,name=request_txn,json=requestTxn,oneof"`
-}
-
-func (*RequestOp_RequestRange) isRequestOp_Request() {}
-func (*RequestOp_RequestPut) isRequestOp_Request() {}
-func (*RequestOp_RequestDeleteRange) isRequestOp_Request() {}
-func (*RequestOp_RequestTxn) isRequestOp_Request() {}
-
-func (m *RequestOp) GetRequest() isRequestOp_Request {
- if m != nil {
- return m.Request
- }
- return nil
-}
-
-func (m *RequestOp) GetRequestRange() *RangeRequest {
- if x, ok := m.GetRequest().(*RequestOp_RequestRange); ok {
- return x.RequestRange
- }
- return nil
-}
-
-func (m *RequestOp) GetRequestPut() *PutRequest {
- if x, ok := m.GetRequest().(*RequestOp_RequestPut); ok {
- return x.RequestPut
- }
- return nil
-}
-
-func (m *RequestOp) GetRequestDeleteRange() *DeleteRangeRequest {
- if x, ok := m.GetRequest().(*RequestOp_RequestDeleteRange); ok {
- return x.RequestDeleteRange
- }
- return nil
-}
-
-func (m *RequestOp) GetRequestTxn() *TxnRequest {
- if x, ok := m.GetRequest().(*RequestOp_RequestTxn); ok {
- return x.RequestTxn
- }
- return nil
-}
-
-// XXX_OneofFuncs is for the internal use of the proto package.
-func (*RequestOp) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) {
- return _RequestOp_OneofMarshaler, _RequestOp_OneofUnmarshaler, _RequestOp_OneofSizer, []interface{}{
- (*RequestOp_RequestRange)(nil),
- (*RequestOp_RequestPut)(nil),
- (*RequestOp_RequestDeleteRange)(nil),
- (*RequestOp_RequestTxn)(nil),
- }
-}
-
-func _RequestOp_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
- m := msg.(*RequestOp)
- // request
- switch x := m.Request.(type) {
- case *RequestOp_RequestRange:
- _ = b.EncodeVarint(1<<3 | proto.WireBytes)
- if err := b.EncodeMessage(x.RequestRange); err != nil {
- return err
- }
- case *RequestOp_RequestPut:
- _ = b.EncodeVarint(2<<3 | proto.WireBytes)
- if err := b.EncodeMessage(x.RequestPut); err != nil {
- return err
- }
- case *RequestOp_RequestDeleteRange:
- _ = b.EncodeVarint(3<<3 | proto.WireBytes)
- if err := b.EncodeMessage(x.RequestDeleteRange); err != nil {
- return err
- }
- case *RequestOp_RequestTxn:
- _ = b.EncodeVarint(4<<3 | proto.WireBytes)
- if err := b.EncodeMessage(x.RequestTxn); err != nil {
- return err
- }
- case nil:
- default:
- return fmt.Errorf("RequestOp.Request has unexpected type %T", x)
- }
- return nil
-}
-
-func _RequestOp_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
- m := msg.(*RequestOp)
- switch tag {
- case 1: // request.request_range
- if wire != proto.WireBytes {
- return true, proto.ErrInternalBadWireType
- }
- msg := new(RangeRequest)
- err := b.DecodeMessage(msg)
- m.Request = &RequestOp_RequestRange{msg}
- return true, err
- case 2: // request.request_put
- if wire != proto.WireBytes {
- return true, proto.ErrInternalBadWireType
- }
- msg := new(PutRequest)
- err := b.DecodeMessage(msg)
- m.Request = &RequestOp_RequestPut{msg}
- return true, err
- case 3: // request.request_delete_range
- if wire != proto.WireBytes {
- return true, proto.ErrInternalBadWireType
- }
- msg := new(DeleteRangeRequest)
- err := b.DecodeMessage(msg)
- m.Request = &RequestOp_RequestDeleteRange{msg}
- return true, err
- case 4: // request.request_txn
- if wire != proto.WireBytes {
- return true, proto.ErrInternalBadWireType
- }
- msg := new(TxnRequest)
- err := b.DecodeMessage(msg)
- m.Request = &RequestOp_RequestTxn{msg}
- return true, err
- default:
- return false, nil
- }
-}
-
-func _RequestOp_OneofSizer(msg proto.Message) (n int) {
- m := msg.(*RequestOp)
- // request
- switch x := m.Request.(type) {
- case *RequestOp_RequestRange:
- s := proto.Size(x.RequestRange)
- n += proto.SizeVarint(1<<3 | proto.WireBytes)
- n += proto.SizeVarint(uint64(s))
- n += s
- case *RequestOp_RequestPut:
- s := proto.Size(x.RequestPut)
- n += proto.SizeVarint(2<<3 | proto.WireBytes)
- n += proto.SizeVarint(uint64(s))
- n += s
- case *RequestOp_RequestDeleteRange:
- s := proto.Size(x.RequestDeleteRange)
- n += proto.SizeVarint(3<<3 | proto.WireBytes)
- n += proto.SizeVarint(uint64(s))
- n += s
- case *RequestOp_RequestTxn:
- s := proto.Size(x.RequestTxn)
- n += proto.SizeVarint(4<<3 | proto.WireBytes)
- n += proto.SizeVarint(uint64(s))
- n += s
- case nil:
- default:
- panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
- }
- return n
-}
-
-type ResponseOp struct {
- // response is a union of response types returned by a transaction.
- //
- // Types that are valid to be assigned to Response:
- // *ResponseOp_ResponseRange
- // *ResponseOp_ResponsePut
- // *ResponseOp_ResponseDeleteRange
- // *ResponseOp_ResponseTxn
- Response isResponseOp_Response `protobuf_oneof:"response"`
-}
-
-func (m *ResponseOp) Reset() { *m = ResponseOp{} }
-func (m *ResponseOp) String() string { return proto.CompactTextString(m) }
-func (*ResponseOp) ProtoMessage() {}
-func (*ResponseOp) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{8} }
-
-type isResponseOp_Response interface {
- isResponseOp_Response()
- MarshalTo([]byte) (int, error)
- Size() int
-}
-
-type ResponseOp_ResponseRange struct {
- ResponseRange *RangeResponse `protobuf:"bytes,1,opt,name=response_range,json=responseRange,oneof"`
-}
-type ResponseOp_ResponsePut struct {
- ResponsePut *PutResponse `protobuf:"bytes,2,opt,name=response_put,json=responsePut,oneof"`
-}
-type ResponseOp_ResponseDeleteRange struct {
- ResponseDeleteRange *DeleteRangeResponse `protobuf:"bytes,3,opt,name=response_delete_range,json=responseDeleteRange,oneof"`
-}
-type ResponseOp_ResponseTxn struct {
- ResponseTxn *TxnResponse `protobuf:"bytes,4,opt,name=response_txn,json=responseTxn,oneof"`
-}
-
-func (*ResponseOp_ResponseRange) isResponseOp_Response() {}
-func (*ResponseOp_ResponsePut) isResponseOp_Response() {}
-func (*ResponseOp_ResponseDeleteRange) isResponseOp_Response() {}
-func (*ResponseOp_ResponseTxn) isResponseOp_Response() {}
-
-func (m *ResponseOp) GetResponse() isResponseOp_Response {
- if m != nil {
- return m.Response
- }
- return nil
-}
-
-func (m *ResponseOp) GetResponseRange() *RangeResponse {
- if x, ok := m.GetResponse().(*ResponseOp_ResponseRange); ok {
- return x.ResponseRange
- }
- return nil
-}
-
-func (m *ResponseOp) GetResponsePut() *PutResponse {
- if x, ok := m.GetResponse().(*ResponseOp_ResponsePut); ok {
- return x.ResponsePut
- }
- return nil
-}
-
-func (m *ResponseOp) GetResponseDeleteRange() *DeleteRangeResponse {
- if x, ok := m.GetResponse().(*ResponseOp_ResponseDeleteRange); ok {
- return x.ResponseDeleteRange
- }
- return nil
-}
-
-func (m *ResponseOp) GetResponseTxn() *TxnResponse {
- if x, ok := m.GetResponse().(*ResponseOp_ResponseTxn); ok {
- return x.ResponseTxn
- }
- return nil
-}
-
-// XXX_OneofFuncs is for the internal use of the proto package.
-func (*ResponseOp) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) {
- return _ResponseOp_OneofMarshaler, _ResponseOp_OneofUnmarshaler, _ResponseOp_OneofSizer, []interface{}{
- (*ResponseOp_ResponseRange)(nil),
- (*ResponseOp_ResponsePut)(nil),
- (*ResponseOp_ResponseDeleteRange)(nil),
- (*ResponseOp_ResponseTxn)(nil),
- }
-}
-
-func _ResponseOp_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
- m := msg.(*ResponseOp)
- // response
- switch x := m.Response.(type) {
- case *ResponseOp_ResponseRange:
- _ = b.EncodeVarint(1<<3 | proto.WireBytes)
- if err := b.EncodeMessage(x.ResponseRange); err != nil {
- return err
- }
- case *ResponseOp_ResponsePut:
- _ = b.EncodeVarint(2<<3 | proto.WireBytes)
- if err := b.EncodeMessage(x.ResponsePut); err != nil {
- return err
- }
- case *ResponseOp_ResponseDeleteRange:
- _ = b.EncodeVarint(3<<3 | proto.WireBytes)
- if err := b.EncodeMessage(x.ResponseDeleteRange); err != nil {
- return err
- }
- case *ResponseOp_ResponseTxn:
- _ = b.EncodeVarint(4<<3 | proto.WireBytes)
- if err := b.EncodeMessage(x.ResponseTxn); err != nil {
- return err
- }
- case nil:
- default:
- return fmt.Errorf("ResponseOp.Response has unexpected type %T", x)
- }
- return nil
-}
-
-func _ResponseOp_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
- m := msg.(*ResponseOp)
- switch tag {
- case 1: // response.response_range
- if wire != proto.WireBytes {
- return true, proto.ErrInternalBadWireType
- }
- msg := new(RangeResponse)
- err := b.DecodeMessage(msg)
- m.Response = &ResponseOp_ResponseRange{msg}
- return true, err
- case 2: // response.response_put
- if wire != proto.WireBytes {
- return true, proto.ErrInternalBadWireType
- }
- msg := new(PutResponse)
- err := b.DecodeMessage(msg)
- m.Response = &ResponseOp_ResponsePut{msg}
- return true, err
- case 3: // response.response_delete_range
- if wire != proto.WireBytes {
- return true, proto.ErrInternalBadWireType
- }
- msg := new(DeleteRangeResponse)
- err := b.DecodeMessage(msg)
- m.Response = &ResponseOp_ResponseDeleteRange{msg}
- return true, err
- case 4: // response.response_txn
- if wire != proto.WireBytes {
- return true, proto.ErrInternalBadWireType
- }
- msg := new(TxnResponse)
- err := b.DecodeMessage(msg)
- m.Response = &ResponseOp_ResponseTxn{msg}
- return true, err
- default:
- return false, nil
- }
-}
-
-func _ResponseOp_OneofSizer(msg proto.Message) (n int) {
- m := msg.(*ResponseOp)
- // response
- switch x := m.Response.(type) {
- case *ResponseOp_ResponseRange:
- s := proto.Size(x.ResponseRange)
- n += proto.SizeVarint(1<<3 | proto.WireBytes)
- n += proto.SizeVarint(uint64(s))
- n += s
- case *ResponseOp_ResponsePut:
- s := proto.Size(x.ResponsePut)
- n += proto.SizeVarint(2<<3 | proto.WireBytes)
- n += proto.SizeVarint(uint64(s))
- n += s
- case *ResponseOp_ResponseDeleteRange:
- s := proto.Size(x.ResponseDeleteRange)
- n += proto.SizeVarint(3<<3 | proto.WireBytes)
- n += proto.SizeVarint(uint64(s))
- n += s
- case *ResponseOp_ResponseTxn:
- s := proto.Size(x.ResponseTxn)
- n += proto.SizeVarint(4<<3 | proto.WireBytes)
- n += proto.SizeVarint(uint64(s))
- n += s
- case nil:
- default:
- panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
- }
- return n
-}
-
-type Compare struct {
- // result is logical comparison operation for this comparison.
- Result Compare_CompareResult `protobuf:"varint,1,opt,name=result,proto3,enum=etcdserverpb.Compare_CompareResult" json:"result,omitempty"`
- // target is the key-value field to inspect for the comparison.
- Target Compare_CompareTarget `protobuf:"varint,2,opt,name=target,proto3,enum=etcdserverpb.Compare_CompareTarget" json:"target,omitempty"`
- // key is the subject key for the comparison operation.
- Key []byte `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"`
- // Types that are valid to be assigned to TargetUnion:
- // *Compare_Version
- // *Compare_CreateRevision
- // *Compare_ModRevision
- // *Compare_Value
- // *Compare_Lease
- TargetUnion isCompare_TargetUnion `protobuf_oneof:"target_union"`
- // range_end compares the given target to all keys in the range [key, range_end).
- // See RangeRequest for more details on key ranges.
- RangeEnd []byte `protobuf:"bytes,64,opt,name=range_end,json=rangeEnd,proto3" json:"range_end,omitempty"`
-}
-
-func (m *Compare) Reset() { *m = Compare{} }
-func (m *Compare) String() string { return proto.CompactTextString(m) }
-func (*Compare) ProtoMessage() {}
-func (*Compare) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{9} }
-
-type isCompare_TargetUnion interface {
- isCompare_TargetUnion()
- MarshalTo([]byte) (int, error)
- Size() int
-}
-
-type Compare_Version struct {
- Version int64 `protobuf:"varint,4,opt,name=version,proto3,oneof"`
-}
-type Compare_CreateRevision struct {
- CreateRevision int64 `protobuf:"varint,5,opt,name=create_revision,json=createRevision,proto3,oneof"`
-}
-type Compare_ModRevision struct {
- ModRevision int64 `protobuf:"varint,6,opt,name=mod_revision,json=modRevision,proto3,oneof"`
-}
-type Compare_Value struct {
- Value []byte `protobuf:"bytes,7,opt,name=value,proto3,oneof"`
-}
-type Compare_Lease struct {
- Lease int64 `protobuf:"varint,8,opt,name=lease,proto3,oneof"`
-}
-
-func (*Compare_Version) isCompare_TargetUnion() {}
-func (*Compare_CreateRevision) isCompare_TargetUnion() {}
-func (*Compare_ModRevision) isCompare_TargetUnion() {}
-func (*Compare_Value) isCompare_TargetUnion() {}
-func (*Compare_Lease) isCompare_TargetUnion() {}
-
-func (m *Compare) GetTargetUnion() isCompare_TargetUnion {
- if m != nil {
- return m.TargetUnion
- }
- return nil
-}
-
-func (m *Compare) GetResult() Compare_CompareResult {
- if m != nil {
- return m.Result
- }
- return Compare_EQUAL
-}
-
-func (m *Compare) GetTarget() Compare_CompareTarget {
- if m != nil {
- return m.Target
- }
- return Compare_VERSION
-}
-
-func (m *Compare) GetKey() []byte {
- if m != nil {
- return m.Key
- }
- return nil
-}
-
-func (m *Compare) GetVersion() int64 {
- if x, ok := m.GetTargetUnion().(*Compare_Version); ok {
- return x.Version
- }
- return 0
-}
-
-func (m *Compare) GetCreateRevision() int64 {
- if x, ok := m.GetTargetUnion().(*Compare_CreateRevision); ok {
- return x.CreateRevision
- }
- return 0
-}
-
-func (m *Compare) GetModRevision() int64 {
- if x, ok := m.GetTargetUnion().(*Compare_ModRevision); ok {
- return x.ModRevision
- }
- return 0
-}
-
-func (m *Compare) GetValue() []byte {
- if x, ok := m.GetTargetUnion().(*Compare_Value); ok {
- return x.Value
- }
- return nil
-}
-
-func (m *Compare) GetLease() int64 {
- if x, ok := m.GetTargetUnion().(*Compare_Lease); ok {
- return x.Lease
- }
- return 0
-}
-
-func (m *Compare) GetRangeEnd() []byte {
- if m != nil {
- return m.RangeEnd
- }
- return nil
-}
-
-// XXX_OneofFuncs is for the internal use of the proto package.
-func (*Compare) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) {
- return _Compare_OneofMarshaler, _Compare_OneofUnmarshaler, _Compare_OneofSizer, []interface{}{
- (*Compare_Version)(nil),
- (*Compare_CreateRevision)(nil),
- (*Compare_ModRevision)(nil),
- (*Compare_Value)(nil),
- (*Compare_Lease)(nil),
- }
-}
-
-func _Compare_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
- m := msg.(*Compare)
- // target_union
- switch x := m.TargetUnion.(type) {
- case *Compare_Version:
- _ = b.EncodeVarint(4<<3 | proto.WireVarint)
- _ = b.EncodeVarint(uint64(x.Version))
- case *Compare_CreateRevision:
- _ = b.EncodeVarint(5<<3 | proto.WireVarint)
- _ = b.EncodeVarint(uint64(x.CreateRevision))
- case *Compare_ModRevision:
- _ = b.EncodeVarint(6<<3 | proto.WireVarint)
- _ = b.EncodeVarint(uint64(x.ModRevision))
- case *Compare_Value:
- _ = b.EncodeVarint(7<<3 | proto.WireBytes)
- _ = b.EncodeRawBytes(x.Value)
- case *Compare_Lease:
- _ = b.EncodeVarint(8<<3 | proto.WireVarint)
- _ = b.EncodeVarint(uint64(x.Lease))
- case nil:
- default:
- return fmt.Errorf("Compare.TargetUnion has unexpected type %T", x)
- }
- return nil
-}
-
-func _Compare_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
- m := msg.(*Compare)
- switch tag {
- case 4: // target_union.version
- if wire != proto.WireVarint {
- return true, proto.ErrInternalBadWireType
- }
- x, err := b.DecodeVarint()
- m.TargetUnion = &Compare_Version{int64(x)}
- return true, err
- case 5: // target_union.create_revision
- if wire != proto.WireVarint {
- return true, proto.ErrInternalBadWireType
- }
- x, err := b.DecodeVarint()
- m.TargetUnion = &Compare_CreateRevision{int64(x)}
- return true, err
- case 6: // target_union.mod_revision
- if wire != proto.WireVarint {
- return true, proto.ErrInternalBadWireType
- }
- x, err := b.DecodeVarint()
- m.TargetUnion = &Compare_ModRevision{int64(x)}
- return true, err
- case 7: // target_union.value
- if wire != proto.WireBytes {
- return true, proto.ErrInternalBadWireType
- }
- x, err := b.DecodeRawBytes(true)
- m.TargetUnion = &Compare_Value{x}
- return true, err
- case 8: // target_union.lease
- if wire != proto.WireVarint {
- return true, proto.ErrInternalBadWireType
- }
- x, err := b.DecodeVarint()
- m.TargetUnion = &Compare_Lease{int64(x)}
- return true, err
- default:
- return false, nil
- }
-}
-
-func _Compare_OneofSizer(msg proto.Message) (n int) {
- m := msg.(*Compare)
- // target_union
- switch x := m.TargetUnion.(type) {
- case *Compare_Version:
- n += proto.SizeVarint(4<<3 | proto.WireVarint)
- n += proto.SizeVarint(uint64(x.Version))
- case *Compare_CreateRevision:
- n += proto.SizeVarint(5<<3 | proto.WireVarint)
- n += proto.SizeVarint(uint64(x.CreateRevision))
- case *Compare_ModRevision:
- n += proto.SizeVarint(6<<3 | proto.WireVarint)
- n += proto.SizeVarint(uint64(x.ModRevision))
- case *Compare_Value:
- n += proto.SizeVarint(7<<3 | proto.WireBytes)
- n += proto.SizeVarint(uint64(len(x.Value)))
- n += len(x.Value)
- case *Compare_Lease:
- n += proto.SizeVarint(8<<3 | proto.WireVarint)
- n += proto.SizeVarint(uint64(x.Lease))
- case nil:
- default:
- panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
- }
- return n
-}
-
-// From google paxosdb paper:
-// Our implementation hinges around a powerful primitive which we call MultiOp. All other database
-// operations except for iteration are implemented as a single call to MultiOp. A MultiOp is applied atomically
-// and consists of three components:
-// 1. A list of tests called guard. Each test in guard checks a single entry in the database. It may check
-// for the absence or presence of a value, or compare with a given value. Two different tests in the guard
-// may apply to the same or different entries in the database. All tests in the guard are applied and
-// MultiOp returns the results. If all tests are true, MultiOp executes t op (see item 2 below), otherwise
-// it executes f op (see item 3 below).
-// 2. A list of database operations called t op. Each operation in the list is either an insert, delete, or
-// lookup operation, and applies to a single database entry. Two different operations in the list may apply
-// to the same or different entries in the database. These operations are executed
-// if guard evaluates to
-// true.
-// 3. A list of database operations called f op. Like t op, but executed if guard evaluates to false.
-type TxnRequest struct {
- // compare is a list of predicates representing a conjunction of terms.
- // If the comparisons succeed, then the success requests will be processed in order,
- // and the response will contain their respective responses in order.
- // If the comparisons fail, then the failure requests will be processed in order,
- // and the response will contain their respective responses in order.
- Compare []*Compare `protobuf:"bytes,1,rep,name=compare" json:"compare,omitempty"`
- // success is a list of requests which will be applied when compare evaluates to true.
- Success []*RequestOp `protobuf:"bytes,2,rep,name=success" json:"success,omitempty"`
- // failure is a list of requests which will be applied when compare evaluates to false.
- Failure []*RequestOp `protobuf:"bytes,3,rep,name=failure" json:"failure,omitempty"`
-}
-
-func (m *TxnRequest) Reset() { *m = TxnRequest{} }
-func (m *TxnRequest) String() string { return proto.CompactTextString(m) }
-func (*TxnRequest) ProtoMessage() {}
-func (*TxnRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{10} }
-
-func (m *TxnRequest) GetCompare() []*Compare {
- if m != nil {
- return m.Compare
- }
- return nil
-}
-
-func (m *TxnRequest) GetSuccess() []*RequestOp {
- if m != nil {
- return m.Success
- }
- return nil
-}
-
-func (m *TxnRequest) GetFailure() []*RequestOp {
- if m != nil {
- return m.Failure
- }
- return nil
-}
-
-type TxnResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
- // succeeded is set to true if the compare evaluated to true or false otherwise.
- Succeeded bool `protobuf:"varint,2,opt,name=succeeded,proto3" json:"succeeded,omitempty"`
- // responses is a list of responses corresponding to the results from applying
- // success if succeeded is true or failure if succeeded is false.
- Responses []*ResponseOp `protobuf:"bytes,3,rep,name=responses" json:"responses,omitempty"`
-}
-
-func (m *TxnResponse) Reset() { *m = TxnResponse{} }
-func (m *TxnResponse) String() string { return proto.CompactTextString(m) }
-func (*TxnResponse) ProtoMessage() {}
-func (*TxnResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{11} }
-
-func (m *TxnResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-func (m *TxnResponse) GetSucceeded() bool {
- if m != nil {
- return m.Succeeded
- }
- return false
-}
-
-func (m *TxnResponse) GetResponses() []*ResponseOp {
- if m != nil {
- return m.Responses
- }
- return nil
-}
-
-// CompactionRequest compacts the key-value store up to a given revision. All superseded keys
-// with a revision less than the compaction revision will be removed.
-type CompactionRequest struct {
- // revision is the key-value store revision for the compaction operation.
- Revision int64 `protobuf:"varint,1,opt,name=revision,proto3" json:"revision,omitempty"`
- // physical is set so the RPC will wait until the compaction is physically
- // applied to the local database such that compacted entries are totally
- // removed from the backend database.
- Physical bool `protobuf:"varint,2,opt,name=physical,proto3" json:"physical,omitempty"`
-}
-
-func (m *CompactionRequest) Reset() { *m = CompactionRequest{} }
-func (m *CompactionRequest) String() string { return proto.CompactTextString(m) }
-func (*CompactionRequest) ProtoMessage() {}
-func (*CompactionRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{12} }
-
-func (m *CompactionRequest) GetRevision() int64 {
- if m != nil {
- return m.Revision
- }
- return 0
-}
-
-func (m *CompactionRequest) GetPhysical() bool {
- if m != nil {
- return m.Physical
- }
- return false
-}
-
-type CompactionResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
-}
-
-func (m *CompactionResponse) Reset() { *m = CompactionResponse{} }
-func (m *CompactionResponse) String() string { return proto.CompactTextString(m) }
-func (*CompactionResponse) ProtoMessage() {}
-func (*CompactionResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{13} }
-
-func (m *CompactionResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-type HashRequest struct {
-}
-
-func (m *HashRequest) Reset() { *m = HashRequest{} }
-func (m *HashRequest) String() string { return proto.CompactTextString(m) }
-func (*HashRequest) ProtoMessage() {}
-func (*HashRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{14} }
-
-type HashKVRequest struct {
- // revision is the key-value store revision for the hash operation.
- Revision int64 `protobuf:"varint,1,opt,name=revision,proto3" json:"revision,omitempty"`
-}
-
-func (m *HashKVRequest) Reset() { *m = HashKVRequest{} }
-func (m *HashKVRequest) String() string { return proto.CompactTextString(m) }
-func (*HashKVRequest) ProtoMessage() {}
-func (*HashKVRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{15} }
-
-func (m *HashKVRequest) GetRevision() int64 {
- if m != nil {
- return m.Revision
- }
- return 0
-}
-
-type HashKVResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
- // hash is the hash value computed from the responding member's MVCC keys up to a given revision.
- Hash uint32 `protobuf:"varint,2,opt,name=hash,proto3" json:"hash,omitempty"`
- // compact_revision is the compacted revision of key-value store when hash begins.
- CompactRevision int64 `protobuf:"varint,3,opt,name=compact_revision,json=compactRevision,proto3" json:"compact_revision,omitempty"`
-}
-
-func (m *HashKVResponse) Reset() { *m = HashKVResponse{} }
-func (m *HashKVResponse) String() string { return proto.CompactTextString(m) }
-func (*HashKVResponse) ProtoMessage() {}
-func (*HashKVResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{16} }
-
-func (m *HashKVResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-func (m *HashKVResponse) GetHash() uint32 {
- if m != nil {
- return m.Hash
- }
- return 0
-}
-
-func (m *HashKVResponse) GetCompactRevision() int64 {
- if m != nil {
- return m.CompactRevision
- }
- return 0
-}
-
-type HashResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
- // hash is the hash value computed from the responding member's KV's backend.
- Hash uint32 `protobuf:"varint,2,opt,name=hash,proto3" json:"hash,omitempty"`
-}
-
-func (m *HashResponse) Reset() { *m = HashResponse{} }
-func (m *HashResponse) String() string { return proto.CompactTextString(m) }
-func (*HashResponse) ProtoMessage() {}
-func (*HashResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{17} }
-
-func (m *HashResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-func (m *HashResponse) GetHash() uint32 {
- if m != nil {
- return m.Hash
- }
- return 0
-}
-
-type SnapshotRequest struct {
-}
-
-func (m *SnapshotRequest) Reset() { *m = SnapshotRequest{} }
-func (m *SnapshotRequest) String() string { return proto.CompactTextString(m) }
-func (*SnapshotRequest) ProtoMessage() {}
-func (*SnapshotRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{18} }
-
-type SnapshotResponse struct {
- // header has the current key-value store information. The first header in the snapshot
- // stream indicates the point in time of the snapshot.
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
- // remaining_bytes is the number of blob bytes to be sent after this message
- RemainingBytes uint64 `protobuf:"varint,2,opt,name=remaining_bytes,json=remainingBytes,proto3" json:"remaining_bytes,omitempty"`
- // blob contains the next chunk of the snapshot in the snapshot stream.
- Blob []byte `protobuf:"bytes,3,opt,name=blob,proto3" json:"blob,omitempty"`
-}
-
-func (m *SnapshotResponse) Reset() { *m = SnapshotResponse{} }
-func (m *SnapshotResponse) String() string { return proto.CompactTextString(m) }
-func (*SnapshotResponse) ProtoMessage() {}
-func (*SnapshotResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{19} }
-
-func (m *SnapshotResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-func (m *SnapshotResponse) GetRemainingBytes() uint64 {
- if m != nil {
- return m.RemainingBytes
- }
- return 0
-}
-
-func (m *SnapshotResponse) GetBlob() []byte {
- if m != nil {
- return m.Blob
- }
- return nil
-}
-
-type WatchRequest struct {
- // request_union is a request to either create a new watcher or cancel an existing watcher.
- //
- // Types that are valid to be assigned to RequestUnion:
- // *WatchRequest_CreateRequest
- // *WatchRequest_CancelRequest
- // *WatchRequest_ProgressRequest
- RequestUnion isWatchRequest_RequestUnion `protobuf_oneof:"request_union"`
-}
-
-func (m *WatchRequest) Reset() { *m = WatchRequest{} }
-func (m *WatchRequest) String() string { return proto.CompactTextString(m) }
-func (*WatchRequest) ProtoMessage() {}
-func (*WatchRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{20} }
-
-type isWatchRequest_RequestUnion interface {
- isWatchRequest_RequestUnion()
- MarshalTo([]byte) (int, error)
- Size() int
-}
-
-type WatchRequest_CreateRequest struct {
- CreateRequest *WatchCreateRequest `protobuf:"bytes,1,opt,name=create_request,json=createRequest,oneof"`
-}
-type WatchRequest_CancelRequest struct {
- CancelRequest *WatchCancelRequest `protobuf:"bytes,2,opt,name=cancel_request,json=cancelRequest,oneof"`
-}
-type WatchRequest_ProgressRequest struct {
- ProgressRequest *WatchProgressRequest `protobuf:"bytes,3,opt,name=progress_request,json=progressRequest,oneof"`
-}
-
-func (*WatchRequest_CreateRequest) isWatchRequest_RequestUnion() {}
-func (*WatchRequest_CancelRequest) isWatchRequest_RequestUnion() {}
-func (*WatchRequest_ProgressRequest) isWatchRequest_RequestUnion() {}
-
-func (m *WatchRequest) GetRequestUnion() isWatchRequest_RequestUnion {
- if m != nil {
- return m.RequestUnion
- }
- return nil
-}
-
-func (m *WatchRequest) GetCreateRequest() *WatchCreateRequest {
- if x, ok := m.GetRequestUnion().(*WatchRequest_CreateRequest); ok {
- return x.CreateRequest
- }
- return nil
-}
-
-func (m *WatchRequest) GetCancelRequest() *WatchCancelRequest {
- if x, ok := m.GetRequestUnion().(*WatchRequest_CancelRequest); ok {
- return x.CancelRequest
- }
- return nil
-}
-
-func (m *WatchRequest) GetProgressRequest() *WatchProgressRequest {
- if x, ok := m.GetRequestUnion().(*WatchRequest_ProgressRequest); ok {
- return x.ProgressRequest
- }
- return nil
-}
-
-// XXX_OneofFuncs is for the internal use of the proto package.
-func (*WatchRequest) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) {
- return _WatchRequest_OneofMarshaler, _WatchRequest_OneofUnmarshaler, _WatchRequest_OneofSizer, []interface{}{
- (*WatchRequest_CreateRequest)(nil),
- (*WatchRequest_CancelRequest)(nil),
- (*WatchRequest_ProgressRequest)(nil),
- }
-}
-
-func _WatchRequest_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
- m := msg.(*WatchRequest)
- // request_union
- switch x := m.RequestUnion.(type) {
- case *WatchRequest_CreateRequest:
- _ = b.EncodeVarint(1<<3 | proto.WireBytes)
- if err := b.EncodeMessage(x.CreateRequest); err != nil {
- return err
- }
- case *WatchRequest_CancelRequest:
- _ = b.EncodeVarint(2<<3 | proto.WireBytes)
- if err := b.EncodeMessage(x.CancelRequest); err != nil {
- return err
- }
- case *WatchRequest_ProgressRequest:
- _ = b.EncodeVarint(3<<3 | proto.WireBytes)
- if err := b.EncodeMessage(x.ProgressRequest); err != nil {
- return err
- }
- case nil:
- default:
- return fmt.Errorf("WatchRequest.RequestUnion has unexpected type %T", x)
- }
- return nil
-}
-
-func _WatchRequest_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
- m := msg.(*WatchRequest)
- switch tag {
- case 1: // request_union.create_request
- if wire != proto.WireBytes {
- return true, proto.ErrInternalBadWireType
- }
- msg := new(WatchCreateRequest)
- err := b.DecodeMessage(msg)
- m.RequestUnion = &WatchRequest_CreateRequest{msg}
- return true, err
- case 2: // request_union.cancel_request
- if wire != proto.WireBytes {
- return true, proto.ErrInternalBadWireType
- }
- msg := new(WatchCancelRequest)
- err := b.DecodeMessage(msg)
- m.RequestUnion = &WatchRequest_CancelRequest{msg}
- return true, err
- case 3: // request_union.progress_request
- if wire != proto.WireBytes {
- return true, proto.ErrInternalBadWireType
- }
- msg := new(WatchProgressRequest)
- err := b.DecodeMessage(msg)
- m.RequestUnion = &WatchRequest_ProgressRequest{msg}
- return true, err
- default:
- return false, nil
- }
-}
-
-func _WatchRequest_OneofSizer(msg proto.Message) (n int) {
- m := msg.(*WatchRequest)
- // request_union
- switch x := m.RequestUnion.(type) {
- case *WatchRequest_CreateRequest:
- s := proto.Size(x.CreateRequest)
- n += proto.SizeVarint(1<<3 | proto.WireBytes)
- n += proto.SizeVarint(uint64(s))
- n += s
- case *WatchRequest_CancelRequest:
- s := proto.Size(x.CancelRequest)
- n += proto.SizeVarint(2<<3 | proto.WireBytes)
- n += proto.SizeVarint(uint64(s))
- n += s
- case *WatchRequest_ProgressRequest:
- s := proto.Size(x.ProgressRequest)
- n += proto.SizeVarint(3<<3 | proto.WireBytes)
- n += proto.SizeVarint(uint64(s))
- n += s
- case nil:
- default:
- panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
- }
- return n
-}
-
-type WatchCreateRequest struct {
- // key is the key to register for watching.
- Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
- // range_end is the end of the range [key, range_end) to watch. If range_end is not given,
- // only the key argument is watched. If range_end is equal to '\0', all keys greater than
- // or equal to the key argument are watched.
- // If the range_end is one bit larger than the given key,
- // then all keys with the prefix (the given key) will be watched.
- RangeEnd []byte `protobuf:"bytes,2,opt,name=range_end,json=rangeEnd,proto3" json:"range_end,omitempty"`
- // start_revision is an optional revision to watch from (inclusive). No start_revision is "now".
- StartRevision int64 `protobuf:"varint,3,opt,name=start_revision,json=startRevision,proto3" json:"start_revision,omitempty"`
- // progress_notify is set so that the etcd server will periodically send a WatchResponse with
- // no events to the new watcher if there are no recent events. It is useful when clients
- // wish to recover a disconnected watcher starting from a recent known revision.
- // The etcd server may decide how often it will send notifications based on current load.
- ProgressNotify bool `protobuf:"varint,4,opt,name=progress_notify,json=progressNotify,proto3" json:"progress_notify,omitempty"`
- // filters filter the events at server side before it sends back to the watcher.
- Filters []WatchCreateRequest_FilterType `protobuf:"varint,5,rep,packed,name=filters,enum=etcdserverpb.WatchCreateRequest_FilterType" json:"filters,omitempty"`
- // If prev_kv is set, created watcher gets the previous KV before the event happens.
- // If the previous KV is already compacted, nothing will be returned.
- PrevKv bool `protobuf:"varint,6,opt,name=prev_kv,json=prevKv,proto3" json:"prev_kv,omitempty"`
- // If watch_id is provided and non-zero, it will be assigned to this watcher.
- // Since creating a watcher in etcd is not a synchronous operation,
- // this can be used ensure that ordering is correct when creating multiple
- // watchers on the same stream. Creating a watcher with an ID already in
- // use on the stream will cause an error to be returned.
- WatchId int64 `protobuf:"varint,7,opt,name=watch_id,json=watchId,proto3" json:"watch_id,omitempty"`
- // fragment enables splitting large revisions into multiple watch responses.
- Fragment bool `protobuf:"varint,8,opt,name=fragment,proto3" json:"fragment,omitempty"`
-}
-
-func (m *WatchCreateRequest) Reset() { *m = WatchCreateRequest{} }
-func (m *WatchCreateRequest) String() string { return proto.CompactTextString(m) }
-func (*WatchCreateRequest) ProtoMessage() {}
-func (*WatchCreateRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{21} }
-
-func (m *WatchCreateRequest) GetKey() []byte {
- if m != nil {
- return m.Key
- }
- return nil
-}
-
-func (m *WatchCreateRequest) GetRangeEnd() []byte {
- if m != nil {
- return m.RangeEnd
- }
- return nil
-}
-
-func (m *WatchCreateRequest) GetStartRevision() int64 {
- if m != nil {
- return m.StartRevision
- }
- return 0
-}
-
-func (m *WatchCreateRequest) GetProgressNotify() bool {
- if m != nil {
- return m.ProgressNotify
- }
- return false
-}
-
-func (m *WatchCreateRequest) GetFilters() []WatchCreateRequest_FilterType {
- if m != nil {
- return m.Filters
- }
- return nil
-}
-
-func (m *WatchCreateRequest) GetPrevKv() bool {
- if m != nil {
- return m.PrevKv
- }
- return false
-}
-
-func (m *WatchCreateRequest) GetWatchId() int64 {
- if m != nil {
- return m.WatchId
- }
- return 0
-}
-
-func (m *WatchCreateRequest) GetFragment() bool {
- if m != nil {
- return m.Fragment
- }
- return false
-}
-
-type WatchCancelRequest struct {
- // watch_id is the watcher id to cancel so that no more events are transmitted.
- WatchId int64 `protobuf:"varint,1,opt,name=watch_id,json=watchId,proto3" json:"watch_id,omitempty"`
-}
-
-func (m *WatchCancelRequest) Reset() { *m = WatchCancelRequest{} }
-func (m *WatchCancelRequest) String() string { return proto.CompactTextString(m) }
-func (*WatchCancelRequest) ProtoMessage() {}
-func (*WatchCancelRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{22} }
-
-func (m *WatchCancelRequest) GetWatchId() int64 {
- if m != nil {
- return m.WatchId
- }
- return 0
-}
-
-// Requests the a watch stream progress status be sent in the watch response stream as soon as
-// possible.
-type WatchProgressRequest struct {
-}
-
-func (m *WatchProgressRequest) Reset() { *m = WatchProgressRequest{} }
-func (m *WatchProgressRequest) String() string { return proto.CompactTextString(m) }
-func (*WatchProgressRequest) ProtoMessage() {}
-func (*WatchProgressRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{23} }
-
-type WatchResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
- // watch_id is the ID of the watcher that corresponds to the response.
- WatchId int64 `protobuf:"varint,2,opt,name=watch_id,json=watchId,proto3" json:"watch_id,omitempty"`
- // created is set to true if the response is for a create watch request.
- // The client should record the watch_id and expect to receive events for
- // the created watcher from the same stream.
- // All events sent to the created watcher will attach with the same watch_id.
- Created bool `protobuf:"varint,3,opt,name=created,proto3" json:"created,omitempty"`
- // canceled is set to true if the response is for a cancel watch request.
- // No further events will be sent to the canceled watcher.
- Canceled bool `protobuf:"varint,4,opt,name=canceled,proto3" json:"canceled,omitempty"`
- // compact_revision is set to the minimum index if a watcher tries to watch
- // at a compacted index.
- //
- // This happens when creating a watcher at a compacted revision or the watcher cannot
- // catch up with the progress of the key-value store.
- //
- // The client should treat the watcher as canceled and should not try to create any
- // watcher with the same start_revision again.
- CompactRevision int64 `protobuf:"varint,5,opt,name=compact_revision,json=compactRevision,proto3" json:"compact_revision,omitempty"`
- // cancel_reason indicates the reason for canceling the watcher.
- CancelReason string `protobuf:"bytes,6,opt,name=cancel_reason,json=cancelReason,proto3" json:"cancel_reason,omitempty"`
- // framgment is true if large watch response was split over multiple responses.
- Fragment bool `protobuf:"varint,7,opt,name=fragment,proto3" json:"fragment,omitempty"`
- Events []*mvccpb.Event `protobuf:"bytes,11,rep,name=events" json:"events,omitempty"`
-}
-
-func (m *WatchResponse) Reset() { *m = WatchResponse{} }
-func (m *WatchResponse) String() string { return proto.CompactTextString(m) }
-func (*WatchResponse) ProtoMessage() {}
-func (*WatchResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{24} }
-
-func (m *WatchResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-func (m *WatchResponse) GetWatchId() int64 {
- if m != nil {
- return m.WatchId
- }
- return 0
-}
-
-func (m *WatchResponse) GetCreated() bool {
- if m != nil {
- return m.Created
- }
- return false
-}
-
-func (m *WatchResponse) GetCanceled() bool {
- if m != nil {
- return m.Canceled
- }
- return false
-}
-
-func (m *WatchResponse) GetCompactRevision() int64 {
- if m != nil {
- return m.CompactRevision
- }
- return 0
-}
-
-func (m *WatchResponse) GetCancelReason() string {
- if m != nil {
- return m.CancelReason
- }
- return ""
-}
-
-func (m *WatchResponse) GetFragment() bool {
- if m != nil {
- return m.Fragment
- }
- return false
-}
-
-func (m *WatchResponse) GetEvents() []*mvccpb.Event {
- if m != nil {
- return m.Events
- }
- return nil
-}
-
-type LeaseGrantRequest struct {
- // TTL is the advisory time-to-live in seconds. Expired lease will return -1.
- TTL int64 `protobuf:"varint,1,opt,name=TTL,proto3" json:"TTL,omitempty"`
- // ID is the requested ID for the lease. If ID is set to 0, the lessor chooses an ID.
- ID int64 `protobuf:"varint,2,opt,name=ID,proto3" json:"ID,omitempty"`
-}
-
-func (m *LeaseGrantRequest) Reset() { *m = LeaseGrantRequest{} }
-func (m *LeaseGrantRequest) String() string { return proto.CompactTextString(m) }
-func (*LeaseGrantRequest) ProtoMessage() {}
-func (*LeaseGrantRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{25} }
-
-func (m *LeaseGrantRequest) GetTTL() int64 {
- if m != nil {
- return m.TTL
- }
- return 0
-}
-
-func (m *LeaseGrantRequest) GetID() int64 {
- if m != nil {
- return m.ID
- }
- return 0
-}
-
-type LeaseGrantResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
- // ID is the lease ID for the granted lease.
- ID int64 `protobuf:"varint,2,opt,name=ID,proto3" json:"ID,omitempty"`
- // TTL is the server chosen lease time-to-live in seconds.
- TTL int64 `protobuf:"varint,3,opt,name=TTL,proto3" json:"TTL,omitempty"`
- Error string `protobuf:"bytes,4,opt,name=error,proto3" json:"error,omitempty"`
-}
-
-func (m *LeaseGrantResponse) Reset() { *m = LeaseGrantResponse{} }
-func (m *LeaseGrantResponse) String() string { return proto.CompactTextString(m) }
-func (*LeaseGrantResponse) ProtoMessage() {}
-func (*LeaseGrantResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{26} }
-
-func (m *LeaseGrantResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-func (m *LeaseGrantResponse) GetID() int64 {
- if m != nil {
- return m.ID
- }
- return 0
-}
-
-func (m *LeaseGrantResponse) GetTTL() int64 {
- if m != nil {
- return m.TTL
- }
- return 0
-}
-
-func (m *LeaseGrantResponse) GetError() string {
- if m != nil {
- return m.Error
- }
- return ""
-}
-
-type LeaseRevokeRequest struct {
- // ID is the lease ID to revoke. When the ID is revoked, all associated keys will be deleted.
- ID int64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"`
-}
-
-func (m *LeaseRevokeRequest) Reset() { *m = LeaseRevokeRequest{} }
-func (m *LeaseRevokeRequest) String() string { return proto.CompactTextString(m) }
-func (*LeaseRevokeRequest) ProtoMessage() {}
-func (*LeaseRevokeRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{27} }
-
-func (m *LeaseRevokeRequest) GetID() int64 {
- if m != nil {
- return m.ID
- }
- return 0
-}
-
-type LeaseRevokeResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
-}
-
-func (m *LeaseRevokeResponse) Reset() { *m = LeaseRevokeResponse{} }
-func (m *LeaseRevokeResponse) String() string { return proto.CompactTextString(m) }
-func (*LeaseRevokeResponse) ProtoMessage() {}
-func (*LeaseRevokeResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{28} }
-
-func (m *LeaseRevokeResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-type LeaseCheckpoint struct {
- // ID is the lease ID to checkpoint.
- ID int64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"`
- // Remaining_TTL is the remaining time until expiry of the lease.
- Remaining_TTL int64 `protobuf:"varint,2,opt,name=remaining_TTL,json=remainingTTL,proto3" json:"remaining_TTL,omitempty"`
-}
-
-func (m *LeaseCheckpoint) Reset() { *m = LeaseCheckpoint{} }
-func (m *LeaseCheckpoint) String() string { return proto.CompactTextString(m) }
-func (*LeaseCheckpoint) ProtoMessage() {}
-func (*LeaseCheckpoint) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{29} }
-
-func (m *LeaseCheckpoint) GetID() int64 {
- if m != nil {
- return m.ID
- }
- return 0
-}
-
-func (m *LeaseCheckpoint) GetRemaining_TTL() int64 {
- if m != nil {
- return m.Remaining_TTL
- }
- return 0
-}
-
-type LeaseCheckpointRequest struct {
- Checkpoints []*LeaseCheckpoint `protobuf:"bytes,1,rep,name=checkpoints" json:"checkpoints,omitempty"`
-}
-
-func (m *LeaseCheckpointRequest) Reset() { *m = LeaseCheckpointRequest{} }
-func (m *LeaseCheckpointRequest) String() string { return proto.CompactTextString(m) }
-func (*LeaseCheckpointRequest) ProtoMessage() {}
-func (*LeaseCheckpointRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{30} }
-
-func (m *LeaseCheckpointRequest) GetCheckpoints() []*LeaseCheckpoint {
- if m != nil {
- return m.Checkpoints
- }
- return nil
-}
-
-type LeaseCheckpointResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
-}
-
-func (m *LeaseCheckpointResponse) Reset() { *m = LeaseCheckpointResponse{} }
-func (m *LeaseCheckpointResponse) String() string { return proto.CompactTextString(m) }
-func (*LeaseCheckpointResponse) ProtoMessage() {}
-func (*LeaseCheckpointResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{31} }
-
-func (m *LeaseCheckpointResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-type LeaseKeepAliveRequest struct {
- // ID is the lease ID for the lease to keep alive.
- ID int64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"`
-}
-
-func (m *LeaseKeepAliveRequest) Reset() { *m = LeaseKeepAliveRequest{} }
-func (m *LeaseKeepAliveRequest) String() string { return proto.CompactTextString(m) }
-func (*LeaseKeepAliveRequest) ProtoMessage() {}
-func (*LeaseKeepAliveRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{32} }
-
-func (m *LeaseKeepAliveRequest) GetID() int64 {
- if m != nil {
- return m.ID
- }
- return 0
-}
-
-type LeaseKeepAliveResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
- // ID is the lease ID from the keep alive request.
- ID int64 `protobuf:"varint,2,opt,name=ID,proto3" json:"ID,omitempty"`
- // TTL is the new time-to-live for the lease.
- TTL int64 `protobuf:"varint,3,opt,name=TTL,proto3" json:"TTL,omitempty"`
-}
-
-func (m *LeaseKeepAliveResponse) Reset() { *m = LeaseKeepAliveResponse{} }
-func (m *LeaseKeepAliveResponse) String() string { return proto.CompactTextString(m) }
-func (*LeaseKeepAliveResponse) ProtoMessage() {}
-func (*LeaseKeepAliveResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{33} }
-
-func (m *LeaseKeepAliveResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-func (m *LeaseKeepAliveResponse) GetID() int64 {
- if m != nil {
- return m.ID
- }
- return 0
-}
-
-func (m *LeaseKeepAliveResponse) GetTTL() int64 {
- if m != nil {
- return m.TTL
- }
- return 0
-}
-
-type LeaseTimeToLiveRequest struct {
- // ID is the lease ID for the lease.
- ID int64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"`
- // keys is true to query all the keys attached to this lease.
- Keys bool `protobuf:"varint,2,opt,name=keys,proto3" json:"keys,omitempty"`
-}
-
-func (m *LeaseTimeToLiveRequest) Reset() { *m = LeaseTimeToLiveRequest{} }
-func (m *LeaseTimeToLiveRequest) String() string { return proto.CompactTextString(m) }
-func (*LeaseTimeToLiveRequest) ProtoMessage() {}
-func (*LeaseTimeToLiveRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{34} }
-
-func (m *LeaseTimeToLiveRequest) GetID() int64 {
- if m != nil {
- return m.ID
- }
- return 0
-}
-
-func (m *LeaseTimeToLiveRequest) GetKeys() bool {
- if m != nil {
- return m.Keys
- }
- return false
-}
-
-type LeaseTimeToLiveResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
- // ID is the lease ID from the keep alive request.
- ID int64 `protobuf:"varint,2,opt,name=ID,proto3" json:"ID,omitempty"`
- // TTL is the remaining TTL in seconds for the lease; the lease will expire in under TTL+1 seconds.
- TTL int64 `protobuf:"varint,3,opt,name=TTL,proto3" json:"TTL,omitempty"`
- // GrantedTTL is the initial granted time in seconds upon lease creation/renewal.
- GrantedTTL int64 `protobuf:"varint,4,opt,name=grantedTTL,proto3" json:"grantedTTL,omitempty"`
- // Keys is the list of keys attached to this lease.
- Keys [][]byte `protobuf:"bytes,5,rep,name=keys" json:"keys,omitempty"`
-}
-
-func (m *LeaseTimeToLiveResponse) Reset() { *m = LeaseTimeToLiveResponse{} }
-func (m *LeaseTimeToLiveResponse) String() string { return proto.CompactTextString(m) }
-func (*LeaseTimeToLiveResponse) ProtoMessage() {}
-func (*LeaseTimeToLiveResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{35} }
-
-func (m *LeaseTimeToLiveResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-func (m *LeaseTimeToLiveResponse) GetID() int64 {
- if m != nil {
- return m.ID
- }
- return 0
-}
-
-func (m *LeaseTimeToLiveResponse) GetTTL() int64 {
- if m != nil {
- return m.TTL
- }
- return 0
-}
-
-func (m *LeaseTimeToLiveResponse) GetGrantedTTL() int64 {
- if m != nil {
- return m.GrantedTTL
- }
- return 0
-}
-
-func (m *LeaseTimeToLiveResponse) GetKeys() [][]byte {
- if m != nil {
- return m.Keys
- }
- return nil
-}
-
-type LeaseLeasesRequest struct {
-}
-
-func (m *LeaseLeasesRequest) Reset() { *m = LeaseLeasesRequest{} }
-func (m *LeaseLeasesRequest) String() string { return proto.CompactTextString(m) }
-func (*LeaseLeasesRequest) ProtoMessage() {}
-func (*LeaseLeasesRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{36} }
-
-type LeaseStatus struct {
- ID int64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"`
-}
-
-func (m *LeaseStatus) Reset() { *m = LeaseStatus{} }
-func (m *LeaseStatus) String() string { return proto.CompactTextString(m) }
-func (*LeaseStatus) ProtoMessage() {}
-func (*LeaseStatus) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{37} }
-
-func (m *LeaseStatus) GetID() int64 {
- if m != nil {
- return m.ID
- }
- return 0
-}
-
-type LeaseLeasesResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
- Leases []*LeaseStatus `protobuf:"bytes,2,rep,name=leases" json:"leases,omitempty"`
-}
-
-func (m *LeaseLeasesResponse) Reset() { *m = LeaseLeasesResponse{} }
-func (m *LeaseLeasesResponse) String() string { return proto.CompactTextString(m) }
-func (*LeaseLeasesResponse) ProtoMessage() {}
-func (*LeaseLeasesResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{38} }
-
-func (m *LeaseLeasesResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-func (m *LeaseLeasesResponse) GetLeases() []*LeaseStatus {
- if m != nil {
- return m.Leases
- }
- return nil
-}
-
-type Member struct {
- // ID is the member ID for this member.
- ID uint64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"`
- // name is the human-readable name of the member. If the member is not started, the name will be an empty string.
- Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
- // peerURLs is the list of URLs the member exposes to the cluster for communication.
- PeerURLs []string `protobuf:"bytes,3,rep,name=peerURLs" json:"peerURLs,omitempty"`
- // clientURLs is the list of URLs the member exposes to clients for communication. If the member is not started, clientURLs will be empty.
- ClientURLs []string `protobuf:"bytes,4,rep,name=clientURLs" json:"clientURLs,omitempty"`
- // isLearner indicates if the member is raft learner.
- IsLearner bool `protobuf:"varint,5,opt,name=isLearner,proto3" json:"isLearner,omitempty"`
-}
-
-func (m *Member) Reset() { *m = Member{} }
-func (m *Member) String() string { return proto.CompactTextString(m) }
-func (*Member) ProtoMessage() {}
-func (*Member) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{39} }
-
-func (m *Member) GetID() uint64 {
- if m != nil {
- return m.ID
- }
- return 0
-}
-
-func (m *Member) GetName() string {
- if m != nil {
- return m.Name
- }
- return ""
-}
-
-func (m *Member) GetPeerURLs() []string {
- if m != nil {
- return m.PeerURLs
- }
- return nil
-}
-
-func (m *Member) GetClientURLs() []string {
- if m != nil {
- return m.ClientURLs
- }
- return nil
-}
-
-func (m *Member) GetIsLearner() bool {
- if m != nil {
- return m.IsLearner
- }
- return false
-}
-
-type MemberAddRequest struct {
- // peerURLs is the list of URLs the added member will use to communicate with the cluster.
- PeerURLs []string `protobuf:"bytes,1,rep,name=peerURLs" json:"peerURLs,omitempty"`
- // isLearner indicates if the added member is raft learner.
- IsLearner bool `protobuf:"varint,2,opt,name=isLearner,proto3" json:"isLearner,omitempty"`
-}
-
-func (m *MemberAddRequest) Reset() { *m = MemberAddRequest{} }
-func (m *MemberAddRequest) String() string { return proto.CompactTextString(m) }
-func (*MemberAddRequest) ProtoMessage() {}
-func (*MemberAddRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{40} }
-
-func (m *MemberAddRequest) GetPeerURLs() []string {
- if m != nil {
- return m.PeerURLs
- }
- return nil
-}
-
-func (m *MemberAddRequest) GetIsLearner() bool {
- if m != nil {
- return m.IsLearner
- }
- return false
-}
-
-type MemberAddResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
- // member is the member information for the added member.
- Member *Member `protobuf:"bytes,2,opt,name=member" json:"member,omitempty"`
- // members is a list of all members after adding the new member.
- Members []*Member `protobuf:"bytes,3,rep,name=members" json:"members,omitempty"`
-}
-
-func (m *MemberAddResponse) Reset() { *m = MemberAddResponse{} }
-func (m *MemberAddResponse) String() string { return proto.CompactTextString(m) }
-func (*MemberAddResponse) ProtoMessage() {}
-func (*MemberAddResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{41} }
-
-func (m *MemberAddResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-func (m *MemberAddResponse) GetMember() *Member {
- if m != nil {
- return m.Member
- }
- return nil
-}
-
-func (m *MemberAddResponse) GetMembers() []*Member {
- if m != nil {
- return m.Members
- }
- return nil
-}
-
-type MemberRemoveRequest struct {
- // ID is the member ID of the member to remove.
- ID uint64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"`
-}
-
-func (m *MemberRemoveRequest) Reset() { *m = MemberRemoveRequest{} }
-func (m *MemberRemoveRequest) String() string { return proto.CompactTextString(m) }
-func (*MemberRemoveRequest) ProtoMessage() {}
-func (*MemberRemoveRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{42} }
-
-func (m *MemberRemoveRequest) GetID() uint64 {
- if m != nil {
- return m.ID
- }
- return 0
-}
-
-type MemberRemoveResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
- // members is a list of all members after removing the member.
- Members []*Member `protobuf:"bytes,2,rep,name=members" json:"members,omitempty"`
-}
-
-func (m *MemberRemoveResponse) Reset() { *m = MemberRemoveResponse{} }
-func (m *MemberRemoveResponse) String() string { return proto.CompactTextString(m) }
-func (*MemberRemoveResponse) ProtoMessage() {}
-func (*MemberRemoveResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{43} }
-
-func (m *MemberRemoveResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-func (m *MemberRemoveResponse) GetMembers() []*Member {
- if m != nil {
- return m.Members
- }
- return nil
-}
-
-type MemberUpdateRequest struct {
- // ID is the member ID of the member to update.
- ID uint64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"`
- // peerURLs is the new list of URLs the member will use to communicate with the cluster.
- PeerURLs []string `protobuf:"bytes,2,rep,name=peerURLs" json:"peerURLs,omitempty"`
-}
-
-func (m *MemberUpdateRequest) Reset() { *m = MemberUpdateRequest{} }
-func (m *MemberUpdateRequest) String() string { return proto.CompactTextString(m) }
-func (*MemberUpdateRequest) ProtoMessage() {}
-func (*MemberUpdateRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{44} }
-
-func (m *MemberUpdateRequest) GetID() uint64 {
- if m != nil {
- return m.ID
- }
- return 0
-}
-
-func (m *MemberUpdateRequest) GetPeerURLs() []string {
- if m != nil {
- return m.PeerURLs
- }
- return nil
-}
-
-type MemberUpdateResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
- // members is a list of all members after updating the member.
- Members []*Member `protobuf:"bytes,2,rep,name=members" json:"members,omitempty"`
-}
-
-func (m *MemberUpdateResponse) Reset() { *m = MemberUpdateResponse{} }
-func (m *MemberUpdateResponse) String() string { return proto.CompactTextString(m) }
-func (*MemberUpdateResponse) ProtoMessage() {}
-func (*MemberUpdateResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{45} }
-
-func (m *MemberUpdateResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-func (m *MemberUpdateResponse) GetMembers() []*Member {
- if m != nil {
- return m.Members
- }
- return nil
-}
-
-type MemberListRequest struct {
-}
-
-func (m *MemberListRequest) Reset() { *m = MemberListRequest{} }
-func (m *MemberListRequest) String() string { return proto.CompactTextString(m) }
-func (*MemberListRequest) ProtoMessage() {}
-func (*MemberListRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{46} }
-
-type MemberListResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
- // members is a list of all members associated with the cluster.
- Members []*Member `protobuf:"bytes,2,rep,name=members" json:"members,omitempty"`
-}
-
-func (m *MemberListResponse) Reset() { *m = MemberListResponse{} }
-func (m *MemberListResponse) String() string { return proto.CompactTextString(m) }
-func (*MemberListResponse) ProtoMessage() {}
-func (*MemberListResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{47} }
-
-func (m *MemberListResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-func (m *MemberListResponse) GetMembers() []*Member {
- if m != nil {
- return m.Members
- }
- return nil
-}
-
-type MemberPromoteRequest struct {
- // ID is the member ID of the member to promote.
- ID uint64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"`
-}
-
-func (m *MemberPromoteRequest) Reset() { *m = MemberPromoteRequest{} }
-func (m *MemberPromoteRequest) String() string { return proto.CompactTextString(m) }
-func (*MemberPromoteRequest) ProtoMessage() {}
-func (*MemberPromoteRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{48} }
-
-func (m *MemberPromoteRequest) GetID() uint64 {
- if m != nil {
- return m.ID
- }
- return 0
-}
-
-type MemberPromoteResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
- // members is a list of all members after promoting the member.
- Members []*Member `protobuf:"bytes,2,rep,name=members" json:"members,omitempty"`
-}
-
-func (m *MemberPromoteResponse) Reset() { *m = MemberPromoteResponse{} }
-func (m *MemberPromoteResponse) String() string { return proto.CompactTextString(m) }
-func (*MemberPromoteResponse) ProtoMessage() {}
-func (*MemberPromoteResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{49} }
-
-func (m *MemberPromoteResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-func (m *MemberPromoteResponse) GetMembers() []*Member {
- if m != nil {
- return m.Members
- }
- return nil
-}
-
-type DefragmentRequest struct {
-}
-
-func (m *DefragmentRequest) Reset() { *m = DefragmentRequest{} }
-func (m *DefragmentRequest) String() string { return proto.CompactTextString(m) }
-func (*DefragmentRequest) ProtoMessage() {}
-func (*DefragmentRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{50} }
-
-type DefragmentResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
-}
-
-func (m *DefragmentResponse) Reset() { *m = DefragmentResponse{} }
-func (m *DefragmentResponse) String() string { return proto.CompactTextString(m) }
-func (*DefragmentResponse) ProtoMessage() {}
-func (*DefragmentResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{51} }
-
-func (m *DefragmentResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-type MoveLeaderRequest struct {
- // targetID is the node ID for the new leader.
- TargetID uint64 `protobuf:"varint,1,opt,name=targetID,proto3" json:"targetID,omitempty"`
-}
-
-func (m *MoveLeaderRequest) Reset() { *m = MoveLeaderRequest{} }
-func (m *MoveLeaderRequest) String() string { return proto.CompactTextString(m) }
-func (*MoveLeaderRequest) ProtoMessage() {}
-func (*MoveLeaderRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{52} }
-
-func (m *MoveLeaderRequest) GetTargetID() uint64 {
- if m != nil {
- return m.TargetID
- }
- return 0
-}
-
-type MoveLeaderResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
-}
-
-func (m *MoveLeaderResponse) Reset() { *m = MoveLeaderResponse{} }
-func (m *MoveLeaderResponse) String() string { return proto.CompactTextString(m) }
-func (*MoveLeaderResponse) ProtoMessage() {}
-func (*MoveLeaderResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{53} }
-
-func (m *MoveLeaderResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-type AlarmRequest struct {
- // action is the kind of alarm request to issue. The action
- // may GET alarm statuses, ACTIVATE an alarm, or DEACTIVATE a
- // raised alarm.
- Action AlarmRequest_AlarmAction `protobuf:"varint,1,opt,name=action,proto3,enum=etcdserverpb.AlarmRequest_AlarmAction" json:"action,omitempty"`
- // memberID is the ID of the member associated with the alarm. If memberID is 0, the
- // alarm request covers all members.
- MemberID uint64 `protobuf:"varint,2,opt,name=memberID,proto3" json:"memberID,omitempty"`
- // alarm is the type of alarm to consider for this request.
- Alarm AlarmType `protobuf:"varint,3,opt,name=alarm,proto3,enum=etcdserverpb.AlarmType" json:"alarm,omitempty"`
-}
-
-func (m *AlarmRequest) Reset() { *m = AlarmRequest{} }
-func (m *AlarmRequest) String() string { return proto.CompactTextString(m) }
-func (*AlarmRequest) ProtoMessage() {}
-func (*AlarmRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{54} }
-
-func (m *AlarmRequest) GetAction() AlarmRequest_AlarmAction {
- if m != nil {
- return m.Action
- }
- return AlarmRequest_GET
-}
-
-func (m *AlarmRequest) GetMemberID() uint64 {
- if m != nil {
- return m.MemberID
- }
- return 0
-}
-
-func (m *AlarmRequest) GetAlarm() AlarmType {
- if m != nil {
- return m.Alarm
- }
- return AlarmType_NONE
-}
-
-type AlarmMember struct {
- // memberID is the ID of the member associated with the raised alarm.
- MemberID uint64 `protobuf:"varint,1,opt,name=memberID,proto3" json:"memberID,omitempty"`
- // alarm is the type of alarm which has been raised.
- Alarm AlarmType `protobuf:"varint,2,opt,name=alarm,proto3,enum=etcdserverpb.AlarmType" json:"alarm,omitempty"`
-}
-
-func (m *AlarmMember) Reset() { *m = AlarmMember{} }
-func (m *AlarmMember) String() string { return proto.CompactTextString(m) }
-func (*AlarmMember) ProtoMessage() {}
-func (*AlarmMember) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{55} }
-
-func (m *AlarmMember) GetMemberID() uint64 {
- if m != nil {
- return m.MemberID
- }
- return 0
-}
-
-func (m *AlarmMember) GetAlarm() AlarmType {
- if m != nil {
- return m.Alarm
- }
- return AlarmType_NONE
-}
-
-type AlarmResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
- // alarms is a list of alarms associated with the alarm request.
- Alarms []*AlarmMember `protobuf:"bytes,2,rep,name=alarms" json:"alarms,omitempty"`
-}
-
-func (m *AlarmResponse) Reset() { *m = AlarmResponse{} }
-func (m *AlarmResponse) String() string { return proto.CompactTextString(m) }
-func (*AlarmResponse) ProtoMessage() {}
-func (*AlarmResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{56} }
-
-func (m *AlarmResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-func (m *AlarmResponse) GetAlarms() []*AlarmMember {
- if m != nil {
- return m.Alarms
- }
- return nil
-}
-
-type StatusRequest struct {
-}
-
-func (m *StatusRequest) Reset() { *m = StatusRequest{} }
-func (m *StatusRequest) String() string { return proto.CompactTextString(m) }
-func (*StatusRequest) ProtoMessage() {}
-func (*StatusRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{57} }
-
-type StatusResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
- // version is the cluster protocol version used by the responding member.
- Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"`
- // dbSize is the size of the backend database physically allocated, in bytes, of the responding member.
- DbSize int64 `protobuf:"varint,3,opt,name=dbSize,proto3" json:"dbSize,omitempty"`
- // leader is the member ID which the responding member believes is the current leader.
- Leader uint64 `protobuf:"varint,4,opt,name=leader,proto3" json:"leader,omitempty"`
- // raftIndex is the current raft committed index of the responding member.
- RaftIndex uint64 `protobuf:"varint,5,opt,name=raftIndex,proto3" json:"raftIndex,omitempty"`
- // raftTerm is the current raft term of the responding member.
- RaftTerm uint64 `protobuf:"varint,6,opt,name=raftTerm,proto3" json:"raftTerm,omitempty"`
- // raftAppliedIndex is the current raft applied index of the responding member.
- RaftAppliedIndex uint64 `protobuf:"varint,7,opt,name=raftAppliedIndex,proto3" json:"raftAppliedIndex,omitempty"`
- // errors contains alarm/health information and status.
- Errors []string `protobuf:"bytes,8,rep,name=errors" json:"errors,omitempty"`
- // dbSizeInUse is the size of the backend database logically in use, in bytes, of the responding member.
- DbSizeInUse int64 `protobuf:"varint,9,opt,name=dbSizeInUse,proto3" json:"dbSizeInUse,omitempty"`
- // isLearner indicates if the member is raft learner.
- IsLearner bool `protobuf:"varint,10,opt,name=isLearner,proto3" json:"isLearner,omitempty"`
-}
-
-func (m *StatusResponse) Reset() { *m = StatusResponse{} }
-func (m *StatusResponse) String() string { return proto.CompactTextString(m) }
-func (*StatusResponse) ProtoMessage() {}
-func (*StatusResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{58} }
-
-func (m *StatusResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-func (m *StatusResponse) GetVersion() string {
- if m != nil {
- return m.Version
- }
- return ""
-}
-
-func (m *StatusResponse) GetDbSize() int64 {
- if m != nil {
- return m.DbSize
- }
- return 0
-}
-
-func (m *StatusResponse) GetLeader() uint64 {
- if m != nil {
- return m.Leader
- }
- return 0
-}
-
-func (m *StatusResponse) GetRaftIndex() uint64 {
- if m != nil {
- return m.RaftIndex
- }
- return 0
-}
-
-func (m *StatusResponse) GetRaftTerm() uint64 {
- if m != nil {
- return m.RaftTerm
- }
- return 0
-}
-
-func (m *StatusResponse) GetRaftAppliedIndex() uint64 {
- if m != nil {
- return m.RaftAppliedIndex
- }
- return 0
-}
-
-func (m *StatusResponse) GetErrors() []string {
- if m != nil {
- return m.Errors
- }
- return nil
-}
-
-func (m *StatusResponse) GetDbSizeInUse() int64 {
- if m != nil {
- return m.DbSizeInUse
- }
- return 0
-}
-
-func (m *StatusResponse) GetIsLearner() bool {
- if m != nil {
- return m.IsLearner
- }
- return false
-}
-
-type AuthEnableRequest struct {
-}
-
-func (m *AuthEnableRequest) Reset() { *m = AuthEnableRequest{} }
-func (m *AuthEnableRequest) String() string { return proto.CompactTextString(m) }
-func (*AuthEnableRequest) ProtoMessage() {}
-func (*AuthEnableRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{59} }
-
-type AuthDisableRequest struct {
-}
-
-func (m *AuthDisableRequest) Reset() { *m = AuthDisableRequest{} }
-func (m *AuthDisableRequest) String() string { return proto.CompactTextString(m) }
-func (*AuthDisableRequest) ProtoMessage() {}
-func (*AuthDisableRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{60} }
-
-type AuthenticateRequest struct {
- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
- Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
-}
-
-func (m *AuthenticateRequest) Reset() { *m = AuthenticateRequest{} }
-func (m *AuthenticateRequest) String() string { return proto.CompactTextString(m) }
-func (*AuthenticateRequest) ProtoMessage() {}
-func (*AuthenticateRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{61} }
-
-func (m *AuthenticateRequest) GetName() string {
- if m != nil {
- return m.Name
- }
- return ""
-}
-
-func (m *AuthenticateRequest) GetPassword() string {
- if m != nil {
- return m.Password
- }
- return ""
-}
-
-type AuthUserAddRequest struct {
- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
- Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
- Options *authpb.UserAddOptions `protobuf:"bytes,3,opt,name=options" json:"options,omitempty"`
-}
-
-func (m *AuthUserAddRequest) Reset() { *m = AuthUserAddRequest{} }
-func (m *AuthUserAddRequest) String() string { return proto.CompactTextString(m) }
-func (*AuthUserAddRequest) ProtoMessage() {}
-func (*AuthUserAddRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{62} }
-
-func (m *AuthUserAddRequest) GetName() string {
- if m != nil {
- return m.Name
- }
- return ""
-}
-
-func (m *AuthUserAddRequest) GetPassword() string {
- if m != nil {
- return m.Password
- }
- return ""
-}
-
-func (m *AuthUserAddRequest) GetOptions() *authpb.UserAddOptions {
- if m != nil {
- return m.Options
- }
- return nil
-}
-
-type AuthUserGetRequest struct {
- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
-}
-
-func (m *AuthUserGetRequest) Reset() { *m = AuthUserGetRequest{} }
-func (m *AuthUserGetRequest) String() string { return proto.CompactTextString(m) }
-func (*AuthUserGetRequest) ProtoMessage() {}
-func (*AuthUserGetRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{63} }
-
-func (m *AuthUserGetRequest) GetName() string {
- if m != nil {
- return m.Name
- }
- return ""
-}
-
-type AuthUserDeleteRequest struct {
- // name is the name of the user to delete.
- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
-}
-
-func (m *AuthUserDeleteRequest) Reset() { *m = AuthUserDeleteRequest{} }
-func (m *AuthUserDeleteRequest) String() string { return proto.CompactTextString(m) }
-func (*AuthUserDeleteRequest) ProtoMessage() {}
-func (*AuthUserDeleteRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{64} }
-
-func (m *AuthUserDeleteRequest) GetName() string {
- if m != nil {
- return m.Name
- }
- return ""
-}
-
-type AuthUserChangePasswordRequest struct {
- // name is the name of the user whose password is being changed.
- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
- // password is the new password for the user.
- Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
-}
-
-func (m *AuthUserChangePasswordRequest) Reset() { *m = AuthUserChangePasswordRequest{} }
-func (m *AuthUserChangePasswordRequest) String() string { return proto.CompactTextString(m) }
-func (*AuthUserChangePasswordRequest) ProtoMessage() {}
-func (*AuthUserChangePasswordRequest) Descriptor() ([]byte, []int) {
- return fileDescriptorRpc, []int{65}
-}
-
-func (m *AuthUserChangePasswordRequest) GetName() string {
- if m != nil {
- return m.Name
- }
- return ""
-}
-
-func (m *AuthUserChangePasswordRequest) GetPassword() string {
- if m != nil {
- return m.Password
- }
- return ""
-}
-
-type AuthUserGrantRoleRequest struct {
- // user is the name of the user which should be granted a given role.
- User string `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
- // role is the name of the role to grant to the user.
- Role string `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"`
-}
-
-func (m *AuthUserGrantRoleRequest) Reset() { *m = AuthUserGrantRoleRequest{} }
-func (m *AuthUserGrantRoleRequest) String() string { return proto.CompactTextString(m) }
-func (*AuthUserGrantRoleRequest) ProtoMessage() {}
-func (*AuthUserGrantRoleRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{66} }
-
-func (m *AuthUserGrantRoleRequest) GetUser() string {
- if m != nil {
- return m.User
- }
- return ""
-}
-
-func (m *AuthUserGrantRoleRequest) GetRole() string {
- if m != nil {
- return m.Role
- }
- return ""
-}
-
-type AuthUserRevokeRoleRequest struct {
- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
- Role string `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"`
-}
-
-func (m *AuthUserRevokeRoleRequest) Reset() { *m = AuthUserRevokeRoleRequest{} }
-func (m *AuthUserRevokeRoleRequest) String() string { return proto.CompactTextString(m) }
-func (*AuthUserRevokeRoleRequest) ProtoMessage() {}
-func (*AuthUserRevokeRoleRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{67} }
-
-func (m *AuthUserRevokeRoleRequest) GetName() string {
- if m != nil {
- return m.Name
- }
- return ""
-}
-
-func (m *AuthUserRevokeRoleRequest) GetRole() string {
- if m != nil {
- return m.Role
- }
- return ""
-}
-
-type AuthRoleAddRequest struct {
- // name is the name of the role to add to the authentication system.
- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
-}
-
-func (m *AuthRoleAddRequest) Reset() { *m = AuthRoleAddRequest{} }
-func (m *AuthRoleAddRequest) String() string { return proto.CompactTextString(m) }
-func (*AuthRoleAddRequest) ProtoMessage() {}
-func (*AuthRoleAddRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{68} }
-
-func (m *AuthRoleAddRequest) GetName() string {
- if m != nil {
- return m.Name
- }
- return ""
-}
-
-type AuthRoleGetRequest struct {
- Role string `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"`
-}
-
-func (m *AuthRoleGetRequest) Reset() { *m = AuthRoleGetRequest{} }
-func (m *AuthRoleGetRequest) String() string { return proto.CompactTextString(m) }
-func (*AuthRoleGetRequest) ProtoMessage() {}
-func (*AuthRoleGetRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{69} }
-
-func (m *AuthRoleGetRequest) GetRole() string {
- if m != nil {
- return m.Role
- }
- return ""
-}
-
-type AuthUserListRequest struct {
-}
-
-func (m *AuthUserListRequest) Reset() { *m = AuthUserListRequest{} }
-func (m *AuthUserListRequest) String() string { return proto.CompactTextString(m) }
-func (*AuthUserListRequest) ProtoMessage() {}
-func (*AuthUserListRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{70} }
-
-type AuthRoleListRequest struct {
-}
-
-func (m *AuthRoleListRequest) Reset() { *m = AuthRoleListRequest{} }
-func (m *AuthRoleListRequest) String() string { return proto.CompactTextString(m) }
-func (*AuthRoleListRequest) ProtoMessage() {}
-func (*AuthRoleListRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{71} }
-
-type AuthRoleDeleteRequest struct {
- Role string `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"`
-}
-
-func (m *AuthRoleDeleteRequest) Reset() { *m = AuthRoleDeleteRequest{} }
-func (m *AuthRoleDeleteRequest) String() string { return proto.CompactTextString(m) }
-func (*AuthRoleDeleteRequest) ProtoMessage() {}
-func (*AuthRoleDeleteRequest) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{72} }
-
-func (m *AuthRoleDeleteRequest) GetRole() string {
- if m != nil {
- return m.Role
- }
- return ""
-}
-
-type AuthRoleGrantPermissionRequest struct {
- // name is the name of the role which will be granted the permission.
- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
- // perm is the permission to grant to the role.
- Perm *authpb.Permission `protobuf:"bytes,2,opt,name=perm" json:"perm,omitempty"`
-}
-
-func (m *AuthRoleGrantPermissionRequest) Reset() { *m = AuthRoleGrantPermissionRequest{} }
-func (m *AuthRoleGrantPermissionRequest) String() string { return proto.CompactTextString(m) }
-func (*AuthRoleGrantPermissionRequest) ProtoMessage() {}
-func (*AuthRoleGrantPermissionRequest) Descriptor() ([]byte, []int) {
- return fileDescriptorRpc, []int{73}
-}
-
-func (m *AuthRoleGrantPermissionRequest) GetName() string {
- if m != nil {
- return m.Name
- }
- return ""
-}
-
-func (m *AuthRoleGrantPermissionRequest) GetPerm() *authpb.Permission {
- if m != nil {
- return m.Perm
- }
- return nil
-}
-
-type AuthRoleRevokePermissionRequest struct {
- Role string `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"`
- Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"`
- RangeEnd []byte `protobuf:"bytes,3,opt,name=range_end,json=rangeEnd,proto3" json:"range_end,omitempty"`
-}
-
-func (m *AuthRoleRevokePermissionRequest) Reset() { *m = AuthRoleRevokePermissionRequest{} }
-func (m *AuthRoleRevokePermissionRequest) String() string { return proto.CompactTextString(m) }
-func (*AuthRoleRevokePermissionRequest) ProtoMessage() {}
-func (*AuthRoleRevokePermissionRequest) Descriptor() ([]byte, []int) {
- return fileDescriptorRpc, []int{74}
-}
-
-func (m *AuthRoleRevokePermissionRequest) GetRole() string {
- if m != nil {
- return m.Role
- }
- return ""
-}
-
-func (m *AuthRoleRevokePermissionRequest) GetKey() []byte {
- if m != nil {
- return m.Key
- }
- return nil
-}
-
-func (m *AuthRoleRevokePermissionRequest) GetRangeEnd() []byte {
- if m != nil {
- return m.RangeEnd
- }
- return nil
-}
-
-type AuthEnableResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
-}
-
-func (m *AuthEnableResponse) Reset() { *m = AuthEnableResponse{} }
-func (m *AuthEnableResponse) String() string { return proto.CompactTextString(m) }
-func (*AuthEnableResponse) ProtoMessage() {}
-func (*AuthEnableResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{75} }
-
-func (m *AuthEnableResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-type AuthDisableResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
-}
-
-func (m *AuthDisableResponse) Reset() { *m = AuthDisableResponse{} }
-func (m *AuthDisableResponse) String() string { return proto.CompactTextString(m) }
-func (*AuthDisableResponse) ProtoMessage() {}
-func (*AuthDisableResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{76} }
-
-func (m *AuthDisableResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-type AuthenticateResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
- // token is an authorized token that can be used in succeeding RPCs
- Token string `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"`
-}
-
-func (m *AuthenticateResponse) Reset() { *m = AuthenticateResponse{} }
-func (m *AuthenticateResponse) String() string { return proto.CompactTextString(m) }
-func (*AuthenticateResponse) ProtoMessage() {}
-func (*AuthenticateResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{77} }
-
-func (m *AuthenticateResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-func (m *AuthenticateResponse) GetToken() string {
- if m != nil {
- return m.Token
- }
- return ""
-}
-
-type AuthUserAddResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
-}
-
-func (m *AuthUserAddResponse) Reset() { *m = AuthUserAddResponse{} }
-func (m *AuthUserAddResponse) String() string { return proto.CompactTextString(m) }
-func (*AuthUserAddResponse) ProtoMessage() {}
-func (*AuthUserAddResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{78} }
-
-func (m *AuthUserAddResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-type AuthUserGetResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
- Roles []string `protobuf:"bytes,2,rep,name=roles" json:"roles,omitempty"`
-}
-
-func (m *AuthUserGetResponse) Reset() { *m = AuthUserGetResponse{} }
-func (m *AuthUserGetResponse) String() string { return proto.CompactTextString(m) }
-func (*AuthUserGetResponse) ProtoMessage() {}
-func (*AuthUserGetResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{79} }
-
-func (m *AuthUserGetResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-func (m *AuthUserGetResponse) GetRoles() []string {
- if m != nil {
- return m.Roles
- }
- return nil
-}
-
-type AuthUserDeleteResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
-}
-
-func (m *AuthUserDeleteResponse) Reset() { *m = AuthUserDeleteResponse{} }
-func (m *AuthUserDeleteResponse) String() string { return proto.CompactTextString(m) }
-func (*AuthUserDeleteResponse) ProtoMessage() {}
-func (*AuthUserDeleteResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{80} }
-
-func (m *AuthUserDeleteResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-type AuthUserChangePasswordResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
-}
-
-func (m *AuthUserChangePasswordResponse) Reset() { *m = AuthUserChangePasswordResponse{} }
-func (m *AuthUserChangePasswordResponse) String() string { return proto.CompactTextString(m) }
-func (*AuthUserChangePasswordResponse) ProtoMessage() {}
-func (*AuthUserChangePasswordResponse) Descriptor() ([]byte, []int) {
- return fileDescriptorRpc, []int{81}
-}
-
-func (m *AuthUserChangePasswordResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-type AuthUserGrantRoleResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
-}
-
-func (m *AuthUserGrantRoleResponse) Reset() { *m = AuthUserGrantRoleResponse{} }
-func (m *AuthUserGrantRoleResponse) String() string { return proto.CompactTextString(m) }
-func (*AuthUserGrantRoleResponse) ProtoMessage() {}
-func (*AuthUserGrantRoleResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{82} }
-
-func (m *AuthUserGrantRoleResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-type AuthUserRevokeRoleResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
-}
-
-func (m *AuthUserRevokeRoleResponse) Reset() { *m = AuthUserRevokeRoleResponse{} }
-func (m *AuthUserRevokeRoleResponse) String() string { return proto.CompactTextString(m) }
-func (*AuthUserRevokeRoleResponse) ProtoMessage() {}
-func (*AuthUserRevokeRoleResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{83} }
-
-func (m *AuthUserRevokeRoleResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-type AuthRoleAddResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
-}
-
-func (m *AuthRoleAddResponse) Reset() { *m = AuthRoleAddResponse{} }
-func (m *AuthRoleAddResponse) String() string { return proto.CompactTextString(m) }
-func (*AuthRoleAddResponse) ProtoMessage() {}
-func (*AuthRoleAddResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{84} }
-
-func (m *AuthRoleAddResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-type AuthRoleGetResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
- Perm []*authpb.Permission `protobuf:"bytes,2,rep,name=perm" json:"perm,omitempty"`
-}
-
-func (m *AuthRoleGetResponse) Reset() { *m = AuthRoleGetResponse{} }
-func (m *AuthRoleGetResponse) String() string { return proto.CompactTextString(m) }
-func (*AuthRoleGetResponse) ProtoMessage() {}
-func (*AuthRoleGetResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{85} }
-
-func (m *AuthRoleGetResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-func (m *AuthRoleGetResponse) GetPerm() []*authpb.Permission {
- if m != nil {
- return m.Perm
- }
- return nil
-}
-
-type AuthRoleListResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
- Roles []string `protobuf:"bytes,2,rep,name=roles" json:"roles,omitempty"`
-}
-
-func (m *AuthRoleListResponse) Reset() { *m = AuthRoleListResponse{} }
-func (m *AuthRoleListResponse) String() string { return proto.CompactTextString(m) }
-func (*AuthRoleListResponse) ProtoMessage() {}
-func (*AuthRoleListResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{86} }
-
-func (m *AuthRoleListResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-func (m *AuthRoleListResponse) GetRoles() []string {
- if m != nil {
- return m.Roles
- }
- return nil
-}
-
-type AuthUserListResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
- Users []string `protobuf:"bytes,2,rep,name=users" json:"users,omitempty"`
-}
-
-func (m *AuthUserListResponse) Reset() { *m = AuthUserListResponse{} }
-func (m *AuthUserListResponse) String() string { return proto.CompactTextString(m) }
-func (*AuthUserListResponse) ProtoMessage() {}
-func (*AuthUserListResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{87} }
-
-func (m *AuthUserListResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-func (m *AuthUserListResponse) GetUsers() []string {
- if m != nil {
- return m.Users
- }
- return nil
-}
-
-type AuthRoleDeleteResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
-}
-
-func (m *AuthRoleDeleteResponse) Reset() { *m = AuthRoleDeleteResponse{} }
-func (m *AuthRoleDeleteResponse) String() string { return proto.CompactTextString(m) }
-func (*AuthRoleDeleteResponse) ProtoMessage() {}
-func (*AuthRoleDeleteResponse) Descriptor() ([]byte, []int) { return fileDescriptorRpc, []int{88} }
-
-func (m *AuthRoleDeleteResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-type AuthRoleGrantPermissionResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
-}
-
-func (m *AuthRoleGrantPermissionResponse) Reset() { *m = AuthRoleGrantPermissionResponse{} }
-func (m *AuthRoleGrantPermissionResponse) String() string { return proto.CompactTextString(m) }
-func (*AuthRoleGrantPermissionResponse) ProtoMessage() {}
-func (*AuthRoleGrantPermissionResponse) Descriptor() ([]byte, []int) {
- return fileDescriptorRpc, []int{89}
-}
-
-func (m *AuthRoleGrantPermissionResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-type AuthRoleRevokePermissionResponse struct {
- Header *ResponseHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
-}
-
-func (m *AuthRoleRevokePermissionResponse) Reset() { *m = AuthRoleRevokePermissionResponse{} }
-func (m *AuthRoleRevokePermissionResponse) String() string { return proto.CompactTextString(m) }
-func (*AuthRoleRevokePermissionResponse) ProtoMessage() {}
-func (*AuthRoleRevokePermissionResponse) Descriptor() ([]byte, []int) {
- return fileDescriptorRpc, []int{90}
-}
-
-func (m *AuthRoleRevokePermissionResponse) GetHeader() *ResponseHeader {
- if m != nil {
- return m.Header
- }
- return nil
-}
-
-func init() {
- proto.RegisterType((*ResponseHeader)(nil), "etcdserverpb.ResponseHeader")
- proto.RegisterType((*RangeRequest)(nil), "etcdserverpb.RangeRequest")
- proto.RegisterType((*RangeResponse)(nil), "etcdserverpb.RangeResponse")
- proto.RegisterType((*PutRequest)(nil), "etcdserverpb.PutRequest")
- proto.RegisterType((*PutResponse)(nil), "etcdserverpb.PutResponse")
- proto.RegisterType((*DeleteRangeRequest)(nil), "etcdserverpb.DeleteRangeRequest")
- proto.RegisterType((*DeleteRangeResponse)(nil), "etcdserverpb.DeleteRangeResponse")
- proto.RegisterType((*RequestOp)(nil), "etcdserverpb.RequestOp")
- proto.RegisterType((*ResponseOp)(nil), "etcdserverpb.ResponseOp")
- proto.RegisterType((*Compare)(nil), "etcdserverpb.Compare")
- proto.RegisterType((*TxnRequest)(nil), "etcdserverpb.TxnRequest")
- proto.RegisterType((*TxnResponse)(nil), "etcdserverpb.TxnResponse")
- proto.RegisterType((*CompactionRequest)(nil), "etcdserverpb.CompactionRequest")
- proto.RegisterType((*CompactionResponse)(nil), "etcdserverpb.CompactionResponse")
- proto.RegisterType((*HashRequest)(nil), "etcdserverpb.HashRequest")
- proto.RegisterType((*HashKVRequest)(nil), "etcdserverpb.HashKVRequest")
- proto.RegisterType((*HashKVResponse)(nil), "etcdserverpb.HashKVResponse")
- proto.RegisterType((*HashResponse)(nil), "etcdserverpb.HashResponse")
- proto.RegisterType((*SnapshotRequest)(nil), "etcdserverpb.SnapshotRequest")
- proto.RegisterType((*SnapshotResponse)(nil), "etcdserverpb.SnapshotResponse")
- proto.RegisterType((*WatchRequest)(nil), "etcdserverpb.WatchRequest")
- proto.RegisterType((*WatchCreateRequest)(nil), "etcdserverpb.WatchCreateRequest")
- proto.RegisterType((*WatchCancelRequest)(nil), "etcdserverpb.WatchCancelRequest")
- proto.RegisterType((*WatchProgressRequest)(nil), "etcdserverpb.WatchProgressRequest")
- proto.RegisterType((*WatchResponse)(nil), "etcdserverpb.WatchResponse")
- proto.RegisterType((*LeaseGrantRequest)(nil), "etcdserverpb.LeaseGrantRequest")
- proto.RegisterType((*LeaseGrantResponse)(nil), "etcdserverpb.LeaseGrantResponse")
- proto.RegisterType((*LeaseRevokeRequest)(nil), "etcdserverpb.LeaseRevokeRequest")
- proto.RegisterType((*LeaseRevokeResponse)(nil), "etcdserverpb.LeaseRevokeResponse")
- proto.RegisterType((*LeaseCheckpoint)(nil), "etcdserverpb.LeaseCheckpoint")
- proto.RegisterType((*LeaseCheckpointRequest)(nil), "etcdserverpb.LeaseCheckpointRequest")
- proto.RegisterType((*LeaseCheckpointResponse)(nil), "etcdserverpb.LeaseCheckpointResponse")
- proto.RegisterType((*LeaseKeepAliveRequest)(nil), "etcdserverpb.LeaseKeepAliveRequest")
- proto.RegisterType((*LeaseKeepAliveResponse)(nil), "etcdserverpb.LeaseKeepAliveResponse")
- proto.RegisterType((*LeaseTimeToLiveRequest)(nil), "etcdserverpb.LeaseTimeToLiveRequest")
- proto.RegisterType((*LeaseTimeToLiveResponse)(nil), "etcdserverpb.LeaseTimeToLiveResponse")
- proto.RegisterType((*LeaseLeasesRequest)(nil), "etcdserverpb.LeaseLeasesRequest")
- proto.RegisterType((*LeaseStatus)(nil), "etcdserverpb.LeaseStatus")
- proto.RegisterType((*LeaseLeasesResponse)(nil), "etcdserverpb.LeaseLeasesResponse")
- proto.RegisterType((*Member)(nil), "etcdserverpb.Member")
- proto.RegisterType((*MemberAddRequest)(nil), "etcdserverpb.MemberAddRequest")
- proto.RegisterType((*MemberAddResponse)(nil), "etcdserverpb.MemberAddResponse")
- proto.RegisterType((*MemberRemoveRequest)(nil), "etcdserverpb.MemberRemoveRequest")
- proto.RegisterType((*MemberRemoveResponse)(nil), "etcdserverpb.MemberRemoveResponse")
- proto.RegisterType((*MemberUpdateRequest)(nil), "etcdserverpb.MemberUpdateRequest")
- proto.RegisterType((*MemberUpdateResponse)(nil), "etcdserverpb.MemberUpdateResponse")
- proto.RegisterType((*MemberListRequest)(nil), "etcdserverpb.MemberListRequest")
- proto.RegisterType((*MemberListResponse)(nil), "etcdserverpb.MemberListResponse")
- proto.RegisterType((*MemberPromoteRequest)(nil), "etcdserverpb.MemberPromoteRequest")
- proto.RegisterType((*MemberPromoteResponse)(nil), "etcdserverpb.MemberPromoteResponse")
- proto.RegisterType((*DefragmentRequest)(nil), "etcdserverpb.DefragmentRequest")
- proto.RegisterType((*DefragmentResponse)(nil), "etcdserverpb.DefragmentResponse")
- proto.RegisterType((*MoveLeaderRequest)(nil), "etcdserverpb.MoveLeaderRequest")
- proto.RegisterType((*MoveLeaderResponse)(nil), "etcdserverpb.MoveLeaderResponse")
- proto.RegisterType((*AlarmRequest)(nil), "etcdserverpb.AlarmRequest")
- proto.RegisterType((*AlarmMember)(nil), "etcdserverpb.AlarmMember")
- proto.RegisterType((*AlarmResponse)(nil), "etcdserverpb.AlarmResponse")
- proto.RegisterType((*StatusRequest)(nil), "etcdserverpb.StatusRequest")
- proto.RegisterType((*StatusResponse)(nil), "etcdserverpb.StatusResponse")
- proto.RegisterType((*AuthEnableRequest)(nil), "etcdserverpb.AuthEnableRequest")
- proto.RegisterType((*AuthDisableRequest)(nil), "etcdserverpb.AuthDisableRequest")
- proto.RegisterType((*AuthenticateRequest)(nil), "etcdserverpb.AuthenticateRequest")
- proto.RegisterType((*AuthUserAddRequest)(nil), "etcdserverpb.AuthUserAddRequest")
- proto.RegisterType((*AuthUserGetRequest)(nil), "etcdserverpb.AuthUserGetRequest")
- proto.RegisterType((*AuthUserDeleteRequest)(nil), "etcdserverpb.AuthUserDeleteRequest")
- proto.RegisterType((*AuthUserChangePasswordRequest)(nil), "etcdserverpb.AuthUserChangePasswordRequest")
- proto.RegisterType((*AuthUserGrantRoleRequest)(nil), "etcdserverpb.AuthUserGrantRoleRequest")
- proto.RegisterType((*AuthUserRevokeRoleRequest)(nil), "etcdserverpb.AuthUserRevokeRoleRequest")
- proto.RegisterType((*AuthRoleAddRequest)(nil), "etcdserverpb.AuthRoleAddRequest")
- proto.RegisterType((*AuthRoleGetRequest)(nil), "etcdserverpb.AuthRoleGetRequest")
- proto.RegisterType((*AuthUserListRequest)(nil), "etcdserverpb.AuthUserListRequest")
- proto.RegisterType((*AuthRoleListRequest)(nil), "etcdserverpb.AuthRoleListRequest")
- proto.RegisterType((*AuthRoleDeleteRequest)(nil), "etcdserverpb.AuthRoleDeleteRequest")
- proto.RegisterType((*AuthRoleGrantPermissionRequest)(nil), "etcdserverpb.AuthRoleGrantPermissionRequest")
- proto.RegisterType((*AuthRoleRevokePermissionRequest)(nil), "etcdserverpb.AuthRoleRevokePermissionRequest")
- proto.RegisterType((*AuthEnableResponse)(nil), "etcdserverpb.AuthEnableResponse")
- proto.RegisterType((*AuthDisableResponse)(nil), "etcdserverpb.AuthDisableResponse")
- proto.RegisterType((*AuthenticateResponse)(nil), "etcdserverpb.AuthenticateResponse")
- proto.RegisterType((*AuthUserAddResponse)(nil), "etcdserverpb.AuthUserAddResponse")
- proto.RegisterType((*AuthUserGetResponse)(nil), "etcdserverpb.AuthUserGetResponse")
- proto.RegisterType((*AuthUserDeleteResponse)(nil), "etcdserverpb.AuthUserDeleteResponse")
- proto.RegisterType((*AuthUserChangePasswordResponse)(nil), "etcdserverpb.AuthUserChangePasswordResponse")
- proto.RegisterType((*AuthUserGrantRoleResponse)(nil), "etcdserverpb.AuthUserGrantRoleResponse")
- proto.RegisterType((*AuthUserRevokeRoleResponse)(nil), "etcdserverpb.AuthUserRevokeRoleResponse")
- proto.RegisterType((*AuthRoleAddResponse)(nil), "etcdserverpb.AuthRoleAddResponse")
- proto.RegisterType((*AuthRoleGetResponse)(nil), "etcdserverpb.AuthRoleGetResponse")
- proto.RegisterType((*AuthRoleListResponse)(nil), "etcdserverpb.AuthRoleListResponse")
- proto.RegisterType((*AuthUserListResponse)(nil), "etcdserverpb.AuthUserListResponse")
- proto.RegisterType((*AuthRoleDeleteResponse)(nil), "etcdserverpb.AuthRoleDeleteResponse")
- proto.RegisterType((*AuthRoleGrantPermissionResponse)(nil), "etcdserverpb.AuthRoleGrantPermissionResponse")
- proto.RegisterType((*AuthRoleRevokePermissionResponse)(nil), "etcdserverpb.AuthRoleRevokePermissionResponse")
- proto.RegisterEnum("etcdserverpb.AlarmType", AlarmType_name, AlarmType_value)
- proto.RegisterEnum("etcdserverpb.RangeRequest_SortOrder", RangeRequest_SortOrder_name, RangeRequest_SortOrder_value)
- proto.RegisterEnum("etcdserverpb.RangeRequest_SortTarget", RangeRequest_SortTarget_name, RangeRequest_SortTarget_value)
- proto.RegisterEnum("etcdserverpb.Compare_CompareResult", Compare_CompareResult_name, Compare_CompareResult_value)
- proto.RegisterEnum("etcdserverpb.Compare_CompareTarget", Compare_CompareTarget_name, Compare_CompareTarget_value)
- proto.RegisterEnum("etcdserverpb.WatchCreateRequest_FilterType", WatchCreateRequest_FilterType_name, WatchCreateRequest_FilterType_value)
- proto.RegisterEnum("etcdserverpb.AlarmRequest_AlarmAction", AlarmRequest_AlarmAction_name, AlarmRequest_AlarmAction_value)
-}
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ context.Context
-var _ grpc.ClientConn
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the grpc package it is being compiled against.
-const _ = grpc.SupportPackageIsVersion4
-
-// Client API for KV service
-
-type KVClient interface {
- // Range gets the keys in the range from the key-value store.
- Range(ctx context.Context, in *RangeRequest, opts ...grpc.CallOption) (*RangeResponse, error)
- // Put puts the given key into the key-value store.
- // A put request increments the revision of the key-value store
- // and generates one event in the event history.
- Put(ctx context.Context, in *PutRequest, opts ...grpc.CallOption) (*PutResponse, error)
- // DeleteRange deletes the given range from the key-value store.
- // A delete request increments the revision of the key-value store
- // and generates a delete event in the event history for every deleted key.
- DeleteRange(ctx context.Context, in *DeleteRangeRequest, opts ...grpc.CallOption) (*DeleteRangeResponse, error)
- // Txn processes multiple requests in a single transaction.
- // A txn request increments the revision of the key-value store
- // and generates events with the same revision for every completed request.
- // It is not allowed to modify the same key several times within one txn.
- Txn(ctx context.Context, in *TxnRequest, opts ...grpc.CallOption) (*TxnResponse, error)
- // Compact compacts the event history in the etcd key-value store. The key-value
- // store should be periodically compacted or the event history will continue to grow
- // indefinitely.
- Compact(ctx context.Context, in *CompactionRequest, opts ...grpc.CallOption) (*CompactionResponse, error)
-}
-
-type kVClient struct {
- cc *grpc.ClientConn
-}
-
-func NewKVClient(cc *grpc.ClientConn) KVClient {
- return &kVClient{cc}
-}
-
-func (c *kVClient) Range(ctx context.Context, in *RangeRequest, opts ...grpc.CallOption) (*RangeResponse, error) {
- out := new(RangeResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.KV/Range", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *kVClient) Put(ctx context.Context, in *PutRequest, opts ...grpc.CallOption) (*PutResponse, error) {
- out := new(PutResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.KV/Put", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *kVClient) DeleteRange(ctx context.Context, in *DeleteRangeRequest, opts ...grpc.CallOption) (*DeleteRangeResponse, error) {
- out := new(DeleteRangeResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.KV/DeleteRange", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *kVClient) Txn(ctx context.Context, in *TxnRequest, opts ...grpc.CallOption) (*TxnResponse, error) {
- out := new(TxnResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.KV/Txn", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *kVClient) Compact(ctx context.Context, in *CompactionRequest, opts ...grpc.CallOption) (*CompactionResponse, error) {
- out := new(CompactionResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.KV/Compact", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-// Server API for KV service
-
-type KVServer interface {
- // Range gets the keys in the range from the key-value store.
- Range(context.Context, *RangeRequest) (*RangeResponse, error)
- // Put puts the given key into the key-value store.
- // A put request increments the revision of the key-value store
- // and generates one event in the event history.
- Put(context.Context, *PutRequest) (*PutResponse, error)
- // DeleteRange deletes the given range from the key-value store.
- // A delete request increments the revision of the key-value store
- // and generates a delete event in the event history for every deleted key.
- DeleteRange(context.Context, *DeleteRangeRequest) (*DeleteRangeResponse, error)
- // Txn processes multiple requests in a single transaction.
- // A txn request increments the revision of the key-value store
- // and generates events with the same revision for every completed request.
- // It is not allowed to modify the same key several times within one txn.
- Txn(context.Context, *TxnRequest) (*TxnResponse, error)
- // Compact compacts the event history in the etcd key-value store. The key-value
- // store should be periodically compacted or the event history will continue to grow
- // indefinitely.
- Compact(context.Context, *CompactionRequest) (*CompactionResponse, error)
-}
-
-func RegisterKVServer(s *grpc.Server, srv KVServer) {
- s.RegisterService(&_KV_serviceDesc, srv)
-}
-
-func _KV_Range_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(RangeRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(KVServer).Range(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.KV/Range",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(KVServer).Range(ctx, req.(*RangeRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _KV_Put_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(PutRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(KVServer).Put(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.KV/Put",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(KVServer).Put(ctx, req.(*PutRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _KV_DeleteRange_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(DeleteRangeRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(KVServer).DeleteRange(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.KV/DeleteRange",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(KVServer).DeleteRange(ctx, req.(*DeleteRangeRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _KV_Txn_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(TxnRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(KVServer).Txn(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.KV/Txn",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(KVServer).Txn(ctx, req.(*TxnRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _KV_Compact_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(CompactionRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(KVServer).Compact(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.KV/Compact",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(KVServer).Compact(ctx, req.(*CompactionRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-var _KV_serviceDesc = grpc.ServiceDesc{
- ServiceName: "etcdserverpb.KV",
- HandlerType: (*KVServer)(nil),
- Methods: []grpc.MethodDesc{
- {
- MethodName: "Range",
- Handler: _KV_Range_Handler,
- },
- {
- MethodName: "Put",
- Handler: _KV_Put_Handler,
- },
- {
- MethodName: "DeleteRange",
- Handler: _KV_DeleteRange_Handler,
- },
- {
- MethodName: "Txn",
- Handler: _KV_Txn_Handler,
- },
- {
- MethodName: "Compact",
- Handler: _KV_Compact_Handler,
- },
- },
- Streams: []grpc.StreamDesc{},
- Metadata: "rpc.proto",
-}
-
-// Client API for Watch service
-
-type WatchClient interface {
- // Watch watches for events happening or that have happened. Both input and output
- // are streams; the input stream is for creating and canceling watchers and the output
- // stream sends events. One watch RPC can watch on multiple key ranges, streaming events
- // for several watches at once. The entire event history can be watched starting from the
- // last compaction revision.
- Watch(ctx context.Context, opts ...grpc.CallOption) (Watch_WatchClient, error)
-}
-
-type watchClient struct {
- cc *grpc.ClientConn
-}
-
-func NewWatchClient(cc *grpc.ClientConn) WatchClient {
- return &watchClient{cc}
-}
-
-func (c *watchClient) Watch(ctx context.Context, opts ...grpc.CallOption) (Watch_WatchClient, error) {
- stream, err := grpc.NewClientStream(ctx, &_Watch_serviceDesc.Streams[0], c.cc, "/etcdserverpb.Watch/Watch", opts...)
- if err != nil {
- return nil, err
- }
- x := &watchWatchClient{stream}
- return x, nil
-}
-
-type Watch_WatchClient interface {
- Send(*WatchRequest) error
- Recv() (*WatchResponse, error)
- grpc.ClientStream
-}
-
-type watchWatchClient struct {
- grpc.ClientStream
-}
-
-func (x *watchWatchClient) Send(m *WatchRequest) error {
- return x.ClientStream.SendMsg(m)
-}
-
-func (x *watchWatchClient) Recv() (*WatchResponse, error) {
- m := new(WatchResponse)
- if err := x.ClientStream.RecvMsg(m); err != nil {
- return nil, err
- }
- return m, nil
-}
-
-// Server API for Watch service
-
-type WatchServer interface {
- // Watch watches for events happening or that have happened. Both input and output
- // are streams; the input stream is for creating and canceling watchers and the output
- // stream sends events. One watch RPC can watch on multiple key ranges, streaming events
- // for several watches at once. The entire event history can be watched starting from the
- // last compaction revision.
- Watch(Watch_WatchServer) error
-}
-
-func RegisterWatchServer(s *grpc.Server, srv WatchServer) {
- s.RegisterService(&_Watch_serviceDesc, srv)
-}
-
-func _Watch_Watch_Handler(srv interface{}, stream grpc.ServerStream) error {
- return srv.(WatchServer).Watch(&watchWatchServer{stream})
-}
-
-type Watch_WatchServer interface {
- Send(*WatchResponse) error
- Recv() (*WatchRequest, error)
- grpc.ServerStream
-}
-
-type watchWatchServer struct {
- grpc.ServerStream
-}
-
-func (x *watchWatchServer) Send(m *WatchResponse) error {
- return x.ServerStream.SendMsg(m)
-}
-
-func (x *watchWatchServer) Recv() (*WatchRequest, error) {
- m := new(WatchRequest)
- if err := x.ServerStream.RecvMsg(m); err != nil {
- return nil, err
- }
- return m, nil
-}
-
-var _Watch_serviceDesc = grpc.ServiceDesc{
- ServiceName: "etcdserverpb.Watch",
- HandlerType: (*WatchServer)(nil),
- Methods: []grpc.MethodDesc{},
- Streams: []grpc.StreamDesc{
- {
- StreamName: "Watch",
- Handler: _Watch_Watch_Handler,
- ServerStreams: true,
- ClientStreams: true,
- },
- },
- Metadata: "rpc.proto",
-}
-
-// Client API for Lease service
-
-type LeaseClient interface {
- // LeaseGrant creates a lease which expires if the server does not receive a keepAlive
- // within a given time to live period. All keys attached to the lease will be expired and
- // deleted if the lease expires. Each expired key generates a delete event in the event history.
- LeaseGrant(ctx context.Context, in *LeaseGrantRequest, opts ...grpc.CallOption) (*LeaseGrantResponse, error)
- // LeaseRevoke revokes a lease. All keys attached to the lease will expire and be deleted.
- LeaseRevoke(ctx context.Context, in *LeaseRevokeRequest, opts ...grpc.CallOption) (*LeaseRevokeResponse, error)
- // LeaseKeepAlive keeps the lease alive by streaming keep alive requests from the client
- // to the server and streaming keep alive responses from the server to the client.
- LeaseKeepAlive(ctx context.Context, opts ...grpc.CallOption) (Lease_LeaseKeepAliveClient, error)
- // LeaseTimeToLive retrieves lease information.
- LeaseTimeToLive(ctx context.Context, in *LeaseTimeToLiveRequest, opts ...grpc.CallOption) (*LeaseTimeToLiveResponse, error)
- // LeaseLeases lists all existing leases.
- LeaseLeases(ctx context.Context, in *LeaseLeasesRequest, opts ...grpc.CallOption) (*LeaseLeasesResponse, error)
-}
-
-type leaseClient struct {
- cc *grpc.ClientConn
-}
-
-func NewLeaseClient(cc *grpc.ClientConn) LeaseClient {
- return &leaseClient{cc}
-}
-
-func (c *leaseClient) LeaseGrant(ctx context.Context, in *LeaseGrantRequest, opts ...grpc.CallOption) (*LeaseGrantResponse, error) {
- out := new(LeaseGrantResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Lease/LeaseGrant", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *leaseClient) LeaseRevoke(ctx context.Context, in *LeaseRevokeRequest, opts ...grpc.CallOption) (*LeaseRevokeResponse, error) {
- out := new(LeaseRevokeResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Lease/LeaseRevoke", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *leaseClient) LeaseKeepAlive(ctx context.Context, opts ...grpc.CallOption) (Lease_LeaseKeepAliveClient, error) {
- stream, err := grpc.NewClientStream(ctx, &_Lease_serviceDesc.Streams[0], c.cc, "/etcdserverpb.Lease/LeaseKeepAlive", opts...)
- if err != nil {
- return nil, err
- }
- x := &leaseLeaseKeepAliveClient{stream}
- return x, nil
-}
-
-type Lease_LeaseKeepAliveClient interface {
- Send(*LeaseKeepAliveRequest) error
- Recv() (*LeaseKeepAliveResponse, error)
- grpc.ClientStream
-}
-
-type leaseLeaseKeepAliveClient struct {
- grpc.ClientStream
-}
-
-func (x *leaseLeaseKeepAliveClient) Send(m *LeaseKeepAliveRequest) error {
- return x.ClientStream.SendMsg(m)
-}
-
-func (x *leaseLeaseKeepAliveClient) Recv() (*LeaseKeepAliveResponse, error) {
- m := new(LeaseKeepAliveResponse)
- if err := x.ClientStream.RecvMsg(m); err != nil {
- return nil, err
- }
- return m, nil
-}
-
-func (c *leaseClient) LeaseTimeToLive(ctx context.Context, in *LeaseTimeToLiveRequest, opts ...grpc.CallOption) (*LeaseTimeToLiveResponse, error) {
- out := new(LeaseTimeToLiveResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Lease/LeaseTimeToLive", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *leaseClient) LeaseLeases(ctx context.Context, in *LeaseLeasesRequest, opts ...grpc.CallOption) (*LeaseLeasesResponse, error) {
- out := new(LeaseLeasesResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Lease/LeaseLeases", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-// Server API for Lease service
-
-type LeaseServer interface {
- // LeaseGrant creates a lease which expires if the server does not receive a keepAlive
- // within a given time to live period. All keys attached to the lease will be expired and
- // deleted if the lease expires. Each expired key generates a delete event in the event history.
- LeaseGrant(context.Context, *LeaseGrantRequest) (*LeaseGrantResponse, error)
- // LeaseRevoke revokes a lease. All keys attached to the lease will expire and be deleted.
- LeaseRevoke(context.Context, *LeaseRevokeRequest) (*LeaseRevokeResponse, error)
- // LeaseKeepAlive keeps the lease alive by streaming keep alive requests from the client
- // to the server and streaming keep alive responses from the server to the client.
- LeaseKeepAlive(Lease_LeaseKeepAliveServer) error
- // LeaseTimeToLive retrieves lease information.
- LeaseTimeToLive(context.Context, *LeaseTimeToLiveRequest) (*LeaseTimeToLiveResponse, error)
- // LeaseLeases lists all existing leases.
- LeaseLeases(context.Context, *LeaseLeasesRequest) (*LeaseLeasesResponse, error)
-}
-
-func RegisterLeaseServer(s *grpc.Server, srv LeaseServer) {
- s.RegisterService(&_Lease_serviceDesc, srv)
-}
-
-func _Lease_LeaseGrant_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(LeaseGrantRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(LeaseServer).LeaseGrant(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Lease/LeaseGrant",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(LeaseServer).LeaseGrant(ctx, req.(*LeaseGrantRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Lease_LeaseRevoke_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(LeaseRevokeRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(LeaseServer).LeaseRevoke(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Lease/LeaseRevoke",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(LeaseServer).LeaseRevoke(ctx, req.(*LeaseRevokeRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Lease_LeaseKeepAlive_Handler(srv interface{}, stream grpc.ServerStream) error {
- return srv.(LeaseServer).LeaseKeepAlive(&leaseLeaseKeepAliveServer{stream})
-}
-
-type Lease_LeaseKeepAliveServer interface {
- Send(*LeaseKeepAliveResponse) error
- Recv() (*LeaseKeepAliveRequest, error)
- grpc.ServerStream
-}
-
-type leaseLeaseKeepAliveServer struct {
- grpc.ServerStream
-}
-
-func (x *leaseLeaseKeepAliveServer) Send(m *LeaseKeepAliveResponse) error {
- return x.ServerStream.SendMsg(m)
-}
-
-func (x *leaseLeaseKeepAliveServer) Recv() (*LeaseKeepAliveRequest, error) {
- m := new(LeaseKeepAliveRequest)
- if err := x.ServerStream.RecvMsg(m); err != nil {
- return nil, err
- }
- return m, nil
-}
-
-func _Lease_LeaseTimeToLive_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(LeaseTimeToLiveRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(LeaseServer).LeaseTimeToLive(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Lease/LeaseTimeToLive",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(LeaseServer).LeaseTimeToLive(ctx, req.(*LeaseTimeToLiveRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Lease_LeaseLeases_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(LeaseLeasesRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(LeaseServer).LeaseLeases(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Lease/LeaseLeases",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(LeaseServer).LeaseLeases(ctx, req.(*LeaseLeasesRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-var _Lease_serviceDesc = grpc.ServiceDesc{
- ServiceName: "etcdserverpb.Lease",
- HandlerType: (*LeaseServer)(nil),
- Methods: []grpc.MethodDesc{
- {
- MethodName: "LeaseGrant",
- Handler: _Lease_LeaseGrant_Handler,
- },
- {
- MethodName: "LeaseRevoke",
- Handler: _Lease_LeaseRevoke_Handler,
- },
- {
- MethodName: "LeaseTimeToLive",
- Handler: _Lease_LeaseTimeToLive_Handler,
- },
- {
- MethodName: "LeaseLeases",
- Handler: _Lease_LeaseLeases_Handler,
- },
- },
- Streams: []grpc.StreamDesc{
- {
- StreamName: "LeaseKeepAlive",
- Handler: _Lease_LeaseKeepAlive_Handler,
- ServerStreams: true,
- ClientStreams: true,
- },
- },
- Metadata: "rpc.proto",
-}
-
-// Client API for Cluster service
-
-type ClusterClient interface {
- // MemberAdd adds a member into the cluster.
- MemberAdd(ctx context.Context, in *MemberAddRequest, opts ...grpc.CallOption) (*MemberAddResponse, error)
- // MemberRemove removes an existing member from the cluster.
- MemberRemove(ctx context.Context, in *MemberRemoveRequest, opts ...grpc.CallOption) (*MemberRemoveResponse, error)
- // MemberUpdate updates the member configuration.
- MemberUpdate(ctx context.Context, in *MemberUpdateRequest, opts ...grpc.CallOption) (*MemberUpdateResponse, error)
- // MemberList lists all the members in the cluster.
- MemberList(ctx context.Context, in *MemberListRequest, opts ...grpc.CallOption) (*MemberListResponse, error)
- // MemberPromote promotes a member from raft learner (non-voting) to raft voting member.
- MemberPromote(ctx context.Context, in *MemberPromoteRequest, opts ...grpc.CallOption) (*MemberPromoteResponse, error)
-}
-
-type clusterClient struct {
- cc *grpc.ClientConn
-}
-
-func NewClusterClient(cc *grpc.ClientConn) ClusterClient {
- return &clusterClient{cc}
-}
-
-func (c *clusterClient) MemberAdd(ctx context.Context, in *MemberAddRequest, opts ...grpc.CallOption) (*MemberAddResponse, error) {
- out := new(MemberAddResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Cluster/MemberAdd", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *clusterClient) MemberRemove(ctx context.Context, in *MemberRemoveRequest, opts ...grpc.CallOption) (*MemberRemoveResponse, error) {
- out := new(MemberRemoveResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Cluster/MemberRemove", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *clusterClient) MemberUpdate(ctx context.Context, in *MemberUpdateRequest, opts ...grpc.CallOption) (*MemberUpdateResponse, error) {
- out := new(MemberUpdateResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Cluster/MemberUpdate", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *clusterClient) MemberList(ctx context.Context, in *MemberListRequest, opts ...grpc.CallOption) (*MemberListResponse, error) {
- out := new(MemberListResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Cluster/MemberList", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *clusterClient) MemberPromote(ctx context.Context, in *MemberPromoteRequest, opts ...grpc.CallOption) (*MemberPromoteResponse, error) {
- out := new(MemberPromoteResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Cluster/MemberPromote", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-// Server API for Cluster service
-
-type ClusterServer interface {
- // MemberAdd adds a member into the cluster.
- MemberAdd(context.Context, *MemberAddRequest) (*MemberAddResponse, error)
- // MemberRemove removes an existing member from the cluster.
- MemberRemove(context.Context, *MemberRemoveRequest) (*MemberRemoveResponse, error)
- // MemberUpdate updates the member configuration.
- MemberUpdate(context.Context, *MemberUpdateRequest) (*MemberUpdateResponse, error)
- // MemberList lists all the members in the cluster.
- MemberList(context.Context, *MemberListRequest) (*MemberListResponse, error)
- // MemberPromote promotes a member from raft learner (non-voting) to raft voting member.
- MemberPromote(context.Context, *MemberPromoteRequest) (*MemberPromoteResponse, error)
-}
-
-func RegisterClusterServer(s *grpc.Server, srv ClusterServer) {
- s.RegisterService(&_Cluster_serviceDesc, srv)
-}
-
-func _Cluster_MemberAdd_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(MemberAddRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(ClusterServer).MemberAdd(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Cluster/MemberAdd",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(ClusterServer).MemberAdd(ctx, req.(*MemberAddRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Cluster_MemberRemove_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(MemberRemoveRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(ClusterServer).MemberRemove(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Cluster/MemberRemove",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(ClusterServer).MemberRemove(ctx, req.(*MemberRemoveRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Cluster_MemberUpdate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(MemberUpdateRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(ClusterServer).MemberUpdate(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Cluster/MemberUpdate",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(ClusterServer).MemberUpdate(ctx, req.(*MemberUpdateRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Cluster_MemberList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(MemberListRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(ClusterServer).MemberList(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Cluster/MemberList",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(ClusterServer).MemberList(ctx, req.(*MemberListRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Cluster_MemberPromote_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(MemberPromoteRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(ClusterServer).MemberPromote(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Cluster/MemberPromote",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(ClusterServer).MemberPromote(ctx, req.(*MemberPromoteRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-var _Cluster_serviceDesc = grpc.ServiceDesc{
- ServiceName: "etcdserverpb.Cluster",
- HandlerType: (*ClusterServer)(nil),
- Methods: []grpc.MethodDesc{
- {
- MethodName: "MemberAdd",
- Handler: _Cluster_MemberAdd_Handler,
- },
- {
- MethodName: "MemberRemove",
- Handler: _Cluster_MemberRemove_Handler,
- },
- {
- MethodName: "MemberUpdate",
- Handler: _Cluster_MemberUpdate_Handler,
- },
- {
- MethodName: "MemberList",
- Handler: _Cluster_MemberList_Handler,
- },
- {
- MethodName: "MemberPromote",
- Handler: _Cluster_MemberPromote_Handler,
- },
- },
- Streams: []grpc.StreamDesc{},
- Metadata: "rpc.proto",
-}
-
-// Client API for Maintenance service
-
-type MaintenanceClient interface {
- // Alarm activates, deactivates, and queries alarms regarding cluster health.
- Alarm(ctx context.Context, in *AlarmRequest, opts ...grpc.CallOption) (*AlarmResponse, error)
- // Status gets the status of the member.
- Status(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*StatusResponse, error)
- // Defragment defragments a member's backend database to recover storage space.
- Defragment(ctx context.Context, in *DefragmentRequest, opts ...grpc.CallOption) (*DefragmentResponse, error)
- // Hash computes the hash of whole backend keyspace,
- // including key, lease, and other buckets in storage.
- // This is designed for testing ONLY!
- // Do not rely on this in production with ongoing transactions,
- // since Hash operation does not hold MVCC locks.
- // Use "HashKV" API instead for "key" bucket consistency checks.
- Hash(ctx context.Context, in *HashRequest, opts ...grpc.CallOption) (*HashResponse, error)
- // HashKV computes the hash of all MVCC keys up to a given revision.
- // It only iterates "key" bucket in backend storage.
- HashKV(ctx context.Context, in *HashKVRequest, opts ...grpc.CallOption) (*HashKVResponse, error)
- // Snapshot sends a snapshot of the entire backend from a member over a stream to a client.
- Snapshot(ctx context.Context, in *SnapshotRequest, opts ...grpc.CallOption) (Maintenance_SnapshotClient, error)
- // MoveLeader requests current leader node to transfer its leadership to transferee.
- MoveLeader(ctx context.Context, in *MoveLeaderRequest, opts ...grpc.CallOption) (*MoveLeaderResponse, error)
-}
-
-type maintenanceClient struct {
- cc *grpc.ClientConn
-}
-
-func NewMaintenanceClient(cc *grpc.ClientConn) MaintenanceClient {
- return &maintenanceClient{cc}
-}
-
-func (c *maintenanceClient) Alarm(ctx context.Context, in *AlarmRequest, opts ...grpc.CallOption) (*AlarmResponse, error) {
- out := new(AlarmResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Maintenance/Alarm", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *maintenanceClient) Status(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*StatusResponse, error) {
- out := new(StatusResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Maintenance/Status", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *maintenanceClient) Defragment(ctx context.Context, in *DefragmentRequest, opts ...grpc.CallOption) (*DefragmentResponse, error) {
- out := new(DefragmentResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Maintenance/Defragment", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *maintenanceClient) Hash(ctx context.Context, in *HashRequest, opts ...grpc.CallOption) (*HashResponse, error) {
- out := new(HashResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Maintenance/Hash", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *maintenanceClient) HashKV(ctx context.Context, in *HashKVRequest, opts ...grpc.CallOption) (*HashKVResponse, error) {
- out := new(HashKVResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Maintenance/HashKV", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *maintenanceClient) Snapshot(ctx context.Context, in *SnapshotRequest, opts ...grpc.CallOption) (Maintenance_SnapshotClient, error) {
- stream, err := grpc.NewClientStream(ctx, &_Maintenance_serviceDesc.Streams[0], c.cc, "/etcdserverpb.Maintenance/Snapshot", opts...)
- if err != nil {
- return nil, err
- }
- x := &maintenanceSnapshotClient{stream}
- if err := x.ClientStream.SendMsg(in); err != nil {
- return nil, err
- }
- if err := x.ClientStream.CloseSend(); err != nil {
- return nil, err
- }
- return x, nil
-}
-
-type Maintenance_SnapshotClient interface {
- Recv() (*SnapshotResponse, error)
- grpc.ClientStream
-}
-
-type maintenanceSnapshotClient struct {
- grpc.ClientStream
-}
-
-func (x *maintenanceSnapshotClient) Recv() (*SnapshotResponse, error) {
- m := new(SnapshotResponse)
- if err := x.ClientStream.RecvMsg(m); err != nil {
- return nil, err
- }
- return m, nil
-}
-
-func (c *maintenanceClient) MoveLeader(ctx context.Context, in *MoveLeaderRequest, opts ...grpc.CallOption) (*MoveLeaderResponse, error) {
- out := new(MoveLeaderResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Maintenance/MoveLeader", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-// Server API for Maintenance service
-
-type MaintenanceServer interface {
- // Alarm activates, deactivates, and queries alarms regarding cluster health.
- Alarm(context.Context, *AlarmRequest) (*AlarmResponse, error)
- // Status gets the status of the member.
- Status(context.Context, *StatusRequest) (*StatusResponse, error)
- // Defragment defragments a member's backend database to recover storage space.
- Defragment(context.Context, *DefragmentRequest) (*DefragmentResponse, error)
- // Hash computes the hash of whole backend keyspace,
- // including key, lease, and other buckets in storage.
- // This is designed for testing ONLY!
- // Do not rely on this in production with ongoing transactions,
- // since Hash operation does not hold MVCC locks.
- // Use "HashKV" API instead for "key" bucket consistency checks.
- Hash(context.Context, *HashRequest) (*HashResponse, error)
- // HashKV computes the hash of all MVCC keys up to a given revision.
- // It only iterates "key" bucket in backend storage.
- HashKV(context.Context, *HashKVRequest) (*HashKVResponse, error)
- // Snapshot sends a snapshot of the entire backend from a member over a stream to a client.
- Snapshot(*SnapshotRequest, Maintenance_SnapshotServer) error
- // MoveLeader requests current leader node to transfer its leadership to transferee.
- MoveLeader(context.Context, *MoveLeaderRequest) (*MoveLeaderResponse, error)
-}
-
-func RegisterMaintenanceServer(s *grpc.Server, srv MaintenanceServer) {
- s.RegisterService(&_Maintenance_serviceDesc, srv)
-}
-
-func _Maintenance_Alarm_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(AlarmRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(MaintenanceServer).Alarm(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Maintenance/Alarm",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(MaintenanceServer).Alarm(ctx, req.(*AlarmRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Maintenance_Status_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(StatusRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(MaintenanceServer).Status(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Maintenance/Status",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(MaintenanceServer).Status(ctx, req.(*StatusRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Maintenance_Defragment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(DefragmentRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(MaintenanceServer).Defragment(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Maintenance/Defragment",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(MaintenanceServer).Defragment(ctx, req.(*DefragmentRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Maintenance_Hash_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(HashRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(MaintenanceServer).Hash(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Maintenance/Hash",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(MaintenanceServer).Hash(ctx, req.(*HashRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Maintenance_HashKV_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(HashKVRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(MaintenanceServer).HashKV(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Maintenance/HashKV",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(MaintenanceServer).HashKV(ctx, req.(*HashKVRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Maintenance_Snapshot_Handler(srv interface{}, stream grpc.ServerStream) error {
- m := new(SnapshotRequest)
- if err := stream.RecvMsg(m); err != nil {
- return err
- }
- return srv.(MaintenanceServer).Snapshot(m, &maintenanceSnapshotServer{stream})
-}
-
-type Maintenance_SnapshotServer interface {
- Send(*SnapshotResponse) error
- grpc.ServerStream
-}
-
-type maintenanceSnapshotServer struct {
- grpc.ServerStream
-}
-
-func (x *maintenanceSnapshotServer) Send(m *SnapshotResponse) error {
- return x.ServerStream.SendMsg(m)
-}
-
-func _Maintenance_MoveLeader_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(MoveLeaderRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(MaintenanceServer).MoveLeader(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Maintenance/MoveLeader",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(MaintenanceServer).MoveLeader(ctx, req.(*MoveLeaderRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-var _Maintenance_serviceDesc = grpc.ServiceDesc{
- ServiceName: "etcdserverpb.Maintenance",
- HandlerType: (*MaintenanceServer)(nil),
- Methods: []grpc.MethodDesc{
- {
- MethodName: "Alarm",
- Handler: _Maintenance_Alarm_Handler,
- },
- {
- MethodName: "Status",
- Handler: _Maintenance_Status_Handler,
- },
- {
- MethodName: "Defragment",
- Handler: _Maintenance_Defragment_Handler,
- },
- {
- MethodName: "Hash",
- Handler: _Maintenance_Hash_Handler,
- },
- {
- MethodName: "HashKV",
- Handler: _Maintenance_HashKV_Handler,
- },
- {
- MethodName: "MoveLeader",
- Handler: _Maintenance_MoveLeader_Handler,
- },
- },
- Streams: []grpc.StreamDesc{
- {
- StreamName: "Snapshot",
- Handler: _Maintenance_Snapshot_Handler,
- ServerStreams: true,
- },
- },
- Metadata: "rpc.proto",
-}
-
-// Client API for Auth service
-
-type AuthClient interface {
- // AuthEnable enables authentication.
- AuthEnable(ctx context.Context, in *AuthEnableRequest, opts ...grpc.CallOption) (*AuthEnableResponse, error)
- // AuthDisable disables authentication.
- AuthDisable(ctx context.Context, in *AuthDisableRequest, opts ...grpc.CallOption) (*AuthDisableResponse, error)
- // Authenticate processes an authenticate request.
- Authenticate(ctx context.Context, in *AuthenticateRequest, opts ...grpc.CallOption) (*AuthenticateResponse, error)
- // UserAdd adds a new user. User name cannot be empty.
- UserAdd(ctx context.Context, in *AuthUserAddRequest, opts ...grpc.CallOption) (*AuthUserAddResponse, error)
- // UserGet gets detailed user information.
- UserGet(ctx context.Context, in *AuthUserGetRequest, opts ...grpc.CallOption) (*AuthUserGetResponse, error)
- // UserList gets a list of all users.
- UserList(ctx context.Context, in *AuthUserListRequest, opts ...grpc.CallOption) (*AuthUserListResponse, error)
- // UserDelete deletes a specified user.
- UserDelete(ctx context.Context, in *AuthUserDeleteRequest, opts ...grpc.CallOption) (*AuthUserDeleteResponse, error)
- // UserChangePassword changes the password of a specified user.
- UserChangePassword(ctx context.Context, in *AuthUserChangePasswordRequest, opts ...grpc.CallOption) (*AuthUserChangePasswordResponse, error)
- // UserGrant grants a role to a specified user.
- UserGrantRole(ctx context.Context, in *AuthUserGrantRoleRequest, opts ...grpc.CallOption) (*AuthUserGrantRoleResponse, error)
- // UserRevokeRole revokes a role of specified user.
- UserRevokeRole(ctx context.Context, in *AuthUserRevokeRoleRequest, opts ...grpc.CallOption) (*AuthUserRevokeRoleResponse, error)
- // RoleAdd adds a new role. Role name cannot be empty.
- RoleAdd(ctx context.Context, in *AuthRoleAddRequest, opts ...grpc.CallOption) (*AuthRoleAddResponse, error)
- // RoleGet gets detailed role information.
- RoleGet(ctx context.Context, in *AuthRoleGetRequest, opts ...grpc.CallOption) (*AuthRoleGetResponse, error)
- // RoleList gets lists of all roles.
- RoleList(ctx context.Context, in *AuthRoleListRequest, opts ...grpc.CallOption) (*AuthRoleListResponse, error)
- // RoleDelete deletes a specified role.
- RoleDelete(ctx context.Context, in *AuthRoleDeleteRequest, opts ...grpc.CallOption) (*AuthRoleDeleteResponse, error)
- // RoleGrantPermission grants a permission of a specified key or range to a specified role.
- RoleGrantPermission(ctx context.Context, in *AuthRoleGrantPermissionRequest, opts ...grpc.CallOption) (*AuthRoleGrantPermissionResponse, error)
- // RoleRevokePermission revokes a key or range permission of a specified role.
- RoleRevokePermission(ctx context.Context, in *AuthRoleRevokePermissionRequest, opts ...grpc.CallOption) (*AuthRoleRevokePermissionResponse, error)
-}
-
-type authClient struct {
- cc *grpc.ClientConn
-}
-
-func NewAuthClient(cc *grpc.ClientConn) AuthClient {
- return &authClient{cc}
-}
-
-func (c *authClient) AuthEnable(ctx context.Context, in *AuthEnableRequest, opts ...grpc.CallOption) (*AuthEnableResponse, error) {
- out := new(AuthEnableResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Auth/AuthEnable", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *authClient) AuthDisable(ctx context.Context, in *AuthDisableRequest, opts ...grpc.CallOption) (*AuthDisableResponse, error) {
- out := new(AuthDisableResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Auth/AuthDisable", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *authClient) Authenticate(ctx context.Context, in *AuthenticateRequest, opts ...grpc.CallOption) (*AuthenticateResponse, error) {
- out := new(AuthenticateResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Auth/Authenticate", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *authClient) UserAdd(ctx context.Context, in *AuthUserAddRequest, opts ...grpc.CallOption) (*AuthUserAddResponse, error) {
- out := new(AuthUserAddResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Auth/UserAdd", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *authClient) UserGet(ctx context.Context, in *AuthUserGetRequest, opts ...grpc.CallOption) (*AuthUserGetResponse, error) {
- out := new(AuthUserGetResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Auth/UserGet", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *authClient) UserList(ctx context.Context, in *AuthUserListRequest, opts ...grpc.CallOption) (*AuthUserListResponse, error) {
- out := new(AuthUserListResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Auth/UserList", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *authClient) UserDelete(ctx context.Context, in *AuthUserDeleteRequest, opts ...grpc.CallOption) (*AuthUserDeleteResponse, error) {
- out := new(AuthUserDeleteResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Auth/UserDelete", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *authClient) UserChangePassword(ctx context.Context, in *AuthUserChangePasswordRequest, opts ...grpc.CallOption) (*AuthUserChangePasswordResponse, error) {
- out := new(AuthUserChangePasswordResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Auth/UserChangePassword", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *authClient) UserGrantRole(ctx context.Context, in *AuthUserGrantRoleRequest, opts ...grpc.CallOption) (*AuthUserGrantRoleResponse, error) {
- out := new(AuthUserGrantRoleResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Auth/UserGrantRole", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *authClient) UserRevokeRole(ctx context.Context, in *AuthUserRevokeRoleRequest, opts ...grpc.CallOption) (*AuthUserRevokeRoleResponse, error) {
- out := new(AuthUserRevokeRoleResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Auth/UserRevokeRole", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *authClient) RoleAdd(ctx context.Context, in *AuthRoleAddRequest, opts ...grpc.CallOption) (*AuthRoleAddResponse, error) {
- out := new(AuthRoleAddResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Auth/RoleAdd", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *authClient) RoleGet(ctx context.Context, in *AuthRoleGetRequest, opts ...grpc.CallOption) (*AuthRoleGetResponse, error) {
- out := new(AuthRoleGetResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Auth/RoleGet", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *authClient) RoleList(ctx context.Context, in *AuthRoleListRequest, opts ...grpc.CallOption) (*AuthRoleListResponse, error) {
- out := new(AuthRoleListResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Auth/RoleList", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *authClient) RoleDelete(ctx context.Context, in *AuthRoleDeleteRequest, opts ...grpc.CallOption) (*AuthRoleDeleteResponse, error) {
- out := new(AuthRoleDeleteResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Auth/RoleDelete", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *authClient) RoleGrantPermission(ctx context.Context, in *AuthRoleGrantPermissionRequest, opts ...grpc.CallOption) (*AuthRoleGrantPermissionResponse, error) {
- out := new(AuthRoleGrantPermissionResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Auth/RoleGrantPermission", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *authClient) RoleRevokePermission(ctx context.Context, in *AuthRoleRevokePermissionRequest, opts ...grpc.CallOption) (*AuthRoleRevokePermissionResponse, error) {
- out := new(AuthRoleRevokePermissionResponse)
- err := grpc.Invoke(ctx, "/etcdserverpb.Auth/RoleRevokePermission", in, out, c.cc, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-// Server API for Auth service
-
-type AuthServer interface {
- // AuthEnable enables authentication.
- AuthEnable(context.Context, *AuthEnableRequest) (*AuthEnableResponse, error)
- // AuthDisable disables authentication.
- AuthDisable(context.Context, *AuthDisableRequest) (*AuthDisableResponse, error)
- // Authenticate processes an authenticate request.
- Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error)
- // UserAdd adds a new user. User name cannot be empty.
- UserAdd(context.Context, *AuthUserAddRequest) (*AuthUserAddResponse, error)
- // UserGet gets detailed user information.
- UserGet(context.Context, *AuthUserGetRequest) (*AuthUserGetResponse, error)
- // UserList gets a list of all users.
- UserList(context.Context, *AuthUserListRequest) (*AuthUserListResponse, error)
- // UserDelete deletes a specified user.
- UserDelete(context.Context, *AuthUserDeleteRequest) (*AuthUserDeleteResponse, error)
- // UserChangePassword changes the password of a specified user.
- UserChangePassword(context.Context, *AuthUserChangePasswordRequest) (*AuthUserChangePasswordResponse, error)
- // UserGrant grants a role to a specified user.
- UserGrantRole(context.Context, *AuthUserGrantRoleRequest) (*AuthUserGrantRoleResponse, error)
- // UserRevokeRole revokes a role of specified user.
- UserRevokeRole(context.Context, *AuthUserRevokeRoleRequest) (*AuthUserRevokeRoleResponse, error)
- // RoleAdd adds a new role. Role name cannot be empty.
- RoleAdd(context.Context, *AuthRoleAddRequest) (*AuthRoleAddResponse, error)
- // RoleGet gets detailed role information.
- RoleGet(context.Context, *AuthRoleGetRequest) (*AuthRoleGetResponse, error)
- // RoleList gets lists of all roles.
- RoleList(context.Context, *AuthRoleListRequest) (*AuthRoleListResponse, error)
- // RoleDelete deletes a specified role.
- RoleDelete(context.Context, *AuthRoleDeleteRequest) (*AuthRoleDeleteResponse, error)
- // RoleGrantPermission grants a permission of a specified key or range to a specified role.
- RoleGrantPermission(context.Context, *AuthRoleGrantPermissionRequest) (*AuthRoleGrantPermissionResponse, error)
- // RoleRevokePermission revokes a key or range permission of a specified role.
- RoleRevokePermission(context.Context, *AuthRoleRevokePermissionRequest) (*AuthRoleRevokePermissionResponse, error)
-}
-
-func RegisterAuthServer(s *grpc.Server, srv AuthServer) {
- s.RegisterService(&_Auth_serviceDesc, srv)
-}
-
-func _Auth_AuthEnable_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(AuthEnableRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(AuthServer).AuthEnable(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Auth/AuthEnable",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(AuthServer).AuthEnable(ctx, req.(*AuthEnableRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Auth_AuthDisable_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(AuthDisableRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(AuthServer).AuthDisable(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Auth/AuthDisable",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(AuthServer).AuthDisable(ctx, req.(*AuthDisableRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Auth_Authenticate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(AuthenticateRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(AuthServer).Authenticate(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Auth/Authenticate",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(AuthServer).Authenticate(ctx, req.(*AuthenticateRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Auth_UserAdd_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(AuthUserAddRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(AuthServer).UserAdd(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Auth/UserAdd",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(AuthServer).UserAdd(ctx, req.(*AuthUserAddRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Auth_UserGet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(AuthUserGetRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(AuthServer).UserGet(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Auth/UserGet",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(AuthServer).UserGet(ctx, req.(*AuthUserGetRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Auth_UserList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(AuthUserListRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(AuthServer).UserList(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Auth/UserList",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(AuthServer).UserList(ctx, req.(*AuthUserListRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Auth_UserDelete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(AuthUserDeleteRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(AuthServer).UserDelete(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Auth/UserDelete",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(AuthServer).UserDelete(ctx, req.(*AuthUserDeleteRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Auth_UserChangePassword_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(AuthUserChangePasswordRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(AuthServer).UserChangePassword(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Auth/UserChangePassword",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(AuthServer).UserChangePassword(ctx, req.(*AuthUserChangePasswordRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Auth_UserGrantRole_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(AuthUserGrantRoleRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(AuthServer).UserGrantRole(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Auth/UserGrantRole",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(AuthServer).UserGrantRole(ctx, req.(*AuthUserGrantRoleRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Auth_UserRevokeRole_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(AuthUserRevokeRoleRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(AuthServer).UserRevokeRole(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Auth/UserRevokeRole",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(AuthServer).UserRevokeRole(ctx, req.(*AuthUserRevokeRoleRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Auth_RoleAdd_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(AuthRoleAddRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(AuthServer).RoleAdd(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Auth/RoleAdd",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(AuthServer).RoleAdd(ctx, req.(*AuthRoleAddRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Auth_RoleGet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(AuthRoleGetRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(AuthServer).RoleGet(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Auth/RoleGet",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(AuthServer).RoleGet(ctx, req.(*AuthRoleGetRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Auth_RoleList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(AuthRoleListRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(AuthServer).RoleList(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Auth/RoleList",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(AuthServer).RoleList(ctx, req.(*AuthRoleListRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Auth_RoleDelete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(AuthRoleDeleteRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(AuthServer).RoleDelete(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Auth/RoleDelete",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(AuthServer).RoleDelete(ctx, req.(*AuthRoleDeleteRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Auth_RoleGrantPermission_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(AuthRoleGrantPermissionRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(AuthServer).RoleGrantPermission(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Auth/RoleGrantPermission",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(AuthServer).RoleGrantPermission(ctx, req.(*AuthRoleGrantPermissionRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Auth_RoleRevokePermission_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(AuthRoleRevokePermissionRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(AuthServer).RoleRevokePermission(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/etcdserverpb.Auth/RoleRevokePermission",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(AuthServer).RoleRevokePermission(ctx, req.(*AuthRoleRevokePermissionRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-var _Auth_serviceDesc = grpc.ServiceDesc{
- ServiceName: "etcdserverpb.Auth",
- HandlerType: (*AuthServer)(nil),
- Methods: []grpc.MethodDesc{
- {
- MethodName: "AuthEnable",
- Handler: _Auth_AuthEnable_Handler,
- },
- {
- MethodName: "AuthDisable",
- Handler: _Auth_AuthDisable_Handler,
- },
- {
- MethodName: "Authenticate",
- Handler: _Auth_Authenticate_Handler,
- },
- {
- MethodName: "UserAdd",
- Handler: _Auth_UserAdd_Handler,
- },
- {
- MethodName: "UserGet",
- Handler: _Auth_UserGet_Handler,
- },
- {
- MethodName: "UserList",
- Handler: _Auth_UserList_Handler,
- },
- {
- MethodName: "UserDelete",
- Handler: _Auth_UserDelete_Handler,
- },
- {
- MethodName: "UserChangePassword",
- Handler: _Auth_UserChangePassword_Handler,
- },
- {
- MethodName: "UserGrantRole",
- Handler: _Auth_UserGrantRole_Handler,
- },
- {
- MethodName: "UserRevokeRole",
- Handler: _Auth_UserRevokeRole_Handler,
- },
- {
- MethodName: "RoleAdd",
- Handler: _Auth_RoleAdd_Handler,
- },
- {
- MethodName: "RoleGet",
- Handler: _Auth_RoleGet_Handler,
- },
- {
- MethodName: "RoleList",
- Handler: _Auth_RoleList_Handler,
- },
- {
- MethodName: "RoleDelete",
- Handler: _Auth_RoleDelete_Handler,
- },
- {
- MethodName: "RoleGrantPermission",
- Handler: _Auth_RoleGrantPermission_Handler,
- },
- {
- MethodName: "RoleRevokePermission",
- Handler: _Auth_RoleRevokePermission_Handler,
- },
- },
- Streams: []grpc.StreamDesc{},
- Metadata: "rpc.proto",
-}
-
-func (m *ResponseHeader) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *ResponseHeader) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.ClusterId != 0 {
- dAtA[i] = 0x8
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.ClusterId))
- }
- if m.MemberId != 0 {
- dAtA[i] = 0x10
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.MemberId))
- }
- if m.Revision != 0 {
- dAtA[i] = 0x18
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Revision))
- }
- if m.RaftTerm != 0 {
- dAtA[i] = 0x20
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.RaftTerm))
- }
- return i, nil
-}
-
-func (m *RangeRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *RangeRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if len(m.Key) > 0 {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.Key)))
- i += copy(dAtA[i:], m.Key)
- }
- if len(m.RangeEnd) > 0 {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.RangeEnd)))
- i += copy(dAtA[i:], m.RangeEnd)
- }
- if m.Limit != 0 {
- dAtA[i] = 0x18
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Limit))
- }
- if m.Revision != 0 {
- dAtA[i] = 0x20
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Revision))
- }
- if m.SortOrder != 0 {
- dAtA[i] = 0x28
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.SortOrder))
- }
- if m.SortTarget != 0 {
- dAtA[i] = 0x30
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.SortTarget))
- }
- if m.Serializable {
- dAtA[i] = 0x38
- i++
- if m.Serializable {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i++
- }
- if m.KeysOnly {
- dAtA[i] = 0x40
- i++
- if m.KeysOnly {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i++
- }
- if m.CountOnly {
- dAtA[i] = 0x48
- i++
- if m.CountOnly {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i++
- }
- if m.MinModRevision != 0 {
- dAtA[i] = 0x50
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.MinModRevision))
- }
- if m.MaxModRevision != 0 {
- dAtA[i] = 0x58
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.MaxModRevision))
- }
- if m.MinCreateRevision != 0 {
- dAtA[i] = 0x60
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.MinCreateRevision))
- }
- if m.MaxCreateRevision != 0 {
- dAtA[i] = 0x68
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.MaxCreateRevision))
- }
- return i, nil
-}
-
-func (m *RangeResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *RangeResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n1, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n1
- }
- if len(m.Kvs) > 0 {
- for _, msg := range m.Kvs {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRpc(dAtA, i, uint64(msg.Size()))
- n, err := msg.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n
- }
- }
- if m.More {
- dAtA[i] = 0x18
- i++
- if m.More {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i++
- }
- if m.Count != 0 {
- dAtA[i] = 0x20
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Count))
- }
- return i, nil
-}
-
-func (m *PutRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *PutRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if len(m.Key) > 0 {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.Key)))
- i += copy(dAtA[i:], m.Key)
- }
- if len(m.Value) > 0 {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.Value)))
- i += copy(dAtA[i:], m.Value)
- }
- if m.Lease != 0 {
- dAtA[i] = 0x18
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Lease))
- }
- if m.PrevKv {
- dAtA[i] = 0x20
- i++
- if m.PrevKv {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i++
- }
- if m.IgnoreValue {
- dAtA[i] = 0x28
- i++
- if m.IgnoreValue {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i++
- }
- if m.IgnoreLease {
- dAtA[i] = 0x30
- i++
- if m.IgnoreLease {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i++
- }
- return i, nil
-}
-
-func (m *PutResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *PutResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n2, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n2
- }
- if m.PrevKv != nil {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.PrevKv.Size()))
- n3, err := m.PrevKv.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n3
- }
- return i, nil
-}
-
-func (m *DeleteRangeRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *DeleteRangeRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if len(m.Key) > 0 {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.Key)))
- i += copy(dAtA[i:], m.Key)
- }
- if len(m.RangeEnd) > 0 {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.RangeEnd)))
- i += copy(dAtA[i:], m.RangeEnd)
- }
- if m.PrevKv {
- dAtA[i] = 0x18
- i++
- if m.PrevKv {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i++
- }
- return i, nil
-}
-
-func (m *DeleteRangeResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *DeleteRangeResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n4, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n4
- }
- if m.Deleted != 0 {
- dAtA[i] = 0x10
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Deleted))
- }
- if len(m.PrevKvs) > 0 {
- for _, msg := range m.PrevKvs {
- dAtA[i] = 0x1a
- i++
- i = encodeVarintRpc(dAtA, i, uint64(msg.Size()))
- n, err := msg.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n
- }
- }
- return i, nil
-}
-
-func (m *RequestOp) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *RequestOp) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Request != nil {
- nn5, err := m.Request.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += nn5
- }
- return i, nil
-}
-
-func (m *RequestOp_RequestRange) MarshalTo(dAtA []byte) (int, error) {
- i := 0
- if m.RequestRange != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.RequestRange.Size()))
- n6, err := m.RequestRange.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n6
- }
- return i, nil
-}
-func (m *RequestOp_RequestPut) MarshalTo(dAtA []byte) (int, error) {
- i := 0
- if m.RequestPut != nil {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.RequestPut.Size()))
- n7, err := m.RequestPut.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n7
- }
- return i, nil
-}
-func (m *RequestOp_RequestDeleteRange) MarshalTo(dAtA []byte) (int, error) {
- i := 0
- if m.RequestDeleteRange != nil {
- dAtA[i] = 0x1a
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.RequestDeleteRange.Size()))
- n8, err := m.RequestDeleteRange.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n8
- }
- return i, nil
-}
-func (m *RequestOp_RequestTxn) MarshalTo(dAtA []byte) (int, error) {
- i := 0
- if m.RequestTxn != nil {
- dAtA[i] = 0x22
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.RequestTxn.Size()))
- n9, err := m.RequestTxn.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n9
- }
- return i, nil
-}
-func (m *ResponseOp) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *ResponseOp) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Response != nil {
- nn10, err := m.Response.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += nn10
- }
- return i, nil
-}
-
-func (m *ResponseOp_ResponseRange) MarshalTo(dAtA []byte) (int, error) {
- i := 0
- if m.ResponseRange != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.ResponseRange.Size()))
- n11, err := m.ResponseRange.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n11
- }
- return i, nil
-}
-func (m *ResponseOp_ResponsePut) MarshalTo(dAtA []byte) (int, error) {
- i := 0
- if m.ResponsePut != nil {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.ResponsePut.Size()))
- n12, err := m.ResponsePut.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n12
- }
- return i, nil
-}
-func (m *ResponseOp_ResponseDeleteRange) MarshalTo(dAtA []byte) (int, error) {
- i := 0
- if m.ResponseDeleteRange != nil {
- dAtA[i] = 0x1a
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.ResponseDeleteRange.Size()))
- n13, err := m.ResponseDeleteRange.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n13
- }
- return i, nil
-}
-func (m *ResponseOp_ResponseTxn) MarshalTo(dAtA []byte) (int, error) {
- i := 0
- if m.ResponseTxn != nil {
- dAtA[i] = 0x22
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.ResponseTxn.Size()))
- n14, err := m.ResponseTxn.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n14
- }
- return i, nil
-}
-func (m *Compare) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *Compare) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Result != 0 {
- dAtA[i] = 0x8
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Result))
- }
- if m.Target != 0 {
- dAtA[i] = 0x10
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Target))
- }
- if len(m.Key) > 0 {
- dAtA[i] = 0x1a
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.Key)))
- i += copy(dAtA[i:], m.Key)
- }
- if m.TargetUnion != nil {
- nn15, err := m.TargetUnion.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += nn15
- }
- if len(m.RangeEnd) > 0 {
- dAtA[i] = 0x82
- i++
- dAtA[i] = 0x4
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.RangeEnd)))
- i += copy(dAtA[i:], m.RangeEnd)
- }
- return i, nil
-}
-
-func (m *Compare_Version) MarshalTo(dAtA []byte) (int, error) {
- i := 0
- dAtA[i] = 0x20
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Version))
- return i, nil
-}
-func (m *Compare_CreateRevision) MarshalTo(dAtA []byte) (int, error) {
- i := 0
- dAtA[i] = 0x28
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.CreateRevision))
- return i, nil
-}
-func (m *Compare_ModRevision) MarshalTo(dAtA []byte) (int, error) {
- i := 0
- dAtA[i] = 0x30
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.ModRevision))
- return i, nil
-}
-func (m *Compare_Value) MarshalTo(dAtA []byte) (int, error) {
- i := 0
- if m.Value != nil {
- dAtA[i] = 0x3a
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.Value)))
- i += copy(dAtA[i:], m.Value)
- }
- return i, nil
-}
-func (m *Compare_Lease) MarshalTo(dAtA []byte) (int, error) {
- i := 0
- dAtA[i] = 0x40
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Lease))
- return i, nil
-}
-func (m *TxnRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *TxnRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if len(m.Compare) > 0 {
- for _, msg := range m.Compare {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(msg.Size()))
- n, err := msg.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n
- }
- }
- if len(m.Success) > 0 {
- for _, msg := range m.Success {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRpc(dAtA, i, uint64(msg.Size()))
- n, err := msg.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n
- }
- }
- if len(m.Failure) > 0 {
- for _, msg := range m.Failure {
- dAtA[i] = 0x1a
- i++
- i = encodeVarintRpc(dAtA, i, uint64(msg.Size()))
- n, err := msg.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n
- }
- }
- return i, nil
-}
-
-func (m *TxnResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *TxnResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n16, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n16
- }
- if m.Succeeded {
- dAtA[i] = 0x10
- i++
- if m.Succeeded {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i++
- }
- if len(m.Responses) > 0 {
- for _, msg := range m.Responses {
- dAtA[i] = 0x1a
- i++
- i = encodeVarintRpc(dAtA, i, uint64(msg.Size()))
- n, err := msg.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n
- }
- }
- return i, nil
-}
-
-func (m *CompactionRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *CompactionRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Revision != 0 {
- dAtA[i] = 0x8
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Revision))
- }
- if m.Physical {
- dAtA[i] = 0x10
- i++
- if m.Physical {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i++
- }
- return i, nil
-}
-
-func (m *CompactionResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *CompactionResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n17, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n17
- }
- return i, nil
-}
-
-func (m *HashRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *HashRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- return i, nil
-}
-
-func (m *HashKVRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *HashKVRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Revision != 0 {
- dAtA[i] = 0x8
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Revision))
- }
- return i, nil
-}
-
-func (m *HashKVResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *HashKVResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n18, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n18
- }
- if m.Hash != 0 {
- dAtA[i] = 0x10
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Hash))
- }
- if m.CompactRevision != 0 {
- dAtA[i] = 0x18
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.CompactRevision))
- }
- return i, nil
-}
-
-func (m *HashResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *HashResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n19, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n19
- }
- if m.Hash != 0 {
- dAtA[i] = 0x10
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Hash))
- }
- return i, nil
-}
-
-func (m *SnapshotRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *SnapshotRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- return i, nil
-}
-
-func (m *SnapshotResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *SnapshotResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n20, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n20
- }
- if m.RemainingBytes != 0 {
- dAtA[i] = 0x10
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.RemainingBytes))
- }
- if len(m.Blob) > 0 {
- dAtA[i] = 0x1a
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.Blob)))
- i += copy(dAtA[i:], m.Blob)
- }
- return i, nil
-}
-
-func (m *WatchRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *WatchRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.RequestUnion != nil {
- nn21, err := m.RequestUnion.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += nn21
- }
- return i, nil
-}
-
-func (m *WatchRequest_CreateRequest) MarshalTo(dAtA []byte) (int, error) {
- i := 0
- if m.CreateRequest != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.CreateRequest.Size()))
- n22, err := m.CreateRequest.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n22
- }
- return i, nil
-}
-func (m *WatchRequest_CancelRequest) MarshalTo(dAtA []byte) (int, error) {
- i := 0
- if m.CancelRequest != nil {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.CancelRequest.Size()))
- n23, err := m.CancelRequest.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n23
- }
- return i, nil
-}
-func (m *WatchRequest_ProgressRequest) MarshalTo(dAtA []byte) (int, error) {
- i := 0
- if m.ProgressRequest != nil {
- dAtA[i] = 0x1a
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.ProgressRequest.Size()))
- n24, err := m.ProgressRequest.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n24
- }
- return i, nil
-}
-func (m *WatchCreateRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *WatchCreateRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if len(m.Key) > 0 {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.Key)))
- i += copy(dAtA[i:], m.Key)
- }
- if len(m.RangeEnd) > 0 {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.RangeEnd)))
- i += copy(dAtA[i:], m.RangeEnd)
- }
- if m.StartRevision != 0 {
- dAtA[i] = 0x18
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.StartRevision))
- }
- if m.ProgressNotify {
- dAtA[i] = 0x20
- i++
- if m.ProgressNotify {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i++
- }
- if len(m.Filters) > 0 {
- dAtA26 := make([]byte, len(m.Filters)*10)
- var j25 int
- for _, num := range m.Filters {
- for num >= 1<<7 {
- dAtA26[j25] = uint8(uint64(num)&0x7f | 0x80)
- num >>= 7
- j25++
- }
- dAtA26[j25] = uint8(num)
- j25++
- }
- dAtA[i] = 0x2a
- i++
- i = encodeVarintRpc(dAtA, i, uint64(j25))
- i += copy(dAtA[i:], dAtA26[:j25])
- }
- if m.PrevKv {
- dAtA[i] = 0x30
- i++
- if m.PrevKv {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i++
- }
- if m.WatchId != 0 {
- dAtA[i] = 0x38
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.WatchId))
- }
- if m.Fragment {
- dAtA[i] = 0x40
- i++
- if m.Fragment {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i++
- }
- return i, nil
-}
-
-func (m *WatchCancelRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *WatchCancelRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.WatchId != 0 {
- dAtA[i] = 0x8
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.WatchId))
- }
- return i, nil
-}
-
-func (m *WatchProgressRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *WatchProgressRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- return i, nil
-}
-
-func (m *WatchResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *WatchResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n27, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n27
- }
- if m.WatchId != 0 {
- dAtA[i] = 0x10
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.WatchId))
- }
- if m.Created {
- dAtA[i] = 0x18
- i++
- if m.Created {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i++
- }
- if m.Canceled {
- dAtA[i] = 0x20
- i++
- if m.Canceled {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i++
- }
- if m.CompactRevision != 0 {
- dAtA[i] = 0x28
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.CompactRevision))
- }
- if len(m.CancelReason) > 0 {
- dAtA[i] = 0x32
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.CancelReason)))
- i += copy(dAtA[i:], m.CancelReason)
- }
- if m.Fragment {
- dAtA[i] = 0x38
- i++
- if m.Fragment {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i++
- }
- if len(m.Events) > 0 {
- for _, msg := range m.Events {
- dAtA[i] = 0x5a
- i++
- i = encodeVarintRpc(dAtA, i, uint64(msg.Size()))
- n, err := msg.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n
- }
- }
- return i, nil
-}
-
-func (m *LeaseGrantRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *LeaseGrantRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.TTL != 0 {
- dAtA[i] = 0x8
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.TTL))
- }
- if m.ID != 0 {
- dAtA[i] = 0x10
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.ID))
- }
- return i, nil
-}
-
-func (m *LeaseGrantResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *LeaseGrantResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n28, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n28
- }
- if m.ID != 0 {
- dAtA[i] = 0x10
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.ID))
- }
- if m.TTL != 0 {
- dAtA[i] = 0x18
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.TTL))
- }
- if len(m.Error) > 0 {
- dAtA[i] = 0x22
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.Error)))
- i += copy(dAtA[i:], m.Error)
- }
- return i, nil
-}
-
-func (m *LeaseRevokeRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *LeaseRevokeRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.ID != 0 {
- dAtA[i] = 0x8
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.ID))
- }
- return i, nil
-}
-
-func (m *LeaseRevokeResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *LeaseRevokeResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n29, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n29
- }
- return i, nil
-}
-
-func (m *LeaseCheckpoint) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *LeaseCheckpoint) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.ID != 0 {
- dAtA[i] = 0x8
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.ID))
- }
- if m.Remaining_TTL != 0 {
- dAtA[i] = 0x10
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Remaining_TTL))
- }
- return i, nil
-}
-
-func (m *LeaseCheckpointRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *LeaseCheckpointRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if len(m.Checkpoints) > 0 {
- for _, msg := range m.Checkpoints {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(msg.Size()))
- n, err := msg.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n
- }
- }
- return i, nil
-}
-
-func (m *LeaseCheckpointResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *LeaseCheckpointResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n30, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n30
- }
- return i, nil
-}
-
-func (m *LeaseKeepAliveRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *LeaseKeepAliveRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.ID != 0 {
- dAtA[i] = 0x8
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.ID))
- }
- return i, nil
-}
-
-func (m *LeaseKeepAliveResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *LeaseKeepAliveResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n31, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n31
- }
- if m.ID != 0 {
- dAtA[i] = 0x10
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.ID))
- }
- if m.TTL != 0 {
- dAtA[i] = 0x18
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.TTL))
- }
- return i, nil
-}
-
-func (m *LeaseTimeToLiveRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *LeaseTimeToLiveRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.ID != 0 {
- dAtA[i] = 0x8
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.ID))
- }
- if m.Keys {
- dAtA[i] = 0x10
- i++
- if m.Keys {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i++
- }
- return i, nil
-}
-
-func (m *LeaseTimeToLiveResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *LeaseTimeToLiveResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n32, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n32
- }
- if m.ID != 0 {
- dAtA[i] = 0x10
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.ID))
- }
- if m.TTL != 0 {
- dAtA[i] = 0x18
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.TTL))
- }
- if m.GrantedTTL != 0 {
- dAtA[i] = 0x20
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.GrantedTTL))
- }
- if len(m.Keys) > 0 {
- for _, b := range m.Keys {
- dAtA[i] = 0x2a
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(b)))
- i += copy(dAtA[i:], b)
- }
- }
- return i, nil
-}
-
-func (m *LeaseLeasesRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *LeaseLeasesRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- return i, nil
-}
-
-func (m *LeaseStatus) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *LeaseStatus) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.ID != 0 {
- dAtA[i] = 0x8
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.ID))
- }
- return i, nil
-}
-
-func (m *LeaseLeasesResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *LeaseLeasesResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n33, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n33
- }
- if len(m.Leases) > 0 {
- for _, msg := range m.Leases {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRpc(dAtA, i, uint64(msg.Size()))
- n, err := msg.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n
- }
- }
- return i, nil
-}
-
-func (m *Member) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *Member) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.ID != 0 {
- dAtA[i] = 0x8
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.ID))
- }
- if len(m.Name) > 0 {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.Name)))
- i += copy(dAtA[i:], m.Name)
- }
- if len(m.PeerURLs) > 0 {
- for _, s := range m.PeerURLs {
- dAtA[i] = 0x1a
- i++
- l = len(s)
- for l >= 1<<7 {
- dAtA[i] = uint8(uint64(l)&0x7f | 0x80)
- l >>= 7
- i++
- }
- dAtA[i] = uint8(l)
- i++
- i += copy(dAtA[i:], s)
- }
- }
- if len(m.ClientURLs) > 0 {
- for _, s := range m.ClientURLs {
- dAtA[i] = 0x22
- i++
- l = len(s)
- for l >= 1<<7 {
- dAtA[i] = uint8(uint64(l)&0x7f | 0x80)
- l >>= 7
- i++
- }
- dAtA[i] = uint8(l)
- i++
- i += copy(dAtA[i:], s)
- }
- }
- if m.IsLearner {
- dAtA[i] = 0x28
- i++
- if m.IsLearner {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i++
- }
- return i, nil
-}
-
-func (m *MemberAddRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MemberAddRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if len(m.PeerURLs) > 0 {
- for _, s := range m.PeerURLs {
- dAtA[i] = 0xa
- i++
- l = len(s)
- for l >= 1<<7 {
- dAtA[i] = uint8(uint64(l)&0x7f | 0x80)
- l >>= 7
- i++
- }
- dAtA[i] = uint8(l)
- i++
- i += copy(dAtA[i:], s)
- }
- }
- if m.IsLearner {
- dAtA[i] = 0x10
- i++
- if m.IsLearner {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i++
- }
- return i, nil
-}
-
-func (m *MemberAddResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MemberAddResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n34, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n34
- }
- if m.Member != nil {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Member.Size()))
- n35, err := m.Member.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n35
- }
- if len(m.Members) > 0 {
- for _, msg := range m.Members {
- dAtA[i] = 0x1a
- i++
- i = encodeVarintRpc(dAtA, i, uint64(msg.Size()))
- n, err := msg.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n
- }
- }
- return i, nil
-}
-
-func (m *MemberRemoveRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MemberRemoveRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.ID != 0 {
- dAtA[i] = 0x8
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.ID))
- }
- return i, nil
-}
-
-func (m *MemberRemoveResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MemberRemoveResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n36, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n36
- }
- if len(m.Members) > 0 {
- for _, msg := range m.Members {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRpc(dAtA, i, uint64(msg.Size()))
- n, err := msg.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n
- }
- }
- return i, nil
-}
-
-func (m *MemberUpdateRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MemberUpdateRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.ID != 0 {
- dAtA[i] = 0x8
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.ID))
- }
- if len(m.PeerURLs) > 0 {
- for _, s := range m.PeerURLs {
- dAtA[i] = 0x12
- i++
- l = len(s)
- for l >= 1<<7 {
- dAtA[i] = uint8(uint64(l)&0x7f | 0x80)
- l >>= 7
- i++
- }
- dAtA[i] = uint8(l)
- i++
- i += copy(dAtA[i:], s)
- }
- }
- return i, nil
-}
-
-func (m *MemberUpdateResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MemberUpdateResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n37, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n37
- }
- if len(m.Members) > 0 {
- for _, msg := range m.Members {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRpc(dAtA, i, uint64(msg.Size()))
- n, err := msg.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n
- }
- }
- return i, nil
-}
-
-func (m *MemberListRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MemberListRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- return i, nil
-}
-
-func (m *MemberListResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MemberListResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n38, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n38
- }
- if len(m.Members) > 0 {
- for _, msg := range m.Members {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRpc(dAtA, i, uint64(msg.Size()))
- n, err := msg.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n
- }
- }
- return i, nil
-}
-
-func (m *MemberPromoteRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MemberPromoteRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.ID != 0 {
- dAtA[i] = 0x8
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.ID))
- }
- return i, nil
-}
-
-func (m *MemberPromoteResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MemberPromoteResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n39, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n39
- }
- if len(m.Members) > 0 {
- for _, msg := range m.Members {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRpc(dAtA, i, uint64(msg.Size()))
- n, err := msg.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n
- }
- }
- return i, nil
-}
-
-func (m *DefragmentRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *DefragmentRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- return i, nil
-}
-
-func (m *DefragmentResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *DefragmentResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n40, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n40
- }
- return i, nil
-}
-
-func (m *MoveLeaderRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MoveLeaderRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.TargetID != 0 {
- dAtA[i] = 0x8
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.TargetID))
- }
- return i, nil
-}
-
-func (m *MoveLeaderResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *MoveLeaderResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n41, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n41
- }
- return i, nil
-}
-
-func (m *AlarmRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AlarmRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Action != 0 {
- dAtA[i] = 0x8
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Action))
- }
- if m.MemberID != 0 {
- dAtA[i] = 0x10
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.MemberID))
- }
- if m.Alarm != 0 {
- dAtA[i] = 0x18
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Alarm))
- }
- return i, nil
-}
-
-func (m *AlarmMember) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AlarmMember) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.MemberID != 0 {
- dAtA[i] = 0x8
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.MemberID))
- }
- if m.Alarm != 0 {
- dAtA[i] = 0x10
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Alarm))
- }
- return i, nil
-}
-
-func (m *AlarmResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AlarmResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n42, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n42
- }
- if len(m.Alarms) > 0 {
- for _, msg := range m.Alarms {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRpc(dAtA, i, uint64(msg.Size()))
- n, err := msg.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n
- }
- }
- return i, nil
-}
-
-func (m *StatusRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *StatusRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- return i, nil
-}
-
-func (m *StatusResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *StatusResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n43, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n43
- }
- if len(m.Version) > 0 {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.Version)))
- i += copy(dAtA[i:], m.Version)
- }
- if m.DbSize != 0 {
- dAtA[i] = 0x18
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.DbSize))
- }
- if m.Leader != 0 {
- dAtA[i] = 0x20
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Leader))
- }
- if m.RaftIndex != 0 {
- dAtA[i] = 0x28
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.RaftIndex))
- }
- if m.RaftTerm != 0 {
- dAtA[i] = 0x30
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.RaftTerm))
- }
- if m.RaftAppliedIndex != 0 {
- dAtA[i] = 0x38
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.RaftAppliedIndex))
- }
- if len(m.Errors) > 0 {
- for _, s := range m.Errors {
- dAtA[i] = 0x42
- i++
- l = len(s)
- for l >= 1<<7 {
- dAtA[i] = uint8(uint64(l)&0x7f | 0x80)
- l >>= 7
- i++
- }
- dAtA[i] = uint8(l)
- i++
- i += copy(dAtA[i:], s)
- }
- }
- if m.DbSizeInUse != 0 {
- dAtA[i] = 0x48
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.DbSizeInUse))
- }
- if m.IsLearner {
- dAtA[i] = 0x50
- i++
- if m.IsLearner {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i++
- }
- return i, nil
-}
-
-func (m *AuthEnableRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthEnableRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- return i, nil
-}
-
-func (m *AuthDisableRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthDisableRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- return i, nil
-}
-
-func (m *AuthenticateRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthenticateRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if len(m.Name) > 0 {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.Name)))
- i += copy(dAtA[i:], m.Name)
- }
- if len(m.Password) > 0 {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.Password)))
- i += copy(dAtA[i:], m.Password)
- }
- return i, nil
-}
-
-func (m *AuthUserAddRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthUserAddRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if len(m.Name) > 0 {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.Name)))
- i += copy(dAtA[i:], m.Name)
- }
- if len(m.Password) > 0 {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.Password)))
- i += copy(dAtA[i:], m.Password)
- }
- if m.Options != nil {
- dAtA[i] = 0x1a
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Options.Size()))
- n44, err := m.Options.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n44
- }
- return i, nil
-}
-
-func (m *AuthUserGetRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthUserGetRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if len(m.Name) > 0 {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.Name)))
- i += copy(dAtA[i:], m.Name)
- }
- return i, nil
-}
-
-func (m *AuthUserDeleteRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthUserDeleteRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if len(m.Name) > 0 {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.Name)))
- i += copy(dAtA[i:], m.Name)
- }
- return i, nil
-}
-
-func (m *AuthUserChangePasswordRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthUserChangePasswordRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if len(m.Name) > 0 {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.Name)))
- i += copy(dAtA[i:], m.Name)
- }
- if len(m.Password) > 0 {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.Password)))
- i += copy(dAtA[i:], m.Password)
- }
- return i, nil
-}
-
-func (m *AuthUserGrantRoleRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthUserGrantRoleRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if len(m.User) > 0 {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.User)))
- i += copy(dAtA[i:], m.User)
- }
- if len(m.Role) > 0 {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.Role)))
- i += copy(dAtA[i:], m.Role)
- }
- return i, nil
-}
-
-func (m *AuthUserRevokeRoleRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthUserRevokeRoleRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if len(m.Name) > 0 {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.Name)))
- i += copy(dAtA[i:], m.Name)
- }
- if len(m.Role) > 0 {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.Role)))
- i += copy(dAtA[i:], m.Role)
- }
- return i, nil
-}
-
-func (m *AuthRoleAddRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthRoleAddRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if len(m.Name) > 0 {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.Name)))
- i += copy(dAtA[i:], m.Name)
- }
- return i, nil
-}
-
-func (m *AuthRoleGetRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthRoleGetRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if len(m.Role) > 0 {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.Role)))
- i += copy(dAtA[i:], m.Role)
- }
- return i, nil
-}
-
-func (m *AuthUserListRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthUserListRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- return i, nil
-}
-
-func (m *AuthRoleListRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthRoleListRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- return i, nil
-}
-
-func (m *AuthRoleDeleteRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthRoleDeleteRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if len(m.Role) > 0 {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.Role)))
- i += copy(dAtA[i:], m.Role)
- }
- return i, nil
-}
-
-func (m *AuthRoleGrantPermissionRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthRoleGrantPermissionRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if len(m.Name) > 0 {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.Name)))
- i += copy(dAtA[i:], m.Name)
- }
- if m.Perm != nil {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Perm.Size()))
- n45, err := m.Perm.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n45
- }
- return i, nil
-}
-
-func (m *AuthRoleRevokePermissionRequest) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthRoleRevokePermissionRequest) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if len(m.Role) > 0 {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.Role)))
- i += copy(dAtA[i:], m.Role)
- }
- if len(m.Key) > 0 {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.Key)))
- i += copy(dAtA[i:], m.Key)
- }
- if len(m.RangeEnd) > 0 {
- dAtA[i] = 0x1a
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.RangeEnd)))
- i += copy(dAtA[i:], m.RangeEnd)
- }
- return i, nil
-}
-
-func (m *AuthEnableResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthEnableResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n46, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n46
- }
- return i, nil
-}
-
-func (m *AuthDisableResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthDisableResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n47, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n47
- }
- return i, nil
-}
-
-func (m *AuthenticateResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthenticateResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n48, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n48
- }
- if len(m.Token) > 0 {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRpc(dAtA, i, uint64(len(m.Token)))
- i += copy(dAtA[i:], m.Token)
- }
- return i, nil
-}
-
-func (m *AuthUserAddResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthUserAddResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n49, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n49
- }
- return i, nil
-}
-
-func (m *AuthUserGetResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthUserGetResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n50, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n50
- }
- if len(m.Roles) > 0 {
- for _, s := range m.Roles {
- dAtA[i] = 0x12
- i++
- l = len(s)
- for l >= 1<<7 {
- dAtA[i] = uint8(uint64(l)&0x7f | 0x80)
- l >>= 7
- i++
- }
- dAtA[i] = uint8(l)
- i++
- i += copy(dAtA[i:], s)
- }
- }
- return i, nil
-}
-
-func (m *AuthUserDeleteResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthUserDeleteResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n51, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n51
- }
- return i, nil
-}
-
-func (m *AuthUserChangePasswordResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthUserChangePasswordResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n52, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n52
- }
- return i, nil
-}
-
-func (m *AuthUserGrantRoleResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthUserGrantRoleResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n53, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n53
- }
- return i, nil
-}
-
-func (m *AuthUserRevokeRoleResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthUserRevokeRoleResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n54, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n54
- }
- return i, nil
-}
-
-func (m *AuthRoleAddResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthRoleAddResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n55, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n55
- }
- return i, nil
-}
-
-func (m *AuthRoleGetResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthRoleGetResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n56, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n56
- }
- if len(m.Perm) > 0 {
- for _, msg := range m.Perm {
- dAtA[i] = 0x12
- i++
- i = encodeVarintRpc(dAtA, i, uint64(msg.Size()))
- n, err := msg.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n
- }
- }
- return i, nil
-}
-
-func (m *AuthRoleListResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthRoleListResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n57, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n57
- }
- if len(m.Roles) > 0 {
- for _, s := range m.Roles {
- dAtA[i] = 0x12
- i++
- l = len(s)
- for l >= 1<<7 {
- dAtA[i] = uint8(uint64(l)&0x7f | 0x80)
- l >>= 7
- i++
- }
- dAtA[i] = uint8(l)
- i++
- i += copy(dAtA[i:], s)
- }
- }
- return i, nil
-}
-
-func (m *AuthUserListResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthUserListResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n58, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n58
- }
- if len(m.Users) > 0 {
- for _, s := range m.Users {
- dAtA[i] = 0x12
- i++
- l = len(s)
- for l >= 1<<7 {
- dAtA[i] = uint8(uint64(l)&0x7f | 0x80)
- l >>= 7
- i++
- }
- dAtA[i] = uint8(l)
- i++
- i += copy(dAtA[i:], s)
- }
- }
- return i, nil
-}
-
-func (m *AuthRoleDeleteResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthRoleDeleteResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n59, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n59
- }
- return i, nil
-}
-
-func (m *AuthRoleGrantPermissionResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthRoleGrantPermissionResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n60, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n60
- }
- return i, nil
-}
-
-func (m *AuthRoleRevokePermissionResponse) Marshal() (dAtA []byte, err error) {
- size := m.Size()
- dAtA = make([]byte, size)
- n, err := m.MarshalTo(dAtA)
- if err != nil {
- return nil, err
- }
- return dAtA[:n], nil
-}
-
-func (m *AuthRoleRevokePermissionResponse) MarshalTo(dAtA []byte) (int, error) {
- var i int
- _ = i
- var l int
- _ = l
- if m.Header != nil {
- dAtA[i] = 0xa
- i++
- i = encodeVarintRpc(dAtA, i, uint64(m.Header.Size()))
- n61, err := m.Header.MarshalTo(dAtA[i:])
- if err != nil {
- return 0, err
- }
- i += n61
- }
- return i, nil
-}
-
-func encodeVarintRpc(dAtA []byte, offset int, v uint64) int {
- for v >= 1<<7 {
- dAtA[offset] = uint8(v&0x7f | 0x80)
- v >>= 7
- offset++
- }
- dAtA[offset] = uint8(v)
- return offset + 1
-}
-func (m *ResponseHeader) Size() (n int) {
- var l int
- _ = l
- if m.ClusterId != 0 {
- n += 1 + sovRpc(uint64(m.ClusterId))
- }
- if m.MemberId != 0 {
- n += 1 + sovRpc(uint64(m.MemberId))
- }
- if m.Revision != 0 {
- n += 1 + sovRpc(uint64(m.Revision))
- }
- if m.RaftTerm != 0 {
- n += 1 + sovRpc(uint64(m.RaftTerm))
- }
- return n
-}
-
-func (m *RangeRequest) Size() (n int) {
- var l int
- _ = l
- l = len(m.Key)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- l = len(m.RangeEnd)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- if m.Limit != 0 {
- n += 1 + sovRpc(uint64(m.Limit))
- }
- if m.Revision != 0 {
- n += 1 + sovRpc(uint64(m.Revision))
- }
- if m.SortOrder != 0 {
- n += 1 + sovRpc(uint64(m.SortOrder))
- }
- if m.SortTarget != 0 {
- n += 1 + sovRpc(uint64(m.SortTarget))
- }
- if m.Serializable {
- n += 2
- }
- if m.KeysOnly {
- n += 2
- }
- if m.CountOnly {
- n += 2
- }
- if m.MinModRevision != 0 {
- n += 1 + sovRpc(uint64(m.MinModRevision))
- }
- if m.MaxModRevision != 0 {
- n += 1 + sovRpc(uint64(m.MaxModRevision))
- }
- if m.MinCreateRevision != 0 {
- n += 1 + sovRpc(uint64(m.MinCreateRevision))
- }
- if m.MaxCreateRevision != 0 {
- n += 1 + sovRpc(uint64(m.MaxCreateRevision))
- }
- return n
-}
-
-func (m *RangeResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- if len(m.Kvs) > 0 {
- for _, e := range m.Kvs {
- l = e.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- }
- if m.More {
- n += 2
- }
- if m.Count != 0 {
- n += 1 + sovRpc(uint64(m.Count))
- }
- return n
-}
-
-func (m *PutRequest) Size() (n int) {
- var l int
- _ = l
- l = len(m.Key)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- l = len(m.Value)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- if m.Lease != 0 {
- n += 1 + sovRpc(uint64(m.Lease))
- }
- if m.PrevKv {
- n += 2
- }
- if m.IgnoreValue {
- n += 2
- }
- if m.IgnoreLease {
- n += 2
- }
- return n
-}
-
-func (m *PutResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- if m.PrevKv != nil {
- l = m.PrevKv.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *DeleteRangeRequest) Size() (n int) {
- var l int
- _ = l
- l = len(m.Key)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- l = len(m.RangeEnd)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- if m.PrevKv {
- n += 2
- }
- return n
-}
-
-func (m *DeleteRangeResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- if m.Deleted != 0 {
- n += 1 + sovRpc(uint64(m.Deleted))
- }
- if len(m.PrevKvs) > 0 {
- for _, e := range m.PrevKvs {
- l = e.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- }
- return n
-}
-
-func (m *RequestOp) Size() (n int) {
- var l int
- _ = l
- if m.Request != nil {
- n += m.Request.Size()
- }
- return n
-}
-
-func (m *RequestOp_RequestRange) Size() (n int) {
- var l int
- _ = l
- if m.RequestRange != nil {
- l = m.RequestRange.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-func (m *RequestOp_RequestPut) Size() (n int) {
- var l int
- _ = l
- if m.RequestPut != nil {
- l = m.RequestPut.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-func (m *RequestOp_RequestDeleteRange) Size() (n int) {
- var l int
- _ = l
- if m.RequestDeleteRange != nil {
- l = m.RequestDeleteRange.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-func (m *RequestOp_RequestTxn) Size() (n int) {
- var l int
- _ = l
- if m.RequestTxn != nil {
- l = m.RequestTxn.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-func (m *ResponseOp) Size() (n int) {
- var l int
- _ = l
- if m.Response != nil {
- n += m.Response.Size()
- }
- return n
-}
-
-func (m *ResponseOp_ResponseRange) Size() (n int) {
- var l int
- _ = l
- if m.ResponseRange != nil {
- l = m.ResponseRange.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-func (m *ResponseOp_ResponsePut) Size() (n int) {
- var l int
- _ = l
- if m.ResponsePut != nil {
- l = m.ResponsePut.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-func (m *ResponseOp_ResponseDeleteRange) Size() (n int) {
- var l int
- _ = l
- if m.ResponseDeleteRange != nil {
- l = m.ResponseDeleteRange.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-func (m *ResponseOp_ResponseTxn) Size() (n int) {
- var l int
- _ = l
- if m.ResponseTxn != nil {
- l = m.ResponseTxn.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-func (m *Compare) Size() (n int) {
- var l int
- _ = l
- if m.Result != 0 {
- n += 1 + sovRpc(uint64(m.Result))
- }
- if m.Target != 0 {
- n += 1 + sovRpc(uint64(m.Target))
- }
- l = len(m.Key)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- if m.TargetUnion != nil {
- n += m.TargetUnion.Size()
- }
- l = len(m.RangeEnd)
- if l > 0 {
- n += 2 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *Compare_Version) Size() (n int) {
- var l int
- _ = l
- n += 1 + sovRpc(uint64(m.Version))
- return n
-}
-func (m *Compare_CreateRevision) Size() (n int) {
- var l int
- _ = l
- n += 1 + sovRpc(uint64(m.CreateRevision))
- return n
-}
-func (m *Compare_ModRevision) Size() (n int) {
- var l int
- _ = l
- n += 1 + sovRpc(uint64(m.ModRevision))
- return n
-}
-func (m *Compare_Value) Size() (n int) {
- var l int
- _ = l
- if m.Value != nil {
- l = len(m.Value)
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-func (m *Compare_Lease) Size() (n int) {
- var l int
- _ = l
- n += 1 + sovRpc(uint64(m.Lease))
- return n
-}
-func (m *TxnRequest) Size() (n int) {
- var l int
- _ = l
- if len(m.Compare) > 0 {
- for _, e := range m.Compare {
- l = e.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- }
- if len(m.Success) > 0 {
- for _, e := range m.Success {
- l = e.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- }
- if len(m.Failure) > 0 {
- for _, e := range m.Failure {
- l = e.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- }
- return n
-}
-
-func (m *TxnResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- if m.Succeeded {
- n += 2
- }
- if len(m.Responses) > 0 {
- for _, e := range m.Responses {
- l = e.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- }
- return n
-}
-
-func (m *CompactionRequest) Size() (n int) {
- var l int
- _ = l
- if m.Revision != 0 {
- n += 1 + sovRpc(uint64(m.Revision))
- }
- if m.Physical {
- n += 2
- }
- return n
-}
-
-func (m *CompactionResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *HashRequest) Size() (n int) {
- var l int
- _ = l
- return n
-}
-
-func (m *HashKVRequest) Size() (n int) {
- var l int
- _ = l
- if m.Revision != 0 {
- n += 1 + sovRpc(uint64(m.Revision))
- }
- return n
-}
-
-func (m *HashKVResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- if m.Hash != 0 {
- n += 1 + sovRpc(uint64(m.Hash))
- }
- if m.CompactRevision != 0 {
- n += 1 + sovRpc(uint64(m.CompactRevision))
- }
- return n
-}
-
-func (m *HashResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- if m.Hash != 0 {
- n += 1 + sovRpc(uint64(m.Hash))
- }
- return n
-}
-
-func (m *SnapshotRequest) Size() (n int) {
- var l int
- _ = l
- return n
-}
-
-func (m *SnapshotResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- if m.RemainingBytes != 0 {
- n += 1 + sovRpc(uint64(m.RemainingBytes))
- }
- l = len(m.Blob)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *WatchRequest) Size() (n int) {
- var l int
- _ = l
- if m.RequestUnion != nil {
- n += m.RequestUnion.Size()
- }
- return n
-}
-
-func (m *WatchRequest_CreateRequest) Size() (n int) {
- var l int
- _ = l
- if m.CreateRequest != nil {
- l = m.CreateRequest.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-func (m *WatchRequest_CancelRequest) Size() (n int) {
- var l int
- _ = l
- if m.CancelRequest != nil {
- l = m.CancelRequest.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-func (m *WatchRequest_ProgressRequest) Size() (n int) {
- var l int
- _ = l
- if m.ProgressRequest != nil {
- l = m.ProgressRequest.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-func (m *WatchCreateRequest) Size() (n int) {
- var l int
- _ = l
- l = len(m.Key)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- l = len(m.RangeEnd)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- if m.StartRevision != 0 {
- n += 1 + sovRpc(uint64(m.StartRevision))
- }
- if m.ProgressNotify {
- n += 2
- }
- if len(m.Filters) > 0 {
- l = 0
- for _, e := range m.Filters {
- l += sovRpc(uint64(e))
- }
- n += 1 + sovRpc(uint64(l)) + l
- }
- if m.PrevKv {
- n += 2
- }
- if m.WatchId != 0 {
- n += 1 + sovRpc(uint64(m.WatchId))
- }
- if m.Fragment {
- n += 2
- }
- return n
-}
-
-func (m *WatchCancelRequest) Size() (n int) {
- var l int
- _ = l
- if m.WatchId != 0 {
- n += 1 + sovRpc(uint64(m.WatchId))
- }
- return n
-}
-
-func (m *WatchProgressRequest) Size() (n int) {
- var l int
- _ = l
- return n
-}
-
-func (m *WatchResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- if m.WatchId != 0 {
- n += 1 + sovRpc(uint64(m.WatchId))
- }
- if m.Created {
- n += 2
- }
- if m.Canceled {
- n += 2
- }
- if m.CompactRevision != 0 {
- n += 1 + sovRpc(uint64(m.CompactRevision))
- }
- l = len(m.CancelReason)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- if m.Fragment {
- n += 2
- }
- if len(m.Events) > 0 {
- for _, e := range m.Events {
- l = e.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- }
- return n
-}
-
-func (m *LeaseGrantRequest) Size() (n int) {
- var l int
- _ = l
- if m.TTL != 0 {
- n += 1 + sovRpc(uint64(m.TTL))
- }
- if m.ID != 0 {
- n += 1 + sovRpc(uint64(m.ID))
- }
- return n
-}
-
-func (m *LeaseGrantResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- if m.ID != 0 {
- n += 1 + sovRpc(uint64(m.ID))
- }
- if m.TTL != 0 {
- n += 1 + sovRpc(uint64(m.TTL))
- }
- l = len(m.Error)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *LeaseRevokeRequest) Size() (n int) {
- var l int
- _ = l
- if m.ID != 0 {
- n += 1 + sovRpc(uint64(m.ID))
- }
- return n
-}
-
-func (m *LeaseRevokeResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *LeaseCheckpoint) Size() (n int) {
- var l int
- _ = l
- if m.ID != 0 {
- n += 1 + sovRpc(uint64(m.ID))
- }
- if m.Remaining_TTL != 0 {
- n += 1 + sovRpc(uint64(m.Remaining_TTL))
- }
- return n
-}
-
-func (m *LeaseCheckpointRequest) Size() (n int) {
- var l int
- _ = l
- if len(m.Checkpoints) > 0 {
- for _, e := range m.Checkpoints {
- l = e.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- }
- return n
-}
-
-func (m *LeaseCheckpointResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *LeaseKeepAliveRequest) Size() (n int) {
- var l int
- _ = l
- if m.ID != 0 {
- n += 1 + sovRpc(uint64(m.ID))
- }
- return n
-}
-
-func (m *LeaseKeepAliveResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- if m.ID != 0 {
- n += 1 + sovRpc(uint64(m.ID))
- }
- if m.TTL != 0 {
- n += 1 + sovRpc(uint64(m.TTL))
- }
- return n
-}
-
-func (m *LeaseTimeToLiveRequest) Size() (n int) {
- var l int
- _ = l
- if m.ID != 0 {
- n += 1 + sovRpc(uint64(m.ID))
- }
- if m.Keys {
- n += 2
- }
- return n
-}
-
-func (m *LeaseTimeToLiveResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- if m.ID != 0 {
- n += 1 + sovRpc(uint64(m.ID))
- }
- if m.TTL != 0 {
- n += 1 + sovRpc(uint64(m.TTL))
- }
- if m.GrantedTTL != 0 {
- n += 1 + sovRpc(uint64(m.GrantedTTL))
- }
- if len(m.Keys) > 0 {
- for _, b := range m.Keys {
- l = len(b)
- n += 1 + l + sovRpc(uint64(l))
- }
- }
- return n
-}
-
-func (m *LeaseLeasesRequest) Size() (n int) {
- var l int
- _ = l
- return n
-}
-
-func (m *LeaseStatus) Size() (n int) {
- var l int
- _ = l
- if m.ID != 0 {
- n += 1 + sovRpc(uint64(m.ID))
- }
- return n
-}
-
-func (m *LeaseLeasesResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- if len(m.Leases) > 0 {
- for _, e := range m.Leases {
- l = e.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- }
- return n
-}
-
-func (m *Member) Size() (n int) {
- var l int
- _ = l
- if m.ID != 0 {
- n += 1 + sovRpc(uint64(m.ID))
- }
- l = len(m.Name)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- if len(m.PeerURLs) > 0 {
- for _, s := range m.PeerURLs {
- l = len(s)
- n += 1 + l + sovRpc(uint64(l))
- }
- }
- if len(m.ClientURLs) > 0 {
- for _, s := range m.ClientURLs {
- l = len(s)
- n += 1 + l + sovRpc(uint64(l))
- }
- }
- if m.IsLearner {
- n += 2
- }
- return n
-}
-
-func (m *MemberAddRequest) Size() (n int) {
- var l int
- _ = l
- if len(m.PeerURLs) > 0 {
- for _, s := range m.PeerURLs {
- l = len(s)
- n += 1 + l + sovRpc(uint64(l))
- }
- }
- if m.IsLearner {
- n += 2
- }
- return n
-}
-
-func (m *MemberAddResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- if m.Member != nil {
- l = m.Member.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- if len(m.Members) > 0 {
- for _, e := range m.Members {
- l = e.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- }
- return n
-}
-
-func (m *MemberRemoveRequest) Size() (n int) {
- var l int
- _ = l
- if m.ID != 0 {
- n += 1 + sovRpc(uint64(m.ID))
- }
- return n
-}
-
-func (m *MemberRemoveResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- if len(m.Members) > 0 {
- for _, e := range m.Members {
- l = e.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- }
- return n
-}
-
-func (m *MemberUpdateRequest) Size() (n int) {
- var l int
- _ = l
- if m.ID != 0 {
- n += 1 + sovRpc(uint64(m.ID))
- }
- if len(m.PeerURLs) > 0 {
- for _, s := range m.PeerURLs {
- l = len(s)
- n += 1 + l + sovRpc(uint64(l))
- }
- }
- return n
-}
-
-func (m *MemberUpdateResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- if len(m.Members) > 0 {
- for _, e := range m.Members {
- l = e.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- }
- return n
-}
-
-func (m *MemberListRequest) Size() (n int) {
- var l int
- _ = l
- return n
-}
-
-func (m *MemberListResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- if len(m.Members) > 0 {
- for _, e := range m.Members {
- l = e.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- }
- return n
-}
-
-func (m *MemberPromoteRequest) Size() (n int) {
- var l int
- _ = l
- if m.ID != 0 {
- n += 1 + sovRpc(uint64(m.ID))
- }
- return n
-}
-
-func (m *MemberPromoteResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- if len(m.Members) > 0 {
- for _, e := range m.Members {
- l = e.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- }
- return n
-}
-
-func (m *DefragmentRequest) Size() (n int) {
- var l int
- _ = l
- return n
-}
-
-func (m *DefragmentResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *MoveLeaderRequest) Size() (n int) {
- var l int
- _ = l
- if m.TargetID != 0 {
- n += 1 + sovRpc(uint64(m.TargetID))
- }
- return n
-}
-
-func (m *MoveLeaderResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *AlarmRequest) Size() (n int) {
- var l int
- _ = l
- if m.Action != 0 {
- n += 1 + sovRpc(uint64(m.Action))
- }
- if m.MemberID != 0 {
- n += 1 + sovRpc(uint64(m.MemberID))
- }
- if m.Alarm != 0 {
- n += 1 + sovRpc(uint64(m.Alarm))
- }
- return n
-}
-
-func (m *AlarmMember) Size() (n int) {
- var l int
- _ = l
- if m.MemberID != 0 {
- n += 1 + sovRpc(uint64(m.MemberID))
- }
- if m.Alarm != 0 {
- n += 1 + sovRpc(uint64(m.Alarm))
- }
- return n
-}
-
-func (m *AlarmResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- if len(m.Alarms) > 0 {
- for _, e := range m.Alarms {
- l = e.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- }
- return n
-}
-
-func (m *StatusRequest) Size() (n int) {
- var l int
- _ = l
- return n
-}
-
-func (m *StatusResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- l = len(m.Version)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- if m.DbSize != 0 {
- n += 1 + sovRpc(uint64(m.DbSize))
- }
- if m.Leader != 0 {
- n += 1 + sovRpc(uint64(m.Leader))
- }
- if m.RaftIndex != 0 {
- n += 1 + sovRpc(uint64(m.RaftIndex))
- }
- if m.RaftTerm != 0 {
- n += 1 + sovRpc(uint64(m.RaftTerm))
- }
- if m.RaftAppliedIndex != 0 {
- n += 1 + sovRpc(uint64(m.RaftAppliedIndex))
- }
- if len(m.Errors) > 0 {
- for _, s := range m.Errors {
- l = len(s)
- n += 1 + l + sovRpc(uint64(l))
- }
- }
- if m.DbSizeInUse != 0 {
- n += 1 + sovRpc(uint64(m.DbSizeInUse))
- }
- if m.IsLearner {
- n += 2
- }
- return n
-}
-
-func (m *AuthEnableRequest) Size() (n int) {
- var l int
- _ = l
- return n
-}
-
-func (m *AuthDisableRequest) Size() (n int) {
- var l int
- _ = l
- return n
-}
-
-func (m *AuthenticateRequest) Size() (n int) {
- var l int
- _ = l
- l = len(m.Name)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- l = len(m.Password)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *AuthUserAddRequest) Size() (n int) {
- var l int
- _ = l
- l = len(m.Name)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- l = len(m.Password)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- if m.Options != nil {
- l = m.Options.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *AuthUserGetRequest) Size() (n int) {
- var l int
- _ = l
- l = len(m.Name)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *AuthUserDeleteRequest) Size() (n int) {
- var l int
- _ = l
- l = len(m.Name)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *AuthUserChangePasswordRequest) Size() (n int) {
- var l int
- _ = l
- l = len(m.Name)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- l = len(m.Password)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *AuthUserGrantRoleRequest) Size() (n int) {
- var l int
- _ = l
- l = len(m.User)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- l = len(m.Role)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *AuthUserRevokeRoleRequest) Size() (n int) {
- var l int
- _ = l
- l = len(m.Name)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- l = len(m.Role)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *AuthRoleAddRequest) Size() (n int) {
- var l int
- _ = l
- l = len(m.Name)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *AuthRoleGetRequest) Size() (n int) {
- var l int
- _ = l
- l = len(m.Role)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *AuthUserListRequest) Size() (n int) {
- var l int
- _ = l
- return n
-}
-
-func (m *AuthRoleListRequest) Size() (n int) {
- var l int
- _ = l
- return n
-}
-
-func (m *AuthRoleDeleteRequest) Size() (n int) {
- var l int
- _ = l
- l = len(m.Role)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *AuthRoleGrantPermissionRequest) Size() (n int) {
- var l int
- _ = l
- l = len(m.Name)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- if m.Perm != nil {
- l = m.Perm.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *AuthRoleRevokePermissionRequest) Size() (n int) {
- var l int
- _ = l
- l = len(m.Role)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- l = len(m.Key)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- l = len(m.RangeEnd)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *AuthEnableResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *AuthDisableResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *AuthenticateResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- l = len(m.Token)
- if l > 0 {
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *AuthUserAddResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *AuthUserGetResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- if len(m.Roles) > 0 {
- for _, s := range m.Roles {
- l = len(s)
- n += 1 + l + sovRpc(uint64(l))
- }
- }
- return n
-}
-
-func (m *AuthUserDeleteResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *AuthUserChangePasswordResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *AuthUserGrantRoleResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *AuthUserRevokeRoleResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *AuthRoleAddResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *AuthRoleGetResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- if len(m.Perm) > 0 {
- for _, e := range m.Perm {
- l = e.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- }
- return n
-}
-
-func (m *AuthRoleListResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- if len(m.Roles) > 0 {
- for _, s := range m.Roles {
- l = len(s)
- n += 1 + l + sovRpc(uint64(l))
- }
- }
- return n
-}
-
-func (m *AuthUserListResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- if len(m.Users) > 0 {
- for _, s := range m.Users {
- l = len(s)
- n += 1 + l + sovRpc(uint64(l))
- }
- }
- return n
-}
-
-func (m *AuthRoleDeleteResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *AuthRoleGrantPermissionResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func (m *AuthRoleRevokePermissionResponse) Size() (n int) {
- var l int
- _ = l
- if m.Header != nil {
- l = m.Header.Size()
- n += 1 + l + sovRpc(uint64(l))
- }
- return n
-}
-
-func sovRpc(x uint64) (n int) {
- for {
- n++
- x >>= 7
- if x == 0 {
- break
- }
- }
- return n
-}
-func sozRpc(x uint64) (n int) {
- return sovRpc(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-}
-func (m *ResponseHeader) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: ResponseHeader: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: ResponseHeader: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field ClusterId", wireType)
- }
- m.ClusterId = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.ClusterId |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field MemberId", wireType)
- }
- m.MemberId = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.MemberId |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 3:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Revision", wireType)
- }
- m.Revision = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Revision |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 4:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field RaftTerm", wireType)
- }
- m.RaftTerm = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.RaftTerm |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *RangeRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: RangeRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: RangeRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + byteLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...)
- if m.Key == nil {
- m.Key = []byte{}
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field RangeEnd", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + byteLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.RangeEnd = append(m.RangeEnd[:0], dAtA[iNdEx:postIndex]...)
- if m.RangeEnd == nil {
- m.RangeEnd = []byte{}
- }
- iNdEx = postIndex
- case 3:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Limit", wireType)
- }
- m.Limit = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Limit |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 4:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Revision", wireType)
- }
- m.Revision = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Revision |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 5:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field SortOrder", wireType)
- }
- m.SortOrder = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.SortOrder |= (RangeRequest_SortOrder(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 6:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field SortTarget", wireType)
- }
- m.SortTarget = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.SortTarget |= (RangeRequest_SortTarget(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 7:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Serializable", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.Serializable = bool(v != 0)
- case 8:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field KeysOnly", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.KeysOnly = bool(v != 0)
- case 9:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field CountOnly", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.CountOnly = bool(v != 0)
- case 10:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field MinModRevision", wireType)
- }
- m.MinModRevision = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.MinModRevision |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 11:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field MaxModRevision", wireType)
- }
- m.MaxModRevision = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.MaxModRevision |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 12:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field MinCreateRevision", wireType)
- }
- m.MinCreateRevision = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.MinCreateRevision |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 13:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field MaxCreateRevision", wireType)
- }
- m.MaxCreateRevision = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.MaxCreateRevision |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *RangeResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: RangeResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: RangeResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Kvs", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Kvs = append(m.Kvs, &mvccpb.KeyValue{})
- if err := m.Kvs[len(m.Kvs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 3:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field More", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.More = bool(v != 0)
- case 4:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Count", wireType)
- }
- m.Count = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Count |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *PutRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: PutRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: PutRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + byteLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...)
- if m.Key == nil {
- m.Key = []byte{}
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + byteLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...)
- if m.Value == nil {
- m.Value = []byte{}
- }
- iNdEx = postIndex
- case 3:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Lease", wireType)
- }
- m.Lease = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Lease |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 4:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field PrevKv", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.PrevKv = bool(v != 0)
- case 5:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field IgnoreValue", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.IgnoreValue = bool(v != 0)
- case 6:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field IgnoreLease", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.IgnoreLease = bool(v != 0)
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *PutResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: PutResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: PutResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field PrevKv", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.PrevKv == nil {
- m.PrevKv = &mvccpb.KeyValue{}
- }
- if err := m.PrevKv.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *DeleteRangeRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: DeleteRangeRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: DeleteRangeRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + byteLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...)
- if m.Key == nil {
- m.Key = []byte{}
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field RangeEnd", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + byteLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.RangeEnd = append(m.RangeEnd[:0], dAtA[iNdEx:postIndex]...)
- if m.RangeEnd == nil {
- m.RangeEnd = []byte{}
- }
- iNdEx = postIndex
- case 3:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field PrevKv", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.PrevKv = bool(v != 0)
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *DeleteRangeResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: DeleteRangeResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: DeleteRangeResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Deleted", wireType)
- }
- m.Deleted = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Deleted |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field PrevKvs", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.PrevKvs = append(m.PrevKvs, &mvccpb.KeyValue{})
- if err := m.PrevKvs[len(m.PrevKvs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *RequestOp) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: RequestOp: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: RequestOp: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field RequestRange", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- v := &RangeRequest{}
- if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- m.Request = &RequestOp_RequestRange{v}
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field RequestPut", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- v := &PutRequest{}
- if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- m.Request = &RequestOp_RequestPut{v}
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field RequestDeleteRange", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- v := &DeleteRangeRequest{}
- if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- m.Request = &RequestOp_RequestDeleteRange{v}
- iNdEx = postIndex
- case 4:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field RequestTxn", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- v := &TxnRequest{}
- if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- m.Request = &RequestOp_RequestTxn{v}
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *ResponseOp) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: ResponseOp: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: ResponseOp: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ResponseRange", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- v := &RangeResponse{}
- if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- m.Response = &ResponseOp_ResponseRange{v}
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ResponsePut", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- v := &PutResponse{}
- if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- m.Response = &ResponseOp_ResponsePut{v}
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ResponseDeleteRange", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- v := &DeleteRangeResponse{}
- if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- m.Response = &ResponseOp_ResponseDeleteRange{v}
- iNdEx = postIndex
- case 4:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ResponseTxn", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- v := &TxnResponse{}
- if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- m.Response = &ResponseOp_ResponseTxn{v}
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *Compare) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: Compare: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: Compare: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType)
- }
- m.Result = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Result |= (Compare_CompareResult(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Target", wireType)
- }
- m.Target = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Target |= (Compare_CompareTarget(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + byteLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...)
- if m.Key == nil {
- m.Key = []byte{}
- }
- iNdEx = postIndex
- case 4:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType)
- }
- var v int64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.TargetUnion = &Compare_Version{v}
- case 5:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field CreateRevision", wireType)
- }
- var v int64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.TargetUnion = &Compare_CreateRevision{v}
- case 6:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field ModRevision", wireType)
- }
- var v int64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.TargetUnion = &Compare_ModRevision{v}
- case 7:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + byteLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- v := make([]byte, postIndex-iNdEx)
- copy(v, dAtA[iNdEx:postIndex])
- m.TargetUnion = &Compare_Value{v}
- iNdEx = postIndex
- case 8:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Lease", wireType)
- }
- var v int64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.TargetUnion = &Compare_Lease{v}
- case 64:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field RangeEnd", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + byteLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.RangeEnd = append(m.RangeEnd[:0], dAtA[iNdEx:postIndex]...)
- if m.RangeEnd == nil {
- m.RangeEnd = []byte{}
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *TxnRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: TxnRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: TxnRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Compare", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Compare = append(m.Compare, &Compare{})
- if err := m.Compare[len(m.Compare)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Success", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Success = append(m.Success, &RequestOp{})
- if err := m.Success[len(m.Success)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Failure", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Failure = append(m.Failure, &RequestOp{})
- if err := m.Failure[len(m.Failure)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *TxnResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: TxnResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: TxnResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Succeeded", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.Succeeded = bool(v != 0)
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Responses", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Responses = append(m.Responses, &ResponseOp{})
- if err := m.Responses[len(m.Responses)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *CompactionRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: CompactionRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: CompactionRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Revision", wireType)
- }
- m.Revision = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Revision |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Physical", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.Physical = bool(v != 0)
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *CompactionResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: CompactionResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: CompactionResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *HashRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: HashRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: HashRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *HashKVRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: HashKVRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: HashKVRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Revision", wireType)
- }
- m.Revision = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Revision |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *HashKVResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: HashKVResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: HashKVResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType)
- }
- m.Hash = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Hash |= (uint32(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 3:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field CompactRevision", wireType)
- }
- m.CompactRevision = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.CompactRevision |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *HashResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: HashResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: HashResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType)
- }
- m.Hash = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Hash |= (uint32(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *SnapshotRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: SnapshotRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: SnapshotRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *SnapshotResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: SnapshotResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: SnapshotResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field RemainingBytes", wireType)
- }
- m.RemainingBytes = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.RemainingBytes |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Blob", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + byteLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Blob = append(m.Blob[:0], dAtA[iNdEx:postIndex]...)
- if m.Blob == nil {
- m.Blob = []byte{}
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *WatchRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: WatchRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: WatchRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field CreateRequest", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- v := &WatchCreateRequest{}
- if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- m.RequestUnion = &WatchRequest_CreateRequest{v}
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field CancelRequest", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- v := &WatchCancelRequest{}
- if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- m.RequestUnion = &WatchRequest_CancelRequest{v}
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ProgressRequest", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- v := &WatchProgressRequest{}
- if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- m.RequestUnion = &WatchRequest_ProgressRequest{v}
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *WatchCreateRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: WatchCreateRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: WatchCreateRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + byteLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...)
- if m.Key == nil {
- m.Key = []byte{}
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field RangeEnd", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + byteLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.RangeEnd = append(m.RangeEnd[:0], dAtA[iNdEx:postIndex]...)
- if m.RangeEnd == nil {
- m.RangeEnd = []byte{}
- }
- iNdEx = postIndex
- case 3:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field StartRevision", wireType)
- }
- m.StartRevision = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.StartRevision |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 4:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field ProgressNotify", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.ProgressNotify = bool(v != 0)
- case 5:
- if wireType == 0 {
- var v WatchCreateRequest_FilterType
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (WatchCreateRequest_FilterType(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.Filters = append(m.Filters, v)
- } else if wireType == 2 {
- var packedLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- packedLen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if packedLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + packedLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- for iNdEx < postIndex {
- var v WatchCreateRequest_FilterType
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (WatchCreateRequest_FilterType(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.Filters = append(m.Filters, v)
- }
- } else {
- return fmt.Errorf("proto: wrong wireType = %d for field Filters", wireType)
- }
- case 6:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field PrevKv", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.PrevKv = bool(v != 0)
- case 7:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field WatchId", wireType)
- }
- m.WatchId = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.WatchId |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 8:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Fragment", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.Fragment = bool(v != 0)
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *WatchCancelRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: WatchCancelRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: WatchCancelRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field WatchId", wireType)
- }
- m.WatchId = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.WatchId |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *WatchProgressRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: WatchProgressRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: WatchProgressRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *WatchResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: WatchResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: WatchResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field WatchId", wireType)
- }
- m.WatchId = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.WatchId |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 3:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Created", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.Created = bool(v != 0)
- case 4:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Canceled", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.Canceled = bool(v != 0)
- case 5:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field CompactRevision", wireType)
- }
- m.CompactRevision = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.CompactRevision |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 6:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field CancelReason", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.CancelReason = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 7:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Fragment", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.Fragment = bool(v != 0)
- case 11:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Events", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Events = append(m.Events, &mvccpb.Event{})
- if err := m.Events[len(m.Events)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *LeaseGrantRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: LeaseGrantRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: LeaseGrantRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field TTL", wireType)
- }
- m.TTL = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.TTL |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
- }
- m.ID = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.ID |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *LeaseGrantResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: LeaseGrantResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: LeaseGrantResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
- }
- m.ID = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.ID |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 3:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field TTL", wireType)
- }
- m.TTL = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.TTL |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 4:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Error", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Error = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *LeaseRevokeRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: LeaseRevokeRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: LeaseRevokeRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
- }
- m.ID = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.ID |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *LeaseRevokeResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: LeaseRevokeResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: LeaseRevokeResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *LeaseCheckpoint) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: LeaseCheckpoint: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: LeaseCheckpoint: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
- }
- m.ID = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.ID |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Remaining_TTL", wireType)
- }
- m.Remaining_TTL = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Remaining_TTL |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *LeaseCheckpointRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: LeaseCheckpointRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: LeaseCheckpointRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Checkpoints", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Checkpoints = append(m.Checkpoints, &LeaseCheckpoint{})
- if err := m.Checkpoints[len(m.Checkpoints)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *LeaseCheckpointResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: LeaseCheckpointResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: LeaseCheckpointResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *LeaseKeepAliveRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: LeaseKeepAliveRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: LeaseKeepAliveRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
- }
- m.ID = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.ID |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *LeaseKeepAliveResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: LeaseKeepAliveResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: LeaseKeepAliveResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
- }
- m.ID = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.ID |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 3:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field TTL", wireType)
- }
- m.TTL = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.TTL |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *LeaseTimeToLiveRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: LeaseTimeToLiveRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: LeaseTimeToLiveRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
- }
- m.ID = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.ID |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Keys", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.Keys = bool(v != 0)
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *LeaseTimeToLiveResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: LeaseTimeToLiveResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: LeaseTimeToLiveResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
- }
- m.ID = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.ID |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 3:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field TTL", wireType)
- }
- m.TTL = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.TTL |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 4:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field GrantedTTL", wireType)
- }
- m.GrantedTTL = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.GrantedTTL |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 5:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Keys", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + byteLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Keys = append(m.Keys, make([]byte, postIndex-iNdEx))
- copy(m.Keys[len(m.Keys)-1], dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *LeaseLeasesRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: LeaseLeasesRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: LeaseLeasesRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *LeaseStatus) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: LeaseStatus: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: LeaseStatus: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
- }
- m.ID = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.ID |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *LeaseLeasesResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: LeaseLeasesResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: LeaseLeasesResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Leases", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Leases = append(m.Leases, &LeaseStatus{})
- if err := m.Leases[len(m.Leases)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *Member) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: Member: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: Member: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
- }
- m.ID = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.ID |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Name = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field PeerURLs", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.PeerURLs = append(m.PeerURLs, string(dAtA[iNdEx:postIndex]))
- iNdEx = postIndex
- case 4:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ClientURLs", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.ClientURLs = append(m.ClientURLs, string(dAtA[iNdEx:postIndex]))
- iNdEx = postIndex
- case 5:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field IsLearner", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.IsLearner = bool(v != 0)
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MemberAddRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MemberAddRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MemberAddRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field PeerURLs", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.PeerURLs = append(m.PeerURLs, string(dAtA[iNdEx:postIndex]))
- iNdEx = postIndex
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field IsLearner", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.IsLearner = bool(v != 0)
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MemberAddResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MemberAddResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MemberAddResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Member", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Member == nil {
- m.Member = &Member{}
- }
- if err := m.Member.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Members", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Members = append(m.Members, &Member{})
- if err := m.Members[len(m.Members)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MemberRemoveRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MemberRemoveRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MemberRemoveRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
- }
- m.ID = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.ID |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MemberRemoveResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MemberRemoveResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MemberRemoveResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Members", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Members = append(m.Members, &Member{})
- if err := m.Members[len(m.Members)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MemberUpdateRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MemberUpdateRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MemberUpdateRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
- }
- m.ID = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.ID |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field PeerURLs", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.PeerURLs = append(m.PeerURLs, string(dAtA[iNdEx:postIndex]))
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MemberUpdateResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MemberUpdateResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MemberUpdateResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Members", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Members = append(m.Members, &Member{})
- if err := m.Members[len(m.Members)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MemberListRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MemberListRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MemberListRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MemberListResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MemberListResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MemberListResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Members", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Members = append(m.Members, &Member{})
- if err := m.Members[len(m.Members)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MemberPromoteRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MemberPromoteRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MemberPromoteRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
- }
- m.ID = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.ID |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MemberPromoteResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MemberPromoteResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MemberPromoteResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Members", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Members = append(m.Members, &Member{})
- if err := m.Members[len(m.Members)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *DefragmentRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: DefragmentRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: DefragmentRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *DefragmentResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: DefragmentResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: DefragmentResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MoveLeaderRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MoveLeaderRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MoveLeaderRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field TargetID", wireType)
- }
- m.TargetID = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.TargetID |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *MoveLeaderResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: MoveLeaderResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: MoveLeaderResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AlarmRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AlarmRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AlarmRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Action", wireType)
- }
- m.Action = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Action |= (AlarmRequest_AlarmAction(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field MemberID", wireType)
- }
- m.MemberID = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.MemberID |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 3:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Alarm", wireType)
- }
- m.Alarm = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Alarm |= (AlarmType(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AlarmMember) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AlarmMember: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AlarmMember: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field MemberID", wireType)
- }
- m.MemberID = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.MemberID |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 2:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Alarm", wireType)
- }
- m.Alarm = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Alarm |= (AlarmType(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AlarmResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AlarmResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AlarmResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Alarms", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Alarms = append(m.Alarms, &AlarmMember{})
- if err := m.Alarms[len(m.Alarms)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *StatusRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: StatusRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: StatusRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *StatusResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: StatusResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: StatusResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Version = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 3:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field DbSize", wireType)
- }
- m.DbSize = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.DbSize |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 4:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field Leader", wireType)
- }
- m.Leader = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.Leader |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 5:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field RaftIndex", wireType)
- }
- m.RaftIndex = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.RaftIndex |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 6:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field RaftTerm", wireType)
- }
- m.RaftTerm = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.RaftTerm |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 7:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field RaftAppliedIndex", wireType)
- }
- m.RaftAppliedIndex = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.RaftAppliedIndex |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 8:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Errors", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Errors = append(m.Errors, string(dAtA[iNdEx:postIndex]))
- iNdEx = postIndex
- case 9:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field DbSizeInUse", wireType)
- }
- m.DbSizeInUse = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.DbSizeInUse |= (int64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 10:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field IsLearner", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.IsLearner = bool(v != 0)
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthEnableRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthEnableRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthEnableRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthDisableRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthDisableRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthDisableRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthenticateRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthenticateRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthenticateRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Name = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Password", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Password = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthUserAddRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthUserAddRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthUserAddRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Name = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Password", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Password = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Options", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Options == nil {
- m.Options = &authpb.UserAddOptions{}
- }
- if err := m.Options.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthUserGetRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthUserGetRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthUserGetRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Name = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthUserDeleteRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthUserDeleteRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthUserDeleteRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Name = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthUserChangePasswordRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthUserChangePasswordRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthUserChangePasswordRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Name = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Password", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Password = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthUserGrantRoleRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthUserGrantRoleRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthUserGrantRoleRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field User", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.User = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Role", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Role = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthUserRevokeRoleRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthUserRevokeRoleRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthUserRevokeRoleRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Name = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Role", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Role = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthRoleAddRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthRoleAddRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthRoleAddRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Name = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthRoleGetRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthRoleGetRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthRoleGetRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Role", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Role = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthUserListRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthUserListRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthUserListRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthRoleListRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthRoleListRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthRoleListRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthRoleDeleteRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthRoleDeleteRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthRoleDeleteRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Role", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Role = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthRoleGrantPermissionRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthRoleGrantPermissionRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthRoleGrantPermissionRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Name = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Perm", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Perm == nil {
- m.Perm = &authpb.Permission{}
- }
- if err := m.Perm.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthRoleRevokePermissionRequest) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthRoleRevokePermissionRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthRoleRevokePermissionRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Role", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Role = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + byteLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...)
- if m.Key == nil {
- m.Key = []byte{}
- }
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field RangeEnd", wireType)
- }
- var byteLen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- byteLen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if byteLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + byteLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.RangeEnd = append(m.RangeEnd[:0], dAtA[iNdEx:postIndex]...)
- if m.RangeEnd == nil {
- m.RangeEnd = []byte{}
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthEnableResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthEnableResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthEnableResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthDisableResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthDisableResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthDisableResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthenticateResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthenticateResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthenticateResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Token = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthUserAddResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthUserAddResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthUserAddResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthUserGetResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthUserGetResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthUserGetResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Roles", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Roles = append(m.Roles, string(dAtA[iNdEx:postIndex]))
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthUserDeleteResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthUserDeleteResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthUserDeleteResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthUserChangePasswordResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthUserChangePasswordResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthUserChangePasswordResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthUserGrantRoleResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthUserGrantRoleResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthUserGrantRoleResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthUserRevokeRoleResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthUserRevokeRoleResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthUserRevokeRoleResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthRoleAddResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthRoleAddResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthRoleAddResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthRoleGetResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthRoleGetResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthRoleGetResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Perm", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Perm = append(m.Perm, &authpb.Permission{})
- if err := m.Perm[len(m.Perm)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthRoleListResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthRoleListResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthRoleListResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Roles", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Roles = append(m.Roles, string(dAtA[iNdEx:postIndex]))
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthUserListResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthUserListResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthUserListResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Users", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + intStringLen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Users = append(m.Users, string(dAtA[iNdEx:postIndex]))
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthRoleDeleteResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthRoleDeleteResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthRoleDeleteResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthRoleGrantPermissionResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthRoleGrantPermissionResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthRoleGrantPermissionResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *AuthRoleRevokePermissionResponse) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: AuthRoleRevokePermissionResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: AuthRoleRevokePermissionResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthRpc
- }
- postIndex := iNdEx + msglen
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- if m.Header == nil {
- m.Header = &ResponseHeader{}
- }
- if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipRpc(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if skippy < 0 {
- return ErrInvalidLengthRpc
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func skipRpc(dAtA []byte) (n int, err error) {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- wireType := int(wire & 0x7)
- switch wireType {
- case 0:
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- iNdEx++
- if dAtA[iNdEx-1] < 0x80 {
- break
- }
- }
- return iNdEx, nil
- case 1:
- iNdEx += 8
- return iNdEx, nil
- case 2:
- var length int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- length |= (int(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- iNdEx += length
- if length < 0 {
- return 0, ErrInvalidLengthRpc
- }
- return iNdEx, nil
- case 3:
- for {
- var innerWire uint64
- var start int = iNdEx
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowRpc
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- innerWire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- innerWireType := int(innerWire & 0x7)
- if innerWireType == 4 {
- break
- }
- next, err := skipRpc(dAtA[start:])
- if err != nil {
- return 0, err
- }
- iNdEx = start + next
- }
- return iNdEx, nil
- case 4:
- return iNdEx, nil
- case 5:
- iNdEx += 4
- return iNdEx, nil
- default:
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
- }
- }
- panic("unreachable")
-}
-
-var (
- ErrInvalidLengthRpc = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowRpc = fmt.Errorf("proto: integer overflow")
-)
-
-func init() { proto.RegisterFile("rpc.proto", fileDescriptorRpc) }
-
-var fileDescriptorRpc = []byte{
- // 3928 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x5b, 0x5b, 0x6f, 0x23, 0xc9,
- 0x75, 0x56, 0x93, 0xe2, 0xed, 0xf0, 0x22, 0xaa, 0x74, 0x19, 0x0e, 0x67, 0x46, 0xa3, 0xad, 0xd9,
- 0xd9, 0xd5, 0xce, 0xec, 0x8a, 0x6b, 0xd9, 0x4e, 0x80, 0x49, 0xe2, 0x58, 0x23, 0x71, 0x67, 0xb4,
- 0xd2, 0x88, 0xda, 0x16, 0x67, 0xf6, 0x02, 0x23, 0x42, 0x8b, 0x2c, 0x49, 0x1d, 0x91, 0xdd, 0x74,
- 0x77, 0x93, 0x23, 0x6d, 0x2e, 0x0e, 0x0c, 0xc7, 0x40, 0xf2, 0x68, 0x03, 0x41, 0xf2, 0x90, 0xa7,
- 0x20, 0x08, 0xfc, 0x90, 0xe7, 0x00, 0xf9, 0x05, 0x79, 0xca, 0x05, 0xf9, 0x03, 0xc1, 0xc6, 0x2f,
- 0xc9, 0xaf, 0x30, 0xea, 0xd6, 0x5d, 0x7d, 0xa3, 0xc6, 0xa6, 0x77, 0x5f, 0xa4, 0xae, 0x53, 0xa7,
- 0xce, 0x39, 0x75, 0xaa, 0xea, 0x9c, 0xd3, 0x5f, 0x17, 0xa1, 0xe4, 0x8c, 0x7a, 0x9b, 0x23, 0xc7,
- 0xf6, 0x6c, 0x54, 0x21, 0x5e, 0xaf, 0xef, 0x12, 0x67, 0x42, 0x9c, 0xd1, 0x69, 0x73, 0xf9, 0xdc,
- 0x3e, 0xb7, 0x59, 0x47, 0x8b, 0x3e, 0x71, 0x9e, 0xe6, 0x6d, 0xca, 0xd3, 0x1a, 0x4e, 0x7a, 0x3d,
- 0xf6, 0x67, 0x74, 0xda, 0xba, 0x9c, 0x88, 0xae, 0x3b, 0xac, 0xcb, 0x18, 0x7b, 0x17, 0xec, 0xcf,
- 0xe8, 0x94, 0xfd, 0x13, 0x9d, 0x77, 0xcf, 0x6d, 0xfb, 0x7c, 0x40, 0x5a, 0xc6, 0xc8, 0x6c, 0x19,
- 0x96, 0x65, 0x7b, 0x86, 0x67, 0xda, 0x96, 0xcb, 0x7b, 0xf1, 0x5f, 0x6a, 0x50, 0xd3, 0x89, 0x3b,
- 0xb2, 0x2d, 0x97, 0x3c, 0x27, 0x46, 0x9f, 0x38, 0xe8, 0x1e, 0x40, 0x6f, 0x30, 0x76, 0x3d, 0xe2,
- 0x9c, 0x98, 0xfd, 0x86, 0xb6, 0xae, 0x6d, 0xcc, 0xeb, 0x25, 0x41, 0xd9, 0xeb, 0xa3, 0x3b, 0x50,
- 0x1a, 0x92, 0xe1, 0x29, 0xef, 0xcd, 0xb0, 0xde, 0x22, 0x27, 0xec, 0xf5, 0x51, 0x13, 0x8a, 0x0e,
- 0x99, 0x98, 0xae, 0x69, 0x5b, 0x8d, 0xec, 0xba, 0xb6, 0x91, 0xd5, 0xfd, 0x36, 0x1d, 0xe8, 0x18,
- 0x67, 0xde, 0x89, 0x47, 0x9c, 0x61, 0x63, 0x9e, 0x0f, 0xa4, 0x84, 0x2e, 0x71, 0x86, 0xf8, 0x27,
- 0x39, 0xa8, 0xe8, 0x86, 0x75, 0x4e, 0x74, 0xf2, 0xc3, 0x31, 0x71, 0x3d, 0x54, 0x87, 0xec, 0x25,
- 0xb9, 0x66, 0xea, 0x2b, 0x3a, 0x7d, 0xe4, 0xe3, 0xad, 0x73, 0x72, 0x42, 0x2c, 0xae, 0xb8, 0x42,
- 0xc7, 0x5b, 0xe7, 0xa4, 0x6d, 0xf5, 0xd1, 0x32, 0xe4, 0x06, 0xe6, 0xd0, 0xf4, 0x84, 0x56, 0xde,
- 0x08, 0x99, 0x33, 0x1f, 0x31, 0x67, 0x07, 0xc0, 0xb5, 0x1d, 0xef, 0xc4, 0x76, 0xfa, 0xc4, 0x69,
- 0xe4, 0xd6, 0xb5, 0x8d, 0xda, 0xd6, 0xdb, 0x9b, 0xea, 0x42, 0x6c, 0xaa, 0x06, 0x6d, 0x1e, 0xdb,
- 0x8e, 0xd7, 0xa1, 0xbc, 0x7a, 0xc9, 0x95, 0x8f, 0xe8, 0x23, 0x28, 0x33, 0x21, 0x9e, 0xe1, 0x9c,
- 0x13, 0xaf, 0x91, 0x67, 0x52, 0x1e, 0xde, 0x20, 0xa5, 0xcb, 0x98, 0x75, 0xa6, 0x9e, 0x3f, 0x23,
- 0x0c, 0x15, 0x97, 0x38, 0xa6, 0x31, 0x30, 0xbf, 0x34, 0x4e, 0x07, 0xa4, 0x51, 0x58, 0xd7, 0x36,
- 0x8a, 0x7a, 0x88, 0x46, 0xe7, 0x7f, 0x49, 0xae, 0xdd, 0x13, 0xdb, 0x1a, 0x5c, 0x37, 0x8a, 0x8c,
- 0xa1, 0x48, 0x09, 0x1d, 0x6b, 0x70, 0xcd, 0x16, 0xcd, 0x1e, 0x5b, 0x1e, 0xef, 0x2d, 0xb1, 0xde,
- 0x12, 0xa3, 0xb0, 0xee, 0x0d, 0xa8, 0x0f, 0x4d, 0xeb, 0x64, 0x68, 0xf7, 0x4f, 0x7c, 0x87, 0x00,
- 0x73, 0x48, 0x6d, 0x68, 0x5a, 0x2f, 0xec, 0xbe, 0x2e, 0xdd, 0x42, 0x39, 0x8d, 0xab, 0x30, 0x67,
- 0x59, 0x70, 0x1a, 0x57, 0x2a, 0xe7, 0x26, 0x2c, 0x51, 0x99, 0x3d, 0x87, 0x18, 0x1e, 0x09, 0x98,
- 0x2b, 0x8c, 0x79, 0x71, 0x68, 0x5a, 0x3b, 0xac, 0x27, 0xc4, 0x6f, 0x5c, 0xc5, 0xf8, 0xab, 0x82,
- 0xdf, 0xb8, 0x0a, 0xf3, 0xe3, 0x4d, 0x28, 0xf9, 0x3e, 0x47, 0x45, 0x98, 0x3f, 0xec, 0x1c, 0xb6,
- 0xeb, 0x73, 0x08, 0x20, 0xbf, 0x7d, 0xbc, 0xd3, 0x3e, 0xdc, 0xad, 0x6b, 0xa8, 0x0c, 0x85, 0xdd,
- 0x36, 0x6f, 0x64, 0xf0, 0x53, 0x80, 0xc0, 0xbb, 0xa8, 0x00, 0xd9, 0xfd, 0xf6, 0xe7, 0xf5, 0x39,
- 0xca, 0xf3, 0xaa, 0xad, 0x1f, 0xef, 0x75, 0x0e, 0xeb, 0x1a, 0x1d, 0xbc, 0xa3, 0xb7, 0xb7, 0xbb,
- 0xed, 0x7a, 0x86, 0x72, 0xbc, 0xe8, 0xec, 0xd6, 0xb3, 0xa8, 0x04, 0xb9, 0x57, 0xdb, 0x07, 0x2f,
- 0xdb, 0xf5, 0x79, 0xfc, 0x73, 0x0d, 0xaa, 0x62, 0xbd, 0xf8, 0x99, 0x40, 0xdf, 0x81, 0xfc, 0x05,
- 0x3b, 0x17, 0x6c, 0x2b, 0x96, 0xb7, 0xee, 0x46, 0x16, 0x37, 0x74, 0x76, 0x74, 0xc1, 0x8b, 0x30,
- 0x64, 0x2f, 0x27, 0x6e, 0x23, 0xb3, 0x9e, 0xdd, 0x28, 0x6f, 0xd5, 0x37, 0xf9, 0x81, 0xdd, 0xdc,
- 0x27, 0xd7, 0xaf, 0x8c, 0xc1, 0x98, 0xe8, 0xb4, 0x13, 0x21, 0x98, 0x1f, 0xda, 0x0e, 0x61, 0x3b,
- 0xb6, 0xa8, 0xb3, 0x67, 0xba, 0x8d, 0xd9, 0xa2, 0x89, 0xdd, 0xca, 0x1b, 0xf8, 0x17, 0x1a, 0xc0,
- 0xd1, 0xd8, 0x4b, 0x3f, 0x1a, 0xcb, 0x90, 0x9b, 0x50, 0xc1, 0xe2, 0x58, 0xf0, 0x06, 0x3b, 0x13,
- 0xc4, 0x70, 0x89, 0x7f, 0x26, 0x68, 0x03, 0xdd, 0x82, 0xc2, 0xc8, 0x21, 0x93, 0x93, 0xcb, 0x09,
- 0x53, 0x52, 0xd4, 0xf3, 0xb4, 0xb9, 0x3f, 0x41, 0x6f, 0x41, 0xc5, 0x3c, 0xb7, 0x6c, 0x87, 0x9c,
- 0x70, 0x59, 0x39, 0xd6, 0x5b, 0xe6, 0x34, 0x66, 0xb7, 0xc2, 0xc2, 0x05, 0xe7, 0x55, 0x96, 0x03,
- 0x4a, 0xc2, 0x16, 0x94, 0x99, 0xa9, 0x33, 0xb9, 0xef, 0xbd, 0xc0, 0xc6, 0x0c, 0x1b, 0x16, 0x77,
- 0xa1, 0xb0, 0x1a, 0xff, 0x00, 0xd0, 0x2e, 0x19, 0x10, 0x8f, 0xcc, 0x12, 0x3d, 0x14, 0x9f, 0x64,
- 0x55, 0x9f, 0xe0, 0x9f, 0x69, 0xb0, 0x14, 0x12, 0x3f, 0xd3, 0xb4, 0x1a, 0x50, 0xe8, 0x33, 0x61,
- 0xdc, 0x82, 0xac, 0x2e, 0x9b, 0xe8, 0x31, 0x14, 0x85, 0x01, 0x6e, 0x23, 0x9b, 0xb2, 0x69, 0x0a,
- 0xdc, 0x26, 0x17, 0xff, 0x22, 0x03, 0x25, 0x31, 0xd1, 0xce, 0x08, 0x6d, 0x43, 0xd5, 0xe1, 0x8d,
- 0x13, 0x36, 0x1f, 0x61, 0x51, 0x33, 0x3d, 0x08, 0x3d, 0x9f, 0xd3, 0x2b, 0x62, 0x08, 0x23, 0xa3,
- 0xdf, 0x83, 0xb2, 0x14, 0x31, 0x1a, 0x7b, 0xc2, 0xe5, 0x8d, 0xb0, 0x80, 0x60, 0xff, 0x3d, 0x9f,
- 0xd3, 0x41, 0xb0, 0x1f, 0x8d, 0x3d, 0xd4, 0x85, 0x65, 0x39, 0x98, 0xcf, 0x46, 0x98, 0x91, 0x65,
- 0x52, 0xd6, 0xc3, 0x52, 0xe2, 0x4b, 0xf5, 0x7c, 0x4e, 0x47, 0x62, 0xbc, 0xd2, 0xa9, 0x9a, 0xe4,
- 0x5d, 0xf1, 0xe0, 0x1d, 0x33, 0xa9, 0x7b, 0x65, 0xc5, 0x4d, 0xea, 0x5e, 0x59, 0x4f, 0x4b, 0x50,
- 0x10, 0x2d, 0xfc, 0x2f, 0x19, 0x00, 0xb9, 0x1a, 0x9d, 0x11, 0xda, 0x85, 0x9a, 0x23, 0x5a, 0x21,
- 0x6f, 0xdd, 0x49, 0xf4, 0x96, 0x58, 0xc4, 0x39, 0xbd, 0x2a, 0x07, 0x71, 0xe3, 0xbe, 0x07, 0x15,
- 0x5f, 0x4a, 0xe0, 0xb0, 0xdb, 0x09, 0x0e, 0xf3, 0x25, 0x94, 0xe5, 0x00, 0xea, 0xb2, 0x4f, 0x61,
- 0xc5, 0x1f, 0x9f, 0xe0, 0xb3, 0xb7, 0xa6, 0xf8, 0xcc, 0x17, 0xb8, 0x24, 0x25, 0xa8, 0x5e, 0x53,
- 0x0d, 0x0b, 0xdc, 0x76, 0x3b, 0xc1, 0x6d, 0x71, 0xc3, 0xa8, 0xe3, 0x80, 0xe6, 0x4b, 0xde, 0xc4,
- 0xff, 0x97, 0x85, 0xc2, 0x8e, 0x3d, 0x1c, 0x19, 0x0e, 0x5d, 0x8d, 0xbc, 0x43, 0xdc, 0xf1, 0xc0,
- 0x63, 0xee, 0xaa, 0x6d, 0x3d, 0x08, 0x4b, 0x14, 0x6c, 0xf2, 0xbf, 0xce, 0x58, 0x75, 0x31, 0x84,
- 0x0e, 0x16, 0xe9, 0x31, 0xf3, 0x06, 0x83, 0x45, 0x72, 0x14, 0x43, 0xe4, 0x41, 0xce, 0x06, 0x07,
- 0xb9, 0x09, 0x85, 0x09, 0x71, 0x82, 0x94, 0xfe, 0x7c, 0x4e, 0x97, 0x04, 0xf4, 0x1e, 0x2c, 0x44,
- 0xd3, 0x4b, 0x4e, 0xf0, 0xd4, 0x7a, 0xe1, 0x6c, 0xf4, 0x00, 0x2a, 0xa1, 0x1c, 0x97, 0x17, 0x7c,
- 0xe5, 0xa1, 0x92, 0xe2, 0x56, 0x65, 0x5c, 0xa5, 0xf9, 0xb8, 0xf2, 0x7c, 0x4e, 0x46, 0xd6, 0x55,
- 0x19, 0x59, 0x8b, 0x62, 0x94, 0x88, 0xad, 0xa1, 0x20, 0xf3, 0xfd, 0x70, 0x90, 0xc1, 0xdf, 0x87,
- 0x6a, 0xc8, 0x41, 0x34, 0xef, 0xb4, 0x3f, 0x79, 0xb9, 0x7d, 0xc0, 0x93, 0xd4, 0x33, 0x96, 0x97,
- 0xf4, 0xba, 0x46, 0x73, 0xdd, 0x41, 0xfb, 0xf8, 0xb8, 0x9e, 0x41, 0x55, 0x28, 0x1d, 0x76, 0xba,
- 0x27, 0x9c, 0x2b, 0x8b, 0x9f, 0xf9, 0x12, 0x44, 0x92, 0x53, 0x72, 0xdb, 0x9c, 0x92, 0xdb, 0x34,
- 0x99, 0xdb, 0x32, 0x41, 0x6e, 0x63, 0x69, 0xee, 0xa0, 0xbd, 0x7d, 0xdc, 0xae, 0xcf, 0x3f, 0xad,
- 0x41, 0x85, 0xfb, 0xf7, 0x64, 0x6c, 0xd1, 0x54, 0xfb, 0x0f, 0x1a, 0x40, 0x70, 0x9a, 0x50, 0x0b,
- 0x0a, 0x3d, 0xae, 0xa7, 0xa1, 0xb1, 0x60, 0xb4, 0x92, 0xb8, 0x64, 0xba, 0xe4, 0x42, 0xdf, 0x82,
- 0x82, 0x3b, 0xee, 0xf5, 0x88, 0x2b, 0x53, 0xde, 0xad, 0x68, 0x3c, 0x14, 0xd1, 0x4a, 0x97, 0x7c,
- 0x74, 0xc8, 0x99, 0x61, 0x0e, 0xc6, 0x2c, 0x01, 0x4e, 0x1f, 0x22, 0xf8, 0xf0, 0xdf, 0x69, 0x50,
- 0x56, 0x36, 0xef, 0x6f, 0x18, 0x84, 0xef, 0x42, 0x89, 0xd9, 0x40, 0xfa, 0x22, 0x0c, 0x17, 0xf5,
- 0x80, 0x80, 0x7e, 0x07, 0x4a, 0xf2, 0x04, 0xc8, 0x48, 0xdc, 0x48, 0x16, 0xdb, 0x19, 0xe9, 0x01,
- 0x2b, 0xde, 0x87, 0x45, 0xe6, 0x95, 0x1e, 0x2d, 0xae, 0xa5, 0x1f, 0xd5, 0xf2, 0x53, 0x8b, 0x94,
- 0x9f, 0x4d, 0x28, 0x8e, 0x2e, 0xae, 0x5d, 0xb3, 0x67, 0x0c, 0x84, 0x15, 0x7e, 0x1b, 0x7f, 0x0c,
- 0x48, 0x15, 0x36, 0xcb, 0x74, 0x71, 0x15, 0xca, 0xcf, 0x0d, 0xf7, 0x42, 0x98, 0x84, 0x1f, 0x43,
- 0x95, 0x36, 0xf7, 0x5f, 0xbd, 0x81, 0x8d, 0xec, 0xe5, 0x40, 0x72, 0xcf, 0xe4, 0x73, 0x04, 0xf3,
- 0x17, 0x86, 0x7b, 0xc1, 0x26, 0x5a, 0xd5, 0xd9, 0x33, 0x7a, 0x0f, 0xea, 0x3d, 0x3e, 0xc9, 0x93,
- 0xc8, 0x2b, 0xc3, 0x82, 0xa0, 0xfb, 0x95, 0xe0, 0x67, 0x50, 0xe1, 0x73, 0xf8, 0x6d, 0x1b, 0x81,
- 0x17, 0x61, 0xe1, 0xd8, 0x32, 0x46, 0xee, 0x85, 0x2d, 0xb3, 0x1b, 0x9d, 0x74, 0x3d, 0xa0, 0xcd,
- 0xa4, 0xf1, 0x5d, 0x58, 0x70, 0xc8, 0xd0, 0x30, 0x2d, 0xd3, 0x3a, 0x3f, 0x39, 0xbd, 0xf6, 0x88,
- 0x2b, 0x5e, 0x98, 0x6a, 0x3e, 0xf9, 0x29, 0xa5, 0x52, 0xd3, 0x4e, 0x07, 0xf6, 0xa9, 0x08, 0x73,
- 0xec, 0x19, 0xff, 0x34, 0x03, 0x95, 0x4f, 0x0d, 0xaf, 0x27, 0x97, 0x0e, 0xed, 0x41, 0xcd, 0x0f,
- 0x6e, 0x8c, 0x22, 0x6c, 0x89, 0xa4, 0x58, 0x36, 0x46, 0x96, 0xd2, 0x32, 0x3b, 0x56, 0x7b, 0x2a,
- 0x81, 0x89, 0x32, 0xac, 0x1e, 0x19, 0xf8, 0xa2, 0x32, 0xe9, 0xa2, 0x18, 0xa3, 0x2a, 0x4a, 0x25,
- 0xa0, 0x0e, 0xd4, 0x47, 0x8e, 0x7d, 0xee, 0x10, 0xd7, 0xf5, 0x85, 0xf1, 0x34, 0x86, 0x13, 0x84,
- 0x1d, 0x09, 0xd6, 0x40, 0xdc, 0xc2, 0x28, 0x4c, 0x7a, 0xba, 0x10, 0xd4, 0x33, 0x3c, 0x38, 0xfd,
- 0x57, 0x06, 0x50, 0x7c, 0x52, 0xbf, 0x6e, 0x89, 0xf7, 0x10, 0x6a, 0xae, 0x67, 0x38, 0xb1, 0xcd,
- 0x56, 0x65, 0x54, 0x3f, 0xe2, 0xbf, 0x0b, 0xbe, 0x41, 0x27, 0x96, 0xed, 0x99, 0x67, 0xd7, 0xa2,
- 0x4a, 0xae, 0x49, 0xf2, 0x21, 0xa3, 0xa2, 0x36, 0x14, 0xce, 0xcc, 0x81, 0x47, 0x1c, 0xb7, 0x91,
- 0x5b, 0xcf, 0x6e, 0xd4, 0xb6, 0x1e, 0xdf, 0xb4, 0x0c, 0x9b, 0x1f, 0x31, 0xfe, 0xee, 0xf5, 0x88,
- 0xe8, 0x72, 0xac, 0x5a, 0x79, 0xe6, 0x43, 0xd5, 0xf8, 0x6d, 0x28, 0xbe, 0xa6, 0x22, 0xe8, 0x5b,
- 0x76, 0x81, 0x17, 0x8b, 0xac, 0xcd, 0x5f, 0xb2, 0xcf, 0x1c, 0xe3, 0x7c, 0x48, 0x2c, 0x4f, 0xbe,
- 0x07, 0xca, 0x36, 0x7e, 0x08, 0x10, 0xa8, 0xa1, 0x21, 0xff, 0xb0, 0x73, 0xf4, 0xb2, 0x5b, 0x9f,
- 0x43, 0x15, 0x28, 0x1e, 0x76, 0x76, 0xdb, 0x07, 0x6d, 0x9a, 0x1f, 0x70, 0x4b, 0xba, 0x34, 0xb4,
- 0x96, 0xaa, 0x4e, 0x2d, 0xa4, 0x13, 0xaf, 0xc2, 0x72, 0xd2, 0x02, 0xd2, 0x5a, 0xb4, 0x2a, 0x76,
- 0xe9, 0x4c, 0x47, 0x45, 0x55, 0x9d, 0x09, 0x4f, 0xb7, 0x01, 0x05, 0xbe, 0x7b, 0xfb, 0xa2, 0x38,
- 0x97, 0x4d, 0xea, 0x08, 0xbe, 0x19, 0x49, 0x5f, 0xac, 0x92, 0xdf, 0x4e, 0x0c, 0x2f, 0xb9, 0xc4,
- 0xf0, 0x82, 0x1e, 0x40, 0xd5, 0x3f, 0x0d, 0x86, 0x2b, 0x6a, 0x81, 0x92, 0x5e, 0x91, 0x1b, 0x9d,
- 0xd2, 0x42, 0x4e, 0x2f, 0x84, 0x9d, 0x8e, 0x1e, 0x42, 0x9e, 0x4c, 0x88, 0xe5, 0xb9, 0x8d, 0x32,
- 0xcb, 0x18, 0x55, 0x59, 0xbb, 0xb7, 0x29, 0x55, 0x17, 0x9d, 0xf8, 0xbb, 0xb0, 0xc8, 0xde, 0x91,
- 0x9e, 0x39, 0x86, 0xa5, 0xbe, 0xcc, 0x75, 0xbb, 0x07, 0xc2, 0xdd, 0xf4, 0x11, 0xd5, 0x20, 0xb3,
- 0xb7, 0x2b, 0x9c, 0x90, 0xd9, 0xdb, 0xc5, 0x3f, 0xd6, 0x00, 0xa9, 0xe3, 0x66, 0xf2, 0x73, 0x44,
- 0xb8, 0x54, 0x9f, 0x0d, 0xd4, 0x2f, 0x43, 0x8e, 0x38, 0x8e, 0xed, 0x30, 0x8f, 0x96, 0x74, 0xde,
- 0xc0, 0x6f, 0x0b, 0x1b, 0x74, 0x32, 0xb1, 0x2f, 0xfd, 0x33, 0xc8, 0xa5, 0x69, 0xbe, 0xa9, 0xfb,
- 0xb0, 0x14, 0xe2, 0x9a, 0x29, 0x73, 0x7d, 0x04, 0x0b, 0x4c, 0xd8, 0xce, 0x05, 0xe9, 0x5d, 0x8e,
- 0x6c, 0xd3, 0x8a, 0xe9, 0xa3, 0x2b, 0x17, 0x04, 0x58, 0x3a, 0x0f, 0x3e, 0xb1, 0x8a, 0x4f, 0xec,
- 0x76, 0x0f, 0xf0, 0xe7, 0xb0, 0x1a, 0x91, 0x23, 0xcd, 0xff, 0x43, 0x28, 0xf7, 0x7c, 0xa2, 0x2b,
- 0x6a, 0x9d, 0x7b, 0x61, 0xe3, 0xa2, 0x43, 0xd5, 0x11, 0xb8, 0x03, 0xb7, 0x62, 0xa2, 0x67, 0x9a,
- 0xf3, 0xbb, 0xb0, 0xc2, 0x04, 0xee, 0x13, 0x32, 0xda, 0x1e, 0x98, 0x93, 0x54, 0x4f, 0x8f, 0xc4,
- 0xa4, 0x14, 0xc6, 0xaf, 0x77, 0x5f, 0xe0, 0xdf, 0x17, 0x1a, 0xbb, 0xe6, 0x90, 0x74, 0xed, 0x83,
- 0x74, 0xdb, 0x68, 0x36, 0xbb, 0x24, 0xd7, 0xae, 0x28, 0x6b, 0xd8, 0x33, 0xfe, 0x47, 0x4d, 0xb8,
- 0x4a, 0x1d, 0xfe, 0x35, 0xef, 0xe4, 0x35, 0x80, 0x73, 0x7a, 0x64, 0x48, 0x9f, 0x76, 0x70, 0x44,
- 0x45, 0xa1, 0xf8, 0x76, 0xd2, 0xf8, 0x5d, 0x11, 0x76, 0x2e, 0x8b, 0x7d, 0xce, 0xfe, 0xf8, 0x51,
- 0xee, 0x1e, 0x94, 0x19, 0xe1, 0xd8, 0x33, 0xbc, 0xb1, 0x1b, 0x5b, 0x8c, 0x3f, 0x17, 0xdb, 0x5e,
- 0x0e, 0x9a, 0x69, 0x5e, 0xdf, 0x82, 0x3c, 0x7b, 0x99, 0x90, 0xa5, 0xf4, 0xed, 0x84, 0xfd, 0xc8,
- 0xed, 0xd0, 0x05, 0x23, 0xfe, 0xa9, 0x06, 0xf9, 0x17, 0x0c, 0x82, 0x55, 0x4c, 0x9b, 0x97, 0x6b,
- 0x61, 0x19, 0x43, 0x0e, 0x0c, 0x95, 0x74, 0xf6, 0xcc, 0x4a, 0x4f, 0x42, 0x9c, 0x97, 0xfa, 0x01,
- 0x2f, 0x71, 0x4b, 0xba, 0xdf, 0xa6, 0x3e, 0xeb, 0x0d, 0x4c, 0x62, 0x79, 0xac, 0x77, 0x9e, 0xf5,
- 0x2a, 0x14, 0x5a, 0x3d, 0x9b, 0xee, 0x01, 0x31, 0x1c, 0x4b, 0x80, 0xa6, 0x45, 0x3d, 0x20, 0xe0,
- 0x03, 0xa8, 0x73, 0x3b, 0xb6, 0xfb, 0x7d, 0xa5, 0xc0, 0xf4, 0xb5, 0x69, 0x11, 0x6d, 0x21, 0x69,
- 0x99, 0xa8, 0xb4, 0x7f, 0xd2, 0x60, 0x51, 0x11, 0x37, 0x93, 0x57, 0xdf, 0x87, 0x3c, 0x07, 0xa9,
- 0x45, 0xa5, 0xb3, 0x1c, 0x1e, 0xc5, 0xd5, 0xe8, 0x82, 0x07, 0x6d, 0x42, 0x81, 0x3f, 0xc9, 0x77,
- 0x80, 0x64, 0x76, 0xc9, 0x84, 0x1f, 0xc2, 0x92, 0x20, 0x91, 0xa1, 0x9d, 0x74, 0x30, 0xd8, 0x62,
- 0xe0, 0x3f, 0x85, 0xe5, 0x30, 0xdb, 0x4c, 0x53, 0x52, 0x8c, 0xcc, 0xbc, 0x89, 0x91, 0xdb, 0xd2,
- 0xc8, 0x97, 0xa3, 0xbe, 0x52, 0x47, 0x45, 0x77, 0x8c, 0xba, 0x5e, 0x99, 0xf0, 0x7a, 0x05, 0x13,
- 0x90, 0x22, 0xbe, 0xd1, 0x09, 0x2c, 0xc9, 0xed, 0x70, 0x60, 0xba, 0x7e, 0xb9, 0xfe, 0x25, 0x20,
- 0x95, 0xf8, 0x8d, 0x1a, 0xf4, 0x8e, 0x74, 0xc7, 0x91, 0x63, 0x0f, 0xed, 0x54, 0x97, 0xe2, 0x3f,
- 0x83, 0x95, 0x08, 0xdf, 0x37, 0xed, 0xb7, 0x5d, 0x22, 0x8b, 0x15, 0xe9, 0xb7, 0x8f, 0x01, 0xa9,
- 0xc4, 0x99, 0xb2, 0x56, 0x0b, 0x16, 0x5f, 0xd8, 0x13, 0x1a, 0xfe, 0x28, 0x35, 0x38, 0xf7, 0x1c,
- 0x63, 0xf0, 0x5d, 0xe1, 0xb7, 0xa9, 0x72, 0x75, 0xc0, 0x4c, 0xca, 0xff, 0x43, 0x83, 0xca, 0xf6,
- 0xc0, 0x70, 0x86, 0x52, 0xf1, 0xf7, 0x20, 0xcf, 0xdf, 0x9c, 0x05, 0x58, 0xf5, 0x4e, 0x58, 0x8c,
- 0xca, 0xcb, 0x1b, 0xdb, 0xfc, 0x3d, 0x5b, 0x8c, 0xa2, 0x86, 0x8b, 0xef, 0x59, 0xbb, 0x91, 0xef,
- 0x5b, 0xbb, 0xe8, 0x03, 0xc8, 0x19, 0x74, 0x08, 0x4b, 0x33, 0xb5, 0x28, 0x66, 0xc1, 0xa4, 0xb1,
- 0xfa, 0x9e, 0x73, 0xe1, 0xef, 0x40, 0x59, 0xd1, 0x80, 0x0a, 0x90, 0x7d, 0xd6, 0x16, 0xc5, 0xf8,
- 0xf6, 0x4e, 0x77, 0xef, 0x15, 0x07, 0x6b, 0x6a, 0x00, 0xbb, 0x6d, 0xbf, 0x9d, 0xc1, 0x9f, 0x89,
- 0x51, 0x22, 0xa4, 0xab, 0xf6, 0x68, 0x69, 0xf6, 0x64, 0xde, 0xc8, 0x9e, 0x2b, 0xa8, 0x8a, 0xe9,
- 0xcf, 0x9a, 0xa2, 0x98, 0xbc, 0x94, 0x14, 0xa5, 0x18, 0xaf, 0x0b, 0x46, 0xbc, 0x00, 0x55, 0x91,
- 0xb4, 0xc4, 0xfe, 0xfb, 0xf7, 0x0c, 0xd4, 0x24, 0x65, 0x56, 0x50, 0x5d, 0xe2, 0x81, 0x3c, 0xc9,
- 0xf9, 0x68, 0xe0, 0x2a, 0xe4, 0xfb, 0xa7, 0xc7, 0xe6, 0x97, 0xf2, 0x03, 0x88, 0x68, 0x51, 0xfa,
- 0x80, 0xeb, 0xe1, 0x5f, 0x21, 0x45, 0x8b, 0x66, 0x23, 0xc7, 0x38, 0xf3, 0xf6, 0xac, 0x3e, 0xb9,
- 0x62, 0xb9, 0x6d, 0x5e, 0x0f, 0x08, 0x0c, 0x28, 0x11, 0x5f, 0x2b, 0xd9, 0x0b, 0x82, 0xf2, 0xf5,
- 0x12, 0x3d, 0x82, 0x3a, 0x7d, 0xde, 0x1e, 0x8d, 0x06, 0x26, 0xe9, 0x73, 0x01, 0x05, 0xc6, 0x13,
- 0xa3, 0x53, 0xed, 0xac, 0xa4, 0x76, 0x1b, 0x45, 0x16, 0x5d, 0x45, 0x0b, 0xad, 0x43, 0x99, 0xdb,
- 0xb7, 0x67, 0xbd, 0x74, 0x09, 0xfb, 0x84, 0x97, 0xd5, 0x55, 0x52, 0x38, 0x5b, 0x42, 0x34, 0x5b,
- 0x2e, 0xc1, 0xe2, 0xf6, 0xd8, 0xbb, 0x68, 0x5b, 0xc6, 0xe9, 0x40, 0x46, 0x22, 0x5a, 0xce, 0x50,
- 0xe2, 0xae, 0xe9, 0xaa, 0xd4, 0x36, 0x2c, 0x51, 0x2a, 0xb1, 0x3c, 0xb3, 0xa7, 0x64, 0x02, 0x59,
- 0x2b, 0x68, 0x91, 0x5a, 0xc1, 0x70, 0xdd, 0xd7, 0xb6, 0xd3, 0x17, 0xee, 0xf5, 0xdb, 0x78, 0xc2,
- 0x85, 0xbf, 0x74, 0x43, 0xf9, 0xfe, 0xd7, 0x94, 0x82, 0x3e, 0x84, 0x82, 0x3d, 0x62, 0x9f, 0xa4,
- 0x05, 0x6e, 0xb0, 0xba, 0xc9, 0x3f, 0x62, 0x6f, 0x0a, 0xc1, 0x1d, 0xde, 0xab, 0x4b, 0x36, 0xbc,
- 0x11, 0xe8, 0x7d, 0x46, 0xbc, 0x29, 0x7a, 0xf1, 0x63, 0x58, 0x91, 0x9c, 0x02, 0x26, 0x9f, 0xc2,
- 0xdc, 0x81, 0x7b, 0x92, 0x79, 0xe7, 0xc2, 0xb0, 0xce, 0xc9, 0x91, 0x30, 0xf1, 0x37, 0xf5, 0xcf,
- 0x53, 0x68, 0xf8, 0x76, 0xb2, 0x57, 0x37, 0x7b, 0xa0, 0x1a, 0x30, 0x76, 0xc5, 0x4e, 0x2f, 0xe9,
- 0xec, 0x99, 0xd2, 0x1c, 0x7b, 0xe0, 0xd7, 0x6a, 0xf4, 0x19, 0xef, 0xc0, 0x6d, 0x29, 0x43, 0xbc,
- 0x54, 0x85, 0x85, 0xc4, 0x0c, 0x4a, 0x12, 0x22, 0x1c, 0x46, 0x87, 0x4e, 0x5f, 0x28, 0x95, 0x33,
- 0xec, 0x5a, 0x26, 0x53, 0x53, 0x64, 0xae, 0xf0, 0x3d, 0x44, 0x0d, 0x53, 0xd3, 0xb1, 0x20, 0x53,
- 0x01, 0x2a, 0x59, 0x2c, 0x04, 0x25, 0xc7, 0x16, 0x22, 0x26, 0xfa, 0x07, 0xb0, 0xe6, 0x1b, 0x41,
- 0xfd, 0x76, 0x44, 0x9c, 0xa1, 0xe9, 0xba, 0x0a, 0xb0, 0x9a, 0x34, 0xf1, 0x77, 0x60, 0x7e, 0x44,
- 0x44, 0x24, 0x2c, 0x6f, 0x21, 0xb9, 0x89, 0x94, 0xc1, 0xac, 0x1f, 0xf7, 0xe1, 0xbe, 0x94, 0xce,
- 0x3d, 0x9a, 0x28, 0x3e, 0x6a, 0x94, 0x84, 0x9b, 0x32, 0x29, 0x70, 0x53, 0x36, 0x02, 0xf6, 0x7f,
- 0xcc, 0x1d, 0x29, 0x4f, 0xe3, 0x4c, 0x19, 0x6e, 0x9f, 0xfb, 0xd4, 0x3f, 0xc4, 0x33, 0x09, 0x3b,
- 0x85, 0xe5, 0xf0, 0xd9, 0x9f, 0x29, 0xf8, 0x2e, 0x43, 0xce, 0xb3, 0x2f, 0x89, 0x0c, 0xbd, 0xbc,
- 0x21, 0x0d, 0xf6, 0x03, 0xc3, 0x4c, 0x06, 0x1b, 0x81, 0x30, 0xb6, 0x25, 0x67, 0xb5, 0x97, 0xae,
- 0xa6, 0xac, 0x6c, 0x79, 0x03, 0x1f, 0xc2, 0x6a, 0x34, 0x4c, 0xcc, 0x64, 0xf2, 0x2b, 0xbe, 0x81,
- 0x93, 0x22, 0xc9, 0x4c, 0x72, 0x3f, 0x09, 0x82, 0x81, 0x12, 0x50, 0x66, 0x12, 0xa9, 0x43, 0x33,
- 0x29, 0xbe, 0xfc, 0x36, 0xf6, 0xab, 0x1f, 0x6e, 0x66, 0x12, 0xe6, 0x06, 0xc2, 0x66, 0x5f, 0xfe,
- 0x20, 0x46, 0x64, 0xa7, 0xc6, 0x08, 0x71, 0x48, 0x82, 0x28, 0xf6, 0x35, 0x6c, 0x3a, 0xa1, 0x23,
- 0x08, 0xa0, 0xb3, 0xea, 0xa0, 0x39, 0xc4, 0xd7, 0xc1, 0x1a, 0x72, 0x63, 0xab, 0x61, 0x77, 0xa6,
- 0xc5, 0xf8, 0x34, 0x88, 0x9d, 0xb1, 0xc8, 0x3c, 0x93, 0xe0, 0xcf, 0x60, 0x3d, 0x3d, 0x28, 0xcf,
- 0x22, 0xf9, 0x51, 0x0b, 0x4a, 0x7e, 0x19, 0xac, 0xdc, 0x22, 0x2a, 0x43, 0xe1, 0xb0, 0x73, 0x7c,
- 0xb4, 0xbd, 0xd3, 0xe6, 0xd7, 0x88, 0x76, 0x3a, 0xba, 0xfe, 0xf2, 0xa8, 0x5b, 0xcf, 0x6c, 0xfd,
- 0x32, 0x0b, 0x99, 0xfd, 0x57, 0xe8, 0x73, 0xc8, 0xf1, 0x6f, 0xea, 0x53, 0x2e, 0x52, 0x34, 0xa7,
- 0x5d, 0x1b, 0xc0, 0xb7, 0x7e, 0xfc, 0xdf, 0xbf, 0xfc, 0x79, 0x66, 0x11, 0x57, 0x5a, 0x93, 0x6f,
- 0xb7, 0x2e, 0x27, 0x2d, 0x96, 0x1b, 0x9e, 0x68, 0x8f, 0xd0, 0x27, 0x90, 0x3d, 0x1a, 0x7b, 0x28,
- 0xf5, 0x82, 0x45, 0x33, 0xfd, 0x26, 0x01, 0x5e, 0x61, 0x42, 0x17, 0x30, 0x08, 0xa1, 0xa3, 0xb1,
- 0x47, 0x45, 0xfe, 0x10, 0xca, 0xea, 0x3d, 0x80, 0x1b, 0x6f, 0x5d, 0x34, 0x6f, 0xbe, 0x63, 0x80,
- 0xef, 0x31, 0x55, 0xb7, 0x30, 0x12, 0xaa, 0xf8, 0x4d, 0x05, 0x75, 0x16, 0xdd, 0x2b, 0x0b, 0xa5,
- 0xde, 0xc9, 0x68, 0xa6, 0x5f, 0x3b, 0x88, 0xcd, 0xc2, 0xbb, 0xb2, 0xa8, 0xc8, 0x3f, 0x16, 0x37,
- 0x0e, 0x7a, 0x1e, 0xba, 0x9f, 0xf0, 0xc5, 0x59, 0xfd, 0xb6, 0xda, 0x5c, 0x4f, 0x67, 0x10, 0x4a,
- 0xee, 0x32, 0x25, 0xab, 0x78, 0x51, 0x28, 0xe9, 0xf9, 0x2c, 0x4f, 0xb4, 0x47, 0x5b, 0x3d, 0xc8,
- 0xb1, 0xef, 0x16, 0xe8, 0x0b, 0xf9, 0xd0, 0x4c, 0xf8, 0x80, 0x93, 0xb2, 0xd0, 0xa1, 0x2f, 0x1e,
- 0x78, 0x99, 0x29, 0xaa, 0xe1, 0x12, 0x55, 0xc4, 0xbe, 0x5a, 0x3c, 0xd1, 0x1e, 0x6d, 0x68, 0x1f,
- 0x6a, 0x5b, 0xff, 0x9c, 0x83, 0x1c, 0x03, 0xec, 0xd0, 0x25, 0x40, 0x80, 0xe1, 0x47, 0x67, 0x17,
- 0xfb, 0x2a, 0x10, 0x9d, 0x5d, 0x1c, 0xfe, 0xc7, 0x4d, 0xa6, 0x74, 0x19, 0x2f, 0x50, 0xa5, 0x0c,
- 0x07, 0x6c, 0x31, 0x68, 0x93, 0xfa, 0xf1, 0xaf, 0x34, 0x81, 0x57, 0xf2, 0xb3, 0x84, 0x92, 0xa4,
- 0x85, 0x80, 0xfc, 0xe8, 0x76, 0x48, 0x00, 0xf1, 0xf1, 0x77, 0x99, 0xc2, 0x16, 0xae, 0x07, 0x0a,
- 0x1d, 0xc6, 0xf1, 0x44, 0x7b, 0xf4, 0x45, 0x03, 0x2f, 0x09, 0x2f, 0x47, 0x7a, 0xd0, 0x8f, 0xa0,
- 0x16, 0x06, 0xaa, 0xd1, 0x83, 0x04, 0x5d, 0x51, 0xbc, 0xbb, 0xf9, 0xf6, 0x74, 0x26, 0x61, 0xd3,
- 0x1a, 0xb3, 0x49, 0x28, 0xe7, 0x9a, 0x2f, 0x09, 0x19, 0x19, 0x94, 0x49, 0xac, 0x01, 0xfa, 0x7b,
- 0x4d, 0x7c, 0x47, 0x08, 0x90, 0x67, 0x94, 0x24, 0x3d, 0x86, 0x6b, 0x37, 0x1f, 0xde, 0xc0, 0x25,
- 0x8c, 0xf8, 0x03, 0x66, 0xc4, 0xef, 0xe2, 0xe5, 0xc0, 0x08, 0xcf, 0x1c, 0x12, 0xcf, 0x16, 0x56,
- 0x7c, 0x71, 0x17, 0xdf, 0x0a, 0x39, 0x27, 0xd4, 0x1b, 0x2c, 0x16, 0x47, 0x8f, 0x13, 0x17, 0x2b,
- 0x84, 0x46, 0x27, 0x2e, 0x56, 0x18, 0x7a, 0x4e, 0x5a, 0x2c, 0x8e, 0x15, 0x27, 0x2d, 0x96, 0xdf,
- 0xb3, 0xf5, 0xff, 0xf3, 0x50, 0xd8, 0xe1, 0x37, 0x7d, 0x91, 0x0d, 0x25, 0x1f, 0x7c, 0x45, 0x6b,
- 0x49, 0x08, 0x53, 0xf0, 0x2e, 0xd1, 0xbc, 0x9f, 0xda, 0x2f, 0x0c, 0x7a, 0x8b, 0x19, 0x74, 0x07,
- 0xaf, 0x52, 0xcd, 0xe2, 0x32, 0x71, 0x8b, 0xc3, 0x18, 0x2d, 0xa3, 0xdf, 0xa7, 0x8e, 0xf8, 0x13,
- 0xa8, 0xa8, 0xe8, 0x28, 0x7a, 0x2b, 0x11, 0xd5, 0x52, 0x01, 0xd6, 0x26, 0x9e, 0xc6, 0x22, 0x34,
- 0xbf, 0xcd, 0x34, 0xaf, 0xe1, 0xdb, 0x09, 0x9a, 0x1d, 0xc6, 0x1a, 0x52, 0xce, 0x91, 0xcd, 0x64,
- 0xe5, 0x21, 0xe0, 0x34, 0x59, 0x79, 0x18, 0x18, 0x9d, 0xaa, 0x7c, 0xcc, 0x58, 0xa9, 0x72, 0x17,
- 0x20, 0xc0, 0x30, 0x51, 0xa2, 0x2f, 0x95, 0x97, 0xa9, 0x68, 0x70, 0x88, 0xc3, 0x9f, 0x18, 0x33,
- 0xb5, 0x62, 0xdf, 0x45, 0xd4, 0x0e, 0x4c, 0xd7, 0xe3, 0x07, 0xb3, 0x1a, 0x02, 0x25, 0x51, 0xe2,
- 0x7c, 0xc2, 0xc8, 0x66, 0xf3, 0xc1, 0x54, 0x1e, 0xa1, 0xfd, 0x21, 0xd3, 0x7e, 0x1f, 0x37, 0x13,
- 0xb4, 0x8f, 0x38, 0x2f, 0xdd, 0x6c, 0x7f, 0x9d, 0x87, 0xf2, 0x0b, 0xc3, 0xb4, 0x3c, 0x62, 0x19,
- 0x56, 0x8f, 0xa0, 0x53, 0xc8, 0xb1, 0x4c, 0x1d, 0x0d, 0xc4, 0x2a, 0x60, 0x17, 0x0d, 0xc4, 0x21,
- 0x34, 0x0b, 0xaf, 0x33, 0xc5, 0x4d, 0xbc, 0x42, 0x15, 0x0f, 0x03, 0xd1, 0x2d, 0x06, 0x42, 0xd1,
- 0x49, 0x9f, 0x41, 0x5e, 0x7c, 0xc3, 0x89, 0x08, 0x0a, 0x81, 0x53, 0xcd, 0xbb, 0xc9, 0x9d, 0x49,
- 0x7b, 0x59, 0x55, 0xe3, 0x32, 0x3e, 0xaa, 0x67, 0x02, 0x10, 0xa0, 0xab, 0xd1, 0x15, 0x8d, 0x81,
- 0xb1, 0xcd, 0xf5, 0x74, 0x86, 0x24, 0x9f, 0xaa, 0x3a, 0xfb, 0x3e, 0x2f, 0xd5, 0xfb, 0x47, 0x30,
- 0xff, 0xdc, 0x70, 0x2f, 0x50, 0x24, 0xf7, 0x2a, 0x37, 0x80, 0x9a, 0xcd, 0xa4, 0x2e, 0xa1, 0xe5,
- 0x3e, 0xd3, 0x72, 0x9b, 0x87, 0x32, 0x55, 0xcb, 0x85, 0xe1, 0xd2, 0xa4, 0x86, 0xfa, 0x90, 0xe7,
- 0x17, 0x82, 0xa2, 0xfe, 0x0b, 0x5d, 0x2a, 0x8a, 0xfa, 0x2f, 0x7c, 0x87, 0xe8, 0x66, 0x2d, 0x23,
- 0x28, 0xca, 0x1b, 0x38, 0x28, 0xf2, 0x39, 0x36, 0x72, 0x5b, 0xa7, 0xb9, 0x96, 0xd6, 0x2d, 0x74,
- 0x3d, 0x60, 0xba, 0xee, 0xe1, 0x46, 0x6c, 0xad, 0x04, 0xe7, 0x13, 0xed, 0xd1, 0x87, 0x1a, 0xfa,
- 0x11, 0x40, 0x00, 0x48, 0xc7, 0x4e, 0x60, 0x14, 0xdb, 0x8e, 0x9d, 0xc0, 0x18, 0x96, 0x8d, 0x37,
- 0x99, 0xde, 0x0d, 0xfc, 0x20, 0xaa, 0xd7, 0x73, 0x0c, 0xcb, 0x3d, 0x23, 0xce, 0x07, 0x1c, 0x74,
- 0x74, 0x2f, 0xcc, 0x11, 0x3d, 0x0c, 0xff, 0xba, 0x00, 0xf3, 0xb4, 0x02, 0xa6, 0x85, 0x42, 0x00,
- 0x1c, 0x44, 0x2d, 0x89, 0x01, 0x7c, 0x51, 0x4b, 0xe2, 0x98, 0x43, 0xb8, 0x50, 0x60, 0xbf, 0x11,
- 0x21, 0x8c, 0x81, 0x3a, 0xda, 0x86, 0xb2, 0x82, 0x2c, 0xa0, 0x04, 0x61, 0x61, 0xe4, 0x30, 0x9a,
- 0x7a, 0x12, 0x60, 0x09, 0x7c, 0x87, 0xe9, 0x5b, 0xe1, 0xa9, 0x87, 0xe9, 0xeb, 0x73, 0x0e, 0xaa,
- 0xf0, 0x35, 0x54, 0x54, 0xf4, 0x01, 0x25, 0xc8, 0x8b, 0xa0, 0x92, 0xd1, 0x30, 0x9b, 0x04, 0x5e,
- 0x84, 0x0f, 0xbe, 0xff, 0x3b, 0x18, 0xc9, 0x46, 0x15, 0x0f, 0xa0, 0x20, 0xe0, 0x88, 0xa4, 0x59,
- 0x86, 0x21, 0xcc, 0xa4, 0x59, 0x46, 0xb0, 0x8c, 0x70, 0x71, 0xc9, 0x34, 0xd2, 0x37, 0x2e, 0x99,
- 0xca, 0x84, 0xb6, 0x67, 0xc4, 0x4b, 0xd3, 0x16, 0xa0, 0x6b, 0x69, 0xda, 0x94, 0xb7, 0xdd, 0x34,
- 0x6d, 0xe7, 0xc4, 0x13, 0xc7, 0x45, 0xbe, 0x45, 0xa2, 0x14, 0x61, 0x6a, 0xfa, 0xc0, 0xd3, 0x58,
- 0x92, 0x6a, 0xff, 0x40, 0xa1, 0xcc, 0x1d, 0x57, 0x00, 0x01, 0x58, 0x12, 0x2d, 0xe8, 0x12, 0x11,
- 0xd7, 0x68, 0x41, 0x97, 0x8c, 0xb7, 0x84, 0x43, 0x43, 0xa0, 0x97, 0xbf, 0x7a, 0x50, 0xcd, 0x3f,
- 0xd3, 0x00, 0xc5, 0x71, 0x15, 0xf4, 0x38, 0x59, 0x7a, 0x22, 0x8e, 0xdb, 0x7c, 0xff, 0xcd, 0x98,
- 0x93, 0xa2, 0x7d, 0x60, 0x52, 0x8f, 0x71, 0x8f, 0x5e, 0x53, 0xa3, 0xfe, 0x42, 0x83, 0x6a, 0x08,
- 0x94, 0x41, 0xef, 0xa4, 0xac, 0x69, 0x04, 0x06, 0x6e, 0xbe, 0x7b, 0x23, 0x5f, 0x52, 0xa5, 0xab,
- 0xec, 0x00, 0x59, 0xf2, 0xff, 0x44, 0x83, 0x5a, 0x18, 0xc4, 0x41, 0x29, 0xb2, 0x63, 0x30, 0x72,
- 0x73, 0xe3, 0x66, 0xc6, 0xe9, 0xcb, 0x13, 0x54, 0xfb, 0x03, 0x28, 0x08, 0xd8, 0x27, 0x69, 0xe3,
- 0x87, 0x01, 0xe8, 0xa4, 0x8d, 0x1f, 0xc1, 0x8c, 0x12, 0x36, 0xbe, 0x63, 0x0f, 0x88, 0x72, 0xcc,
- 0x04, 0x2e, 0x94, 0xa6, 0x6d, 0xfa, 0x31, 0x8b, 0x80, 0x4a, 0x69, 0xda, 0x82, 0x63, 0x26, 0x01,
- 0x21, 0x94, 0x22, 0xec, 0x86, 0x63, 0x16, 0xc5, 0x93, 0x12, 0x8e, 0x19, 0x53, 0xa8, 0x1c, 0xb3,
- 0x00, 0xba, 0x49, 0x3a, 0x66, 0x31, 0x3c, 0x3d, 0xe9, 0x98, 0xc5, 0xd1, 0x9f, 0x84, 0x75, 0x64,
- 0x7a, 0x43, 0xc7, 0x6c, 0x29, 0x01, 0xe5, 0x41, 0xef, 0xa7, 0x38, 0x31, 0x11, 0xa6, 0x6f, 0x7e,
- 0xf0, 0x86, 0xdc, 0xa9, 0x7b, 0x9c, 0xbb, 0x5f, 0xee, 0xf1, 0xbf, 0xd1, 0x60, 0x39, 0x09, 0x21,
- 0x42, 0x29, 0x7a, 0x52, 0xe0, 0xfd, 0xe6, 0xe6, 0x9b, 0xb2, 0x4f, 0xf7, 0x96, 0xbf, 0xeb, 0x9f,
- 0xd6, 0xff, 0xed, 0xab, 0x35, 0xed, 0x3f, 0xbf, 0x5a, 0xd3, 0xfe, 0xe7, 0xab, 0x35, 0xed, 0x6f,
- 0xff, 0x77, 0x6d, 0xee, 0x34, 0xcf, 0x7e, 0x5d, 0xf9, 0xed, 0x5f, 0x05, 0x00, 0x00, 0xff, 0xff,
- 0x52, 0x4e, 0xd7, 0x33, 0xe4, 0x39, 0x00, 0x00,
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/etcdserverpb/rpc.proto b/vendor/go.etcd.io/etcd/etcdserver/etcdserverpb/rpc.proto
deleted file mode 100644
index 423eaba..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/etcdserverpb/rpc.proto
+++ /dev/null
@@ -1,1146 +0,0 @@
-syntax = "proto3";
-package etcdserverpb;
-
-import "gogoproto/gogo.proto";
-import "etcd/mvcc/mvccpb/kv.proto";
-import "etcd/auth/authpb/auth.proto";
-
-// for grpc-gateway
-import "google/api/annotations.proto";
-
-option (gogoproto.marshaler_all) = true;
-option (gogoproto.unmarshaler_all) = true;
-
-service KV {
- // Range gets the keys in the range from the key-value store.
- rpc Range(RangeRequest) returns (RangeResponse) {
- option (google.api.http) = {
- post: "/v3/kv/range"
- body: "*"
- };
- }
-
- // Put puts the given key into the key-value store.
- // A put request increments the revision of the key-value store
- // and generates one event in the event history.
- rpc Put(PutRequest) returns (PutResponse) {
- option (google.api.http) = {
- post: "/v3/kv/put"
- body: "*"
- };
- }
-
- // DeleteRange deletes the given range from the key-value store.
- // A delete request increments the revision of the key-value store
- // and generates a delete event in the event history for every deleted key.
- rpc DeleteRange(DeleteRangeRequest) returns (DeleteRangeResponse) {
- option (google.api.http) = {
- post: "/v3/kv/deleterange"
- body: "*"
- };
- }
-
- // Txn processes multiple requests in a single transaction.
- // A txn request increments the revision of the key-value store
- // and generates events with the same revision for every completed request.
- // It is not allowed to modify the same key several times within one txn.
- rpc Txn(TxnRequest) returns (TxnResponse) {
- option (google.api.http) = {
- post: "/v3/kv/txn"
- body: "*"
- };
- }
-
- // Compact compacts the event history in the etcd key-value store. The key-value
- // store should be periodically compacted or the event history will continue to grow
- // indefinitely.
- rpc Compact(CompactionRequest) returns (CompactionResponse) {
- option (google.api.http) = {
- post: "/v3/kv/compaction"
- body: "*"
- };
- }
-}
-
-service Watch {
- // Watch watches for events happening or that have happened. Both input and output
- // are streams; the input stream is for creating and canceling watchers and the output
- // stream sends events. One watch RPC can watch on multiple key ranges, streaming events
- // for several watches at once. The entire event history can be watched starting from the
- // last compaction revision.
- rpc Watch(stream WatchRequest) returns (stream WatchResponse) {
- option (google.api.http) = {
- post: "/v3/watch"
- body: "*"
- };
- }
-}
-
-service Lease {
- // LeaseGrant creates a lease which expires if the server does not receive a keepAlive
- // within a given time to live period. All keys attached to the lease will be expired and
- // deleted if the lease expires. Each expired key generates a delete event in the event history.
- rpc LeaseGrant(LeaseGrantRequest) returns (LeaseGrantResponse) {
- option (google.api.http) = {
- post: "/v3/lease/grant"
- body: "*"
- };
- }
-
- // LeaseRevoke revokes a lease. All keys attached to the lease will expire and be deleted.
- rpc LeaseRevoke(LeaseRevokeRequest) returns (LeaseRevokeResponse) {
- option (google.api.http) = {
- post: "/v3/lease/revoke"
- body: "*"
- additional_bindings {
- post: "/v3/kv/lease/revoke"
- body: "*"
- }
- };
- }
-
- // LeaseKeepAlive keeps the lease alive by streaming keep alive requests from the client
- // to the server and streaming keep alive responses from the server to the client.
- rpc LeaseKeepAlive(stream LeaseKeepAliveRequest) returns (stream LeaseKeepAliveResponse) {
- option (google.api.http) = {
- post: "/v3/lease/keepalive"
- body: "*"
- };
- }
-
- // LeaseTimeToLive retrieves lease information.
- rpc LeaseTimeToLive(LeaseTimeToLiveRequest) returns (LeaseTimeToLiveResponse) {
- option (google.api.http) = {
- post: "/v3/lease/timetolive"
- body: "*"
- additional_bindings {
- post: "/v3/kv/lease/timetolive"
- body: "*"
- }
- };
- }
-
- // LeaseLeases lists all existing leases.
- rpc LeaseLeases(LeaseLeasesRequest) returns (LeaseLeasesResponse) {
- option (google.api.http) = {
- post: "/v3/lease/leases"
- body: "*"
- additional_bindings {
- post: "/v3/kv/lease/leases"
- body: "*"
- }
- };
- }
-}
-
-service Cluster {
- // MemberAdd adds a member into the cluster.
- rpc MemberAdd(MemberAddRequest) returns (MemberAddResponse) {
- option (google.api.http) = {
- post: "/v3/cluster/member/add"
- body: "*"
- };
- }
-
- // MemberRemove removes an existing member from the cluster.
- rpc MemberRemove(MemberRemoveRequest) returns (MemberRemoveResponse) {
- option (google.api.http) = {
- post: "/v3/cluster/member/remove"
- body: "*"
- };
- }
-
- // MemberUpdate updates the member configuration.
- rpc MemberUpdate(MemberUpdateRequest) returns (MemberUpdateResponse) {
- option (google.api.http) = {
- post: "/v3/cluster/member/update"
- body: "*"
- };
- }
-
- // MemberList lists all the members in the cluster.
- rpc MemberList(MemberListRequest) returns (MemberListResponse) {
- option (google.api.http) = {
- post: "/v3/cluster/member/list"
- body: "*"
- };
- }
-
- // MemberPromote promotes a member from raft learner (non-voting) to raft voting member.
- rpc MemberPromote(MemberPromoteRequest) returns (MemberPromoteResponse) {
- option (google.api.http) = {
- post: "/v3/cluster/member/promote"
- body: "*"
- };
- }
-}
-
-service Maintenance {
- // Alarm activates, deactivates, and queries alarms regarding cluster health.
- rpc Alarm(AlarmRequest) returns (AlarmResponse) {
- option (google.api.http) = {
- post: "/v3/maintenance/alarm"
- body: "*"
- };
- }
-
- // Status gets the status of the member.
- rpc Status(StatusRequest) returns (StatusResponse) {
- option (google.api.http) = {
- post: "/v3/maintenance/status"
- body: "*"
- };
- }
-
- // Defragment defragments a member's backend database to recover storage space.
- rpc Defragment(DefragmentRequest) returns (DefragmentResponse) {
- option (google.api.http) = {
- post: "/v3/maintenance/defragment"
- body: "*"
- };
- }
-
- // Hash computes the hash of whole backend keyspace,
- // including key, lease, and other buckets in storage.
- // This is designed for testing ONLY!
- // Do not rely on this in production with ongoing transactions,
- // since Hash operation does not hold MVCC locks.
- // Use "HashKV" API instead for "key" bucket consistency checks.
- rpc Hash(HashRequest) returns (HashResponse) {
- option (google.api.http) = {
- post: "/v3/maintenance/hash"
- body: "*"
- };
- }
-
- // HashKV computes the hash of all MVCC keys up to a given revision.
- // It only iterates "key" bucket in backend storage.
- rpc HashKV(HashKVRequest) returns (HashKVResponse) {
- option (google.api.http) = {
- post: "/v3/maintenance/hash"
- body: "*"
- };
- }
-
- // Snapshot sends a snapshot of the entire backend from a member over a stream to a client.
- rpc Snapshot(SnapshotRequest) returns (stream SnapshotResponse) {
- option (google.api.http) = {
- post: "/v3/maintenance/snapshot"
- body: "*"
- };
- }
-
- // MoveLeader requests current leader node to transfer its leadership to transferee.
- rpc MoveLeader(MoveLeaderRequest) returns (MoveLeaderResponse) {
- option (google.api.http) = {
- post: "/v3/maintenance/transfer-leadership"
- body: "*"
- };
- }
-}
-
-service Auth {
- // AuthEnable enables authentication.
- rpc AuthEnable(AuthEnableRequest) returns (AuthEnableResponse) {
- option (google.api.http) = {
- post: "/v3/auth/enable"
- body: "*"
- };
- }
-
- // AuthDisable disables authentication.
- rpc AuthDisable(AuthDisableRequest) returns (AuthDisableResponse) {
- option (google.api.http) = {
- post: "/v3/auth/disable"
- body: "*"
- };
- }
-
- // Authenticate processes an authenticate request.
- rpc Authenticate(AuthenticateRequest) returns (AuthenticateResponse) {
- option (google.api.http) = {
- post: "/v3/auth/authenticate"
- body: "*"
- };
- }
-
- // UserAdd adds a new user. User name cannot be empty.
- rpc UserAdd(AuthUserAddRequest) returns (AuthUserAddResponse) {
- option (google.api.http) = {
- post: "/v3/auth/user/add"
- body: "*"
- };
- }
-
- // UserGet gets detailed user information.
- rpc UserGet(AuthUserGetRequest) returns (AuthUserGetResponse) {
- option (google.api.http) = {
- post: "/v3/auth/user/get"
- body: "*"
- };
- }
-
- // UserList gets a list of all users.
- rpc UserList(AuthUserListRequest) returns (AuthUserListResponse) {
- option (google.api.http) = {
- post: "/v3/auth/user/list"
- body: "*"
- };
- }
-
- // UserDelete deletes a specified user.
- rpc UserDelete(AuthUserDeleteRequest) returns (AuthUserDeleteResponse) {
- option (google.api.http) = {
- post: "/v3/auth/user/delete"
- body: "*"
- };
- }
-
- // UserChangePassword changes the password of a specified user.
- rpc UserChangePassword(AuthUserChangePasswordRequest) returns (AuthUserChangePasswordResponse) {
- option (google.api.http) = {
- post: "/v3/auth/user/changepw"
- body: "*"
- };
- }
-
- // UserGrant grants a role to a specified user.
- rpc UserGrantRole(AuthUserGrantRoleRequest) returns (AuthUserGrantRoleResponse) {
- option (google.api.http) = {
- post: "/v3/auth/user/grant"
- body: "*"
- };
- }
-
- // UserRevokeRole revokes a role of specified user.
- rpc UserRevokeRole(AuthUserRevokeRoleRequest) returns (AuthUserRevokeRoleResponse) {
- option (google.api.http) = {
- post: "/v3/auth/user/revoke"
- body: "*"
- };
- }
-
- // RoleAdd adds a new role. Role name cannot be empty.
- rpc RoleAdd(AuthRoleAddRequest) returns (AuthRoleAddResponse) {
- option (google.api.http) = {
- post: "/v3/auth/role/add"
- body: "*"
- };
- }
-
- // RoleGet gets detailed role information.
- rpc RoleGet(AuthRoleGetRequest) returns (AuthRoleGetResponse) {
- option (google.api.http) = {
- post: "/v3/auth/role/get"
- body: "*"
- };
- }
-
- // RoleList gets lists of all roles.
- rpc RoleList(AuthRoleListRequest) returns (AuthRoleListResponse) {
- option (google.api.http) = {
- post: "/v3/auth/role/list"
- body: "*"
- };
- }
-
- // RoleDelete deletes a specified role.
- rpc RoleDelete(AuthRoleDeleteRequest) returns (AuthRoleDeleteResponse) {
- option (google.api.http) = {
- post: "/v3/auth/role/delete"
- body: "*"
- };
- }
-
- // RoleGrantPermission grants a permission of a specified key or range to a specified role.
- rpc RoleGrantPermission(AuthRoleGrantPermissionRequest) returns (AuthRoleGrantPermissionResponse) {
- option (google.api.http) = {
- post: "/v3/auth/role/grant"
- body: "*"
- };
- }
-
- // RoleRevokePermission revokes a key or range permission of a specified role.
- rpc RoleRevokePermission(AuthRoleRevokePermissionRequest) returns (AuthRoleRevokePermissionResponse) {
- option (google.api.http) = {
- post: "/v3/auth/role/revoke"
- body: "*"
- };
- }
-}
-
-message ResponseHeader {
- // cluster_id is the ID of the cluster which sent the response.
- uint64 cluster_id = 1;
- // member_id is the ID of the member which sent the response.
- uint64 member_id = 2;
- // revision is the key-value store revision when the request was applied.
- // For watch progress responses, the header.revision indicates progress. All future events
- // recieved in this stream are guaranteed to have a higher revision number than the
- // header.revision number.
- int64 revision = 3;
- // raft_term is the raft term when the request was applied.
- uint64 raft_term = 4;
-}
-
-message RangeRequest {
- enum SortOrder {
- NONE = 0; // default, no sorting
- ASCEND = 1; // lowest target value first
- DESCEND = 2; // highest target value first
- }
- enum SortTarget {
- KEY = 0;
- VERSION = 1;
- CREATE = 2;
- MOD = 3;
- VALUE = 4;
- }
-
- // key is the first key for the range. If range_end is not given, the request only looks up key.
- bytes key = 1;
- // range_end is the upper bound on the requested range [key, range_end).
- // If range_end is '\0', the range is all keys >= key.
- // If range_end is key plus one (e.g., "aa"+1 == "ab", "a\xff"+1 == "b"),
- // then the range request gets all keys prefixed with key.
- // If both key and range_end are '\0', then the range request returns all keys.
- bytes range_end = 2;
- // limit is a limit on the number of keys returned for the request. When limit is set to 0,
- // it is treated as no limit.
- int64 limit = 3;
- // revision is the point-in-time of the key-value store to use for the range.
- // If revision is less or equal to zero, the range is over the newest key-value store.
- // If the revision has been compacted, ErrCompacted is returned as a response.
- int64 revision = 4;
-
- // sort_order is the order for returned sorted results.
- SortOrder sort_order = 5;
-
- // sort_target is the key-value field to use for sorting.
- SortTarget sort_target = 6;
-
- // serializable sets the range request to use serializable member-local reads.
- // Range requests are linearizable by default; linearizable requests have higher
- // latency and lower throughput than serializable requests but reflect the current
- // consensus of the cluster. For better performance, in exchange for possible stale reads,
- // a serializable range request is served locally without needing to reach consensus
- // with other nodes in the cluster.
- bool serializable = 7;
-
- // keys_only when set returns only the keys and not the values.
- bool keys_only = 8;
-
- // count_only when set returns only the count of the keys in the range.
- bool count_only = 9;
-
- // min_mod_revision is the lower bound for returned key mod revisions; all keys with
- // lesser mod revisions will be filtered away.
- int64 min_mod_revision = 10;
-
- // max_mod_revision is the upper bound for returned key mod revisions; all keys with
- // greater mod revisions will be filtered away.
- int64 max_mod_revision = 11;
-
- // min_create_revision is the lower bound for returned key create revisions; all keys with
- // lesser create revisions will be filtered away.
- int64 min_create_revision = 12;
-
- // max_create_revision is the upper bound for returned key create revisions; all keys with
- // greater create revisions will be filtered away.
- int64 max_create_revision = 13;
-}
-
-message RangeResponse {
- ResponseHeader header = 1;
- // kvs is the list of key-value pairs matched by the range request.
- // kvs is empty when count is requested.
- repeated mvccpb.KeyValue kvs = 2;
- // more indicates if there are more keys to return in the requested range.
- bool more = 3;
- // count is set to the number of keys within the range when requested.
- int64 count = 4;
-}
-
-message PutRequest {
- // key is the key, in bytes, to put into the key-value store.
- bytes key = 1;
- // value is the value, in bytes, to associate with the key in the key-value store.
- bytes value = 2;
- // lease is the lease ID to associate with the key in the key-value store. A lease
- // value of 0 indicates no lease.
- int64 lease = 3;
-
- // If prev_kv is set, etcd gets the previous key-value pair before changing it.
- // The previous key-value pair will be returned in the put response.
- bool prev_kv = 4;
-
- // If ignore_value is set, etcd updates the key using its current value.
- // Returns an error if the key does not exist.
- bool ignore_value = 5;
-
- // If ignore_lease is set, etcd updates the key using its current lease.
- // Returns an error if the key does not exist.
- bool ignore_lease = 6;
-}
-
-message PutResponse {
- ResponseHeader header = 1;
- // if prev_kv is set in the request, the previous key-value pair will be returned.
- mvccpb.KeyValue prev_kv = 2;
-}
-
-message DeleteRangeRequest {
- // key is the first key to delete in the range.
- bytes key = 1;
- // range_end is the key following the last key to delete for the range [key, range_end).
- // If range_end is not given, the range is defined to contain only the key argument.
- // If range_end is one bit larger than the given key, then the range is all the keys
- // with the prefix (the given key).
- // If range_end is '\0', the range is all keys greater than or equal to the key argument.
- bytes range_end = 2;
-
- // If prev_kv is set, etcd gets the previous key-value pairs before deleting it.
- // The previous key-value pairs will be returned in the delete response.
- bool prev_kv = 3;
-}
-
-message DeleteRangeResponse {
- ResponseHeader header = 1;
- // deleted is the number of keys deleted by the delete range request.
- int64 deleted = 2;
- // if prev_kv is set in the request, the previous key-value pairs will be returned.
- repeated mvccpb.KeyValue prev_kvs = 3;
-}
-
-message RequestOp {
- // request is a union of request types accepted by a transaction.
- oneof request {
- RangeRequest request_range = 1;
- PutRequest request_put = 2;
- DeleteRangeRequest request_delete_range = 3;
- TxnRequest request_txn = 4;
- }
-}
-
-message ResponseOp {
- // response is a union of response types returned by a transaction.
- oneof response {
- RangeResponse response_range = 1;
- PutResponse response_put = 2;
- DeleteRangeResponse response_delete_range = 3;
- TxnResponse response_txn = 4;
- }
-}
-
-message Compare {
- enum CompareResult {
- EQUAL = 0;
- GREATER = 1;
- LESS = 2;
- NOT_EQUAL = 3;
- }
- enum CompareTarget {
- VERSION = 0;
- CREATE = 1;
- MOD = 2;
- VALUE = 3;
- LEASE = 4;
- }
- // result is logical comparison operation for this comparison.
- CompareResult result = 1;
- // target is the key-value field to inspect for the comparison.
- CompareTarget target = 2;
- // key is the subject key for the comparison operation.
- bytes key = 3;
- oneof target_union {
- // version is the version of the given key
- int64 version = 4;
- // create_revision is the creation revision of the given key
- int64 create_revision = 5;
- // mod_revision is the last modified revision of the given key.
- int64 mod_revision = 6;
- // value is the value of the given key, in bytes.
- bytes value = 7;
- // lease is the lease id of the given key.
- int64 lease = 8;
- // leave room for more target_union field tags, jump to 64
- }
-
- // range_end compares the given target to all keys in the range [key, range_end).
- // See RangeRequest for more details on key ranges.
- bytes range_end = 64;
- // TODO: fill out with most of the rest of RangeRequest fields when needed.
-}
-
-// From google paxosdb paper:
-// Our implementation hinges around a powerful primitive which we call MultiOp. All other database
-// operations except for iteration are implemented as a single call to MultiOp. A MultiOp is applied atomically
-// and consists of three components:
-// 1. A list of tests called guard. Each test in guard checks a single entry in the database. It may check
-// for the absence or presence of a value, or compare with a given value. Two different tests in the guard
-// may apply to the same or different entries in the database. All tests in the guard are applied and
-// MultiOp returns the results. If all tests are true, MultiOp executes t op (see item 2 below), otherwise
-// it executes f op (see item 3 below).
-// 2. A list of database operations called t op. Each operation in the list is either an insert, delete, or
-// lookup operation, and applies to a single database entry. Two different operations in the list may apply
-// to the same or different entries in the database. These operations are executed
-// if guard evaluates to
-// true.
-// 3. A list of database operations called f op. Like t op, but executed if guard evaluates to false.
-message TxnRequest {
- // compare is a list of predicates representing a conjunction of terms.
- // If the comparisons succeed, then the success requests will be processed in order,
- // and the response will contain their respective responses in order.
- // If the comparisons fail, then the failure requests will be processed in order,
- // and the response will contain their respective responses in order.
- repeated Compare compare = 1;
- // success is a list of requests which will be applied when compare evaluates to true.
- repeated RequestOp success = 2;
- // failure is a list of requests which will be applied when compare evaluates to false.
- repeated RequestOp failure = 3;
-}
-
-message TxnResponse {
- ResponseHeader header = 1;
- // succeeded is set to true if the compare evaluated to true or false otherwise.
- bool succeeded = 2;
- // responses is a list of responses corresponding to the results from applying
- // success if succeeded is true or failure if succeeded is false.
- repeated ResponseOp responses = 3;
-}
-
-// CompactionRequest compacts the key-value store up to a given revision. All superseded keys
-// with a revision less than the compaction revision will be removed.
-message CompactionRequest {
- // revision is the key-value store revision for the compaction operation.
- int64 revision = 1;
- // physical is set so the RPC will wait until the compaction is physically
- // applied to the local database such that compacted entries are totally
- // removed from the backend database.
- bool physical = 2;
-}
-
-message CompactionResponse {
- ResponseHeader header = 1;
-}
-
-message HashRequest {
-}
-
-message HashKVRequest {
- // revision is the key-value store revision for the hash operation.
- int64 revision = 1;
-}
-
-message HashKVResponse {
- ResponseHeader header = 1;
- // hash is the hash value computed from the responding member's MVCC keys up to a given revision.
- uint32 hash = 2;
- // compact_revision is the compacted revision of key-value store when hash begins.
- int64 compact_revision = 3;
-}
-
-message HashResponse {
- ResponseHeader header = 1;
- // hash is the hash value computed from the responding member's KV's backend.
- uint32 hash = 2;
-}
-
-message SnapshotRequest {
-}
-
-message SnapshotResponse {
- // header has the current key-value store information. The first header in the snapshot
- // stream indicates the point in time of the snapshot.
- ResponseHeader header = 1;
-
- // remaining_bytes is the number of blob bytes to be sent after this message
- uint64 remaining_bytes = 2;
-
- // blob contains the next chunk of the snapshot in the snapshot stream.
- bytes blob = 3;
-}
-
-message WatchRequest {
- // request_union is a request to either create a new watcher or cancel an existing watcher.
- oneof request_union {
- WatchCreateRequest create_request = 1;
- WatchCancelRequest cancel_request = 2;
- WatchProgressRequest progress_request = 3;
- }
-}
-
-message WatchCreateRequest {
- // key is the key to register for watching.
- bytes key = 1;
-
- // range_end is the end of the range [key, range_end) to watch. If range_end is not given,
- // only the key argument is watched. If range_end is equal to '\0', all keys greater than
- // or equal to the key argument are watched.
- // If the range_end is one bit larger than the given key,
- // then all keys with the prefix (the given key) will be watched.
- bytes range_end = 2;
-
- // start_revision is an optional revision to watch from (inclusive). No start_revision is "now".
- int64 start_revision = 3;
-
- // progress_notify is set so that the etcd server will periodically send a WatchResponse with
- // no events to the new watcher if there are no recent events. It is useful when clients
- // wish to recover a disconnected watcher starting from a recent known revision.
- // The etcd server may decide how often it will send notifications based on current load.
- bool progress_notify = 4;
-
- enum FilterType {
- // filter out put event.
- NOPUT = 0;
- // filter out delete event.
- NODELETE = 1;
- }
-
- // filters filter the events at server side before it sends back to the watcher.
- repeated FilterType filters = 5;
-
- // If prev_kv is set, created watcher gets the previous KV before the event happens.
- // If the previous KV is already compacted, nothing will be returned.
- bool prev_kv = 6;
-
- // If watch_id is provided and non-zero, it will be assigned to this watcher.
- // Since creating a watcher in etcd is not a synchronous operation,
- // this can be used ensure that ordering is correct when creating multiple
- // watchers on the same stream. Creating a watcher with an ID already in
- // use on the stream will cause an error to be returned.
- int64 watch_id = 7;
-
- // fragment enables splitting large revisions into multiple watch responses.
- bool fragment = 8;
-}
-
-message WatchCancelRequest {
- // watch_id is the watcher id to cancel so that no more events are transmitted.
- int64 watch_id = 1;
-}
-
-// Requests the a watch stream progress status be sent in the watch response stream as soon as
-// possible.
-message WatchProgressRequest {
-}
-
-message WatchResponse {
- ResponseHeader header = 1;
- // watch_id is the ID of the watcher that corresponds to the response.
- int64 watch_id = 2;
-
- // created is set to true if the response is for a create watch request.
- // The client should record the watch_id and expect to receive events for
- // the created watcher from the same stream.
- // All events sent to the created watcher will attach with the same watch_id.
- bool created = 3;
-
- // canceled is set to true if the response is for a cancel watch request.
- // No further events will be sent to the canceled watcher.
- bool canceled = 4;
-
- // compact_revision is set to the minimum index if a watcher tries to watch
- // at a compacted index.
- //
- // This happens when creating a watcher at a compacted revision or the watcher cannot
- // catch up with the progress of the key-value store.
- //
- // The client should treat the watcher as canceled and should not try to create any
- // watcher with the same start_revision again.
- int64 compact_revision = 5;
-
- // cancel_reason indicates the reason for canceling the watcher.
- string cancel_reason = 6;
-
- // framgment is true if large watch response was split over multiple responses.
- bool fragment = 7;
-
- repeated mvccpb.Event events = 11;
-}
-
-message LeaseGrantRequest {
- // TTL is the advisory time-to-live in seconds. Expired lease will return -1.
- int64 TTL = 1;
- // ID is the requested ID for the lease. If ID is set to 0, the lessor chooses an ID.
- int64 ID = 2;
-}
-
-message LeaseGrantResponse {
- ResponseHeader header = 1;
- // ID is the lease ID for the granted lease.
- int64 ID = 2;
- // TTL is the server chosen lease time-to-live in seconds.
- int64 TTL = 3;
- string error = 4;
-}
-
-message LeaseRevokeRequest {
- // ID is the lease ID to revoke. When the ID is revoked, all associated keys will be deleted.
- int64 ID = 1;
-}
-
-message LeaseRevokeResponse {
- ResponseHeader header = 1;
-}
-
-message LeaseCheckpoint {
- // ID is the lease ID to checkpoint.
- int64 ID = 1;
-
- // Remaining_TTL is the remaining time until expiry of the lease.
- int64 remaining_TTL = 2;
-}
-
-message LeaseCheckpointRequest {
- repeated LeaseCheckpoint checkpoints = 1;
-}
-
-message LeaseCheckpointResponse {
- ResponseHeader header = 1;
-}
-
-message LeaseKeepAliveRequest {
- // ID is the lease ID for the lease to keep alive.
- int64 ID = 1;
-}
-
-message LeaseKeepAliveResponse {
- ResponseHeader header = 1;
- // ID is the lease ID from the keep alive request.
- int64 ID = 2;
- // TTL is the new time-to-live for the lease.
- int64 TTL = 3;
-}
-
-message LeaseTimeToLiveRequest {
- // ID is the lease ID for the lease.
- int64 ID = 1;
- // keys is true to query all the keys attached to this lease.
- bool keys = 2;
-}
-
-message LeaseTimeToLiveResponse {
- ResponseHeader header = 1;
- // ID is the lease ID from the keep alive request.
- int64 ID = 2;
- // TTL is the remaining TTL in seconds for the lease; the lease will expire in under TTL+1 seconds.
- int64 TTL = 3;
- // GrantedTTL is the initial granted time in seconds upon lease creation/renewal.
- int64 grantedTTL = 4;
- // Keys is the list of keys attached to this lease.
- repeated bytes keys = 5;
-}
-
-message LeaseLeasesRequest {
-}
-
-message LeaseStatus {
- int64 ID = 1;
- // TODO: int64 TTL = 2;
-}
-
-message LeaseLeasesResponse {
- ResponseHeader header = 1;
- repeated LeaseStatus leases = 2;
-}
-
-message Member {
- // ID is the member ID for this member.
- uint64 ID = 1;
- // name is the human-readable name of the member. If the member is not started, the name will be an empty string.
- string name = 2;
- // peerURLs is the list of URLs the member exposes to the cluster for communication.
- repeated string peerURLs = 3;
- // clientURLs is the list of URLs the member exposes to clients for communication. If the member is not started, clientURLs will be empty.
- repeated string clientURLs = 4;
- // isLearner indicates if the member is raft learner.
- bool isLearner = 5;
-}
-
-message MemberAddRequest {
- // peerURLs is the list of URLs the added member will use to communicate with the cluster.
- repeated string peerURLs = 1;
- // isLearner indicates if the added member is raft learner.
- bool isLearner = 2;
-}
-
-message MemberAddResponse {
- ResponseHeader header = 1;
- // member is the member information for the added member.
- Member member = 2;
- // members is a list of all members after adding the new member.
- repeated Member members = 3;
-}
-
-message MemberRemoveRequest {
- // ID is the member ID of the member to remove.
- uint64 ID = 1;
-}
-
-message MemberRemoveResponse {
- ResponseHeader header = 1;
- // members is a list of all members after removing the member.
- repeated Member members = 2;
-}
-
-message MemberUpdateRequest {
- // ID is the member ID of the member to update.
- uint64 ID = 1;
- // peerURLs is the new list of URLs the member will use to communicate with the cluster.
- repeated string peerURLs = 2;
-}
-
-message MemberUpdateResponse{
- ResponseHeader header = 1;
- // members is a list of all members after updating the member.
- repeated Member members = 2;
-}
-
-message MemberListRequest {
-}
-
-message MemberListResponse {
- ResponseHeader header = 1;
- // members is a list of all members associated with the cluster.
- repeated Member members = 2;
-}
-
-message MemberPromoteRequest {
- // ID is the member ID of the member to promote.
- uint64 ID = 1;
-}
-
-message MemberPromoteResponse {
- ResponseHeader header = 1;
- // members is a list of all members after promoting the member.
- repeated Member members = 2;
-}
-
-message DefragmentRequest {
-}
-
-message DefragmentResponse {
- ResponseHeader header = 1;
-}
-
-message MoveLeaderRequest {
- // targetID is the node ID for the new leader.
- uint64 targetID = 1;
-}
-
-message MoveLeaderResponse {
- ResponseHeader header = 1;
-}
-
-enum AlarmType {
- NONE = 0; // default, used to query if any alarm is active
- NOSPACE = 1; // space quota is exhausted
- CORRUPT = 2; // kv store corruption detected
-}
-
-message AlarmRequest {
- enum AlarmAction {
- GET = 0;
- ACTIVATE = 1;
- DEACTIVATE = 2;
- }
- // action is the kind of alarm request to issue. The action
- // may GET alarm statuses, ACTIVATE an alarm, or DEACTIVATE a
- // raised alarm.
- AlarmAction action = 1;
- // memberID is the ID of the member associated with the alarm. If memberID is 0, the
- // alarm request covers all members.
- uint64 memberID = 2;
- // alarm is the type of alarm to consider for this request.
- AlarmType alarm = 3;
-}
-
-message AlarmMember {
- // memberID is the ID of the member associated with the raised alarm.
- uint64 memberID = 1;
- // alarm is the type of alarm which has been raised.
- AlarmType alarm = 2;
-}
-
-message AlarmResponse {
- ResponseHeader header = 1;
- // alarms is a list of alarms associated with the alarm request.
- repeated AlarmMember alarms = 2;
-}
-
-message StatusRequest {
-}
-
-message StatusResponse {
- ResponseHeader header = 1;
- // version is the cluster protocol version used by the responding member.
- string version = 2;
- // dbSize is the size of the backend database physically allocated, in bytes, of the responding member.
- int64 dbSize = 3;
- // leader is the member ID which the responding member believes is the current leader.
- uint64 leader = 4;
- // raftIndex is the current raft committed index of the responding member.
- uint64 raftIndex = 5;
- // raftTerm is the current raft term of the responding member.
- uint64 raftTerm = 6;
- // raftAppliedIndex is the current raft applied index of the responding member.
- uint64 raftAppliedIndex = 7;
- // errors contains alarm/health information and status.
- repeated string errors = 8;
- // dbSizeInUse is the size of the backend database logically in use, in bytes, of the responding member.
- int64 dbSizeInUse = 9;
- // isLearner indicates if the member is raft learner.
- bool isLearner = 10;
-}
-
-message AuthEnableRequest {
-}
-
-message AuthDisableRequest {
-}
-
-message AuthenticateRequest {
- string name = 1;
- string password = 2;
-}
-
-message AuthUserAddRequest {
- string name = 1;
- string password = 2;
- authpb.UserAddOptions options = 3;
-}
-
-message AuthUserGetRequest {
- string name = 1;
-}
-
-message AuthUserDeleteRequest {
- // name is the name of the user to delete.
- string name = 1;
-}
-
-message AuthUserChangePasswordRequest {
- // name is the name of the user whose password is being changed.
- string name = 1;
- // password is the new password for the user.
- string password = 2;
-}
-
-message AuthUserGrantRoleRequest {
- // user is the name of the user which should be granted a given role.
- string user = 1;
- // role is the name of the role to grant to the user.
- string role = 2;
-}
-
-message AuthUserRevokeRoleRequest {
- string name = 1;
- string role = 2;
-}
-
-message AuthRoleAddRequest {
- // name is the name of the role to add to the authentication system.
- string name = 1;
-}
-
-message AuthRoleGetRequest {
- string role = 1;
-}
-
-message AuthUserListRequest {
-}
-
-message AuthRoleListRequest {
-}
-
-message AuthRoleDeleteRequest {
- string role = 1;
-}
-
-message AuthRoleGrantPermissionRequest {
- // name is the name of the role which will be granted the permission.
- string name = 1;
- // perm is the permission to grant to the role.
- authpb.Permission perm = 2;
-}
-
-message AuthRoleRevokePermissionRequest {
- string role = 1;
- bytes key = 2;
- bytes range_end = 3;
-}
-
-message AuthEnableResponse {
- ResponseHeader header = 1;
-}
-
-message AuthDisableResponse {
- ResponseHeader header = 1;
-}
-
-message AuthenticateResponse {
- ResponseHeader header = 1;
- // token is an authorized token that can be used in succeeding RPCs
- string token = 2;
-}
-
-message AuthUserAddResponse {
- ResponseHeader header = 1;
-}
-
-message AuthUserGetResponse {
- ResponseHeader header = 1;
-
- repeated string roles = 2;
-}
-
-message AuthUserDeleteResponse {
- ResponseHeader header = 1;
-}
-
-message AuthUserChangePasswordResponse {
- ResponseHeader header = 1;
-}
-
-message AuthUserGrantRoleResponse {
- ResponseHeader header = 1;
-}
-
-message AuthUserRevokeRoleResponse {
- ResponseHeader header = 1;
-}
-
-message AuthRoleAddResponse {
- ResponseHeader header = 1;
-}
-
-message AuthRoleGetResponse {
- ResponseHeader header = 1;
-
- repeated authpb.Permission perm = 2;
-}
-
-message AuthRoleListResponse {
- ResponseHeader header = 1;
-
- repeated string roles = 2;
-}
-
-message AuthUserListResponse {
- ResponseHeader header = 1;
-
- repeated string users = 2;
-}
-
-message AuthRoleDeleteResponse {
- ResponseHeader header = 1;
-}
-
-message AuthRoleGrantPermissionResponse {
- ResponseHeader header = 1;
-}
-
-message AuthRoleRevokePermissionResponse {
- ResponseHeader header = 1;
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/metrics.go b/vendor/go.etcd.io/etcd/etcdserver/metrics.go
deleted file mode 100644
index e0c0cde..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/metrics.go
+++ /dev/null
@@ -1,221 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package etcdserver
-
-import (
- goruntime "runtime"
- "time"
-
- "go.etcd.io/etcd/pkg/runtime"
- "go.etcd.io/etcd/version"
-
- "github.com/prometheus/client_golang/prometheus"
- "go.uber.org/zap"
-)
-
-var (
- hasLeader = prometheus.NewGauge(prometheus.GaugeOpts{
- Namespace: "etcd",
- Subsystem: "server",
- Name: "has_leader",
- Help: "Whether or not a leader exists. 1 is existence, 0 is not.",
- })
- isLeader = prometheus.NewGauge(prometheus.GaugeOpts{
- Namespace: "etcd",
- Subsystem: "server",
- Name: "is_leader",
- Help: "Whether or not this member is a leader. 1 if is, 0 otherwise.",
- })
- leaderChanges = prometheus.NewCounter(prometheus.CounterOpts{
- Namespace: "etcd",
- Subsystem: "server",
- Name: "leader_changes_seen_total",
- Help: "The number of leader changes seen.",
- })
- isLearner = prometheus.NewGauge(prometheus.GaugeOpts{
- Namespace: "etcd",
- Subsystem: "server",
- Name: "is_learner",
- Help: "Whether or not this member is a learner. 1 if is, 0 otherwise.",
- })
- learnerPromoteFailed = prometheus.NewCounterVec(prometheus.CounterOpts{
- Namespace: "etcd",
- Subsystem: "server",
- Name: "learner_promote_failures",
- Help: "The total number of failed learner promotions (likely learner not ready) while this member is leader.",
- },
- []string{"Reason"},
- )
- learnerPromoteSucceed = prometheus.NewCounter(prometheus.CounterOpts{
- Namespace: "etcd",
- Subsystem: "server",
- Name: "learner_promote_successes",
- Help: "The total number of successful learner promotions while this member is leader.",
- })
- heartbeatSendFailures = prometheus.NewCounter(prometheus.CounterOpts{
- Namespace: "etcd",
- Subsystem: "server",
- Name: "heartbeat_send_failures_total",
- Help: "The total number of leader heartbeat send failures (likely overloaded from slow disk).",
- })
- slowApplies = prometheus.NewCounter(prometheus.CounterOpts{
- Namespace: "etcd",
- Subsystem: "server",
- Name: "slow_apply_total",
- Help: "The total number of slow apply requests (likely overloaded from slow disk).",
- })
- applySnapshotInProgress = prometheus.NewGauge(prometheus.GaugeOpts{
- Namespace: "etcd",
- Subsystem: "server",
- Name: "snapshot_apply_in_progress_total",
- Help: "1 if the server is applying the incoming snapshot. 0 if none.",
- })
- proposalsCommitted = prometheus.NewGauge(prometheus.GaugeOpts{
- Namespace: "etcd",
- Subsystem: "server",
- Name: "proposals_committed_total",
- Help: "The total number of consensus proposals committed.",
- })
- proposalsApplied = prometheus.NewGauge(prometheus.GaugeOpts{
- Namespace: "etcd",
- Subsystem: "server",
- Name: "proposals_applied_total",
- Help: "The total number of consensus proposals applied.",
- })
- proposalsPending = prometheus.NewGauge(prometheus.GaugeOpts{
- Namespace: "etcd",
- Subsystem: "server",
- Name: "proposals_pending",
- Help: "The current number of pending proposals to commit.",
- })
- proposalsFailed = prometheus.NewCounter(prometheus.CounterOpts{
- Namespace: "etcd",
- Subsystem: "server",
- Name: "proposals_failed_total",
- Help: "The total number of failed proposals seen.",
- })
- slowReadIndex = prometheus.NewCounter(prometheus.CounterOpts{
- Namespace: "etcd",
- Subsystem: "server",
- Name: "slow_read_indexes_total",
- Help: "The total number of pending read indexes not in sync with leader's or timed out read index requests.",
- })
- readIndexFailed = prometheus.NewCounter(prometheus.CounterOpts{
- Namespace: "etcd",
- Subsystem: "server",
- Name: "read_indexes_failed_total",
- Help: "The total number of failed read indexes seen.",
- })
- leaseExpired = prometheus.NewCounter(prometheus.CounterOpts{
- Namespace: "etcd_debugging",
- Subsystem: "server",
- Name: "lease_expired_total",
- Help: "The total number of expired leases.",
- })
- quotaBackendBytes = prometheus.NewGauge(prometheus.GaugeOpts{
- Namespace: "etcd",
- Subsystem: "server",
- Name: "quota_backend_bytes",
- Help: "Current backend storage quota size in bytes.",
- })
- currentVersion = prometheus.NewGaugeVec(prometheus.GaugeOpts{
- Namespace: "etcd",
- Subsystem: "server",
- Name: "version",
- Help: "Which version is running. 1 for 'server_version' label with current version.",
- },
- []string{"server_version"})
- currentGoVersion = prometheus.NewGaugeVec(prometheus.GaugeOpts{
- Namespace: "etcd",
- Subsystem: "server",
- Name: "go_version",
- Help: "Which Go version server is running with. 1 for 'server_go_version' label with current version.",
- },
- []string{"server_go_version"})
- serverID = prometheus.NewGaugeVec(prometheus.GaugeOpts{
- Namespace: "etcd",
- Subsystem: "server",
- Name: "id",
- Help: "Server or member ID in hexadecimal format. 1 for 'server_id' label with current ID.",
- },
- []string{"server_id"})
-)
-
-func init() {
- prometheus.MustRegister(hasLeader)
- prometheus.MustRegister(isLeader)
- prometheus.MustRegister(leaderChanges)
- prometheus.MustRegister(heartbeatSendFailures)
- prometheus.MustRegister(slowApplies)
- prometheus.MustRegister(applySnapshotInProgress)
- prometheus.MustRegister(proposalsCommitted)
- prometheus.MustRegister(proposalsApplied)
- prometheus.MustRegister(proposalsPending)
- prometheus.MustRegister(proposalsFailed)
- prometheus.MustRegister(slowReadIndex)
- prometheus.MustRegister(readIndexFailed)
- prometheus.MustRegister(leaseExpired)
- prometheus.MustRegister(quotaBackendBytes)
- prometheus.MustRegister(currentVersion)
- prometheus.MustRegister(currentGoVersion)
- prometheus.MustRegister(serverID)
- prometheus.MustRegister(isLearner)
- prometheus.MustRegister(learnerPromoteSucceed)
- prometheus.MustRegister(learnerPromoteFailed)
-
- currentVersion.With(prometheus.Labels{
- "server_version": version.Version,
- }).Set(1)
- currentGoVersion.With(prometheus.Labels{
- "server_go_version": goruntime.Version(),
- }).Set(1)
-}
-
-func monitorFileDescriptor(lg *zap.Logger, done <-chan struct{}) {
- ticker := time.NewTicker(5 * time.Second)
- defer ticker.Stop()
- for {
- used, err := runtime.FDUsage()
- if err != nil {
- if lg != nil {
- lg.Warn("failed to get file descriptor usage", zap.Error(err))
- } else {
- plog.Errorf("cannot monitor file descriptor usage (%v)", err)
- }
- return
- }
- limit, err := runtime.FDLimit()
- if err != nil {
- if lg != nil {
- lg.Warn("failed to get file descriptor limit", zap.Error(err))
- } else {
- plog.Errorf("cannot monitor file descriptor usage (%v)", err)
- }
- return
- }
- if used >= limit/5*4 {
- if lg != nil {
- lg.Warn("80% of file descriptors are used", zap.Uint64("used", used), zap.Uint64("limit", limit))
- } else {
- plog.Warningf("80%% of the file descriptor limit is used [used = %d, limit = %d]", used, limit)
- }
- }
- select {
- case <-ticker.C:
- case <-done:
- return
- }
- }
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/quota.go b/vendor/go.etcd.io/etcd/etcdserver/quota.go
deleted file mode 100644
index 6d70430..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/quota.go
+++ /dev/null
@@ -1,182 +0,0 @@
-// Copyright 2016 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package etcdserver
-
-import (
- "sync"
-
- pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
-
- humanize "github.com/dustin/go-humanize"
- "go.uber.org/zap"
-)
-
-const (
- // DefaultQuotaBytes is the number of bytes the backend Size may
- // consume before exceeding the space quota.
- DefaultQuotaBytes = int64(2 * 1024 * 1024 * 1024) // 2GB
- // MaxQuotaBytes is the maximum number of bytes suggested for a backend
- // quota. A larger quota may lead to degraded performance.
- MaxQuotaBytes = int64(8 * 1024 * 1024 * 1024) // 8GB
-)
-
-// Quota represents an arbitrary quota against arbitrary requests. Each request
-// costs some charge; if there is not enough remaining charge, then there are
-// too few resources available within the quota to apply the request.
-type Quota interface {
- // Available judges whether the given request fits within the quota.
- Available(req interface{}) bool
- // Cost computes the charge against the quota for a given request.
- Cost(req interface{}) int
- // Remaining is the amount of charge left for the quota.
- Remaining() int64
-}
-
-type passthroughQuota struct{}
-
-func (*passthroughQuota) Available(interface{}) bool { return true }
-func (*passthroughQuota) Cost(interface{}) int { return 0 }
-func (*passthroughQuota) Remaining() int64 { return 1 }
-
-type backendQuota struct {
- s *EtcdServer
- maxBackendBytes int64
-}
-
-const (
- // leaseOverhead is an estimate for the cost of storing a lease
- leaseOverhead = 64
- // kvOverhead is an estimate for the cost of storing a key's metadata
- kvOverhead = 256
-)
-
-var (
- // only log once
- quotaLogOnce sync.Once
-
- DefaultQuotaSize = humanize.Bytes(uint64(DefaultQuotaBytes))
- maxQuotaSize = humanize.Bytes(uint64(MaxQuotaBytes))
-)
-
-// NewBackendQuota creates a quota layer with the given storage limit.
-func NewBackendQuota(s *EtcdServer, name string) Quota {
- lg := s.getLogger()
- quotaBackendBytes.Set(float64(s.Cfg.QuotaBackendBytes))
-
- if s.Cfg.QuotaBackendBytes < 0 {
- // disable quotas if negative
- quotaLogOnce.Do(func() {
- if lg != nil {
- lg.Info(
- "disabled backend quota",
- zap.String("quota-name", name),
- zap.Int64("quota-size-bytes", s.Cfg.QuotaBackendBytes),
- )
- } else {
- plog.Warningf("disabling backend quota")
- }
- })
- return &passthroughQuota{}
- }
-
- if s.Cfg.QuotaBackendBytes == 0 {
- // use default size if no quota size given
- quotaLogOnce.Do(func() {
- if lg != nil {
- lg.Info(
- "enabled backend quota with default value",
- zap.String("quota-name", name),
- zap.Int64("quota-size-bytes", DefaultQuotaBytes),
- zap.String("quota-size", DefaultQuotaSize),
- )
- }
- })
- quotaBackendBytes.Set(float64(DefaultQuotaBytes))
- return &backendQuota{s, DefaultQuotaBytes}
- }
-
- quotaLogOnce.Do(func() {
- if s.Cfg.QuotaBackendBytes > MaxQuotaBytes {
- if lg != nil {
- lg.Warn(
- "quota exceeds the maximum value",
- zap.String("quota-name", name),
- zap.Int64("quota-size-bytes", s.Cfg.QuotaBackendBytes),
- zap.String("quota-size", humanize.Bytes(uint64(s.Cfg.QuotaBackendBytes))),
- zap.Int64("quota-maximum-size-bytes", MaxQuotaBytes),
- zap.String("quota-maximum-size", maxQuotaSize),
- )
- } else {
- plog.Warningf("backend quota %v exceeds maximum recommended quota %v", s.Cfg.QuotaBackendBytes, MaxQuotaBytes)
- }
- }
- if lg != nil {
- lg.Info(
- "enabled backend quota",
- zap.String("quota-name", name),
- zap.Int64("quota-size-bytes", s.Cfg.QuotaBackendBytes),
- zap.String("quota-size", humanize.Bytes(uint64(s.Cfg.QuotaBackendBytes))),
- )
- }
- })
- return &backendQuota{s, s.Cfg.QuotaBackendBytes}
-}
-
-func (b *backendQuota) Available(v interface{}) bool {
- // TODO: maybe optimize backend.Size()
- return b.s.Backend().Size()+int64(b.Cost(v)) < b.maxBackendBytes
-}
-
-func (b *backendQuota) Cost(v interface{}) int {
- switch r := v.(type) {
- case *pb.PutRequest:
- return costPut(r)
- case *pb.TxnRequest:
- return costTxn(r)
- case *pb.LeaseGrantRequest:
- return leaseOverhead
- default:
- panic("unexpected cost")
- }
-}
-
-func costPut(r *pb.PutRequest) int { return kvOverhead + len(r.Key) + len(r.Value) }
-
-func costTxnReq(u *pb.RequestOp) int {
- r := u.GetRequestPut()
- if r == nil {
- return 0
- }
- return costPut(r)
-}
-
-func costTxn(r *pb.TxnRequest) int {
- sizeSuccess := 0
- for _, u := range r.Success {
- sizeSuccess += costTxnReq(u)
- }
- sizeFailure := 0
- for _, u := range r.Failure {
- sizeFailure += costTxnReq(u)
- }
- if sizeFailure > sizeSuccess {
- return sizeFailure
- }
- return sizeSuccess
-}
-
-func (b *backendQuota) Remaining() int64 {
- return b.maxBackendBytes - b.s.Backend().Size()
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/raft.go b/vendor/go.etcd.io/etcd/etcdserver/raft.go
deleted file mode 100644
index c0fe979..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/raft.go
+++ /dev/null
@@ -1,753 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package etcdserver
-
-import (
- "encoding/json"
- "expvar"
- "fmt"
- "log"
- "sort"
- "sync"
- "time"
-
- "go.etcd.io/etcd/etcdserver/api/membership"
- "go.etcd.io/etcd/etcdserver/api/rafthttp"
- pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
- "go.etcd.io/etcd/pkg/contention"
- "go.etcd.io/etcd/pkg/logutil"
- "go.etcd.io/etcd/pkg/pbutil"
- "go.etcd.io/etcd/pkg/types"
- "go.etcd.io/etcd/raft"
- "go.etcd.io/etcd/raft/raftpb"
- "go.etcd.io/etcd/wal"
- "go.etcd.io/etcd/wal/walpb"
- "go.uber.org/zap"
-)
-
-const (
- // The max throughput of etcd will not exceed 100MB/s (100K * 1KB value).
- // Assuming the RTT is around 10ms, 1MB max size is large enough.
- maxSizePerMsg = 1 * 1024 * 1024
- // Never overflow the rafthttp buffer, which is 4096.
- // TODO: a better const?
- maxInflightMsgs = 4096 / 8
-)
-
-var (
- // protects raftStatus
- raftStatusMu sync.Mutex
- // indirection for expvar func interface
- // expvar panics when publishing duplicate name
- // expvar does not support remove a registered name
- // so only register a func that calls raftStatus
- // and change raftStatus as we need.
- raftStatus func() raft.Status
-)
-
-func init() {
- expvar.Publish("raft.status", expvar.Func(func() interface{} {
- raftStatusMu.Lock()
- defer raftStatusMu.Unlock()
- return raftStatus()
- }))
-}
-
-// apply contains entries, snapshot to be applied. Once
-// an apply is consumed, the entries will be persisted to
-// to raft storage concurrently; the application must read
-// raftDone before assuming the raft messages are stable.
-type apply struct {
- entries []raftpb.Entry
- snapshot raftpb.Snapshot
- // notifyc synchronizes etcd server applies with the raft node
- notifyc chan struct{}
-}
-
-type raftNode struct {
- lg *zap.Logger
-
- tickMu *sync.Mutex
- raftNodeConfig
-
- // a chan to send/receive snapshot
- msgSnapC chan raftpb.Message
-
- // a chan to send out apply
- applyc chan apply
-
- // a chan to send out readState
- readStateC chan raft.ReadState
-
- // utility
- ticker *time.Ticker
- // contention detectors for raft heartbeat message
- td *contention.TimeoutDetector
-
- stopped chan struct{}
- done chan struct{}
-}
-
-type raftNodeConfig struct {
- lg *zap.Logger
-
- // to check if msg receiver is removed from cluster
- isIDRemoved func(id uint64) bool
- raft.Node
- raftStorage *raft.MemoryStorage
- storage Storage
- heartbeat time.Duration // for logging
- // transport specifies the transport to send and receive msgs to members.
- // Sending messages MUST NOT block. It is okay to drop messages, since
- // clients should timeout and reissue their messages.
- // If transport is nil, server will panic.
- transport rafthttp.Transporter
-}
-
-func newRaftNode(cfg raftNodeConfig) *raftNode {
- var lg raft.Logger
- if cfg.lg != nil {
- lg = logutil.NewRaftLoggerZap(cfg.lg)
- } else {
- lcfg := logutil.DefaultZapLoggerConfig
- var err error
- lg, err = logutil.NewRaftLogger(&lcfg)
- if err != nil {
- log.Fatalf("cannot create raft logger %v", err)
- }
- }
- raft.SetLogger(lg)
- r := &raftNode{
- lg: cfg.lg,
- tickMu: new(sync.Mutex),
- raftNodeConfig: cfg,
- // set up contention detectors for raft heartbeat message.
- // expect to send a heartbeat within 2 heartbeat intervals.
- td: contention.NewTimeoutDetector(2 * cfg.heartbeat),
- readStateC: make(chan raft.ReadState, 1),
- msgSnapC: make(chan raftpb.Message, maxInFlightMsgSnap),
- applyc: make(chan apply),
- stopped: make(chan struct{}),
- done: make(chan struct{}),
- }
- if r.heartbeat == 0 {
- r.ticker = &time.Ticker{}
- } else {
- r.ticker = time.NewTicker(r.heartbeat)
- }
- return r
-}
-
-// raft.Node does not have locks in Raft package
-func (r *raftNode) tick() {
- r.tickMu.Lock()
- r.Tick()
- r.tickMu.Unlock()
-}
-
-// start prepares and starts raftNode in a new goroutine. It is no longer safe
-// to modify the fields after it has been started.
-func (r *raftNode) start(rh *raftReadyHandler) {
- internalTimeout := time.Second
-
- go func() {
- defer r.onStop()
- islead := false
-
- for {
- select {
- case <-r.ticker.C:
- r.tick()
- case rd := <-r.Ready():
- if rd.SoftState != nil {
- newLeader := rd.SoftState.Lead != raft.None && rh.getLead() != rd.SoftState.Lead
- if newLeader {
- leaderChanges.Inc()
- }
-
- if rd.SoftState.Lead == raft.None {
- hasLeader.Set(0)
- } else {
- hasLeader.Set(1)
- }
-
- rh.updateLead(rd.SoftState.Lead)
- islead = rd.RaftState == raft.StateLeader
- if islead {
- isLeader.Set(1)
- } else {
- isLeader.Set(0)
- }
- rh.updateLeadership(newLeader)
- r.td.Reset()
- }
-
- if len(rd.ReadStates) != 0 {
- select {
- case r.readStateC <- rd.ReadStates[len(rd.ReadStates)-1]:
- case <-time.After(internalTimeout):
- if r.lg != nil {
- r.lg.Warn("timed out sending read state", zap.Duration("timeout", internalTimeout))
- } else {
- plog.Warningf("timed out sending read state")
- }
- case <-r.stopped:
- return
- }
- }
-
- notifyc := make(chan struct{}, 1)
- ap := apply{
- entries: rd.CommittedEntries,
- snapshot: rd.Snapshot,
- notifyc: notifyc,
- }
-
- updateCommittedIndex(&ap, rh)
-
- select {
- case r.applyc <- ap:
- case <-r.stopped:
- return
- }
-
- // the leader can write to its disk in parallel with replicating to the followers and them
- // writing to their disks.
- // For more details, check raft thesis 10.2.1
- if islead {
- // gofail: var raftBeforeLeaderSend struct{}
- r.transport.Send(r.processMessages(rd.Messages))
- }
-
- // gofail: var raftBeforeSave struct{}
- if err := r.storage.Save(rd.HardState, rd.Entries); err != nil {
- if r.lg != nil {
- r.lg.Fatal("failed to save Raft hard state and entries", zap.Error(err))
- } else {
- plog.Fatalf("raft save state and entries error: %v", err)
- }
- }
- if !raft.IsEmptyHardState(rd.HardState) {
- proposalsCommitted.Set(float64(rd.HardState.Commit))
- }
- // gofail: var raftAfterSave struct{}
-
- if !raft.IsEmptySnap(rd.Snapshot) {
- // gofail: var raftBeforeSaveSnap struct{}
- if err := r.storage.SaveSnap(rd.Snapshot); err != nil {
- if r.lg != nil {
- r.lg.Fatal("failed to save Raft snapshot", zap.Error(err))
- } else {
- plog.Fatalf("raft save snapshot error: %v", err)
- }
- }
- // etcdserver now claim the snapshot has been persisted onto the disk
- notifyc <- struct{}{}
-
- // gofail: var raftAfterSaveSnap struct{}
- r.raftStorage.ApplySnapshot(rd.Snapshot)
- if r.lg != nil {
- r.lg.Info("applied incoming Raft snapshot", zap.Uint64("snapshot-index", rd.Snapshot.Metadata.Index))
- } else {
- plog.Infof("raft applied incoming snapshot at index %d", rd.Snapshot.Metadata.Index)
- }
- // gofail: var raftAfterApplySnap struct{}
- }
-
- r.raftStorage.Append(rd.Entries)
-
- if !islead {
- // finish processing incoming messages before we signal raftdone chan
- msgs := r.processMessages(rd.Messages)
-
- // now unblocks 'applyAll' that waits on Raft log disk writes before triggering snapshots
- notifyc <- struct{}{}
-
- // Candidate or follower needs to wait for all pending configuration
- // changes to be applied before sending messages.
- // Otherwise we might incorrectly count votes (e.g. votes from removed members).
- // Also slow machine's follower raft-layer could proceed to become the leader
- // on its own single-node cluster, before apply-layer applies the config change.
- // We simply wait for ALL pending entries to be applied for now.
- // We might improve this later on if it causes unnecessary long blocking issues.
- waitApply := false
- for _, ent := range rd.CommittedEntries {
- if ent.Type == raftpb.EntryConfChange {
- waitApply = true
- break
- }
- }
- if waitApply {
- // blocks until 'applyAll' calls 'applyWait.Trigger'
- // to be in sync with scheduled config-change job
- // (assume notifyc has cap of 1)
- select {
- case notifyc <- struct{}{}:
- case <-r.stopped:
- return
- }
- }
-
- // gofail: var raftBeforeFollowerSend struct{}
- r.transport.Send(msgs)
- } else {
- // leader already processed 'MsgSnap' and signaled
- notifyc <- struct{}{}
- }
-
- r.Advance()
- case <-r.stopped:
- return
- }
- }
- }()
-}
-
-func updateCommittedIndex(ap *apply, rh *raftReadyHandler) {
- var ci uint64
- if len(ap.entries) != 0 {
- ci = ap.entries[len(ap.entries)-1].Index
- }
- if ap.snapshot.Metadata.Index > ci {
- ci = ap.snapshot.Metadata.Index
- }
- if ci != 0 {
- rh.updateCommittedIndex(ci)
- }
-}
-
-func (r *raftNode) processMessages(ms []raftpb.Message) []raftpb.Message {
- sentAppResp := false
- for i := len(ms) - 1; i >= 0; i-- {
- if r.isIDRemoved(ms[i].To) {
- ms[i].To = 0
- }
-
- if ms[i].Type == raftpb.MsgAppResp {
- if sentAppResp {
- ms[i].To = 0
- } else {
- sentAppResp = true
- }
- }
-
- if ms[i].Type == raftpb.MsgSnap {
- // There are two separate data store: the store for v2, and the KV for v3.
- // The msgSnap only contains the most recent snapshot of store without KV.
- // So we need to redirect the msgSnap to etcd server main loop for merging in the
- // current store snapshot and KV snapshot.
- select {
- case r.msgSnapC <- ms[i]:
- default:
- // drop msgSnap if the inflight chan if full.
- }
- ms[i].To = 0
- }
- if ms[i].Type == raftpb.MsgHeartbeat {
- ok, exceed := r.td.Observe(ms[i].To)
- if !ok {
- // TODO: limit request rate.
- if r.lg != nil {
- r.lg.Warn(
- "leader failed to send out heartbeat on time; took too long, leader is overloaded likely from slow disk",
- zap.String("to", fmt.Sprintf("%x", ms[i].To)),
- zap.Duration("heartbeat-interval", r.heartbeat),
- zap.Duration("expected-duration", 2*r.heartbeat),
- zap.Duration("exceeded-duration", exceed),
- )
- } else {
- plog.Warningf("failed to send out heartbeat on time (exceeded the %v timeout for %v, to %x)", r.heartbeat, exceed, ms[i].To)
- plog.Warningf("server is likely overloaded")
- }
- heartbeatSendFailures.Inc()
- }
- }
- }
- return ms
-}
-
-func (r *raftNode) apply() chan apply {
- return r.applyc
-}
-
-func (r *raftNode) stop() {
- r.stopped <- struct{}{}
- <-r.done
-}
-
-func (r *raftNode) onStop() {
- r.Stop()
- r.ticker.Stop()
- r.transport.Stop()
- if err := r.storage.Close(); err != nil {
- if r.lg != nil {
- r.lg.Panic("failed to close Raft storage", zap.Error(err))
- } else {
- plog.Panicf("raft close storage error: %v", err)
- }
- }
- close(r.done)
-}
-
-// for testing
-func (r *raftNode) pauseSending() {
- p := r.transport.(rafthttp.Pausable)
- p.Pause()
-}
-
-func (r *raftNode) resumeSending() {
- p := r.transport.(rafthttp.Pausable)
- p.Resume()
-}
-
-// advanceTicks advances ticks of Raft node.
-// This can be used for fast-forwarding election
-// ticks in multi data-center deployments, thus
-// speeding up election process.
-func (r *raftNode) advanceTicks(ticks int) {
- for i := 0; i < ticks; i++ {
- r.tick()
- }
-}
-
-func startNode(cfg ServerConfig, cl *membership.RaftCluster, ids []types.ID) (id types.ID, n raft.Node, s *raft.MemoryStorage, w *wal.WAL) {
- var err error
- member := cl.MemberByName(cfg.Name)
- metadata := pbutil.MustMarshal(
- &pb.Metadata{
- NodeID: uint64(member.ID),
- ClusterID: uint64(cl.ID()),
- },
- )
- if w, err = wal.Create(cfg.Logger, cfg.WALDir(), metadata); err != nil {
- if cfg.Logger != nil {
- cfg.Logger.Panic("failed to create WAL", zap.Error(err))
- } else {
- plog.Panicf("create wal error: %v", err)
- }
- }
- peers := make([]raft.Peer, len(ids))
- for i, id := range ids {
- var ctx []byte
- ctx, err = json.Marshal((*cl).Member(id))
- if err != nil {
- if cfg.Logger != nil {
- cfg.Logger.Panic("failed to marshal member", zap.Error(err))
- } else {
- plog.Panicf("marshal member should never fail: %v", err)
- }
- }
- peers[i] = raft.Peer{ID: uint64(id), Context: ctx}
- }
- id = member.ID
- if cfg.Logger != nil {
- cfg.Logger.Info(
- "starting local member",
- zap.String("local-member-id", id.String()),
- zap.String("cluster-id", cl.ID().String()),
- )
- } else {
- plog.Infof("starting member %s in cluster %s", id, cl.ID())
- }
- s = raft.NewMemoryStorage()
- c := &raft.Config{
- ID: uint64(id),
- ElectionTick: cfg.ElectionTicks,
- HeartbeatTick: 1,
- Storage: s,
- MaxSizePerMsg: maxSizePerMsg,
- MaxInflightMsgs: maxInflightMsgs,
- CheckQuorum: true,
- PreVote: cfg.PreVote,
- }
- if cfg.Logger != nil {
- // called after capnslog setting in "init" function
- if cfg.LoggerConfig != nil {
- c.Logger, err = logutil.NewRaftLogger(cfg.LoggerConfig)
- if err != nil {
- log.Fatalf("cannot create raft logger %v", err)
- }
- } else if cfg.LoggerCore != nil && cfg.LoggerWriteSyncer != nil {
- c.Logger = logutil.NewRaftLoggerFromZapCore(cfg.LoggerCore, cfg.LoggerWriteSyncer)
- }
- }
-
- if len(peers) == 0 {
- n = raft.RestartNode(c)
- } else {
- n = raft.StartNode(c, peers)
- }
- raftStatusMu.Lock()
- raftStatus = n.Status
- raftStatusMu.Unlock()
- return id, n, s, w
-}
-
-func restartNode(cfg ServerConfig, snapshot *raftpb.Snapshot) (types.ID, *membership.RaftCluster, raft.Node, *raft.MemoryStorage, *wal.WAL) {
- var walsnap walpb.Snapshot
- if snapshot != nil {
- walsnap.Index, walsnap.Term = snapshot.Metadata.Index, snapshot.Metadata.Term
- }
- w, id, cid, st, ents := readWAL(cfg.Logger, cfg.WALDir(), walsnap)
-
- if cfg.Logger != nil {
- cfg.Logger.Info(
- "restarting local member",
- zap.String("cluster-id", cid.String()),
- zap.String("local-member-id", id.String()),
- zap.Uint64("commit-index", st.Commit),
- )
- } else {
- plog.Infof("restarting member %s in cluster %s at commit index %d", id, cid, st.Commit)
- }
- cl := membership.NewCluster(cfg.Logger, "")
- cl.SetID(id, cid)
- s := raft.NewMemoryStorage()
- if snapshot != nil {
- s.ApplySnapshot(*snapshot)
- }
- s.SetHardState(st)
- s.Append(ents)
- c := &raft.Config{
- ID: uint64(id),
- ElectionTick: cfg.ElectionTicks,
- HeartbeatTick: 1,
- Storage: s,
- MaxSizePerMsg: maxSizePerMsg,
- MaxInflightMsgs: maxInflightMsgs,
- CheckQuorum: true,
- PreVote: cfg.PreVote,
- }
- if cfg.Logger != nil {
- // called after capnslog setting in "init" function
- var err error
- if cfg.LoggerConfig != nil {
- c.Logger, err = logutil.NewRaftLogger(cfg.LoggerConfig)
- if err != nil {
- log.Fatalf("cannot create raft logger %v", err)
- }
- } else if cfg.LoggerCore != nil && cfg.LoggerWriteSyncer != nil {
- c.Logger = logutil.NewRaftLoggerFromZapCore(cfg.LoggerCore, cfg.LoggerWriteSyncer)
- }
- }
-
- n := raft.RestartNode(c)
- raftStatusMu.Lock()
- raftStatus = n.Status
- raftStatusMu.Unlock()
- return id, cl, n, s, w
-}
-
-func restartAsStandaloneNode(cfg ServerConfig, snapshot *raftpb.Snapshot) (types.ID, *membership.RaftCluster, raft.Node, *raft.MemoryStorage, *wal.WAL) {
- var walsnap walpb.Snapshot
- if snapshot != nil {
- walsnap.Index, walsnap.Term = snapshot.Metadata.Index, snapshot.Metadata.Term
- }
- w, id, cid, st, ents := readWAL(cfg.Logger, cfg.WALDir(), walsnap)
-
- // discard the previously uncommitted entries
- for i, ent := range ents {
- if ent.Index > st.Commit {
- if cfg.Logger != nil {
- cfg.Logger.Info(
- "discarding uncommitted WAL entries",
- zap.Uint64("entry-index", ent.Index),
- zap.Uint64("commit-index-from-wal", st.Commit),
- zap.Int("number-of-discarded-entries", len(ents)-i),
- )
- } else {
- plog.Infof("discarding %d uncommitted WAL entries ", len(ents)-i)
- }
- ents = ents[:i]
- break
- }
- }
-
- // force append the configuration change entries
- toAppEnts := createConfigChangeEnts(
- cfg.Logger,
- getIDs(cfg.Logger, snapshot, ents),
- uint64(id),
- st.Term,
- st.Commit,
- )
- ents = append(ents, toAppEnts...)
-
- // force commit newly appended entries
- err := w.Save(raftpb.HardState{}, toAppEnts)
- if err != nil {
- if cfg.Logger != nil {
- cfg.Logger.Fatal("failed to save hard state and entries", zap.Error(err))
- } else {
- plog.Fatalf("%v", err)
- }
- }
- if len(ents) != 0 {
- st.Commit = ents[len(ents)-1].Index
- }
-
- if cfg.Logger != nil {
- cfg.Logger.Info(
- "forcing restart member",
- zap.String("cluster-id", cid.String()),
- zap.String("local-member-id", id.String()),
- zap.Uint64("commit-index", st.Commit),
- )
- } else {
- plog.Printf("forcing restart of member %s in cluster %s at commit index %d", id, cid, st.Commit)
- }
-
- cl := membership.NewCluster(cfg.Logger, "")
- cl.SetID(id, cid)
- s := raft.NewMemoryStorage()
- if snapshot != nil {
- s.ApplySnapshot(*snapshot)
- }
- s.SetHardState(st)
- s.Append(ents)
- c := &raft.Config{
- ID: uint64(id),
- ElectionTick: cfg.ElectionTicks,
- HeartbeatTick: 1,
- Storage: s,
- MaxSizePerMsg: maxSizePerMsg,
- MaxInflightMsgs: maxInflightMsgs,
- CheckQuorum: true,
- PreVote: cfg.PreVote,
- }
- if cfg.Logger != nil {
- // called after capnslog setting in "init" function
- if cfg.LoggerConfig != nil {
- c.Logger, err = logutil.NewRaftLogger(cfg.LoggerConfig)
- if err != nil {
- log.Fatalf("cannot create raft logger %v", err)
- }
- } else if cfg.LoggerCore != nil && cfg.LoggerWriteSyncer != nil {
- c.Logger = logutil.NewRaftLoggerFromZapCore(cfg.LoggerCore, cfg.LoggerWriteSyncer)
- }
- }
-
- n := raft.RestartNode(c)
- raftStatus = n.Status
- return id, cl, n, s, w
-}
-
-// getIDs returns an ordered set of IDs included in the given snapshot and
-// the entries. The given snapshot/entries can contain two kinds of
-// ID-related entry:
-// - ConfChangeAddNode, in which case the contained ID will be added into the set.
-// - ConfChangeRemoveNode, in which case the contained ID will be removed from the set.
-func getIDs(lg *zap.Logger, snap *raftpb.Snapshot, ents []raftpb.Entry) []uint64 {
- ids := make(map[uint64]bool)
- if snap != nil {
- for _, id := range snap.Metadata.ConfState.Voters {
- ids[id] = true
- }
- }
- for _, e := range ents {
- if e.Type != raftpb.EntryConfChange {
- continue
- }
- var cc raftpb.ConfChange
- pbutil.MustUnmarshal(&cc, e.Data)
- switch cc.Type {
- case raftpb.ConfChangeAddNode:
- ids[cc.NodeID] = true
- case raftpb.ConfChangeRemoveNode:
- delete(ids, cc.NodeID)
- case raftpb.ConfChangeUpdateNode:
- // do nothing
- default:
- if lg != nil {
- lg.Panic("unknown ConfChange Type", zap.String("type", cc.Type.String()))
- } else {
- plog.Panicf("ConfChange Type should be either ConfChangeAddNode or ConfChangeRemoveNode!")
- }
- }
- }
- sids := make(types.Uint64Slice, 0, len(ids))
- for id := range ids {
- sids = append(sids, id)
- }
- sort.Sort(sids)
- return []uint64(sids)
-}
-
-// createConfigChangeEnts creates a series of Raft entries (i.e.
-// EntryConfChange) to remove the set of given IDs from the cluster. The ID
-// `self` is _not_ removed, even if present in the set.
-// If `self` is not inside the given ids, it creates a Raft entry to add a
-// default member with the given `self`.
-func createConfigChangeEnts(lg *zap.Logger, ids []uint64, self uint64, term, index uint64) []raftpb.Entry {
- found := false
- for _, id := range ids {
- if id == self {
- found = true
- }
- }
-
- var ents []raftpb.Entry
- next := index + 1
-
- // NB: always add self first, then remove other nodes. Raft will panic if the
- // set of voters ever becomes empty.
- if !found {
- m := membership.Member{
- ID: types.ID(self),
- RaftAttributes: membership.RaftAttributes{PeerURLs: []string{"http://localhost:2380"}},
- }
- ctx, err := json.Marshal(m)
- if err != nil {
- if lg != nil {
- lg.Panic("failed to marshal member", zap.Error(err))
- } else {
- plog.Panicf("marshal member should never fail: %v", err)
- }
- }
- cc := &raftpb.ConfChange{
- Type: raftpb.ConfChangeAddNode,
- NodeID: self,
- Context: ctx,
- }
- e := raftpb.Entry{
- Type: raftpb.EntryConfChange,
- Data: pbutil.MustMarshal(cc),
- Term: term,
- Index: next,
- }
- ents = append(ents, e)
- next++
- }
-
- for _, id := range ids {
- if id == self {
- continue
- }
- cc := &raftpb.ConfChange{
- Type: raftpb.ConfChangeRemoveNode,
- NodeID: id,
- }
- e := raftpb.Entry{
- Type: raftpb.EntryConfChange,
- Data: pbutil.MustMarshal(cc),
- Term: term,
- Index: next,
- }
- ents = append(ents, e)
- next++
- }
-
- return ents
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/server.go b/vendor/go.etcd.io/etcd/etcdserver/server.go
deleted file mode 100644
index 78daa0e..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/server.go
+++ /dev/null
@@ -1,2656 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package etcdserver
-
-import (
- "context"
- "encoding/json"
- "expvar"
- "fmt"
- "math"
- "math/rand"
- "net/http"
- "os"
- "path"
- "regexp"
- "sync"
- "sync/atomic"
- "time"
-
- "go.etcd.io/etcd/auth"
- "go.etcd.io/etcd/etcdserver/api"
- "go.etcd.io/etcd/etcdserver/api/membership"
- "go.etcd.io/etcd/etcdserver/api/rafthttp"
- "go.etcd.io/etcd/etcdserver/api/snap"
- "go.etcd.io/etcd/etcdserver/api/v2discovery"
- "go.etcd.io/etcd/etcdserver/api/v2http/httptypes"
- stats "go.etcd.io/etcd/etcdserver/api/v2stats"
- "go.etcd.io/etcd/etcdserver/api/v2store"
- "go.etcd.io/etcd/etcdserver/api/v3alarm"
- "go.etcd.io/etcd/etcdserver/api/v3compactor"
- pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
- "go.etcd.io/etcd/lease"
- "go.etcd.io/etcd/lease/leasehttp"
- "go.etcd.io/etcd/mvcc"
- "go.etcd.io/etcd/mvcc/backend"
- "go.etcd.io/etcd/pkg/fileutil"
- "go.etcd.io/etcd/pkg/idutil"
- "go.etcd.io/etcd/pkg/pbutil"
- "go.etcd.io/etcd/pkg/runtime"
- "go.etcd.io/etcd/pkg/schedule"
- "go.etcd.io/etcd/pkg/types"
- "go.etcd.io/etcd/pkg/wait"
- "go.etcd.io/etcd/raft"
- "go.etcd.io/etcd/raft/raftpb"
- "go.etcd.io/etcd/version"
- "go.etcd.io/etcd/wal"
-
- "github.com/coreos/go-semver/semver"
- "github.com/coreos/pkg/capnslog"
- humanize "github.com/dustin/go-humanize"
- "github.com/prometheus/client_golang/prometheus"
- "go.uber.org/zap"
-)
-
-const (
- DefaultSnapshotCount = 100000
-
- // DefaultSnapshotCatchUpEntries is the number of entries for a slow follower
- // to catch-up after compacting the raft storage entries.
- // We expect the follower has a millisecond level latency with the leader.
- // The max throughput is around 10K. Keep a 5K entries is enough for helping
- // follower to catch up.
- DefaultSnapshotCatchUpEntries uint64 = 5000
-
- StoreClusterPrefix = "/0"
- StoreKeysPrefix = "/1"
-
- // HealthInterval is the minimum time the cluster should be healthy
- // before accepting add member requests.
- HealthInterval = 5 * time.Second
-
- purgeFileInterval = 30 * time.Second
- // monitorVersionInterval should be smaller than the timeout
- // on the connection. Or we will not be able to reuse the connection
- // (since it will timeout).
- monitorVersionInterval = rafthttp.ConnWriteTimeout - time.Second
-
- // max number of in-flight snapshot messages etcdserver allows to have
- // This number is more than enough for most clusters with 5 machines.
- maxInFlightMsgSnap = 16
-
- releaseDelayAfterSnapshot = 30 * time.Second
-
- // maxPendingRevokes is the maximum number of outstanding expired lease revocations.
- maxPendingRevokes = 16
-
- recommendedMaxRequestBytes = 10 * 1024 * 1024
-
- readyPercent = 0.9
-)
-
-var (
- plog = capnslog.NewPackageLogger("go.etcd.io/etcd", "etcdserver")
-
- storeMemberAttributeRegexp = regexp.MustCompile(path.Join(membership.StoreMembersPrefix, "[[:xdigit:]]{1,16}", "attributes"))
-)
-
-func init() {
- rand.Seed(time.Now().UnixNano())
-
- expvar.Publish(
- "file_descriptor_limit",
- expvar.Func(
- func() interface{} {
- n, _ := runtime.FDLimit()
- return n
- },
- ),
- )
-}
-
-type Response struct {
- Term uint64
- Index uint64
- Event *v2store.Event
- Watcher v2store.Watcher
- Err error
-}
-
-type ServerV2 interface {
- Server
- Leader() types.ID
-
- // Do takes a V2 request and attempts to fulfill it, returning a Response.
- Do(ctx context.Context, r pb.Request) (Response, error)
- stats.Stats
- ClientCertAuthEnabled() bool
-}
-
-type ServerV3 interface {
- Server
- RaftStatusGetter
-}
-
-func (s *EtcdServer) ClientCertAuthEnabled() bool { return s.Cfg.ClientCertAuthEnabled }
-
-type Server interface {
- // AddMember attempts to add a member into the cluster. It will return
- // ErrIDRemoved if member ID is removed from the cluster, or return
- // ErrIDExists if member ID exists in the cluster.
- AddMember(ctx context.Context, memb membership.Member) ([]*membership.Member, error)
- // RemoveMember attempts to remove a member from the cluster. It will
- // return ErrIDRemoved if member ID is removed from the cluster, or return
- // ErrIDNotFound if member ID is not in the cluster.
- RemoveMember(ctx context.Context, id uint64) ([]*membership.Member, error)
- // UpdateMember attempts to update an existing member in the cluster. It will
- // return ErrIDNotFound if the member ID does not exist.
- UpdateMember(ctx context.Context, updateMemb membership.Member) ([]*membership.Member, error)
- // PromoteMember attempts to promote a non-voting node to a voting node. It will
- // return ErrIDNotFound if the member ID does not exist.
- // return ErrLearnerNotReady if the member are not ready.
- // return ErrMemberNotLearner if the member is not a learner.
- PromoteMember(ctx context.Context, id uint64) ([]*membership.Member, error)
-
- // ClusterVersion is the cluster-wide minimum major.minor version.
- // Cluster version is set to the min version that an etcd member is
- // compatible with when first bootstrap.
- //
- // ClusterVersion is nil until the cluster is bootstrapped (has a quorum).
- //
- // During a rolling upgrades, the ClusterVersion will be updated
- // automatically after a sync. (5 second by default)
- //
- // The API/raft component can utilize ClusterVersion to determine if
- // it can accept a client request or a raft RPC.
- // NOTE: ClusterVersion might be nil when etcd 2.1 works with etcd 2.0 and
- // the leader is etcd 2.0. etcd 2.0 leader will not update clusterVersion since
- // this feature is introduced post 2.0.
- ClusterVersion() *semver.Version
- Cluster() api.Cluster
- Alarms() []*pb.AlarmMember
-}
-
-// EtcdServer is the production implementation of the Server interface
-type EtcdServer struct {
- // inflightSnapshots holds count the number of snapshots currently inflight.
- inflightSnapshots int64 // must use atomic operations to access; keep 64-bit aligned.
- appliedIndex uint64 // must use atomic operations to access; keep 64-bit aligned.
- committedIndex uint64 // must use atomic operations to access; keep 64-bit aligned.
- term uint64 // must use atomic operations to access; keep 64-bit aligned.
- lead uint64 // must use atomic operations to access; keep 64-bit aligned.
-
- // consistIndex used to hold the offset of current executing entry
- // It is initialized to 0 before executing any entry.
- consistIndex consistentIndex // must use atomic operations to access; keep 64-bit aligned.
- r raftNode // uses 64-bit atomics; keep 64-bit aligned.
-
- readych chan struct{}
- Cfg ServerConfig
-
- lgMu *sync.RWMutex
- lg *zap.Logger
-
- w wait.Wait
-
- readMu sync.RWMutex
- // read routine notifies etcd server that it waits for reading by sending an empty struct to
- // readwaitC
- readwaitc chan struct{}
- // readNotifier is used to notify the read routine that it can process the request
- // when there is no error
- readNotifier *notifier
-
- // stop signals the run goroutine should shutdown.
- stop chan struct{}
- // stopping is closed by run goroutine on shutdown.
- stopping chan struct{}
- // done is closed when all goroutines from start() complete.
- done chan struct{}
- // leaderChanged is used to notify the linearizable read loop to drop the old read requests.
- leaderChanged chan struct{}
- leaderChangedMu sync.RWMutex
-
- errorc chan error
- id types.ID
- attributes membership.Attributes
-
- cluster *membership.RaftCluster
-
- v2store v2store.Store
- snapshotter *snap.Snapshotter
-
- applyV2 ApplierV2
-
- // applyV3 is the applier with auth and quotas
- applyV3 applierV3
- // applyV3Base is the core applier without auth or quotas
- applyV3Base applierV3
- applyWait wait.WaitTime
-
- kv mvcc.ConsistentWatchableKV
- lessor lease.Lessor
- bemu sync.Mutex
- be backend.Backend
- authStore auth.AuthStore
- alarmStore *v3alarm.AlarmStore
-
- stats *stats.ServerStats
- lstats *stats.LeaderStats
-
- SyncTicker *time.Ticker
- // compactor is used to auto-compact the KV.
- compactor v3compactor.Compactor
-
- // peerRt used to send requests (version, lease) to peers.
- peerRt http.RoundTripper
- reqIDGen *idutil.Generator
-
- // forceVersionC is used to force the version monitor loop
- // to detect the cluster version immediately.
- forceVersionC chan struct{}
-
- // wgMu blocks concurrent waitgroup mutation while server stopping
- wgMu sync.RWMutex
- // wg is used to wait for the go routines that depends on the server state
- // to exit when stopping the server.
- wg sync.WaitGroup
-
- // ctx is used for etcd-initiated requests that may need to be canceled
- // on etcd server shutdown.
- ctx context.Context
- cancel context.CancelFunc
-
- leadTimeMu sync.RWMutex
- leadElectedTime time.Time
-
- *AccessController
-}
-
-// NewServer creates a new EtcdServer from the supplied configuration. The
-// configuration is considered static for the lifetime of the EtcdServer.
-func NewServer(cfg ServerConfig) (srv *EtcdServer, err error) {
- st := v2store.New(StoreClusterPrefix, StoreKeysPrefix)
-
- var (
- w *wal.WAL
- n raft.Node
- s *raft.MemoryStorage
- id types.ID
- cl *membership.RaftCluster
- )
-
- if cfg.MaxRequestBytes > recommendedMaxRequestBytes {
- if cfg.Logger != nil {
- cfg.Logger.Warn(
- "exceeded recommended request limit",
- zap.Uint("max-request-bytes", cfg.MaxRequestBytes),
- zap.String("max-request-size", humanize.Bytes(uint64(cfg.MaxRequestBytes))),
- zap.Int("recommended-request-bytes", recommendedMaxRequestBytes),
- zap.String("recommended-request-size", humanize.Bytes(uint64(recommendedMaxRequestBytes))),
- )
- } else {
- plog.Warningf("MaxRequestBytes %v exceeds maximum recommended size %v", cfg.MaxRequestBytes, recommendedMaxRequestBytes)
- }
- }
-
- if terr := fileutil.TouchDirAll(cfg.DataDir); terr != nil {
- return nil, fmt.Errorf("cannot access data directory: %v", terr)
- }
-
- haveWAL := wal.Exist(cfg.WALDir())
-
- if err = fileutil.TouchDirAll(cfg.SnapDir()); err != nil {
- if cfg.Logger != nil {
- cfg.Logger.Fatal(
- "failed to create snapshot directory",
- zap.String("path", cfg.SnapDir()),
- zap.Error(err),
- )
- } else {
- plog.Fatalf("create snapshot directory error: %v", err)
- }
- }
- ss := snap.New(cfg.Logger, cfg.SnapDir())
-
- bepath := cfg.backendPath()
- beExist := fileutil.Exist(bepath)
- be := openBackend(cfg)
-
- defer func() {
- if err != nil {
- be.Close()
- }
- }()
-
- prt, err := rafthttp.NewRoundTripper(cfg.PeerTLSInfo, cfg.peerDialTimeout())
- if err != nil {
- return nil, err
- }
- var (
- remotes []*membership.Member
- snapshot *raftpb.Snapshot
- )
-
- switch {
- case !haveWAL && !cfg.NewCluster:
- if err = cfg.VerifyJoinExisting(); err != nil {
- return nil, err
- }
- cl, err = membership.NewClusterFromURLsMap(cfg.Logger, cfg.InitialClusterToken, cfg.InitialPeerURLsMap)
- if err != nil {
- return nil, err
- }
- existingCluster, gerr := GetClusterFromRemotePeers(cfg.Logger, getRemotePeerURLs(cl, cfg.Name), prt)
- if gerr != nil {
- return nil, fmt.Errorf("cannot fetch cluster info from peer urls: %v", gerr)
- }
- if err = membership.ValidateClusterAndAssignIDs(cfg.Logger, cl, existingCluster); err != nil {
- return nil, fmt.Errorf("error validating peerURLs %s: %v", existingCluster, err)
- }
- if !isCompatibleWithCluster(cfg.Logger, cl, cl.MemberByName(cfg.Name).ID, prt) {
- return nil, fmt.Errorf("incompatible with current running cluster")
- }
-
- remotes = existingCluster.Members()
- cl.SetID(types.ID(0), existingCluster.ID())
- cl.SetStore(st)
- cl.SetBackend(be)
- id, n, s, w = startNode(cfg, cl, nil)
- cl.SetID(id, existingCluster.ID())
-
- case !haveWAL && cfg.NewCluster:
- if err = cfg.VerifyBootstrap(); err != nil {
- return nil, err
- }
- cl, err = membership.NewClusterFromURLsMap(cfg.Logger, cfg.InitialClusterToken, cfg.InitialPeerURLsMap)
- if err != nil {
- return nil, err
- }
- m := cl.MemberByName(cfg.Name)
- if isMemberBootstrapped(cfg.Logger, cl, cfg.Name, prt, cfg.bootstrapTimeout()) {
- return nil, fmt.Errorf("member %s has already been bootstrapped", m.ID)
- }
- if cfg.ShouldDiscover() {
- var str string
- str, err = v2discovery.JoinCluster(cfg.Logger, cfg.DiscoveryURL, cfg.DiscoveryProxy, m.ID, cfg.InitialPeerURLsMap.String())
- if err != nil {
- return nil, &DiscoveryError{Op: "join", Err: err}
- }
- var urlsmap types.URLsMap
- urlsmap, err = types.NewURLsMap(str)
- if err != nil {
- return nil, err
- }
- if checkDuplicateURL(urlsmap) {
- return nil, fmt.Errorf("discovery cluster %s has duplicate url", urlsmap)
- }
- if cl, err = membership.NewClusterFromURLsMap(cfg.Logger, cfg.InitialClusterToken, urlsmap); err != nil {
- return nil, err
- }
- }
- cl.SetStore(st)
- cl.SetBackend(be)
- id, n, s, w = startNode(cfg, cl, cl.MemberIDs())
- cl.SetID(id, cl.ID())
-
- case haveWAL:
- if err = fileutil.IsDirWriteable(cfg.MemberDir()); err != nil {
- return nil, fmt.Errorf("cannot write to member directory: %v", err)
- }
-
- if err = fileutil.IsDirWriteable(cfg.WALDir()); err != nil {
- return nil, fmt.Errorf("cannot write to WAL directory: %v", err)
- }
-
- if cfg.ShouldDiscover() {
- if cfg.Logger != nil {
- cfg.Logger.Warn(
- "discovery token is ignored since cluster already initialized; valid logs are found",
- zap.String("wal-dir", cfg.WALDir()),
- )
- } else {
- plog.Warningf("discovery token ignored since a cluster has already been initialized. Valid log found at %q", cfg.WALDir())
- }
- }
- snapshot, err = ss.Load()
- if err != nil && err != snap.ErrNoSnapshot {
- return nil, err
- }
- if snapshot != nil {
- if err = st.Recovery(snapshot.Data); err != nil {
- if cfg.Logger != nil {
- cfg.Logger.Panic("failed to recover from snapshot")
- } else {
- plog.Panicf("recovered store from snapshot error: %v", err)
- }
- }
-
- if cfg.Logger != nil {
- cfg.Logger.Info(
- "recovered v2 store from snapshot",
- zap.Uint64("snapshot-index", snapshot.Metadata.Index),
- zap.String("snapshot-size", humanize.Bytes(uint64(snapshot.Size()))),
- )
- } else {
- plog.Infof("recovered store from snapshot at index %d", snapshot.Metadata.Index)
- }
-
- if be, err = recoverSnapshotBackend(cfg, be, *snapshot); err != nil {
- if cfg.Logger != nil {
- cfg.Logger.Panic("failed to recover v3 backend from snapshot", zap.Error(err))
- } else {
- plog.Panicf("recovering backend from snapshot error: %v", err)
- }
- }
- if cfg.Logger != nil {
- s1, s2 := be.Size(), be.SizeInUse()
- cfg.Logger.Info(
- "recovered v3 backend from snapshot",
- zap.Int64("backend-size-bytes", s1),
- zap.String("backend-size", humanize.Bytes(uint64(s1))),
- zap.Int64("backend-size-in-use-bytes", s2),
- zap.String("backend-size-in-use", humanize.Bytes(uint64(s2))),
- )
- }
- }
-
- if !cfg.ForceNewCluster {
- id, cl, n, s, w = restartNode(cfg, snapshot)
- } else {
- id, cl, n, s, w = restartAsStandaloneNode(cfg, snapshot)
- }
-
- cl.SetStore(st)
- cl.SetBackend(be)
- cl.Recover(api.UpdateCapability)
- if cl.Version() != nil && !cl.Version().LessThan(semver.Version{Major: 3}) && !beExist {
- os.RemoveAll(bepath)
- return nil, fmt.Errorf("database file (%v) of the backend is missing", bepath)
- }
-
- default:
- return nil, fmt.Errorf("unsupported bootstrap config")
- }
-
- if terr := fileutil.TouchDirAll(cfg.MemberDir()); terr != nil {
- return nil, fmt.Errorf("cannot access member directory: %v", terr)
- }
-
- sstats := stats.NewServerStats(cfg.Name, id.String())
- lstats := stats.NewLeaderStats(id.String())
-
- heartbeat := time.Duration(cfg.TickMs) * time.Millisecond
- srv = &EtcdServer{
- readych: make(chan struct{}),
- Cfg: cfg,
- lgMu: new(sync.RWMutex),
- lg: cfg.Logger,
- errorc: make(chan error, 1),
- v2store: st,
- snapshotter: ss,
- r: *newRaftNode(
- raftNodeConfig{
- lg: cfg.Logger,
- isIDRemoved: func(id uint64) bool { return cl.IsIDRemoved(types.ID(id)) },
- Node: n,
- heartbeat: heartbeat,
- raftStorage: s,
- storage: NewStorage(w, ss),
- },
- ),
- id: id,
- attributes: membership.Attributes{Name: cfg.Name, ClientURLs: cfg.ClientURLs.StringSlice()},
- cluster: cl,
- stats: sstats,
- lstats: lstats,
- SyncTicker: time.NewTicker(500 * time.Millisecond),
- peerRt: prt,
- reqIDGen: idutil.NewGenerator(uint16(id), time.Now()),
- forceVersionC: make(chan struct{}),
- AccessController: &AccessController{CORS: cfg.CORS, HostWhitelist: cfg.HostWhitelist},
- }
- serverID.With(prometheus.Labels{"server_id": id.String()}).Set(1)
-
- srv.applyV2 = &applierV2store{store: srv.v2store, cluster: srv.cluster}
-
- srv.be = be
- minTTL := time.Duration((3*cfg.ElectionTicks)/2) * heartbeat
-
- // always recover lessor before kv. When we recover the mvcc.KV it will reattach keys to its leases.
- // If we recover mvcc.KV first, it will attach the keys to the wrong lessor before it recovers.
- srv.lessor = lease.NewLessor(
- srv.getLogger(),
- srv.be,
- lease.LessorConfig{
- MinLeaseTTL: int64(math.Ceil(minTTL.Seconds())),
- CheckpointInterval: cfg.LeaseCheckpointInterval,
- ExpiredLeasesRetryInterval: srv.Cfg.ReqTimeout(),
- })
- srv.kv = mvcc.New(srv.getLogger(), srv.be, srv.lessor, &srv.consistIndex, mvcc.StoreConfig{CompactionBatchLimit: cfg.CompactionBatchLimit})
- if beExist {
- kvindex := srv.kv.ConsistentIndex()
- // TODO: remove kvindex != 0 checking when we do not expect users to upgrade
- // etcd from pre-3.0 release.
- if snapshot != nil && kvindex < snapshot.Metadata.Index {
- if kvindex != 0 {
- return nil, fmt.Errorf("database file (%v index %d) does not match with snapshot (index %d)", bepath, kvindex, snapshot.Metadata.Index)
- }
- if cfg.Logger != nil {
- cfg.Logger.Warn(
- "consistent index was never saved",
- zap.Uint64("snapshot-index", snapshot.Metadata.Index),
- )
- } else {
- plog.Warningf("consistent index never saved (snapshot index=%d)", snapshot.Metadata.Index)
- }
- }
- }
- newSrv := srv // since srv == nil in defer if srv is returned as nil
- defer func() {
- // closing backend without first closing kv can cause
- // resumed compactions to fail with closed tx errors
- if err != nil {
- newSrv.kv.Close()
- }
- }()
-
- srv.consistIndex.setConsistentIndex(srv.kv.ConsistentIndex())
- tp, err := auth.NewTokenProvider(cfg.Logger, cfg.AuthToken,
- func(index uint64) <-chan struct{} {
- return srv.applyWait.Wait(index)
- },
- )
- if err != nil {
- if cfg.Logger != nil {
- cfg.Logger.Warn("failed to create token provider", zap.Error(err))
- } else {
- plog.Errorf("failed to create token provider: %s", err)
- }
- return nil, err
- }
- srv.authStore = auth.NewAuthStore(srv.getLogger(), srv.be, tp, int(cfg.BcryptCost))
- if num := cfg.AutoCompactionRetention; num != 0 {
- srv.compactor, err = v3compactor.New(cfg.Logger, cfg.AutoCompactionMode, num, srv.kv, srv)
- if err != nil {
- return nil, err
- }
- srv.compactor.Run()
- }
-
- srv.applyV3Base = srv.newApplierV3Backend()
- if err = srv.restoreAlarms(); err != nil {
- return nil, err
- }
-
- if srv.Cfg.EnableLeaseCheckpoint {
- // setting checkpointer enables lease checkpoint feature.
- srv.lessor.SetCheckpointer(func(ctx context.Context, cp *pb.LeaseCheckpointRequest) {
- srv.raftRequestOnce(ctx, pb.InternalRaftRequest{LeaseCheckpoint: cp})
- })
- }
-
- // TODO: move transport initialization near the definition of remote
- tr := &rafthttp.Transport{
- Logger: cfg.Logger,
- TLSInfo: cfg.PeerTLSInfo,
- DialTimeout: cfg.peerDialTimeout(),
- ID: id,
- URLs: cfg.PeerURLs,
- ClusterID: cl.ID(),
- Raft: srv,
- Snapshotter: ss,
- ServerStats: sstats,
- LeaderStats: lstats,
- ErrorC: srv.errorc,
- }
- if err = tr.Start(); err != nil {
- return nil, err
- }
- // add all remotes into transport
- for _, m := range remotes {
- if m.ID != id {
- tr.AddRemote(m.ID, m.PeerURLs)
- }
- }
- for _, m := range cl.Members() {
- if m.ID != id {
- tr.AddPeer(m.ID, m.PeerURLs)
- }
- }
- srv.r.transport = tr
-
- return srv, nil
-}
-
-func (s *EtcdServer) getLogger() *zap.Logger {
- s.lgMu.RLock()
- l := s.lg
- s.lgMu.RUnlock()
- return l
-}
-
-func tickToDur(ticks int, tickMs uint) string {
- return fmt.Sprintf("%v", time.Duration(ticks)*time.Duration(tickMs)*time.Millisecond)
-}
-
-func (s *EtcdServer) adjustTicks() {
- lg := s.getLogger()
- clusterN := len(s.cluster.Members())
-
- // single-node fresh start, or single-node recovers from snapshot
- if clusterN == 1 {
- ticks := s.Cfg.ElectionTicks - 1
- if lg != nil {
- lg.Info(
- "started as single-node; fast-forwarding election ticks",
- zap.String("local-member-id", s.ID().String()),
- zap.Int("forward-ticks", ticks),
- zap.String("forward-duration", tickToDur(ticks, s.Cfg.TickMs)),
- zap.Int("election-ticks", s.Cfg.ElectionTicks),
- zap.String("election-timeout", tickToDur(s.Cfg.ElectionTicks, s.Cfg.TickMs)),
- )
- } else {
- plog.Infof("%s as single-node; fast-forwarding %d ticks (election ticks %d)", s.ID(), ticks, s.Cfg.ElectionTicks)
- }
- s.r.advanceTicks(ticks)
- return
- }
-
- if !s.Cfg.InitialElectionTickAdvance {
- if lg != nil {
- lg.Info("skipping initial election tick advance", zap.Int("election-ticks", s.Cfg.ElectionTicks))
- }
- return
- }
- if lg != nil {
- lg.Info("starting initial election tick advance", zap.Int("election-ticks", s.Cfg.ElectionTicks))
- }
-
- // retry up to "rafthttp.ConnReadTimeout", which is 5-sec
- // until peer connection reports; otherwise:
- // 1. all connections failed, or
- // 2. no active peers, or
- // 3. restarted single-node with no snapshot
- // then, do nothing, because advancing ticks would have no effect
- waitTime := rafthttp.ConnReadTimeout
- itv := 50 * time.Millisecond
- for i := int64(0); i < int64(waitTime/itv); i++ {
- select {
- case <-time.After(itv):
- case <-s.stopping:
- return
- }
-
- peerN := s.r.transport.ActivePeers()
- if peerN > 1 {
- // multi-node received peer connection reports
- // adjust ticks, in case slow leader message receive
- ticks := s.Cfg.ElectionTicks - 2
-
- if lg != nil {
- lg.Info(
- "initialized peer connections; fast-forwarding election ticks",
- zap.String("local-member-id", s.ID().String()),
- zap.Int("forward-ticks", ticks),
- zap.String("forward-duration", tickToDur(ticks, s.Cfg.TickMs)),
- zap.Int("election-ticks", s.Cfg.ElectionTicks),
- zap.String("election-timeout", tickToDur(s.Cfg.ElectionTicks, s.Cfg.TickMs)),
- zap.Int("active-remote-members", peerN),
- )
- } else {
- plog.Infof("%s initialized peer connection; fast-forwarding %d ticks (election ticks %d) with %d active peer(s)", s.ID(), ticks, s.Cfg.ElectionTicks, peerN)
- }
-
- s.r.advanceTicks(ticks)
- return
- }
- }
-}
-
-// Start performs any initialization of the Server necessary for it to
-// begin serving requests. It must be called before Do or Process.
-// Start must be non-blocking; any long-running server functionality
-// should be implemented in goroutines.
-func (s *EtcdServer) Start() {
- s.start()
- s.goAttach(func() { s.adjustTicks() })
- s.goAttach(func() { s.publish(s.Cfg.ReqTimeout()) })
- s.goAttach(s.purgeFile)
- s.goAttach(func() { monitorFileDescriptor(s.getLogger(), s.stopping) })
- s.goAttach(s.monitorVersions)
- s.goAttach(s.linearizableReadLoop)
- s.goAttach(s.monitorKVHash)
-}
-
-// start prepares and starts server in a new goroutine. It is no longer safe to
-// modify a server's fields after it has been sent to Start.
-// This function is just used for testing.
-func (s *EtcdServer) start() {
- lg := s.getLogger()
-
- if s.Cfg.SnapshotCount == 0 {
- if lg != nil {
- lg.Info(
- "updating snapshot-count to default",
- zap.Uint64("given-snapshot-count", s.Cfg.SnapshotCount),
- zap.Uint64("updated-snapshot-count", DefaultSnapshotCount),
- )
- } else {
- plog.Infof("set snapshot count to default %d", DefaultSnapshotCount)
- }
- s.Cfg.SnapshotCount = DefaultSnapshotCount
- }
- if s.Cfg.SnapshotCatchUpEntries == 0 {
- if lg != nil {
- lg.Info(
- "updating snapshot catch-up entries to default",
- zap.Uint64("given-snapshot-catchup-entries", s.Cfg.SnapshotCatchUpEntries),
- zap.Uint64("updated-snapshot-catchup-entries", DefaultSnapshotCatchUpEntries),
- )
- }
- s.Cfg.SnapshotCatchUpEntries = DefaultSnapshotCatchUpEntries
- }
-
- s.w = wait.New()
- s.applyWait = wait.NewTimeList()
- s.done = make(chan struct{})
- s.stop = make(chan struct{})
- s.stopping = make(chan struct{})
- s.ctx, s.cancel = context.WithCancel(context.Background())
- s.readwaitc = make(chan struct{}, 1)
- s.readNotifier = newNotifier()
- s.leaderChanged = make(chan struct{})
- if s.ClusterVersion() != nil {
- if lg != nil {
- lg.Info(
- "starting etcd server",
- zap.String("local-member-id", s.ID().String()),
- zap.String("local-server-version", version.Version),
- zap.String("cluster-id", s.Cluster().ID().String()),
- zap.String("cluster-version", version.Cluster(s.ClusterVersion().String())),
- )
- } else {
- plog.Infof("starting server... [version: %v, cluster version: %v]", version.Version, version.Cluster(s.ClusterVersion().String()))
- }
- membership.ClusterVersionMetrics.With(prometheus.Labels{"cluster_version": s.ClusterVersion().String()}).Set(1)
- } else {
- if lg != nil {
- lg.Info(
- "starting etcd server",
- zap.String("local-member-id", s.ID().String()),
- zap.String("local-server-version", version.Version),
- zap.String("cluster-version", "to_be_decided"),
- )
- } else {
- plog.Infof("starting server... [version: %v, cluster version: to_be_decided]", version.Version)
- }
- }
-
- // TODO: if this is an empty log, writes all peer infos
- // into the first entry
- go s.run()
-}
-
-func (s *EtcdServer) purgeFile() {
- var dberrc, serrc, werrc <-chan error
- if s.Cfg.MaxSnapFiles > 0 {
- dberrc = fileutil.PurgeFile(s.getLogger(), s.Cfg.SnapDir(), "snap.db", s.Cfg.MaxSnapFiles, purgeFileInterval, s.done)
- serrc = fileutil.PurgeFile(s.getLogger(), s.Cfg.SnapDir(), "snap", s.Cfg.MaxSnapFiles, purgeFileInterval, s.done)
- }
- if s.Cfg.MaxWALFiles > 0 {
- werrc = fileutil.PurgeFile(s.getLogger(), s.Cfg.WALDir(), "wal", s.Cfg.MaxWALFiles, purgeFileInterval, s.done)
- }
-
- lg := s.getLogger()
- select {
- case e := <-dberrc:
- if lg != nil {
- lg.Fatal("failed to purge snap db file", zap.Error(e))
- } else {
- plog.Fatalf("failed to purge snap db file %v", e)
- }
- case e := <-serrc:
- if lg != nil {
- lg.Fatal("failed to purge snap file", zap.Error(e))
- } else {
- plog.Fatalf("failed to purge snap file %v", e)
- }
- case e := <-werrc:
- if lg != nil {
- lg.Fatal("failed to purge wal file", zap.Error(e))
- } else {
- plog.Fatalf("failed to purge wal file %v", e)
- }
- case <-s.stopping:
- return
- }
-}
-
-func (s *EtcdServer) Cluster() api.Cluster { return s.cluster }
-
-func (s *EtcdServer) ApplyWait() <-chan struct{} { return s.applyWait.Wait(s.getCommittedIndex()) }
-
-type ServerPeer interface {
- ServerV2
- RaftHandler() http.Handler
- LeaseHandler() http.Handler
-}
-
-func (s *EtcdServer) LeaseHandler() http.Handler {
- if s.lessor == nil {
- return nil
- }
- return leasehttp.NewHandler(s.lessor, s.ApplyWait)
-}
-
-func (s *EtcdServer) RaftHandler() http.Handler { return s.r.transport.Handler() }
-
-// Process takes a raft message and applies it to the server's raft state
-// machine, respecting any timeout of the given context.
-func (s *EtcdServer) Process(ctx context.Context, m raftpb.Message) error {
- if s.cluster.IsIDRemoved(types.ID(m.From)) {
- if lg := s.getLogger(); lg != nil {
- lg.Warn(
- "rejected Raft message from removed member",
- zap.String("local-member-id", s.ID().String()),
- zap.String("removed-member-id", types.ID(m.From).String()),
- )
- } else {
- plog.Warningf("reject message from removed member %s", types.ID(m.From).String())
- }
- return httptypes.NewHTTPError(http.StatusForbidden, "cannot process message from removed member")
- }
- if m.Type == raftpb.MsgApp {
- s.stats.RecvAppendReq(types.ID(m.From).String(), m.Size())
- }
- return s.r.Step(ctx, m)
-}
-
-func (s *EtcdServer) IsIDRemoved(id uint64) bool { return s.cluster.IsIDRemoved(types.ID(id)) }
-
-func (s *EtcdServer) ReportUnreachable(id uint64) { s.r.ReportUnreachable(id) }
-
-// ReportSnapshot reports snapshot sent status to the raft state machine,
-// and clears the used snapshot from the snapshot store.
-func (s *EtcdServer) ReportSnapshot(id uint64, status raft.SnapshotStatus) {
- s.r.ReportSnapshot(id, status)
-}
-
-type etcdProgress struct {
- confState raftpb.ConfState
- snapi uint64
- appliedt uint64
- appliedi uint64
-}
-
-// raftReadyHandler contains a set of EtcdServer operations to be called by raftNode,
-// and helps decouple state machine logic from Raft algorithms.
-// TODO: add a state machine interface to apply the commit entries and do snapshot/recover
-type raftReadyHandler struct {
- getLead func() (lead uint64)
- updateLead func(lead uint64)
- updateLeadership func(newLeader bool)
- updateCommittedIndex func(uint64)
-}
-
-func (s *EtcdServer) run() {
- lg := s.getLogger()
-
- sn, err := s.r.raftStorage.Snapshot()
- if err != nil {
- if lg != nil {
- lg.Panic("failed to get snapshot from Raft storage", zap.Error(err))
- } else {
- plog.Panicf("get snapshot from raft storage error: %v", err)
- }
- }
-
- // asynchronously accept apply packets, dispatch progress in-order
- sched := schedule.NewFIFOScheduler()
-
- var (
- smu sync.RWMutex
- syncC <-chan time.Time
- )
- setSyncC := func(ch <-chan time.Time) {
- smu.Lock()
- syncC = ch
- smu.Unlock()
- }
- getSyncC := func() (ch <-chan time.Time) {
- smu.RLock()
- ch = syncC
- smu.RUnlock()
- return
- }
- rh := &raftReadyHandler{
- getLead: func() (lead uint64) { return s.getLead() },
- updateLead: func(lead uint64) { s.setLead(lead) },
- updateLeadership: func(newLeader bool) {
- if !s.isLeader() {
- if s.lessor != nil {
- s.lessor.Demote()
- }
- if s.compactor != nil {
- s.compactor.Pause()
- }
- setSyncC(nil)
- } else {
- if newLeader {
- t := time.Now()
- s.leadTimeMu.Lock()
- s.leadElectedTime = t
- s.leadTimeMu.Unlock()
- }
- setSyncC(s.SyncTicker.C)
- if s.compactor != nil {
- s.compactor.Resume()
- }
- }
- if newLeader {
- s.leaderChangedMu.Lock()
- lc := s.leaderChanged
- s.leaderChanged = make(chan struct{})
- close(lc)
- s.leaderChangedMu.Unlock()
- }
- // TODO: remove the nil checking
- // current test utility does not provide the stats
- if s.stats != nil {
- s.stats.BecomeLeader()
- }
- },
- updateCommittedIndex: func(ci uint64) {
- cci := s.getCommittedIndex()
- if ci > cci {
- s.setCommittedIndex(ci)
- }
- },
- }
- s.r.start(rh)
-
- ep := etcdProgress{
- confState: sn.Metadata.ConfState,
- snapi: sn.Metadata.Index,
- appliedt: sn.Metadata.Term,
- appliedi: sn.Metadata.Index,
- }
-
- defer func() {
- s.wgMu.Lock() // block concurrent waitgroup adds in goAttach while stopping
- close(s.stopping)
- s.wgMu.Unlock()
- s.cancel()
-
- sched.Stop()
-
- // wait for gouroutines before closing raft so wal stays open
- s.wg.Wait()
-
- s.SyncTicker.Stop()
-
- // must stop raft after scheduler-- etcdserver can leak rafthttp pipelines
- // by adding a peer after raft stops the transport
- s.r.stop()
-
- // kv, lessor and backend can be nil if running without v3 enabled
- // or running unit tests.
- if s.lessor != nil {
- s.lessor.Stop()
- }
- if s.kv != nil {
- s.kv.Close()
- }
- if s.authStore != nil {
- s.authStore.Close()
- }
- if s.be != nil {
- s.be.Close()
- }
- if s.compactor != nil {
- s.compactor.Stop()
- }
- close(s.done)
- }()
-
- var expiredLeaseC <-chan []*lease.Lease
- if s.lessor != nil {
- expiredLeaseC = s.lessor.ExpiredLeasesC()
- }
-
- for {
- select {
- case ap := <-s.r.apply():
- f := func(context.Context) { s.applyAll(&ep, &ap) }
- sched.Schedule(f)
- case leases := <-expiredLeaseC:
- s.goAttach(func() {
- // Increases throughput of expired leases deletion process through parallelization
- c := make(chan struct{}, maxPendingRevokes)
- for _, lease := range leases {
- select {
- case c <- struct{}{}:
- case <-s.stopping:
- return
- }
- lid := lease.ID
- s.goAttach(func() {
- ctx := s.authStore.WithRoot(s.ctx)
- _, lerr := s.LeaseRevoke(ctx, &pb.LeaseRevokeRequest{ID: int64(lid)})
- if lerr == nil {
- leaseExpired.Inc()
- } else {
- if lg != nil {
- lg.Warn(
- "failed to revoke lease",
- zap.String("lease-id", fmt.Sprintf("%016x", lid)),
- zap.Error(lerr),
- )
- } else {
- plog.Warningf("failed to revoke %016x (%q)", lid, lerr.Error())
- }
- }
-
- <-c
- })
- }
- })
- case err := <-s.errorc:
- if lg != nil {
- lg.Warn("server error", zap.Error(err))
- lg.Warn("data-dir used by this member must be removed")
- } else {
- plog.Errorf("%s", err)
- plog.Infof("the data-dir used by this member must be removed.")
- }
- return
- case <-getSyncC():
- if s.v2store.HasTTLKeys() {
- s.sync(s.Cfg.ReqTimeout())
- }
- case <-s.stop:
- return
- }
- }
-}
-
-func (s *EtcdServer) applyAll(ep *etcdProgress, apply *apply) {
- s.applySnapshot(ep, apply)
- s.applyEntries(ep, apply)
-
- proposalsApplied.Set(float64(ep.appliedi))
- s.applyWait.Trigger(ep.appliedi)
-
- // wait for the raft routine to finish the disk writes before triggering a
- // snapshot. or applied index might be greater than the last index in raft
- // storage, since the raft routine might be slower than apply routine.
- <-apply.notifyc
-
- s.triggerSnapshot(ep)
- select {
- // snapshot requested via send()
- case m := <-s.r.msgSnapC:
- merged := s.createMergedSnapshotMessage(m, ep.appliedt, ep.appliedi, ep.confState)
- s.sendMergedSnap(merged)
- default:
- }
-}
-
-func (s *EtcdServer) applySnapshot(ep *etcdProgress, apply *apply) {
- if raft.IsEmptySnap(apply.snapshot) {
- return
- }
- applySnapshotInProgress.Inc()
-
- lg := s.getLogger()
- if lg != nil {
- lg.Info(
- "applying snapshot",
- zap.Uint64("current-snapshot-index", ep.snapi),
- zap.Uint64("current-applied-index", ep.appliedi),
- zap.Uint64("incoming-leader-snapshot-index", apply.snapshot.Metadata.Index),
- zap.Uint64("incoming-leader-snapshot-term", apply.snapshot.Metadata.Term),
- )
- } else {
- plog.Infof("applying snapshot at index %d...", ep.snapi)
- }
- defer func() {
- if lg != nil {
- lg.Info(
- "applied snapshot",
- zap.Uint64("current-snapshot-index", ep.snapi),
- zap.Uint64("current-applied-index", ep.appliedi),
- zap.Uint64("incoming-leader-snapshot-index", apply.snapshot.Metadata.Index),
- zap.Uint64("incoming-leader-snapshot-term", apply.snapshot.Metadata.Term),
- )
- } else {
- plog.Infof("finished applying incoming snapshot at index %d", ep.snapi)
- }
- applySnapshotInProgress.Dec()
- }()
-
- if apply.snapshot.Metadata.Index <= ep.appliedi {
- if lg != nil {
- lg.Panic(
- "unexpected leader snapshot from outdated index",
- zap.Uint64("current-snapshot-index", ep.snapi),
- zap.Uint64("current-applied-index", ep.appliedi),
- zap.Uint64("incoming-leader-snapshot-index", apply.snapshot.Metadata.Index),
- zap.Uint64("incoming-leader-snapshot-term", apply.snapshot.Metadata.Term),
- )
- } else {
- plog.Panicf("snapshot index [%d] should > appliedi[%d] + 1",
- apply.snapshot.Metadata.Index, ep.appliedi)
- }
- }
-
- // wait for raftNode to persist snapshot onto the disk
- <-apply.notifyc
-
- newbe, err := openSnapshotBackend(s.Cfg, s.snapshotter, apply.snapshot)
- if err != nil {
- if lg != nil {
- lg.Panic("failed to open snapshot backend", zap.Error(err))
- } else {
- plog.Panic(err)
- }
- }
-
- // always recover lessor before kv. When we recover the mvcc.KV it will reattach keys to its leases.
- // If we recover mvcc.KV first, it will attach the keys to the wrong lessor before it recovers.
- if s.lessor != nil {
- if lg != nil {
- lg.Info("restoring lease store")
- } else {
- plog.Info("recovering lessor...")
- }
-
- s.lessor.Recover(newbe, func() lease.TxnDelete { return s.kv.Write() })
-
- if lg != nil {
- lg.Info("restored lease store")
- } else {
- plog.Info("finished recovering lessor")
- }
- }
-
- if lg != nil {
- lg.Info("restoring mvcc store")
- } else {
- plog.Info("restoring mvcc store...")
- }
-
- if err := s.kv.Restore(newbe); err != nil {
- if lg != nil {
- lg.Panic("failed to restore mvcc store", zap.Error(err))
- } else {
- plog.Panicf("restore KV error: %v", err)
- }
- }
-
- s.consistIndex.setConsistentIndex(s.kv.ConsistentIndex())
- if lg != nil {
- lg.Info("restored mvcc store")
- } else {
- plog.Info("finished restoring mvcc store")
- }
-
- // Closing old backend might block until all the txns
- // on the backend are finished.
- // We do not want to wait on closing the old backend.
- s.bemu.Lock()
- oldbe := s.be
- go func() {
- if lg != nil {
- lg.Info("closing old backend file")
- } else {
- plog.Info("closing old backend...")
- }
- defer func() {
- if lg != nil {
- lg.Info("closed old backend file")
- } else {
- plog.Info("finished closing old backend")
- }
- }()
- if err := oldbe.Close(); err != nil {
- if lg != nil {
- lg.Panic("failed to close old backend", zap.Error(err))
- } else {
- plog.Panicf("close backend error: %v", err)
- }
- }
- }()
-
- s.be = newbe
- s.bemu.Unlock()
-
- if lg != nil {
- lg.Info("restoring alarm store")
- } else {
- plog.Info("recovering alarms...")
- }
-
- if err := s.restoreAlarms(); err != nil {
- if lg != nil {
- lg.Panic("failed to restore alarm store", zap.Error(err))
- } else {
- plog.Panicf("restore alarms error: %v", err)
- }
- }
-
- if lg != nil {
- lg.Info("restored alarm store")
- } else {
- plog.Info("finished recovering alarms")
- }
-
- if s.authStore != nil {
- if lg != nil {
- lg.Info("restoring auth store")
- } else {
- plog.Info("recovering auth store...")
- }
-
- s.authStore.Recover(newbe)
-
- if lg != nil {
- lg.Info("restored auth store")
- } else {
- plog.Info("finished recovering auth store")
- }
- }
-
- if lg != nil {
- lg.Info("restoring v2 store")
- } else {
- plog.Info("recovering store v2...")
- }
- if err := s.v2store.Recovery(apply.snapshot.Data); err != nil {
- if lg != nil {
- lg.Panic("failed to restore v2 store", zap.Error(err))
- } else {
- plog.Panicf("recovery store error: %v", err)
- }
- }
-
- if lg != nil {
- lg.Info("restored v2 store")
- } else {
- plog.Info("finished recovering store v2")
- }
-
- s.cluster.SetBackend(newbe)
-
- if lg != nil {
- lg.Info("restoring cluster configuration")
- } else {
- plog.Info("recovering cluster configuration...")
- }
-
- s.cluster.Recover(api.UpdateCapability)
-
- if lg != nil {
- lg.Info("restored cluster configuration")
- lg.Info("removing old peers from network")
- } else {
- plog.Info("finished recovering cluster configuration")
- plog.Info("removing old peers from network...")
- }
-
- // recover raft transport
- s.r.transport.RemoveAllPeers()
-
- if lg != nil {
- lg.Info("removed old peers from network")
- lg.Info("adding peers from new cluster configuration")
- } else {
- plog.Info("finished removing old peers from network")
- plog.Info("adding peers from new cluster configuration into network...")
- }
-
- for _, m := range s.cluster.Members() {
- if m.ID == s.ID() {
- continue
- }
- s.r.transport.AddPeer(m.ID, m.PeerURLs)
- }
-
- if lg != nil {
- lg.Info("added peers from new cluster configuration")
- } else {
- plog.Info("finished adding peers from new cluster configuration into network...")
- }
-
- ep.appliedt = apply.snapshot.Metadata.Term
- ep.appliedi = apply.snapshot.Metadata.Index
- ep.snapi = ep.appliedi
- ep.confState = apply.snapshot.Metadata.ConfState
-}
-
-func (s *EtcdServer) applyEntries(ep *etcdProgress, apply *apply) {
- if len(apply.entries) == 0 {
- return
- }
- firsti := apply.entries[0].Index
- if firsti > ep.appliedi+1 {
- if lg := s.getLogger(); lg != nil {
- lg.Panic(
- "unexpected committed entry index",
- zap.Uint64("current-applied-index", ep.appliedi),
- zap.Uint64("first-committed-entry-index", firsti),
- )
- } else {
- plog.Panicf("first index of committed entry[%d] should <= appliedi[%d] + 1", firsti, ep.appliedi)
- }
- }
- var ents []raftpb.Entry
- if ep.appliedi+1-firsti < uint64(len(apply.entries)) {
- ents = apply.entries[ep.appliedi+1-firsti:]
- }
- if len(ents) == 0 {
- return
- }
- var shouldstop bool
- if ep.appliedt, ep.appliedi, shouldstop = s.apply(ents, &ep.confState); shouldstop {
- go s.stopWithDelay(10*100*time.Millisecond, fmt.Errorf("the member has been permanently removed from the cluster"))
- }
-}
-
-func (s *EtcdServer) triggerSnapshot(ep *etcdProgress) {
- if ep.appliedi-ep.snapi <= s.Cfg.SnapshotCount {
- return
- }
-
- if lg := s.getLogger(); lg != nil {
- lg.Info(
- "triggering snapshot",
- zap.String("local-member-id", s.ID().String()),
- zap.Uint64("local-member-applied-index", ep.appliedi),
- zap.Uint64("local-member-snapshot-index", ep.snapi),
- zap.Uint64("local-member-snapshot-count", s.Cfg.SnapshotCount),
- )
- } else {
- plog.Infof("start to snapshot (applied: %d, lastsnap: %d)", ep.appliedi, ep.snapi)
- }
-
- s.snapshot(ep.appliedi, ep.confState)
- ep.snapi = ep.appliedi
-}
-
-func (s *EtcdServer) hasMultipleVotingMembers() bool {
- return s.cluster != nil && len(s.cluster.VotingMemberIDs()) > 1
-}
-
-func (s *EtcdServer) isLeader() bool {
- return uint64(s.ID()) == s.Lead()
-}
-
-// MoveLeader transfers the leader to the given transferee.
-func (s *EtcdServer) MoveLeader(ctx context.Context, lead, transferee uint64) error {
- if !s.cluster.IsMemberExist(types.ID(transferee)) || s.cluster.Member(types.ID(transferee)).IsLearner {
- return ErrBadLeaderTransferee
- }
-
- now := time.Now()
- interval := time.Duration(s.Cfg.TickMs) * time.Millisecond
-
- if lg := s.getLogger(); lg != nil {
- lg.Info(
- "leadership transfer starting",
- zap.String("local-member-id", s.ID().String()),
- zap.String("current-leader-member-id", types.ID(lead).String()),
- zap.String("transferee-member-id", types.ID(transferee).String()),
- )
- } else {
- plog.Infof("%s starts leadership transfer from %s to %s", s.ID(), types.ID(lead), types.ID(transferee))
- }
-
- s.r.TransferLeadership(ctx, lead, transferee)
- for s.Lead() != transferee {
- select {
- case <-ctx.Done(): // time out
- return ErrTimeoutLeaderTransfer
- case <-time.After(interval):
- }
- }
-
- // TODO: drain all requests, or drop all messages to the old leader
- if lg := s.getLogger(); lg != nil {
- lg.Info(
- "leadership transfer finished",
- zap.String("local-member-id", s.ID().String()),
- zap.String("old-leader-member-id", types.ID(lead).String()),
- zap.String("new-leader-member-id", types.ID(transferee).String()),
- zap.Duration("took", time.Since(now)),
- )
- } else {
- plog.Infof("%s finished leadership transfer from %s to %s (took %v)", s.ID(), types.ID(lead), types.ID(transferee), time.Since(now))
- }
- return nil
-}
-
-// TransferLeadership transfers the leader to the chosen transferee.
-func (s *EtcdServer) TransferLeadership() error {
- if !s.isLeader() {
- if lg := s.getLogger(); lg != nil {
- lg.Info(
- "skipped leadership transfer; local server is not leader",
- zap.String("local-member-id", s.ID().String()),
- zap.String("current-leader-member-id", types.ID(s.Lead()).String()),
- )
- } else {
- plog.Printf("skipped leadership transfer for stopping non-leader member")
- }
- return nil
- }
-
- if !s.hasMultipleVotingMembers() {
- if lg := s.getLogger(); lg != nil {
- lg.Info(
- "skipped leadership transfer for single voting member cluster",
- zap.String("local-member-id", s.ID().String()),
- zap.String("current-leader-member-id", types.ID(s.Lead()).String()),
- )
- } else {
- plog.Printf("skipped leadership transfer for single voting member cluster")
- }
- return nil
- }
-
- transferee, ok := longestConnected(s.r.transport, s.cluster.VotingMemberIDs())
- if !ok {
- return ErrUnhealthy
- }
-
- tm := s.Cfg.ReqTimeout()
- ctx, cancel := context.WithTimeout(s.ctx, tm)
- err := s.MoveLeader(ctx, s.Lead(), uint64(transferee))
- cancel()
- return err
-}
-
-// HardStop stops the server without coordination with other members in the cluster.
-func (s *EtcdServer) HardStop() {
- select {
- case s.stop <- struct{}{}:
- case <-s.done:
- return
- }
- <-s.done
-}
-
-// Stop stops the server gracefully, and shuts down the running goroutine.
-// Stop should be called after a Start(s), otherwise it will block forever.
-// When stopping leader, Stop transfers its leadership to one of its peers
-// before stopping the server.
-// Stop terminates the Server and performs any necessary finalization.
-// Do and Process cannot be called after Stop has been invoked.
-func (s *EtcdServer) Stop() {
- if err := s.TransferLeadership(); err != nil {
- if lg := s.getLogger(); lg != nil {
- lg.Warn("leadership transfer failed", zap.String("local-member-id", s.ID().String()), zap.Error(err))
- } else {
- plog.Warningf("%s failed to transfer leadership (%v)", s.ID(), err)
- }
- }
- s.HardStop()
-}
-
-// ReadyNotify returns a channel that will be closed when the server
-// is ready to serve client requests
-func (s *EtcdServer) ReadyNotify() <-chan struct{} { return s.readych }
-
-func (s *EtcdServer) stopWithDelay(d time.Duration, err error) {
- select {
- case <-time.After(d):
- case <-s.done:
- }
- select {
- case s.errorc <- err:
- default:
- }
-}
-
-// StopNotify returns a channel that receives a empty struct
-// when the server is stopped.
-func (s *EtcdServer) StopNotify() <-chan struct{} { return s.done }
-
-func (s *EtcdServer) SelfStats() []byte { return s.stats.JSON() }
-
-func (s *EtcdServer) LeaderStats() []byte {
- lead := s.getLead()
- if lead != uint64(s.id) {
- return nil
- }
- return s.lstats.JSON()
-}
-
-func (s *EtcdServer) StoreStats() []byte { return s.v2store.JsonStats() }
-
-func (s *EtcdServer) checkMembershipOperationPermission(ctx context.Context) error {
- if s.authStore == nil {
- // In the context of ordinary etcd process, s.authStore will never be nil.
- // This branch is for handling cases in server_test.go
- return nil
- }
-
- // Note that this permission check is done in the API layer,
- // so TOCTOU problem can be caused potentially in a schedule like this:
- // update membership with user A -> revoke root role of A -> apply membership change
- // in the state machine layer
- // However, both of membership change and role management requires the root privilege.
- // So careful operation by admins can prevent the problem.
- authInfo, err := s.AuthInfoFromCtx(ctx)
- if err != nil {
- return err
- }
-
- return s.AuthStore().IsAdminPermitted(authInfo)
-}
-
-func (s *EtcdServer) AddMember(ctx context.Context, memb membership.Member) ([]*membership.Member, error) {
- if err := s.checkMembershipOperationPermission(ctx); err != nil {
- return nil, err
- }
-
- // TODO: move Member to protobuf type
- b, err := json.Marshal(memb)
- if err != nil {
- return nil, err
- }
-
- // by default StrictReconfigCheck is enabled; reject new members if unhealthy.
- if err := s.mayAddMember(memb); err != nil {
- return nil, err
- }
-
- cc := raftpb.ConfChange{
- Type: raftpb.ConfChangeAddNode,
- NodeID: uint64(memb.ID),
- Context: b,
- }
-
- if memb.IsLearner {
- cc.Type = raftpb.ConfChangeAddLearnerNode
- }
-
- return s.configure(ctx, cc)
-}
-
-func (s *EtcdServer) mayAddMember(memb membership.Member) error {
- if !s.Cfg.StrictReconfigCheck {
- return nil
- }
-
- // protect quorum when adding voting member
- if !memb.IsLearner && !s.cluster.IsReadyToAddVotingMember() {
- if lg := s.getLogger(); lg != nil {
- lg.Warn(
- "rejecting member add request; not enough healthy members",
- zap.String("local-member-id", s.ID().String()),
- zap.String("requested-member-add", fmt.Sprintf("%+v", memb)),
- zap.Error(ErrNotEnoughStartedMembers),
- )
- } else {
- plog.Warningf("not enough started members, rejecting member add %+v", memb)
- }
- return ErrNotEnoughStartedMembers
- }
-
- if !isConnectedFullySince(s.r.transport, time.Now().Add(-HealthInterval), s.ID(), s.cluster.VotingMembers()) {
- if lg := s.getLogger(); lg != nil {
- lg.Warn(
- "rejecting member add request; local member has not been connected to all peers, reconfigure breaks active quorum",
- zap.String("local-member-id", s.ID().String()),
- zap.String("requested-member-add", fmt.Sprintf("%+v", memb)),
- zap.Error(ErrUnhealthy),
- )
- } else {
- plog.Warningf("not healthy for reconfigure, rejecting member add %+v", memb)
- }
- return ErrUnhealthy
- }
-
- return nil
-}
-
-func (s *EtcdServer) RemoveMember(ctx context.Context, id uint64) ([]*membership.Member, error) {
- if err := s.checkMembershipOperationPermission(ctx); err != nil {
- return nil, err
- }
-
- // by default StrictReconfigCheck is enabled; reject removal if leads to quorum loss
- if err := s.mayRemoveMember(types.ID(id)); err != nil {
- return nil, err
- }
-
- cc := raftpb.ConfChange{
- Type: raftpb.ConfChangeRemoveNode,
- NodeID: id,
- }
- return s.configure(ctx, cc)
-}
-
-// PromoteMember promotes a learner node to a voting node.
-func (s *EtcdServer) PromoteMember(ctx context.Context, id uint64) ([]*membership.Member, error) {
- // only raft leader has information on whether the to-be-promoted learner node is ready. If promoteMember call
- // fails with ErrNotLeader, forward the request to leader node via HTTP. If promoteMember call fails with error
- // other than ErrNotLeader, return the error.
- resp, err := s.promoteMember(ctx, id)
- if err == nil {
- learnerPromoteSucceed.Inc()
- return resp, nil
- }
- if err != ErrNotLeader {
- learnerPromoteFailed.WithLabelValues(err.Error()).Inc()
- return resp, err
- }
-
- cctx, cancel := context.WithTimeout(ctx, s.Cfg.ReqTimeout())
- defer cancel()
- // forward to leader
- for cctx.Err() == nil {
- leader, err := s.waitLeader(cctx)
- if err != nil {
- return nil, err
- }
- for _, url := range leader.PeerURLs {
- resp, err := promoteMemberHTTP(cctx, url, id, s.peerRt)
- if err == nil {
- return resp, nil
- }
- // If member promotion failed, return early. Otherwise keep retry.
- if err == ErrLearnerNotReady || err == membership.ErrIDNotFound || err == membership.ErrMemberNotLearner {
- return nil, err
- }
- }
- }
-
- if cctx.Err() == context.DeadlineExceeded {
- return nil, ErrTimeout
- }
- return nil, ErrCanceled
-}
-
-// promoteMember checks whether the to-be-promoted learner node is ready before sending the promote
-// request to raft.
-// The function returns ErrNotLeader if the local node is not raft leader (therefore does not have
-// enough information to determine if the learner node is ready), returns ErrLearnerNotReady if the
-// local node is leader (therefore has enough information) but decided the learner node is not ready
-// to be promoted.
-func (s *EtcdServer) promoteMember(ctx context.Context, id uint64) ([]*membership.Member, error) {
- if err := s.checkMembershipOperationPermission(ctx); err != nil {
- return nil, err
- }
-
- // check if we can promote this learner.
- if err := s.mayPromoteMember(types.ID(id)); err != nil {
- return nil, err
- }
-
- // build the context for the promote confChange. mark IsLearner to false and IsPromote to true.
- promoteChangeContext := membership.ConfigChangeContext{
- Member: membership.Member{
- ID: types.ID(id),
- },
- IsPromote: true,
- }
-
- b, err := json.Marshal(promoteChangeContext)
- if err != nil {
- return nil, err
- }
-
- cc := raftpb.ConfChange{
- Type: raftpb.ConfChangeAddNode,
- NodeID: id,
- Context: b,
- }
-
- return s.configure(ctx, cc)
-}
-
-func (s *EtcdServer) mayPromoteMember(id types.ID) error {
- err := s.isLearnerReady(uint64(id))
- if err != nil {
- return err
- }
-
- if !s.Cfg.StrictReconfigCheck {
- return nil
- }
- if !s.cluster.IsReadyToPromoteMember(uint64(id)) {
- if lg := s.getLogger(); lg != nil {
- lg.Warn(
- "rejecting member promote request; not enough healthy members",
- zap.String("local-member-id", s.ID().String()),
- zap.String("requested-member-remove-id", id.String()),
- zap.Error(ErrNotEnoughStartedMembers),
- )
- } else {
- plog.Warningf("not enough started members, rejecting promote member %s", id)
- }
- return ErrNotEnoughStartedMembers
- }
-
- return nil
-}
-
-// check whether the learner catches up with leader or not.
-// Note: it will return nil if member is not found in cluster or if member is not learner.
-// These two conditions will be checked before apply phase later.
-func (s *EtcdServer) isLearnerReady(id uint64) error {
- rs := s.raftStatus()
-
- // leader's raftStatus.Progress is not nil
- if rs.Progress == nil {
- return ErrNotLeader
- }
-
- var learnerMatch uint64
- isFound := false
- leaderID := rs.ID
- for memberID, progress := range rs.Progress {
- if id == memberID {
- // check its status
- learnerMatch = progress.Match
- isFound = true
- break
- }
- }
-
- if isFound {
- leaderMatch := rs.Progress[leaderID].Match
- // the learner's Match not caught up with leader yet
- if float64(learnerMatch) < float64(leaderMatch)*readyPercent {
- return ErrLearnerNotReady
- }
- }
-
- return nil
-}
-
-func (s *EtcdServer) mayRemoveMember(id types.ID) error {
- if !s.Cfg.StrictReconfigCheck {
- return nil
- }
-
- isLearner := s.cluster.IsMemberExist(id) && s.cluster.Member(id).IsLearner
- // no need to check quorum when removing non-voting member
- if isLearner {
- return nil
- }
-
- if !s.cluster.IsReadyToRemoveVotingMember(uint64(id)) {
- if lg := s.getLogger(); lg != nil {
- lg.Warn(
- "rejecting member remove request; not enough healthy members",
- zap.String("local-member-id", s.ID().String()),
- zap.String("requested-member-remove-id", id.String()),
- zap.Error(ErrNotEnoughStartedMembers),
- )
- } else {
- plog.Warningf("not enough started members, rejecting remove member %s", id)
- }
- return ErrNotEnoughStartedMembers
- }
-
- // downed member is safe to remove since it's not part of the active quorum
- if t := s.r.transport.ActiveSince(id); id != s.ID() && t.IsZero() {
- return nil
- }
-
- // protect quorum if some members are down
- m := s.cluster.VotingMembers()
- active := numConnectedSince(s.r.transport, time.Now().Add(-HealthInterval), s.ID(), m)
- if (active - 1) < 1+((len(m)-1)/2) {
- if lg := s.getLogger(); lg != nil {
- lg.Warn(
- "rejecting member remove request; local member has not been connected to all peers, reconfigure breaks active quorum",
- zap.String("local-member-id", s.ID().String()),
- zap.String("requested-member-remove", id.String()),
- zap.Int("active-peers", active),
- zap.Error(ErrUnhealthy),
- )
- } else {
- plog.Warningf("reconfigure breaks active quorum, rejecting remove member %s", id)
- }
- return ErrUnhealthy
- }
-
- return nil
-}
-
-func (s *EtcdServer) UpdateMember(ctx context.Context, memb membership.Member) ([]*membership.Member, error) {
- b, merr := json.Marshal(memb)
- if merr != nil {
- return nil, merr
- }
-
- if err := s.checkMembershipOperationPermission(ctx); err != nil {
- return nil, err
- }
- cc := raftpb.ConfChange{
- Type: raftpb.ConfChangeUpdateNode,
- NodeID: uint64(memb.ID),
- Context: b,
- }
- return s.configure(ctx, cc)
-}
-
-func (s *EtcdServer) setCommittedIndex(v uint64) {
- atomic.StoreUint64(&s.committedIndex, v)
-}
-
-func (s *EtcdServer) getCommittedIndex() uint64 {
- return atomic.LoadUint64(&s.committedIndex)
-}
-
-func (s *EtcdServer) setAppliedIndex(v uint64) {
- atomic.StoreUint64(&s.appliedIndex, v)
-}
-
-func (s *EtcdServer) getAppliedIndex() uint64 {
- return atomic.LoadUint64(&s.appliedIndex)
-}
-
-func (s *EtcdServer) setTerm(v uint64) {
- atomic.StoreUint64(&s.term, v)
-}
-
-func (s *EtcdServer) getTerm() uint64 {
- return atomic.LoadUint64(&s.term)
-}
-
-func (s *EtcdServer) setLead(v uint64) {
- atomic.StoreUint64(&s.lead, v)
-}
-
-func (s *EtcdServer) getLead() uint64 {
- return atomic.LoadUint64(&s.lead)
-}
-
-func (s *EtcdServer) leaderChangedNotify() <-chan struct{} {
- s.leaderChangedMu.RLock()
- defer s.leaderChangedMu.RUnlock()
- return s.leaderChanged
-}
-
-// RaftStatusGetter represents etcd server and Raft progress.
-type RaftStatusGetter interface {
- ID() types.ID
- Leader() types.ID
- CommittedIndex() uint64
- AppliedIndex() uint64
- Term() uint64
-}
-
-func (s *EtcdServer) ID() types.ID { return s.id }
-
-func (s *EtcdServer) Leader() types.ID { return types.ID(s.getLead()) }
-
-func (s *EtcdServer) Lead() uint64 { return s.getLead() }
-
-func (s *EtcdServer) CommittedIndex() uint64 { return s.getCommittedIndex() }
-
-func (s *EtcdServer) AppliedIndex() uint64 { return s.getAppliedIndex() }
-
-func (s *EtcdServer) Term() uint64 { return s.getTerm() }
-
-type confChangeResponse struct {
- membs []*membership.Member
- err error
-}
-
-// configure sends a configuration change through consensus and
-// then waits for it to be applied to the server. It
-// will block until the change is performed or there is an error.
-func (s *EtcdServer) configure(ctx context.Context, cc raftpb.ConfChange) ([]*membership.Member, error) {
- cc.ID = s.reqIDGen.Next()
- ch := s.w.Register(cc.ID)
-
- start := time.Now()
- if err := s.r.ProposeConfChange(ctx, cc); err != nil {
- s.w.Trigger(cc.ID, nil)
- return nil, err
- }
-
- select {
- case x := <-ch:
- if x == nil {
- if lg := s.getLogger(); lg != nil {
- lg.Panic("failed to configure")
- } else {
- plog.Panicf("configure trigger value should never be nil")
- }
- }
- resp := x.(*confChangeResponse)
- if lg := s.getLogger(); lg != nil {
- lg.Info(
- "applied a configuration change through raft",
- zap.String("local-member-id", s.ID().String()),
- zap.String("raft-conf-change", cc.Type.String()),
- zap.String("raft-conf-change-node-id", types.ID(cc.NodeID).String()),
- )
- }
- return resp.membs, resp.err
-
- case <-ctx.Done():
- s.w.Trigger(cc.ID, nil) // GC wait
- return nil, s.parseProposeCtxErr(ctx.Err(), start)
-
- case <-s.stopping:
- return nil, ErrStopped
- }
-}
-
-// sync proposes a SYNC request and is non-blocking.
-// This makes no guarantee that the request will be proposed or performed.
-// The request will be canceled after the given timeout.
-func (s *EtcdServer) sync(timeout time.Duration) {
- req := pb.Request{
- Method: "SYNC",
- ID: s.reqIDGen.Next(),
- Time: time.Now().UnixNano(),
- }
- data := pbutil.MustMarshal(&req)
- // There is no promise that node has leader when do SYNC request,
- // so it uses goroutine to propose.
- ctx, cancel := context.WithTimeout(s.ctx, timeout)
- s.goAttach(func() {
- s.r.Propose(ctx, data)
- cancel()
- })
-}
-
-// publish registers server information into the cluster. The information
-// is the JSON representation of this server's member struct, updated with the
-// static clientURLs of the server.
-// The function keeps attempting to register until it succeeds,
-// or its server is stopped.
-//
-// Use v2 store to encode member attributes, and apply through Raft
-// but does not go through v2 API endpoint, which means even with v2
-// client handler disabled (e.g. --enable-v2=false), cluster can still
-// process publish requests through rafthttp
-// TODO: Deprecate v2 store
-func (s *EtcdServer) publish(timeout time.Duration) {
- b, err := json.Marshal(s.attributes)
- if err != nil {
- if lg := s.getLogger(); lg != nil {
- lg.Panic("failed to marshal JSON", zap.Error(err))
- } else {
- plog.Panicf("json marshal error: %v", err)
- }
- return
- }
- req := pb.Request{
- Method: "PUT",
- Path: membership.MemberAttributesStorePath(s.id),
- Val: string(b),
- }
-
- for {
- ctx, cancel := context.WithTimeout(s.ctx, timeout)
- _, err := s.Do(ctx, req)
- cancel()
- switch err {
- case nil:
- close(s.readych)
- if lg := s.getLogger(); lg != nil {
- lg.Info(
- "published local member to cluster through raft",
- zap.String("local-member-id", s.ID().String()),
- zap.String("local-member-attributes", fmt.Sprintf("%+v", s.attributes)),
- zap.String("request-path", req.Path),
- zap.String("cluster-id", s.cluster.ID().String()),
- zap.Duration("publish-timeout", timeout),
- )
- } else {
- plog.Infof("published %+v to cluster %s", s.attributes, s.cluster.ID())
- }
- return
-
- case ErrStopped:
- if lg := s.getLogger(); lg != nil {
- lg.Warn(
- "stopped publish because server is stopped",
- zap.String("local-member-id", s.ID().String()),
- zap.String("local-member-attributes", fmt.Sprintf("%+v", s.attributes)),
- zap.Duration("publish-timeout", timeout),
- zap.Error(err),
- )
- } else {
- plog.Infof("aborting publish because server is stopped")
- }
- return
-
- default:
- if lg := s.getLogger(); lg != nil {
- lg.Warn(
- "failed to publish local member to cluster through raft",
- zap.String("local-member-id", s.ID().String()),
- zap.String("local-member-attributes", fmt.Sprintf("%+v", s.attributes)),
- zap.String("request-path", req.Path),
- zap.Duration("publish-timeout", timeout),
- zap.Error(err),
- )
- } else {
- plog.Errorf("publish error: %v", err)
- }
- }
- }
-}
-
-func (s *EtcdServer) sendMergedSnap(merged snap.Message) {
- atomic.AddInt64(&s.inflightSnapshots, 1)
-
- lg := s.getLogger()
- fields := []zap.Field{
- zap.String("from", s.ID().String()),
- zap.String("to", types.ID(merged.To).String()),
- zap.Int64("bytes", merged.TotalSize),
- zap.String("size", humanize.Bytes(uint64(merged.TotalSize))),
- }
-
- now := time.Now()
- s.r.transport.SendSnapshot(merged)
- if lg != nil {
- lg.Info("sending merged snapshot", fields...)
- }
-
- s.goAttach(func() {
- select {
- case ok := <-merged.CloseNotify():
- // delay releasing inflight snapshot for another 30 seconds to
- // block log compaction.
- // If the follower still fails to catch up, it is probably just too slow
- // to catch up. We cannot avoid the snapshot cycle anyway.
- if ok {
- select {
- case <-time.After(releaseDelayAfterSnapshot):
- case <-s.stopping:
- }
- }
-
- atomic.AddInt64(&s.inflightSnapshots, -1)
-
- if lg != nil {
- lg.Info("sent merged snapshot", append(fields, zap.Duration("took", time.Since(now)))...)
- }
-
- case <-s.stopping:
- if lg != nil {
- lg.Warn("canceled sending merged snapshot; server stopping", fields...)
- }
- return
- }
- })
-}
-
-// apply takes entries received from Raft (after it has been committed) and
-// applies them to the current state of the EtcdServer.
-// The given entries should not be empty.
-func (s *EtcdServer) apply(
- es []raftpb.Entry,
- confState *raftpb.ConfState,
-) (appliedt uint64, appliedi uint64, shouldStop bool) {
- for i := range es {
- e := es[i]
- switch e.Type {
- case raftpb.EntryNormal:
- s.applyEntryNormal(&e)
- s.setAppliedIndex(e.Index)
- s.setTerm(e.Term)
-
- case raftpb.EntryConfChange:
- // set the consistent index of current executing entry
- if e.Index > s.consistIndex.ConsistentIndex() {
- s.consistIndex.setConsistentIndex(e.Index)
- }
- var cc raftpb.ConfChange
- pbutil.MustUnmarshal(&cc, e.Data)
- removedSelf, err := s.applyConfChange(cc, confState)
- s.setAppliedIndex(e.Index)
- s.setTerm(e.Term)
- shouldStop = shouldStop || removedSelf
- s.w.Trigger(cc.ID, &confChangeResponse{s.cluster.Members(), err})
-
- default:
- if lg := s.getLogger(); lg != nil {
- lg.Panic(
- "unknown entry type; must be either EntryNormal or EntryConfChange",
- zap.String("type", e.Type.String()),
- )
- } else {
- plog.Panicf("entry type should be either EntryNormal or EntryConfChange")
- }
- }
- appliedi, appliedt = e.Index, e.Term
- }
- return appliedt, appliedi, shouldStop
-}
-
-// applyEntryNormal apples an EntryNormal type raftpb request to the EtcdServer
-func (s *EtcdServer) applyEntryNormal(e *raftpb.Entry) {
- shouldApplyV3 := false
- if e.Index > s.consistIndex.ConsistentIndex() {
- // set the consistent index of current executing entry
- s.consistIndex.setConsistentIndex(e.Index)
- shouldApplyV3 = true
- }
-
- // raft state machine may generate noop entry when leader confirmation.
- // skip it in advance to avoid some potential bug in the future
- if len(e.Data) == 0 {
- select {
- case s.forceVersionC <- struct{}{}:
- default:
- }
- // promote lessor when the local member is leader and finished
- // applying all entries from the last term.
- if s.isLeader() {
- s.lessor.Promote(s.Cfg.electionTimeout())
- }
- return
- }
-
- var raftReq pb.InternalRaftRequest
- if !pbutil.MaybeUnmarshal(&raftReq, e.Data) { // backward compatible
- var r pb.Request
- rp := &r
- pbutil.MustUnmarshal(rp, e.Data)
- s.w.Trigger(r.ID, s.applyV2Request((*RequestV2)(rp)))
- return
- }
- if raftReq.V2 != nil {
- req := (*RequestV2)(raftReq.V2)
- s.w.Trigger(req.ID, s.applyV2Request(req))
- return
- }
-
- // do not re-apply applied entries.
- if !shouldApplyV3 {
- return
- }
-
- id := raftReq.ID
- if id == 0 {
- id = raftReq.Header.ID
- }
-
- var ar *applyResult
- needResult := s.w.IsRegistered(id)
- if needResult || !noSideEffect(&raftReq) {
- if !needResult && raftReq.Txn != nil {
- removeNeedlessRangeReqs(raftReq.Txn)
- }
- ar = s.applyV3.Apply(&raftReq)
- }
-
- if ar == nil {
- return
- }
-
- if ar.err != ErrNoSpace || len(s.alarmStore.Get(pb.AlarmType_NOSPACE)) > 0 {
- s.w.Trigger(id, ar)
- return
- }
-
- if lg := s.getLogger(); lg != nil {
- lg.Warn(
- "message exceeded backend quota; raising alarm",
- zap.Int64("quota-size-bytes", s.Cfg.QuotaBackendBytes),
- zap.String("quota-size", humanize.Bytes(uint64(s.Cfg.QuotaBackendBytes))),
- zap.Error(ar.err),
- )
- } else {
- plog.Errorf("applying raft message exceeded backend quota")
- }
-
- s.goAttach(func() {
- a := &pb.AlarmRequest{
- MemberID: uint64(s.ID()),
- Action: pb.AlarmRequest_ACTIVATE,
- Alarm: pb.AlarmType_NOSPACE,
- }
- s.raftRequest(s.ctx, pb.InternalRaftRequest{Alarm: a})
- s.w.Trigger(id, ar)
- })
-}
-
-// applyConfChange applies a ConfChange to the server. It is only
-// invoked with a ConfChange that has already passed through Raft
-func (s *EtcdServer) applyConfChange(cc raftpb.ConfChange, confState *raftpb.ConfState) (bool, error) {
- if err := s.cluster.ValidateConfigurationChange(cc); err != nil {
- cc.NodeID = raft.None
- s.r.ApplyConfChange(cc)
- return false, err
- }
-
- lg := s.getLogger()
- *confState = *s.r.ApplyConfChange(cc)
- switch cc.Type {
- case raftpb.ConfChangeAddNode, raftpb.ConfChangeAddLearnerNode:
- confChangeContext := new(membership.ConfigChangeContext)
- if err := json.Unmarshal(cc.Context, confChangeContext); err != nil {
- if lg != nil {
- lg.Panic("failed to unmarshal member", zap.Error(err))
- } else {
- plog.Panicf("unmarshal member should never fail: %v", err)
- }
- }
- if cc.NodeID != uint64(confChangeContext.Member.ID) {
- if lg != nil {
- lg.Panic(
- "got different member ID",
- zap.String("member-id-from-config-change-entry", types.ID(cc.NodeID).String()),
- zap.String("member-id-from-message", confChangeContext.Member.ID.String()),
- )
- } else {
- plog.Panicf("nodeID should always be equal to member ID")
- }
- }
- if confChangeContext.IsPromote {
- s.cluster.PromoteMember(confChangeContext.Member.ID)
- } else {
- s.cluster.AddMember(&confChangeContext.Member)
-
- if confChangeContext.Member.ID != s.id {
- s.r.transport.AddPeer(confChangeContext.Member.ID, confChangeContext.PeerURLs)
- }
- }
-
- // update the isLearner metric when this server id is equal to the id in raft member confChange
- if confChangeContext.Member.ID == s.id {
- if cc.Type == raftpb.ConfChangeAddLearnerNode {
- isLearner.Set(1)
- } else {
- isLearner.Set(0)
- }
- }
-
- case raftpb.ConfChangeRemoveNode:
- id := types.ID(cc.NodeID)
- s.cluster.RemoveMember(id)
- if id == s.id {
- return true, nil
- }
- s.r.transport.RemovePeer(id)
-
- case raftpb.ConfChangeUpdateNode:
- m := new(membership.Member)
- if err := json.Unmarshal(cc.Context, m); err != nil {
- if lg != nil {
- lg.Panic("failed to unmarshal member", zap.Error(err))
- } else {
- plog.Panicf("unmarshal member should never fail: %v", err)
- }
- }
- if cc.NodeID != uint64(m.ID) {
- if lg != nil {
- lg.Panic(
- "got different member ID",
- zap.String("member-id-from-config-change-entry", types.ID(cc.NodeID).String()),
- zap.String("member-id-from-message", m.ID.String()),
- )
- } else {
- plog.Panicf("nodeID should always be equal to member ID")
- }
- }
- s.cluster.UpdateRaftAttributes(m.ID, m.RaftAttributes)
- if m.ID != s.id {
- s.r.transport.UpdatePeer(m.ID, m.PeerURLs)
- }
- }
- return false, nil
-}
-
-// TODO: non-blocking snapshot
-func (s *EtcdServer) snapshot(snapi uint64, confState raftpb.ConfState) {
- clone := s.v2store.Clone()
- // commit kv to write metadata (for example: consistent index) to disk.
- // KV().commit() updates the consistent index in backend.
- // All operations that update consistent index must be called sequentially
- // from applyAll function.
- // So KV().Commit() cannot run in parallel with apply. It has to be called outside
- // the go routine created below.
- s.KV().Commit()
-
- s.goAttach(func() {
- lg := s.getLogger()
-
- d, err := clone.SaveNoCopy()
- // TODO: current store will never fail to do a snapshot
- // what should we do if the store might fail?
- if err != nil {
- if lg != nil {
- lg.Panic("failed to save v2 store", zap.Error(err))
- } else {
- plog.Panicf("store save should never fail: %v", err)
- }
- }
- snap, err := s.r.raftStorage.CreateSnapshot(snapi, &confState, d)
- if err != nil {
- // the snapshot was done asynchronously with the progress of raft.
- // raft might have already got a newer snapshot.
- if err == raft.ErrSnapOutOfDate {
- return
- }
- if lg != nil {
- lg.Panic("failed to create snapshot", zap.Error(err))
- } else {
- plog.Panicf("unexpected create snapshot error %v", err)
- }
- }
- // SaveSnap saves the snapshot and releases the locked wal files
- // to the snapshot index.
- if err = s.r.storage.SaveSnap(snap); err != nil {
- if lg != nil {
- lg.Panic("failed to save snapshot", zap.Error(err))
- } else {
- plog.Fatalf("save snapshot error: %v", err)
- }
- }
- if lg != nil {
- lg.Info(
- "saved snapshot",
- zap.Uint64("snapshot-index", snap.Metadata.Index),
- )
- } else {
- plog.Infof("saved snapshot at index %d", snap.Metadata.Index)
- }
-
- // When sending a snapshot, etcd will pause compaction.
- // After receives a snapshot, the slow follower needs to get all the entries right after
- // the snapshot sent to catch up. If we do not pause compaction, the log entries right after
- // the snapshot sent might already be compacted. It happens when the snapshot takes long time
- // to send and save. Pausing compaction avoids triggering a snapshot sending cycle.
- if atomic.LoadInt64(&s.inflightSnapshots) != 0 {
- if lg != nil {
- lg.Info("skip compaction since there is an inflight snapshot")
- } else {
- plog.Infof("skip compaction since there is an inflight snapshot")
- }
- return
- }
-
- // keep some in memory log entries for slow followers.
- compacti := uint64(1)
- if snapi > s.Cfg.SnapshotCatchUpEntries {
- compacti = snapi - s.Cfg.SnapshotCatchUpEntries
- }
-
- err = s.r.raftStorage.Compact(compacti)
- if err != nil {
- // the compaction was done asynchronously with the progress of raft.
- // raft log might already been compact.
- if err == raft.ErrCompacted {
- return
- }
- if lg != nil {
- lg.Panic("failed to compact", zap.Error(err))
- } else {
- plog.Panicf("unexpected compaction error %v", err)
- }
- }
- if lg != nil {
- lg.Info(
- "compacted Raft logs",
- zap.Uint64("compact-index", compacti),
- )
- } else {
- plog.Infof("compacted raft log at %d", compacti)
- }
- })
-}
-
-// CutPeer drops messages to the specified peer.
-func (s *EtcdServer) CutPeer(id types.ID) {
- tr, ok := s.r.transport.(*rafthttp.Transport)
- if ok {
- tr.CutPeer(id)
- }
-}
-
-// MendPeer recovers the message dropping behavior of the given peer.
-func (s *EtcdServer) MendPeer(id types.ID) {
- tr, ok := s.r.transport.(*rafthttp.Transport)
- if ok {
- tr.MendPeer(id)
- }
-}
-
-func (s *EtcdServer) PauseSending() { s.r.pauseSending() }
-
-func (s *EtcdServer) ResumeSending() { s.r.resumeSending() }
-
-func (s *EtcdServer) ClusterVersion() *semver.Version {
- if s.cluster == nil {
- return nil
- }
- return s.cluster.Version()
-}
-
-// monitorVersions checks the member's version every monitorVersionInterval.
-// It updates the cluster version if all members agrees on a higher one.
-// It prints out log if there is a member with a higher version than the
-// local version.
-func (s *EtcdServer) monitorVersions() {
- for {
- select {
- case <-s.forceVersionC:
- case <-time.After(monitorVersionInterval):
- case <-s.stopping:
- return
- }
-
- if s.Leader() != s.ID() {
- continue
- }
-
- v := decideClusterVersion(s.getLogger(), getVersions(s.getLogger(), s.cluster, s.id, s.peerRt))
- if v != nil {
- // only keep major.minor version for comparison
- v = &semver.Version{
- Major: v.Major,
- Minor: v.Minor,
- }
- }
-
- // if the current version is nil:
- // 1. use the decided version if possible
- // 2. or use the min cluster version
- if s.cluster.Version() == nil {
- verStr := version.MinClusterVersion
- if v != nil {
- verStr = v.String()
- }
- s.goAttach(func() { s.updateClusterVersion(verStr) })
- continue
- }
-
- // update cluster version only if the decided version is greater than
- // the current cluster version
- if v != nil && s.cluster.Version().LessThan(*v) {
- s.goAttach(func() { s.updateClusterVersion(v.String()) })
- }
- }
-}
-
-func (s *EtcdServer) updateClusterVersion(ver string) {
- lg := s.getLogger()
-
- if s.cluster.Version() == nil {
- if lg != nil {
- lg.Info(
- "setting up initial cluster version",
- zap.String("cluster-version", version.Cluster(ver)),
- )
- } else {
- plog.Infof("setting up the initial cluster version to %s", version.Cluster(ver))
- }
- } else {
- if lg != nil {
- lg.Info(
- "updating cluster version",
- zap.String("from", version.Cluster(s.cluster.Version().String())),
- zap.String("to", version.Cluster(ver)),
- )
- } else {
- plog.Infof("updating the cluster version from %s to %s", version.Cluster(s.cluster.Version().String()), version.Cluster(ver))
- }
- }
-
- req := pb.Request{
- Method: "PUT",
- Path: membership.StoreClusterVersionKey(),
- Val: ver,
- }
-
- ctx, cancel := context.WithTimeout(s.ctx, s.Cfg.ReqTimeout())
- _, err := s.Do(ctx, req)
- cancel()
-
- switch err {
- case nil:
- if lg != nil {
- lg.Info("cluster version is updated", zap.String("cluster-version", version.Cluster(ver)))
- }
- return
-
- case ErrStopped:
- if lg != nil {
- lg.Warn("aborting cluster version update; server is stopped", zap.Error(err))
- } else {
- plog.Infof("aborting update cluster version because server is stopped")
- }
- return
-
- default:
- if lg != nil {
- lg.Warn("failed to update cluster version", zap.Error(err))
- } else {
- plog.Errorf("error updating cluster version (%v)", err)
- }
- }
-}
-
-func (s *EtcdServer) parseProposeCtxErr(err error, start time.Time) error {
- switch err {
- case context.Canceled:
- return ErrCanceled
-
- case context.DeadlineExceeded:
- s.leadTimeMu.RLock()
- curLeadElected := s.leadElectedTime
- s.leadTimeMu.RUnlock()
- prevLeadLost := curLeadElected.Add(-2 * time.Duration(s.Cfg.ElectionTicks) * time.Duration(s.Cfg.TickMs) * time.Millisecond)
- if start.After(prevLeadLost) && start.Before(curLeadElected) {
- return ErrTimeoutDueToLeaderFail
- }
- lead := types.ID(s.getLead())
- switch lead {
- case types.ID(raft.None):
- // TODO: return error to specify it happens because the cluster does not have leader now
- case s.ID():
- if !isConnectedToQuorumSince(s.r.transport, start, s.ID(), s.cluster.Members()) {
- return ErrTimeoutDueToConnectionLost
- }
- default:
- if !isConnectedSince(s.r.transport, start, lead) {
- return ErrTimeoutDueToConnectionLost
- }
- }
- return ErrTimeout
-
- default:
- return err
- }
-}
-
-func (s *EtcdServer) KV() mvcc.ConsistentWatchableKV { return s.kv }
-func (s *EtcdServer) Backend() backend.Backend {
- s.bemu.Lock()
- defer s.bemu.Unlock()
- return s.be
-}
-
-func (s *EtcdServer) AuthStore() auth.AuthStore { return s.authStore }
-
-func (s *EtcdServer) restoreAlarms() error {
- s.applyV3 = s.newApplierV3()
- as, err := v3alarm.NewAlarmStore(s)
- if err != nil {
- return err
- }
- s.alarmStore = as
- if len(as.Get(pb.AlarmType_NOSPACE)) > 0 {
- s.applyV3 = newApplierV3Capped(s.applyV3)
- }
- if len(as.Get(pb.AlarmType_CORRUPT)) > 0 {
- s.applyV3 = newApplierV3Corrupt(s.applyV3)
- }
- return nil
-}
-
-// goAttach creates a goroutine on a given function and tracks it using
-// the etcdserver waitgroup.
-func (s *EtcdServer) goAttach(f func()) {
- s.wgMu.RLock() // this blocks with ongoing close(s.stopping)
- defer s.wgMu.RUnlock()
- select {
- case <-s.stopping:
- if lg := s.getLogger(); lg != nil {
- lg.Warn("server has stopped; skipping goAttach")
- } else {
- plog.Warning("server has stopped (skipping goAttach)")
- }
- return
- default:
- }
-
- // now safe to add since waitgroup wait has not started yet
- s.wg.Add(1)
- go func() {
- defer s.wg.Done()
- f()
- }()
-}
-
-func (s *EtcdServer) Alarms() []*pb.AlarmMember {
- return s.alarmStore.Get(pb.AlarmType_NONE)
-}
-
-func (s *EtcdServer) Logger() *zap.Logger {
- return s.lg
-}
-
-// IsLearner returns if the local member is raft learner
-func (s *EtcdServer) IsLearner() bool {
- return s.cluster.IsLocalMemberLearner()
-}
-
-// IsMemberExist returns if the member with the given id exists in cluster.
-func (s *EtcdServer) IsMemberExist(id types.ID) bool {
- return s.cluster.IsMemberExist(id)
-}
-
-// raftStatus returns the raft status of this etcd node.
-func (s *EtcdServer) raftStatus() raft.Status {
- return s.r.Node.Status()
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/server_access_control.go b/vendor/go.etcd.io/etcd/etcdserver/server_access_control.go
deleted file mode 100644
index 09e2255..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/server_access_control.go
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright 2018 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package etcdserver
-
-import "sync"
-
-// AccessController controls etcd server HTTP request access.
-type AccessController struct {
- corsMu sync.RWMutex
- CORS map[string]struct{}
- hostWhitelistMu sync.RWMutex
- HostWhitelist map[string]struct{}
-}
-
-// NewAccessController returns a new "AccessController" with default "*" values.
-func NewAccessController() *AccessController {
- return &AccessController{
- CORS: map[string]struct{}{"*": {}},
- HostWhitelist: map[string]struct{}{"*": {}},
- }
-}
-
-// OriginAllowed determines whether the server will allow a given CORS origin.
-// If CORS is empty, allow all.
-func (ac *AccessController) OriginAllowed(origin string) bool {
- ac.corsMu.RLock()
- defer ac.corsMu.RUnlock()
- if len(ac.CORS) == 0 { // allow all
- return true
- }
- _, ok := ac.CORS["*"]
- if ok {
- return true
- }
- _, ok = ac.CORS[origin]
- return ok
-}
-
-// IsHostWhitelisted returns true if the host is whitelisted.
-// If whitelist is empty, allow all.
-func (ac *AccessController) IsHostWhitelisted(host string) bool {
- ac.hostWhitelistMu.RLock()
- defer ac.hostWhitelistMu.RUnlock()
- if len(ac.HostWhitelist) == 0 { // allow all
- return true
- }
- _, ok := ac.HostWhitelist["*"]
- if ok {
- return true
- }
- _, ok = ac.HostWhitelist[host]
- return ok
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/snapshot_merge.go b/vendor/go.etcd.io/etcd/etcdserver/snapshot_merge.go
deleted file mode 100644
index 4177768..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/snapshot_merge.go
+++ /dev/null
@@ -1,100 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package etcdserver
-
-import (
- "io"
-
- "go.etcd.io/etcd/etcdserver/api/snap"
- "go.etcd.io/etcd/mvcc/backend"
- "go.etcd.io/etcd/raft/raftpb"
-
- humanize "github.com/dustin/go-humanize"
- "go.uber.org/zap"
-)
-
-// createMergedSnapshotMessage creates a snapshot message that contains: raft status (term, conf),
-// a snapshot of v2 store inside raft.Snapshot as []byte, a snapshot of v3 KV in the top level message
-// as ReadCloser.
-func (s *EtcdServer) createMergedSnapshotMessage(m raftpb.Message, snapt, snapi uint64, confState raftpb.ConfState) snap.Message {
- // get a snapshot of v2 store as []byte
- clone := s.v2store.Clone()
- d, err := clone.SaveNoCopy()
- if err != nil {
- if lg := s.getLogger(); lg != nil {
- lg.Panic("failed to save v2 store data", zap.Error(err))
- } else {
- plog.Panicf("store save should never fail: %v", err)
- }
- }
-
- // commit kv to write metadata(for example: consistent index).
- s.KV().Commit()
- dbsnap := s.be.Snapshot()
- // get a snapshot of v3 KV as readCloser
- rc := newSnapshotReaderCloser(s.getLogger(), dbsnap)
-
- // put the []byte snapshot of store into raft snapshot and return the merged snapshot with
- // KV readCloser snapshot.
- snapshot := raftpb.Snapshot{
- Metadata: raftpb.SnapshotMetadata{
- Index: snapi,
- Term: snapt,
- ConfState: confState,
- },
- Data: d,
- }
- m.Snapshot = snapshot
-
- return *snap.NewMessage(m, rc, dbsnap.Size())
-}
-
-func newSnapshotReaderCloser(lg *zap.Logger, snapshot backend.Snapshot) io.ReadCloser {
- pr, pw := io.Pipe()
- go func() {
- n, err := snapshot.WriteTo(pw)
- if err == nil {
- if lg != nil {
- lg.Info(
- "sent database snapshot to writer",
- zap.Int64("bytes", n),
- zap.String("size", humanize.Bytes(uint64(n))),
- )
- } else {
- plog.Infof("wrote database snapshot out [total bytes: %d]", n)
- }
- } else {
- if lg != nil {
- lg.Warn(
- "failed to send database snapshot to writer",
- zap.String("size", humanize.Bytes(uint64(n))),
- zap.Error(err),
- )
- } else {
- plog.Warningf("failed to write database snapshot out [written bytes: %d]: %v", n, err)
- }
- }
- pw.CloseWithError(err)
- err = snapshot.Close()
- if err != nil {
- if lg != nil {
- lg.Panic("failed to close database snapshot", zap.Error(err))
- } else {
- plog.Panicf("failed to close database snapshot: %v", err)
- }
- }
- }()
- return pr
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/storage.go b/vendor/go.etcd.io/etcd/etcdserver/storage.go
deleted file mode 100644
index d57b6f9..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/storage.go
+++ /dev/null
@@ -1,116 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package etcdserver
-
-import (
- "io"
-
- "go.etcd.io/etcd/etcdserver/api/snap"
- pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
- "go.etcd.io/etcd/pkg/pbutil"
- "go.etcd.io/etcd/pkg/types"
- "go.etcd.io/etcd/raft/raftpb"
- "go.etcd.io/etcd/wal"
- "go.etcd.io/etcd/wal/walpb"
-
- "go.uber.org/zap"
-)
-
-type Storage interface {
- // Save function saves ents and state to the underlying stable storage.
- // Save MUST block until st and ents are on stable storage.
- Save(st raftpb.HardState, ents []raftpb.Entry) error
- // SaveSnap function saves snapshot to the underlying stable storage.
- SaveSnap(snap raftpb.Snapshot) error
- // Close closes the Storage and performs finalization.
- Close() error
-}
-
-type storage struct {
- *wal.WAL
- *snap.Snapshotter
-}
-
-func NewStorage(w *wal.WAL, s *snap.Snapshotter) Storage {
- return &storage{w, s}
-}
-
-// SaveSnap saves the snapshot to disk and release the locked
-// wal files since they will not be used.
-func (st *storage) SaveSnap(snap raftpb.Snapshot) error {
- walsnap := walpb.Snapshot{
- Index: snap.Metadata.Index,
- Term: snap.Metadata.Term,
- }
- err := st.WAL.SaveSnapshot(walsnap)
- if err != nil {
- return err
- }
- err = st.Snapshotter.SaveSnap(snap)
- if err != nil {
- return err
- }
- return st.WAL.ReleaseLockTo(snap.Metadata.Index)
-}
-
-func readWAL(lg *zap.Logger, waldir string, snap walpb.Snapshot) (w *wal.WAL, id, cid types.ID, st raftpb.HardState, ents []raftpb.Entry) {
- var (
- err error
- wmetadata []byte
- )
-
- repaired := false
- for {
- if w, err = wal.Open(lg, waldir, snap); err != nil {
- if lg != nil {
- lg.Fatal("failed to open WAL", zap.Error(err))
- } else {
- plog.Fatalf("open wal error: %v", err)
- }
- }
- if wmetadata, st, ents, err = w.ReadAll(); err != nil {
- w.Close()
- // we can only repair ErrUnexpectedEOF and we never repair twice.
- if repaired || err != io.ErrUnexpectedEOF {
- if lg != nil {
- lg.Fatal("failed to read WAL, cannot be repaired", zap.Error(err))
- } else {
- plog.Fatalf("read wal error (%v) and cannot be repaired", err)
- }
- }
- if !wal.Repair(lg, waldir) {
- if lg != nil {
- lg.Fatal("failed to repair WAL", zap.Error(err))
- } else {
- plog.Fatalf("WAL error (%v) cannot be repaired", err)
- }
- } else {
- if lg != nil {
- lg.Info("repaired WAL", zap.Error(err))
- } else {
- plog.Infof("repaired WAL error (%v)", err)
- }
- repaired = true
- }
- continue
- }
- break
- }
- var metadata pb.Metadata
- pbutil.MustUnmarshal(&metadata, wmetadata)
- id = types.ID(metadata.NodeID)
- cid = types.ID(metadata.ClusterID)
- return w, id, cid, st, ents
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/util.go b/vendor/go.etcd.io/etcd/etcdserver/util.go
deleted file mode 100644
index fe5024e..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/util.go
+++ /dev/null
@@ -1,168 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package etcdserver
-
-import (
- "fmt"
- "reflect"
- "strings"
- "time"
-
- "github.com/golang/protobuf/proto"
- "go.etcd.io/etcd/etcdserver/api/membership"
- "go.etcd.io/etcd/etcdserver/api/rafthttp"
- pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
- "go.etcd.io/etcd/pkg/types"
-
- "go.uber.org/zap"
-)
-
-// isConnectedToQuorumSince checks whether the local member is connected to the
-// quorum of the cluster since the given time.
-func isConnectedToQuorumSince(transport rafthttp.Transporter, since time.Time, self types.ID, members []*membership.Member) bool {
- return numConnectedSince(transport, since, self, members) >= (len(members)/2)+1
-}
-
-// isConnectedSince checks whether the local member is connected to the
-// remote member since the given time.
-func isConnectedSince(transport rafthttp.Transporter, since time.Time, remote types.ID) bool {
- t := transport.ActiveSince(remote)
- return !t.IsZero() && t.Before(since)
-}
-
-// isConnectedFullySince checks whether the local member is connected to all
-// members in the cluster since the given time.
-func isConnectedFullySince(transport rafthttp.Transporter, since time.Time, self types.ID, members []*membership.Member) bool {
- return numConnectedSince(transport, since, self, members) == len(members)
-}
-
-// numConnectedSince counts how many members are connected to the local member
-// since the given time.
-func numConnectedSince(transport rafthttp.Transporter, since time.Time, self types.ID, members []*membership.Member) int {
- connectedNum := 0
- for _, m := range members {
- if m.ID == self || isConnectedSince(transport, since, m.ID) {
- connectedNum++
- }
- }
- return connectedNum
-}
-
-// longestConnected chooses the member with longest active-since-time.
-// It returns false, if nothing is active.
-func longestConnected(tp rafthttp.Transporter, membs []types.ID) (types.ID, bool) {
- var longest types.ID
- var oldest time.Time
- for _, id := range membs {
- tm := tp.ActiveSince(id)
- if tm.IsZero() { // inactive
- continue
- }
-
- if oldest.IsZero() { // first longest candidate
- oldest = tm
- longest = id
- }
-
- if tm.Before(oldest) {
- oldest = tm
- longest = id
- }
- }
- if uint64(longest) == 0 {
- return longest, false
- }
- return longest, true
-}
-
-type notifier struct {
- c chan struct{}
- err error
-}
-
-func newNotifier() *notifier {
- return ¬ifier{
- c: make(chan struct{}),
- }
-}
-
-func (nc *notifier) notify(err error) {
- nc.err = err
- close(nc.c)
-}
-
-func warnOfExpensiveRequest(lg *zap.Logger, now time.Time, reqStringer fmt.Stringer, respMsg proto.Message, err error) {
- var resp string
- if !isNil(respMsg) {
- resp = fmt.Sprintf("size:%d", proto.Size(respMsg))
- }
- warnOfExpensiveGenericRequest(lg, now, reqStringer, "", resp, err)
-}
-
-func warnOfExpensiveReadOnlyTxnRequest(lg *zap.Logger, now time.Time, r *pb.TxnRequest, txnResponse *pb.TxnResponse, err error) {
- reqStringer := pb.NewLoggableTxnRequest(r)
- var resp string
- if !isNil(txnResponse) {
- var resps []string
- for _, r := range txnResponse.Responses {
- switch op := r.Response.(type) {
- case *pb.ResponseOp_ResponseRange:
- resps = append(resps, fmt.Sprintf("range_response_count:%d", len(op.ResponseRange.Kvs)))
- default:
- // only range responses should be in a read only txn request
- }
- }
- resp = fmt.Sprintf("responses:<%s> size:%d", strings.Join(resps, " "), proto.Size(txnResponse))
- }
- warnOfExpensiveGenericRequest(lg, now, reqStringer, "read-only range ", resp, err)
-}
-
-func warnOfExpensiveReadOnlyRangeRequest(lg *zap.Logger, now time.Time, reqStringer fmt.Stringer, rangeResponse *pb.RangeResponse, err error) {
- var resp string
- if !isNil(rangeResponse) {
- resp = fmt.Sprintf("range_response_count:%d size:%d", len(rangeResponse.Kvs), proto.Size(rangeResponse))
- }
- warnOfExpensiveGenericRequest(lg, now, reqStringer, "read-only range ", resp, err)
-}
-
-func warnOfExpensiveGenericRequest(lg *zap.Logger, now time.Time, reqStringer fmt.Stringer, prefix string, resp string, err error) {
- d := time.Since(now)
- if d > warnApplyDuration {
- if lg != nil {
- lg.Warn(
- "apply request took too long",
- zap.Duration("took", d),
- zap.Duration("expected-duration", warnApplyDuration),
- zap.String("prefix", prefix),
- zap.String("request", reqStringer.String()),
- zap.String("response", resp),
- zap.Error(err),
- )
- } else {
- var result string
- if err != nil {
- result = fmt.Sprintf("error:%v", err)
- } else {
- result = resp
- }
- plog.Warningf("%srequest %q with result %q took too long (%v) to execute", prefix, reqStringer.String(), result, d)
- }
- slowApplies.Inc()
- }
-}
-
-func isNil(msg proto.Message) bool {
- return msg == nil || reflect.ValueOf(msg).IsNil()
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/v2_server.go b/vendor/go.etcd.io/etcd/etcdserver/v2_server.go
deleted file mode 100644
index 9238b2d..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/v2_server.go
+++ /dev/null
@@ -1,165 +0,0 @@
-// Copyright 2016 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package etcdserver
-
-import (
- "context"
- "time"
-
- "go.etcd.io/etcd/etcdserver/api/v2store"
- pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
-)
-
-type RequestV2 pb.Request
-
-type RequestV2Handler interface {
- Post(ctx context.Context, r *RequestV2) (Response, error)
- Put(ctx context.Context, r *RequestV2) (Response, error)
- Delete(ctx context.Context, r *RequestV2) (Response, error)
- QGet(ctx context.Context, r *RequestV2) (Response, error)
- Get(ctx context.Context, r *RequestV2) (Response, error)
- Head(ctx context.Context, r *RequestV2) (Response, error)
-}
-
-type reqV2HandlerEtcdServer struct {
- reqV2HandlerStore
- s *EtcdServer
-}
-
-type reqV2HandlerStore struct {
- store v2store.Store
- applier ApplierV2
-}
-
-func NewStoreRequestV2Handler(s v2store.Store, applier ApplierV2) RequestV2Handler {
- return &reqV2HandlerStore{s, applier}
-}
-
-func (a *reqV2HandlerStore) Post(ctx context.Context, r *RequestV2) (Response, error) {
- return a.applier.Post(r), nil
-}
-
-func (a *reqV2HandlerStore) Put(ctx context.Context, r *RequestV2) (Response, error) {
- return a.applier.Put(r), nil
-}
-
-func (a *reqV2HandlerStore) Delete(ctx context.Context, r *RequestV2) (Response, error) {
- return a.applier.Delete(r), nil
-}
-
-func (a *reqV2HandlerStore) QGet(ctx context.Context, r *RequestV2) (Response, error) {
- return a.applier.QGet(r), nil
-}
-
-func (a *reqV2HandlerStore) Get(ctx context.Context, r *RequestV2) (Response, error) {
- if r.Wait {
- wc, err := a.store.Watch(r.Path, r.Recursive, r.Stream, r.Since)
- return Response{Watcher: wc}, err
- }
- ev, err := a.store.Get(r.Path, r.Recursive, r.Sorted)
- return Response{Event: ev}, err
-}
-
-func (a *reqV2HandlerStore) Head(ctx context.Context, r *RequestV2) (Response, error) {
- ev, err := a.store.Get(r.Path, r.Recursive, r.Sorted)
- return Response{Event: ev}, err
-}
-
-func (a *reqV2HandlerEtcdServer) Post(ctx context.Context, r *RequestV2) (Response, error) {
- return a.processRaftRequest(ctx, r)
-}
-
-func (a *reqV2HandlerEtcdServer) Put(ctx context.Context, r *RequestV2) (Response, error) {
- return a.processRaftRequest(ctx, r)
-}
-
-func (a *reqV2HandlerEtcdServer) Delete(ctx context.Context, r *RequestV2) (Response, error) {
- return a.processRaftRequest(ctx, r)
-}
-
-func (a *reqV2HandlerEtcdServer) QGet(ctx context.Context, r *RequestV2) (Response, error) {
- return a.processRaftRequest(ctx, r)
-}
-
-func (a *reqV2HandlerEtcdServer) processRaftRequest(ctx context.Context, r *RequestV2) (Response, error) {
- data, err := ((*pb.Request)(r)).Marshal()
- if err != nil {
- return Response{}, err
- }
- ch := a.s.w.Register(r.ID)
-
- start := time.Now()
- a.s.r.Propose(ctx, data)
- proposalsPending.Inc()
- defer proposalsPending.Dec()
-
- select {
- case x := <-ch:
- resp := x.(Response)
- return resp, resp.Err
- case <-ctx.Done():
- proposalsFailed.Inc()
- a.s.w.Trigger(r.ID, nil) // GC wait
- return Response{}, a.s.parseProposeCtxErr(ctx.Err(), start)
- case <-a.s.stopping:
- }
- return Response{}, ErrStopped
-}
-
-func (s *EtcdServer) Do(ctx context.Context, r pb.Request) (Response, error) {
- r.ID = s.reqIDGen.Next()
- h := &reqV2HandlerEtcdServer{
- reqV2HandlerStore: reqV2HandlerStore{
- store: s.v2store,
- applier: s.applyV2,
- },
- s: s,
- }
- rp := &r
- resp, err := ((*RequestV2)(rp)).Handle(ctx, h)
- resp.Term, resp.Index = s.Term(), s.CommittedIndex()
- return resp, err
-}
-
-// Handle interprets r and performs an operation on s.store according to r.Method
-// and other fields. If r.Method is "POST", "PUT", "DELETE", or a "GET" with
-// Quorum == true, r will be sent through consensus before performing its
-// respective operation. Do will block until an action is performed or there is
-// an error.
-func (r *RequestV2) Handle(ctx context.Context, v2api RequestV2Handler) (Response, error) {
- if r.Method == "GET" && r.Quorum {
- r.Method = "QGET"
- }
- switch r.Method {
- case "POST":
- return v2api.Post(ctx, r)
- case "PUT":
- return v2api.Put(ctx, r)
- case "DELETE":
- return v2api.Delete(ctx, r)
- case "QGET":
- return v2api.QGet(ctx, r)
- case "GET":
- return v2api.Get(ctx, r)
- case "HEAD":
- return v2api.Head(ctx, r)
- }
- return Response{}, ErrUnknownMethod
-}
-
-func (r *RequestV2) String() string {
- rpb := pb.Request(*r)
- return rpb.String()
-}
diff --git a/vendor/go.etcd.io/etcd/etcdserver/v3_server.go b/vendor/go.etcd.io/etcd/etcdserver/v3_server.go
deleted file mode 100644
index b208461..0000000
--- a/vendor/go.etcd.io/etcd/etcdserver/v3_server.go
+++ /dev/null
@@ -1,768 +0,0 @@
-// Copyright 2015 The etcd Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package etcdserver
-
-import (
- "bytes"
- "context"
- "encoding/binary"
- "time"
-
- "go.etcd.io/etcd/auth"
- "go.etcd.io/etcd/etcdserver/api/membership"
- pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
- "go.etcd.io/etcd/lease"
- "go.etcd.io/etcd/lease/leasehttp"
- "go.etcd.io/etcd/mvcc"
- "go.etcd.io/etcd/raft"
-
- "github.com/gogo/protobuf/proto"
- "go.uber.org/zap"
-)
-
-const (
- // In the health case, there might be a small gap (10s of entries) between
- // the applied index and committed index.
- // However, if the committed entries are very heavy to apply, the gap might grow.
- // We should stop accepting new proposals if the gap growing to a certain point.
- maxGapBetweenApplyAndCommitIndex = 5000
-)
-
-type RaftKV interface {
- Range(ctx context.Context, r *pb.RangeRequest) (*pb.RangeResponse, error)
- Put(ctx context.Context, r *pb.PutRequest) (*pb.PutResponse, error)
- DeleteRange(ctx context.Context, r *pb.DeleteRangeRequest) (*pb.DeleteRangeResponse, error)
- Txn(ctx context.Context, r *pb.TxnRequest) (*pb.TxnResponse, error)
- Compact(ctx context.Context, r *pb.CompactionRequest) (*pb.CompactionResponse, error)
-}
-
-type Lessor interface {
- // LeaseGrant sends LeaseGrant request to raft and apply it after committed.
- LeaseGrant(ctx context.Context, r *pb.LeaseGrantRequest) (*pb.LeaseGrantResponse, error)
- // LeaseRevoke sends LeaseRevoke request to raft and apply it after committed.
- LeaseRevoke(ctx context.Context, r *pb.LeaseRevokeRequest) (*pb.LeaseRevokeResponse, error)
-
- // LeaseRenew renews the lease with given ID. The renewed TTL is returned. Or an error
- // is returned.
- LeaseRenew(ctx context.Context, id lease.LeaseID) (int64, error)
-
- // LeaseTimeToLive retrieves lease information.
- LeaseTimeToLive(ctx context.Context, r *pb.LeaseTimeToLiveRequest) (*pb.LeaseTimeToLiveResponse, error)
-
- // LeaseLeases lists all leases.
- LeaseLeases(ctx context.Context, r *pb.LeaseLeasesRequest) (*pb.LeaseLeasesResponse, error)
-}
-
-type Authenticator interface {
- AuthEnable(ctx context.Context, r *pb.AuthEnableRequest) (*pb.AuthEnableResponse, error)
- AuthDisable(ctx context.Context, r *pb.AuthDisableRequest) (*pb.AuthDisableResponse, error)
- Authenticate(ctx context.Context, r *pb.AuthenticateRequest) (*pb.AuthenticateResponse, error)
- UserAdd(ctx context.Context, r *pb.AuthUserAddRequest) (*pb.AuthUserAddResponse, error)
- UserDelete(ctx context.Context, r *pb.AuthUserDeleteRequest) (*pb.AuthUserDeleteResponse, error)
- UserChangePassword(ctx context.Context, r *pb.AuthUserChangePasswordRequest) (*pb.AuthUserChangePasswordResponse, error)
- UserGrantRole(ctx context.Context, r *pb.AuthUserGrantRoleRequest) (*pb.AuthUserGrantRoleResponse, error)
- UserGet(ctx context.Context, r *pb.AuthUserGetRequest) (*pb.AuthUserGetResponse, error)
- UserRevokeRole(ctx context.Context, r *pb.AuthUserRevokeRoleRequest) (*pb.AuthUserRevokeRoleResponse, error)
- RoleAdd(ctx context.Context, r *pb.AuthRoleAddRequest) (*pb.AuthRoleAddResponse, error)
- RoleGrantPermission(ctx context.Context, r *pb.AuthRoleGrantPermissionRequest) (*pb.AuthRoleGrantPermissionResponse, error)
- RoleGet(ctx context.Context, r *pb.AuthRoleGetRequest) (*pb.AuthRoleGetResponse, error)
- RoleRevokePermission(ctx context.Context, r *pb.AuthRoleRevokePermissionRequest) (*pb.AuthRoleRevokePermissionResponse, error)
- RoleDelete(ctx context.Context, r *pb.AuthRoleDeleteRequest) (*pb.AuthRoleDeleteResponse, error)
- UserList(ctx context.Context, r *pb.AuthUserListRequest) (*pb.AuthUserListResponse, error)
- RoleList(ctx context.Context, r *pb.AuthRoleListRequest) (*pb.AuthRoleListResponse, error)
-}
-
-func (s *EtcdServer) Range(ctx context.Context, r *pb.RangeRequest) (*pb.RangeResponse, error) {
- var resp *pb.RangeResponse
- var err error
- defer func(start time.Time) {
- warnOfExpensiveReadOnlyRangeRequest(s.getLogger(), start, r, resp, err)
- }(time.Now())
-
- if !r.Serializable {
- err = s.linearizableReadNotify(ctx)
- if err != nil {
- return nil, err
- }
- }
- chk := func(ai *auth.AuthInfo) error {
- return s.authStore.IsRangePermitted(ai, r.Key, r.RangeEnd)
- }
-
- get := func() { resp, err = s.applyV3Base.Range(nil, r) }
- if serr := s.doSerialize(ctx, chk, get); serr != nil {
- err = serr
- return nil, err
- }
- return resp, err
-}
-
-func (s *EtcdServer) Put(ctx context.Context, r *pb.PutRequest) (*pb.PutResponse, error) {
- resp, err := s.raftRequest(ctx, pb.InternalRaftRequest{Put: r})
- if err != nil {
- return nil, err
- }
- return resp.(*pb.PutResponse), nil
-}
-
-func (s *EtcdServer) DeleteRange(ctx context.Context, r *pb.DeleteRangeRequest) (*pb.DeleteRangeResponse, error) {
- resp, err := s.raftRequest(ctx, pb.InternalRaftRequest{DeleteRange: r})
- if err != nil {
- return nil, err
- }
- return resp.(*pb.DeleteRangeResponse), nil
-}
-
-func (s *EtcdServer) Txn(ctx context.Context, r *pb.TxnRequest) (*pb.TxnResponse, error) {
- if isTxnReadonly(r) {
- if !isTxnSerializable(r) {
- err := s.linearizableReadNotify(ctx)
- if err != nil {
- return nil, err
- }
- }
- var resp *pb.TxnResponse
- var err error
- chk := func(ai *auth.AuthInfo) error {
- return checkTxnAuth(s.authStore, ai, r)
- }
-
- defer func(start time.Time) {
- warnOfExpensiveReadOnlyTxnRequest(s.getLogger(), start, r, resp, err)
- }(time.Now())
-
- get := func() { resp, err = s.applyV3Base.Txn(r) }
- if serr := s.doSerialize(ctx, chk, get); serr != nil {
- return nil, serr
- }
- return resp, err
- }
-
- resp, err := s.raftRequest(ctx, pb.InternalRaftRequest{Txn: r})
- if err != nil {
- return nil, err
- }
- return resp.(*pb.TxnResponse), nil
-}
-
-func isTxnSerializable(r *pb.TxnRequest) bool {
- for _, u := range r.Success {
- if r := u.GetRequestRange(); r == nil || !r.Serializable {
- return false
- }
- }
- for _, u := range r.Failure {
- if r := u.GetRequestRange(); r == nil || !r.Serializable {
- return false
- }
- }
- return true
-}
-
-func isTxnReadonly(r *pb.TxnRequest) bool {
- for _, u := range r.Success {
- if r := u.GetRequestRange(); r == nil {
- return false
- }
- }
- for _, u := range r.Failure {
- if r := u.GetRequestRange(); r == nil {
- return false
- }
- }
- return true
-}
-
-func (s *EtcdServer) Compact(ctx context.Context, r *pb.CompactionRequest) (*pb.CompactionResponse, error) {
- result, err := s.processInternalRaftRequestOnce(ctx, pb.InternalRaftRequest{Compaction: r})
- if r.Physical && result != nil && result.physc != nil {
- <-result.physc
- // The compaction is done deleting keys; the hash is now settled
- // but the data is not necessarily committed. If there's a crash,
- // the hash may revert to a hash prior to compaction completing
- // if the compaction resumes. Force the finished compaction to
- // commit so it won't resume following a crash.
- s.be.ForceCommit()
- }
- if err != nil {
- return nil, err
- }
- if result.err != nil {
- return nil, result.err
- }
- resp := result.resp.(*pb.CompactionResponse)
- if resp == nil {
- resp = &pb.CompactionResponse{}
- }
- if resp.Header == nil {
- resp.Header = &pb.ResponseHeader{}
- }
- resp.Header.Revision = s.kv.Rev()
- return resp, nil
-}
-
-func (s *EtcdServer) LeaseGrant(ctx context.Context, r *pb.LeaseGrantRequest) (*pb.LeaseGrantResponse, error) {
- // no id given? choose one
- for r.ID == int64(lease.NoLease) {
- // only use positive int64 id's
- r.ID = int64(s.reqIDGen.Next() & ((1 << 63) - 1))
- }
- resp, err := s.raftRequestOnce(ctx, pb.InternalRaftRequest{LeaseGrant: r})
- if err != nil {
- return nil, err
- }
- return resp.(*pb.LeaseGrantResponse), nil
-}
-
-func (s *EtcdServer) LeaseRevoke(ctx context.Context, r *pb.LeaseRevokeRequest) (*pb.LeaseRevokeResponse, error) {
- resp, err := s.raftRequestOnce(ctx, pb.InternalRaftRequest{LeaseRevoke: r})
- if err != nil {
- return nil, err
- }
- return resp.(*pb.LeaseRevokeResponse), nil
-}
-
-func (s *EtcdServer) LeaseRenew(ctx context.Context, id lease.LeaseID) (int64, error) {
- ttl, err := s.lessor.Renew(id)
- if err == nil { // already requested to primary lessor(leader)
- return ttl, nil
- }
- if err != lease.ErrNotPrimary {
- return -1, err
- }
-
- cctx, cancel := context.WithTimeout(ctx, s.Cfg.ReqTimeout())
- defer cancel()
-
- // renewals don't go through raft; forward to leader manually
- for cctx.Err() == nil && err != nil {
- leader, lerr := s.waitLeader(cctx)
- if lerr != nil {
- return -1, lerr
- }
- for _, url := range leader.PeerURLs {
- lurl := url + leasehttp.LeasePrefix
- ttl, err = leasehttp.RenewHTTP(cctx, id, lurl, s.peerRt)
- if err == nil || err == lease.ErrLeaseNotFound {
- return ttl, err
- }
- }
- }
-
- if cctx.Err() == context.DeadlineExceeded {
- return -1, ErrTimeout
- }
- return -1, ErrCanceled
-}
-
-func (s *EtcdServer) LeaseTimeToLive(ctx context.Context, r *pb.LeaseTimeToLiveRequest) (*pb.LeaseTimeToLiveResponse, error) {
- if s.Leader() == s.ID() {
- // primary; timetolive directly from leader
- le := s.lessor.Lookup(lease.LeaseID(r.ID))
- if le == nil {
- return nil, lease.ErrLeaseNotFound
- }
- // TODO: fill out ResponseHeader
- resp := &pb.LeaseTimeToLiveResponse{Header: &pb.ResponseHeader{}, ID: r.ID, TTL: int64(le.Remaining().Seconds()), GrantedTTL: le.TTL()}
- if r.Keys {
- ks := le.Keys()
- kbs := make([][]byte, len(ks))
- for i := range ks {
- kbs[i] = []byte(ks[i])
- }
- resp.Keys = kbs
- }
- return resp, nil
- }
-
- cctx, cancel := context.WithTimeout(ctx, s.Cfg.ReqTimeout())
- defer cancel()
-
- // forward to leader
- for cctx.Err() == nil {
- leader, err := s.waitLeader(cctx)
- if err != nil {
- return nil, err
- }
- for _, url := range leader.PeerURLs {
- lurl := url + leasehttp.LeaseInternalPrefix
- resp, err := leasehttp.TimeToLiveHTTP(cctx, lease.LeaseID(r.ID), r.Keys, lurl, s.peerRt)
- if err == nil {
- return resp.LeaseTimeToLiveResponse, nil
- }
- if err == lease.ErrLeaseNotFound {
- return nil, err
- }
- }
- }
-
- if cctx.Err() == context.DeadlineExceeded {
- return nil, ErrTimeout
- }
- return nil, ErrCanceled
-}
-
-func (s *EtcdServer) LeaseLeases(ctx context.Context, r *pb.LeaseLeasesRequest) (*pb.LeaseLeasesResponse, error) {
- ls := s.lessor.Leases()
- lss := make([]*pb.LeaseStatus, len(ls))
- for i := range ls {
- lss[i] = &pb.LeaseStatus{ID: int64(ls[i].ID)}
- }
- return &pb.LeaseLeasesResponse{Header: newHeader(s), Leases: lss}, nil
-}
-
-func (s *EtcdServer) waitLeader(ctx context.Context) (*membership.Member, error) {
- leader := s.cluster.Member(s.Leader())
- for leader == nil {
- // wait an election
- dur := time.Duration(s.Cfg.ElectionTicks) * time.Duration(s.Cfg.TickMs) * time.Millisecond
- select {
- case <-time.After(dur):
- leader = s.cluster.Member(s.Leader())
- case <-s.stopping:
- return nil, ErrStopped
- case <-ctx.Done():
- return nil, ErrNoLeader
- }
- }
- if leader == nil || len(leader.PeerURLs) == 0 {
- return nil, ErrNoLeader
- }
- return leader, nil
-}
-
-func (s *EtcdServer) Alarm(ctx context.Context, r *pb.AlarmRequest) (*pb.AlarmResponse, error) {
- resp, err := s.raftRequestOnce(ctx, pb.InternalRaftRequest{Alarm: r})
- if err != nil {
- return nil, err
- }
- return resp.(*pb.AlarmResponse), nil
-}
-
-func (s *EtcdServer) AuthEnable(ctx context.Context, r *pb.AuthEnableRequest) (*pb.AuthEnableResponse, error) {
- resp, err := s.raftRequestOnce(ctx, pb.InternalRaftRequest{AuthEnable: r})
- if err != nil {
- return nil, err
- }
- return resp.(*pb.AuthEnableResponse), nil
-}
-
-func (s *EtcdServer) AuthDisable(ctx context.Context, r *pb.AuthDisableRequest) (*pb.AuthDisableResponse, error) {
- resp, err := s.raftRequest(ctx, pb.InternalRaftRequest{AuthDisable: r})
- if err != nil {
- return nil, err
- }
- return resp.(*pb.AuthDisableResponse), nil
-}
-
-func (s *EtcdServer) Authenticate(ctx context.Context, r *pb.AuthenticateRequest) (*pb.AuthenticateResponse, error) {
- if err := s.linearizableReadNotify(ctx); err != nil {
- return nil, err
- }
-
- lg := s.getLogger()
-
- var resp proto.Message
- for {
- checkedRevision, err := s.AuthStore().CheckPassword(r.Name, r.Password)
- if err != nil {
- if err != auth.ErrAuthNotEnabled {
- if lg != nil {
- lg.Warn(
- "invalid authentication was requested",
- zap.String("user", r.Name),
- zap.Error(err),
- )
- } else {
- plog.Errorf("invalid authentication request to user %s was issued", r.Name)
- }
- }
- return nil, err
- }
-
- st, err := s.AuthStore().GenTokenPrefix()
- if err != nil {
- return nil, err
- }
-
- internalReq := &pb.InternalAuthenticateRequest{
- Name: r.Name,
- Password: r.Password,
- SimpleToken: st,
- }
-
- resp, err = s.raftRequestOnce(ctx, pb.InternalRaftRequest{Authenticate: internalReq})
- if err != nil {
- return nil, err
- }
- if checkedRevision == s.AuthStore().Revision() {
- break
- }
-
- if lg != nil {
- lg.Info("revision when password checked became stale; retrying")
- } else {
- plog.Infof("revision when password checked is obsolete, retrying")
- }
- }
-
- return resp.(*pb.AuthenticateResponse), nil
-}
-
-func (s *EtcdServer) UserAdd(ctx context.Context, r *pb.AuthUserAddRequest) (*pb.AuthUserAddResponse, error) {
- resp, err := s.raftRequest(ctx, pb.InternalRaftRequest{AuthUserAdd: r})
- if err != nil {
- return nil, err
- }
- return resp.(*pb.AuthUserAddResponse), nil
-}
-
-func (s *EtcdServer) UserDelete(ctx context.Context, r *pb.AuthUserDeleteRequest) (*pb.AuthUserDeleteResponse, error) {
- resp, err := s.raftRequest(ctx, pb.InternalRaftRequest{AuthUserDelete: r})
- if err != nil {
- return nil, err
- }
- return resp.(*pb.AuthUserDeleteResponse), nil
-}
-
-func (s *EtcdServer) UserChangePassword(ctx context.Context, r *pb.AuthUserChangePasswordRequest) (*pb.AuthUserChangePasswordResponse, error) {
- resp, err := s.raftRequest(ctx, pb.InternalRaftRequest{AuthUserChangePassword: r})
- if err != nil {
- return nil, err
- }
- return resp.(*pb.AuthUserChangePasswordResponse), nil
-}
-
-func (s *EtcdServer) UserGrantRole(ctx context.Context, r *pb.AuthUserGrantRoleRequest) (*pb.AuthUserGrantRoleResponse, error) {
- resp, err := s.raftRequest(ctx, pb.InternalRaftRequest{AuthUserGrantRole: r})
- if err != nil {
- return nil, err
- }
- return resp.(*pb.AuthUserGrantRoleResponse), nil
-}
-
-func (s *EtcdServer) UserGet(ctx context.Context, r *pb.AuthUserGetRequest) (*pb.AuthUserGetResponse, error) {
- resp, err := s.raftRequest(ctx, pb.InternalRaftRequest{AuthUserGet: r})
- if err != nil {
- return nil, err
- }
- return resp.(*pb.AuthUserGetResponse), nil
-}
-
-func (s *EtcdServer) UserList(ctx context.Context, r *pb.AuthUserListRequest) (*pb.AuthUserListResponse, error) {
- resp, err := s.raftRequest(ctx, pb.InternalRaftRequest{AuthUserList: r})
- if err != nil {
- return nil, err
- }
- return resp.(*pb.AuthUserListResponse), nil
-}
-
-func (s *EtcdServer) UserRevokeRole(ctx context.Context, r *pb.AuthUserRevokeRoleRequest) (*pb.AuthUserRevokeRoleResponse, error) {
- resp, err := s.raftRequest(ctx, pb.InternalRaftRequest{AuthUserRevokeRole: r})
- if err != nil {
- return nil, err
- }
- return resp.(*pb.AuthUserRevokeRoleResponse), nil
-}
-
-func (s *EtcdServer) RoleAdd(ctx context.Context, r *pb.AuthRoleAddRequest) (*pb.AuthRoleAddResponse, error) {
- resp, err := s.raftRequest(ctx, pb.InternalRaftRequest{AuthRoleAdd: r})
- if err != nil {
- return nil, err
- }
- return resp.(*pb.AuthRoleAddResponse), nil
-}
-
-func (s *EtcdServer) RoleGrantPermission(ctx context.Context, r *pb.AuthRoleGrantPermissionRequest) (*pb.AuthRoleGrantPermissionResponse, error) {
- resp, err := s.raftRequest(ctx, pb.InternalRaftRequest{AuthRoleGrantPermission: r})
- if err != nil {
- return nil, err
- }
- return resp.(*pb.AuthRoleGrantPermissionResponse), nil
-}
-
-func (s *EtcdServer) RoleGet(ctx context.Context, r *pb.AuthRoleGetRequest) (*pb.AuthRoleGetResponse, error) {
- resp, err := s.raftRequest(ctx, pb.InternalRaftRequest{AuthRoleGet: r})
- if err != nil {
- return nil, err
- }
- return resp.(*pb.AuthRoleGetResponse), nil
-}
-
-func (s *EtcdServer) RoleList(ctx context.Context, r *pb.AuthRoleListRequest) (*pb.AuthRoleListResponse, error) {
- resp, err := s.raftRequest(ctx, pb.InternalRaftRequest{AuthRoleList: r})
- if err != nil {
- return nil, err
- }
- return resp.(*pb.AuthRoleListResponse), nil
-}
-
-func (s *EtcdServer) RoleRevokePermission(ctx context.Context, r *pb.AuthRoleRevokePermissionRequest) (*pb.AuthRoleRevokePermissionResponse, error) {
- resp, err := s.raftRequest(ctx, pb.InternalRaftRequest{AuthRoleRevokePermission: r})
- if err != nil {
- return nil, err
- }
- return resp.(*pb.AuthRoleRevokePermissionResponse), nil
-}
-
-func (s *EtcdServer) RoleDelete(ctx context.Context, r *pb.AuthRoleDeleteRequest) (*pb.AuthRoleDeleteResponse, error) {
- resp, err := s.raftRequest(ctx, pb.InternalRaftRequest{AuthRoleDelete: r})
- if err != nil {
- return nil, err
- }
- return resp.(*pb.AuthRoleDeleteResponse), nil
-}
-
-func (s *EtcdServer) raftRequestOnce(ctx context.Context, r pb.InternalRaftRequest) (proto.Message, error) {
- result, err := s.processInternalRaftRequestOnce(ctx, r)
- if err != nil {
- return nil, err
- }
- if result.err != nil {
- return nil, result.err
- }
- return result.resp, nil
-}
-
-func (s *EtcdServer) raftRequest(ctx context.Context, r pb.InternalRaftRequest) (proto.Message, error) {
- for {
- resp, err := s.raftRequestOnce(ctx, r)
- if err != auth.ErrAuthOldRevision {
- return resp, err
- }
- }
-}
-
-// doSerialize handles the auth logic, with permissions checked by "chk", for a serialized request "get". Returns a non-nil error on authentication failure.
-func (s *EtcdServer) doSerialize(ctx context.Context, chk func(*auth.AuthInfo) error, get func()) error {
- ai, err := s.AuthInfoFromCtx(ctx)
- if err != nil {
- return err
- }
- if ai == nil {
- // chk expects non-nil AuthInfo; use empty credentials
- ai = &auth.AuthInfo{}
- }
- if err = chk(ai); err != nil {
- return err
- }
- // fetch response for serialized request
- get()
- // check for stale token revision in case the auth store was updated while
- // the request has been handled.
- if ai.Revision != 0 && ai.Revision != s.authStore.Revision() {
- return auth.ErrAuthOldRevision
- }
- return nil
-}
-
-func (s *EtcdServer) processInternalRaftRequestOnce(ctx context.Context, r pb.InternalRaftRequest) (*applyResult, error) {
- ai := s.getAppliedIndex()
- ci := s.getCommittedIndex()
- if ci > ai+maxGapBetweenApplyAndCommitIndex {
- return nil, ErrTooManyRequests
- }
-
- r.Header = &pb.RequestHeader{
- ID: s.reqIDGen.Next(),
- }
-
- authInfo, err := s.AuthInfoFromCtx(ctx)
- if err != nil {
- return nil, err
- }
- if authInfo != nil {
- r.Header.Username = authInfo.Username
- r.Header.AuthRevision = authInfo.Revision
- }
-
- data, err := r.Marshal()
- if err != nil {
- return nil, err
- }
-
- if len(data) > int(s.Cfg.MaxRequestBytes) {
- return nil, ErrRequestTooLarge
- }
-
- id := r.ID
- if id == 0 {
- id = r.Header.ID
- }
- ch := s.w.Register(id)
-
- cctx, cancel := context.WithTimeout(ctx, s.Cfg.ReqTimeout())
- defer cancel()
-
- start := time.Now()
- err = s.r.Propose(cctx, data)
- if err != nil {
- proposalsFailed.Inc()
- s.w.Trigger(id, nil) // GC wait
- return nil, err
- }
- proposalsPending.Inc()
- defer proposalsPending.Dec()
-
- select {
- case x := <-ch:
- return x.(*applyResult), nil
- case <-cctx.Done():
- proposalsFailed.Inc()
- s.w.Trigger(id, nil) // GC wait
- return nil, s.parseProposeCtxErr(cctx.Err(), start)
- case <-s.done:
- return nil, ErrStopped
- }
-}
-
-// Watchable returns a watchable interface attached to the etcdserver.
-func (s *EtcdServer) Watchable() mvcc.WatchableKV { return s.KV() }
-
-func (s *EtcdServer) linearizableReadLoop() {
- var rs raft.ReadState
-
- for {
- ctxToSend := make([]byte, 8)
- id1 := s.reqIDGen.Next()
- binary.BigEndian.PutUint64(ctxToSend, id1)
- leaderChangedNotifier := s.leaderChangedNotify()
- select {
- case <-leaderChangedNotifier:
- continue
- case <-s.readwaitc:
- case <-s.stopping:
- return
- }
-
- nextnr := newNotifier()
-
- s.readMu.Lock()
- nr := s.readNotifier
- s.readNotifier = nextnr
- s.readMu.Unlock()
-
- lg := s.getLogger()
- cctx, cancel := context.WithTimeout(context.Background(), s.Cfg.ReqTimeout())
- if err := s.r.ReadIndex(cctx, ctxToSend); err != nil {
- cancel()
- if err == raft.ErrStopped {
- return
- }
- if lg != nil {
- lg.Warn("failed to get read index from Raft", zap.Error(err))
- } else {
- plog.Errorf("failed to get read index from raft: %v", err)
- }
- readIndexFailed.Inc()
- nr.notify(err)
- continue
- }
- cancel()
-
- var (
- timeout bool
- done bool
- )
- for !timeout && !done {
- select {
- case rs = <-s.r.readStateC:
- done = bytes.Equal(rs.RequestCtx, ctxToSend)
- if !done {
- // a previous request might time out. now we should ignore the response of it and
- // continue waiting for the response of the current requests.
- id2 := uint64(0)
- if len(rs.RequestCtx) == 8 {
- id2 = binary.BigEndian.Uint64(rs.RequestCtx)
- }
- if lg != nil {
- lg.Warn(
- "ignored out-of-date read index response; local node read indexes queueing up and waiting to be in sync with leader",
- zap.Uint64("sent-request-id", id1),
- zap.Uint64("received-request-id", id2),
- )
- } else {
- plog.Warningf("ignored out-of-date read index response; local node read indexes queueing up and waiting to be in sync with leader (request ID want %d, got %d)", id1, id2)
- }
- slowReadIndex.Inc()
- }
- case <-leaderChangedNotifier:
- timeout = true
- readIndexFailed.Inc()
- // return a retryable error.
- nr.notify(ErrLeaderChanged)
- case <-time.After(s.Cfg.ReqTimeout()):
- if lg != nil {
- lg.Warn("timed out waiting for read index response (local node might have slow network)", zap.Duration("timeout", s.Cfg.ReqTimeout()))
- } else {
- plog.Warningf("timed out waiting for read index response (local node might have slow network)")
- }
- nr.notify(ErrTimeout)
- timeout = true
- slowReadIndex.Inc()
- case <-s.stopping:
- return
- }
- }
- if !done {
- continue
- }
-
- if ai := s.getAppliedIndex(); ai < rs.Index {
- select {
- case <-s.applyWait.Wait(rs.Index):
- case <-s.stopping:
- return
- }
- }
- // unblock all l-reads requested at indices before rs.Index
- nr.notify(nil)
- }
-}
-
-func (s *EtcdServer) linearizableReadNotify(ctx context.Context) error {
- s.readMu.RLock()
- nc := s.readNotifier
- s.readMu.RUnlock()
-
- // signal linearizable loop for current notify if it hasn't been already
- select {
- case s.readwaitc <- struct{}{}:
- default:
- }
-
- // wait for read state notification
- select {
- case <-nc.c:
- return nc.err
- case <-ctx.Done():
- return ctx.Err()
- case <-s.done:
- return ErrStopped
- }
-}
-
-func (s *EtcdServer) AuthInfoFromCtx(ctx context.Context) (*auth.AuthInfo, error) {
- authInfo, err := s.AuthStore().AuthInfoFromCtx(ctx)
- if authInfo != nil || err != nil {
- return authInfo, err
- }
- if !s.Cfg.ClientCertAuthEnabled {
- return nil, nil
- }
- authInfo = s.AuthStore().AuthInfoFromTLS(ctx)
- return authInfo, nil
-
-}