agent: move the SnapshotReplyFn out of the way

When splitting up the consul package into server and client
the SnapshotReplyFn needs to be in a separate package to avoid
a circular dependency.
This commit is contained in:
Frank Schroeder 2017-06-15 11:50:28 +02:00 committed by Frank Schröder
parent b805a79078
commit e930b55f71
4 changed files with 8 additions and 8 deletions

View File

@ -68,7 +68,7 @@ type delegate interface {
JoinLAN(addrs []string) (n int, err error) JoinLAN(addrs []string) (n int, err error)
RemoveFailedNode(node string) error RemoveFailedNode(node string) error
RPC(method string, args interface{}, reply interface{}) error RPC(method string, args interface{}, reply interface{}) error
SnapshotRPC(args *structs.SnapshotRequest, in io.Reader, out io.Writer, replyFn consul.SnapshotReplyFn) error SnapshotRPC(args *structs.SnapshotRequest, in io.Reader, out io.Writer, replyFn structs.SnapshotReplyFn) error
Shutdown() error Shutdown() error
Stats() map[string]map[string]string Stats() map[string]map[string]string
} }
@ -1080,7 +1080,7 @@ func (a *Agent) RPC(method string, args interface{}, reply interface{}) error {
// payload, and the response message will determine the error status, and any // payload, and the response message will determine the error status, and any
// return payload will be written to out. // return payload will be written to out.
func (a *Agent) SnapshotRPC(args *structs.SnapshotRequest, in io.Reader, out io.Writer, func (a *Agent) SnapshotRPC(args *structs.SnapshotRequest, in io.Reader, out io.Writer,
replyFn consul.SnapshotReplyFn) error { replyFn structs.SnapshotReplyFn) error {
return a.delegate.SnapshotRPC(args, in, out, replyFn) return a.delegate.SnapshotRPC(args, in, out, replyFn)
} }

View File

@ -341,15 +341,11 @@ func (c *Client) RPC(method string, args interface{}, reply interface{}) error {
return nil return nil
} }
// SnapshotReplyFn gets a peek at the reply before the snapshot streams, which
// is useful for setting headers.
type SnapshotReplyFn func(reply *structs.SnapshotResponse) error
// SnapshotRPC sends the snapshot request to one of the servers, reading from // SnapshotRPC sends the snapshot request to one of the servers, reading from
// the streaming input and writing to the streaming output depending on the // the streaming input and writing to the streaming output depending on the
// operation. // operation.
func (c *Client) SnapshotRPC(args *structs.SnapshotRequest, in io.Reader, out io.Writer, func (c *Client) SnapshotRPC(args *structs.SnapshotRequest, in io.Reader, out io.Writer,
replyFn SnapshotReplyFn) error { replyFn structs.SnapshotReplyFn) error {
// Locate a server to make the request to. // Locate a server to make the request to.
server := c.servers.FindServer() server := c.servers.FindServer()

View File

@ -937,7 +937,7 @@ func (s *Server) RPC(method string, args interface{}, reply interface{}) error {
// SnapshotRPC dispatches the given snapshot request, reading from the streaming // SnapshotRPC dispatches the given snapshot request, reading from the streaming
// input and writing to the streaming output depending on the operation. // input and writing to the streaming output depending on the operation.
func (s *Server) SnapshotRPC(args *structs.SnapshotRequest, in io.Reader, out io.Writer, func (s *Server) SnapshotRPC(args *structs.SnapshotRequest, in io.Reader, out io.Writer,
replyFn SnapshotReplyFn) error { replyFn structs.SnapshotReplyFn) error {
// Perform the operation. // Perform the operation.
var reply structs.SnapshotResponse var reply structs.SnapshotResponse

View File

@ -7,6 +7,10 @@ const (
SnapshotRestore SnapshotRestore
) )
// SnapshotReplyFn gets a peek at the reply before the snapshot streams, which
// is useful for setting headers.
type SnapshotReplyFn func(reply *SnapshotResponse) error
// SnapshotRequest is used as a header for a snapshot RPC request. This will // SnapshotRequest is used as a header for a snapshot RPC request. This will
// precede any streaming data that's part of the request and is JSON-encoded on // precede any streaming data that's part of the request and is JSON-encoded on
// the wire. // the wire.