One way to accomplish this would be to pass in a piece of state controlled by an atom to the dochan function in threadpool.clj. This function controls the loop that pulls commands off of the internal queue (command-chan) and then calls the function to process and store those commands. We could have the function check the state of the atom and refuse to pull more commands off of the queue if it was set to false or something along those lines. We'll want to make sure to add some sort of slow down to this check so it doesn't run too quickly if the atom is set to block commands. The docahn func is used here during the start of the command service. We could add a TK service method to the PuppetDBCommandDispatcher service which can flip the atom back and forth to allow/block command processing. Acceptance criteria: * A new TK service method which allows the toggling of command processing, this should be possible from both the FOSS pdb repo and from the pdbext repo * A test which shows that command processing can be halted by using this TK service method Testing notes: It's possible that there could be a race between setting the atom and any inflight commands when testing. It's probably fine to block command processing first, submit commands, and then check that they're still waiting to be processed without worrying about testing this for a command queue with in flight commands. |