@@ -197,6 +197,44 @@ static struct command_result *json_checkthis(struct command *cmd,
197197 return send_outreq (req );
198198}
199199
200+ static struct command_result * spam_done (struct command * cmd , void * unused )
201+ {
202+ return command_success (cmd , json_out_obj (cmd , NULL , NULL ));
203+ }
204+
205+ static struct command_result * spam_errcb (struct command * cmd ,
206+ const char * method ,
207+ const char * buf ,
208+ const jsmntok_t * tok ,
209+ void * unused )
210+ {
211+ plugin_err (cmd -> plugin , "%.*s" ,
212+ json_tok_full_len (tok ),
213+ json_tok_full (buf , tok ));
214+ }
215+
216+ static struct command_result * json_spamcommand (struct command * cmd ,
217+ const char * buf ,
218+ const jsmntok_t * params )
219+ {
220+ u64 * iterations ;
221+ struct request_batch * batch ;
222+
223+ if (!param (cmd , buf , params ,
224+ p_req ("iterations" , param_u64 , & iterations ),
225+ NULL ))
226+ return command_param_failed ();
227+
228+ batch = request_batch_new (cmd , NULL , spam_errcb , spam_done , NULL );
229+ for (size_t i = 0 ; i < * iterations ; i ++ ) {
230+ struct out_req * req = add_to_batch (cmd , batch , "batching" );
231+ json_add_bool (req -> js , "enable" , true);
232+ send_outreq (req );
233+ }
234+ return batch_done (cmd , batch );
235+ }
236+
237+
200238static char * set_dynamic (struct plugin * plugin ,
201239 const char * arg ,
202240 bool check_only ,
@@ -270,6 +308,10 @@ static const struct plugin_command commands[] = { {
270308 "checkthis" ,
271309 json_checkthis ,
272310 },
311+ {
312+ "spamcommand" ,
313+ json_spamcommand ,
314+ },
273315};
274316
275317static const char * before [] = { "dummy" , NULL };
0 commit comments