introduce EmptyReadRequest for status_endpoint (#12653)
Co-authored-by: Daniel Nephin <dnephin@hashicorp.com>
This commit is contained in:
parent
0ae60adff9
commit
0fd6cdc900
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue