From 329d76fd0e144e095e340e5ff9eadc1650a8637b Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Wed, 25 Mar 2020 16:42:43 -0400 Subject: [PATCH] Remove SnapshotRPC passthrough The caller has access to the delegate, so we do not gain anything by wrapping the call in Agent. --- agent/agent.go | 9 --------- agent/snapshot_endpoint.go | 4 ++-- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/agent/agent.go b/agent/agent.go index 2567857744..581199f229 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -1715,15 +1715,6 @@ func (a *Agent) RPC(method string, args interface{}, reply interface{}) error { return a.delegate.RPC(method, args, reply) } -// SnapshotRPC performs the requested snapshot RPC against the Consul server in -// a streaming manner. The contents of in will be read and passed along as the -// payload, and the response message will determine the error status, and any -// return payload will be written to out. -func (a *Agent) SnapshotRPC(args *structs.SnapshotRequest, in io.Reader, out io.Writer, - replyFn structs.SnapshotReplyFn) error { - return a.delegate.SnapshotRPC(args, in, out, replyFn) -} - // Leave is used to prepare the agent for a graceful shutdown func (a *Agent) Leave() error { return a.delegate.Leave() diff --git a/agent/snapshot_endpoint.go b/agent/snapshot_endpoint.go index 7c1bed366d..483eae18d7 100644 --- a/agent/snapshot_endpoint.go +++ b/agent/snapshot_endpoint.go @@ -31,14 +31,14 @@ func (s *HTTPServer) Snapshot(resp http.ResponseWriter, req *http.Request) (inte // Don't bother sending any request body through since it will // be ignored. var null bytes.Buffer - if err := s.agent.SnapshotRPC(&args, &null, resp, replyFn); err != nil { + if err := s.agent.delegate.SnapshotRPC(&args, &null, resp, replyFn); err != nil { return nil, err } return nil, nil case "PUT": args.Op = structs.SnapshotRestore - if err := s.agent.SnapshotRPC(&args, req.Body, resp, nil); err != nil { + if err := s.agent.delegate.SnapshotRPC(&args, req.Body, resp, nil); err != nil { return nil, err } return nil, nil