diff --git a/agent/consul/stats_fetcher.go b/agent/consul/stats_fetcher.go index d486ae504b..334472be5c 100644 --- a/agent/consul/stats_fetcher.go +++ b/agent/consul/stats_fetcher.go @@ -5,11 +5,12 @@ import ( "net" "sync" - "github.com/hashicorp/consul/agent/pool" - "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/go-hclog" "github.com/hashicorp/raft" autopilot "github.com/hashicorp/raft-autopilot" + + "github.com/hashicorp/consul/agent/pool" + "github.com/hashicorp/consul/agent/structs" ) // StatsFetcher has two functions for autopilot. First, lets us fetch all the @@ -42,7 +43,7 @@ func NewStatsFetcher(logger hclog.Logger, pool *pool.ConnPool, datacenter string // RPC to each server, so we let it finish and then clean up the in-flight // tracking. func (f *StatsFetcher) fetch(server *autopilot.Server, replyCh chan *autopilot.ServerStats) { - var args struct{} + var args EmptyReadRequest var reply structs.RaftStats // defer some cleanup to notify everything else that the fetching is no longer occurring diff --git a/agent/consul/status_endpoint.go b/agent/consul/status_endpoint.go index ac0dc03147..b82baf8426 100644 --- a/agent/consul/status_endpoint.go +++ b/agent/consul/status_endpoint.go @@ -13,7 +13,7 @@ type Status struct { } // Ping is used to just check for connectivity -func (s *Status) Ping(args struct{}, reply *struct{}) error { +func (s *Status) Ping(args EmptyReadRequest, reply *struct{}) error { return nil } @@ -55,8 +55,16 @@ func (s *Status) Peers(args *structs.DCSpecificRequest, reply *[]string) error { return nil } -// Used by Autopilot to query the raft stats of the local server. -func (s *Status) RaftStats(args struct{}, reply *structs.RaftStats) error { +// EmptyReadRequest implements the interface used by middleware.RequestRecorder +// to communicate properties of requests. +type EmptyReadRequest struct{} + +func (e EmptyReadRequest) IsRead() bool { + return true +} + +// RaftStats is used by Autopilot to query the raft stats of the local server. +func (s *Status) RaftStats(args EmptyReadRequest, reply *structs.RaftStats) error { stats := s.server.raft.Stats() var err error