@@ -168,6 +168,28 @@ func (c *Client) CheckForUpdate(ctx context.Context, creds Credentials) (bool, e
168168 return result .Data .UpdateAvailable , nil
169169}
170170
171+ // LongPollWait sends a signed message to a DNClient API endpoint that will block, returning only
172+ // if there is an action the client should take before the timeout (config updates, debug commands)
173+ func (c * Client ) LongPollWait (ctx context.Context , creds Credentials , supportedActions []string ) (string , error ) {
174+ value , err := json .Marshal (message.LongPollWaitRequest {
175+ SupportedActions : supportedActions ,
176+ })
177+ if err != nil {
178+ return "" , fmt .Errorf ("failed to marshal DNClient message: %s" , err )
179+ }
180+
181+ respBody , err := c .postDNClient (ctx , message .LongPollWait , value , creds .HostID , creds .Counter , creds .PrivateKey )
182+ if err != nil {
183+ return "" , fmt .Errorf ("failed to post message to dnclient api: %w" , err )
184+ }
185+ result := message.LongPollWaitResponseWrapper {}
186+ err = json .Unmarshal (respBody , & result )
187+ if err != nil {
188+ return "" , fmt .Errorf ("failed to interpret API response: %s" , err )
189+ }
190+ return result .Data .Action , nil
191+ }
192+
171193func (c * Client ) DoUpdateWithTimeout (ctx context.Context , t time.Duration , creds Credentials ) ([]byte , []byte , * Credentials , error ) {
172194 toCtx , cancel := context .WithTimeout (ctx , t )
173195 defer cancel ()
0 commit comments