From: Simon Ruderich Date: Tue, 18 May 2021 16:36:11 +0000 (+0200) Subject: frontend: add Loop.HostSyncMsg() X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=cd7436284aa538d6a8a83811a33b3a3cc32d87a3;p=safcm%2Fsafcm.git frontend: add Loop.HostSyncMsg() --- diff --git a/cmd/safcm/sync_sync.go b/cmd/safcm/sync_sync.go index bc11043..01e712c 100644 --- a/cmd/safcm/sync_sync.go +++ b/cmd/safcm/sync_sync.go @@ -35,14 +35,10 @@ func (s *Sync) hostSync(conn *rpc.Conn, detectedGroups []string) error { if err != nil { return err } - x, err := s.loop.SendRecv(s, conn, req) + resp, err := s.loop.HostSyncMsg(s, conn, req) if err != nil { return err } - resp, ok := x.(safcm.MsgSyncResp) - if !ok { - return fmt.Errorf("unexpected response %v", x) - } // Display changes c := frontend.Changes{ diff --git a/frontend/conn.go b/frontend/conn.go index 02dfe8b..01486ff 100644 --- a/frontend/conn.go +++ b/frontend/conn.go @@ -64,3 +64,20 @@ func (l *Loop) HostInfoMsg(host Host, conn *rpc.Conn, req safcm.MsgInfoReq) ( } return resp, nil } + +// HostSyncMsg sends a MsgSyncReq for host via conn and returns the resulting +// MsgSyncResp. +func (l *Loop) HostSyncMsg(host Host, conn *rpc.Conn, req safcm.MsgSyncReq) ( + safcm.MsgSyncResp, error) { + + var empty safcm.MsgSyncResp + x, err := l.SendRecv(host, conn, req) + if err != nil { + return empty, err + } + resp, ok := x.(safcm.MsgSyncResp) + if !ok { + return empty, fmt.Errorf("unexpected response %v", x) + } + return resp, nil +}