Move SequentialHookRunner into Java

This required a bit more refactoring of some interfaces which I didn't do quite
right previously
This commit is contained in:
R. Tyler Croy 2015-04-03 07:44:42 -07:00
parent 1b44cd2c1e
commit aa84bad7b9
4 changed files with 32 additions and 24 deletions

View File

@ -24,7 +24,7 @@ public abstract class AbstractHookRunner {
}
/** Block forever and run the runner's runloop. */
public abstract void run();
public abstract void run() throws Exception;
/**
* Tell the runloop to stop

View File

@ -2,5 +2,5 @@ package com.github.lookout.whoas;
public interface QueueAction {
public void call(HookRequest request);
public void call(HookRequest request) throws Exception;
}

View File

@ -1,22 +0,0 @@
package com.github.lookout.whoas
import groovy.transform.InheritConstructors
/**
* The SequentialHookRunner is will dequeue HookRequest items from the
* configured AbstractHookQueue and publish those webhooks sequentially.
*
* This is the simplest and slowest hook runner
*/
@InheritConstructors
class SequentialHookRunner extends AbstractHookRunner {
/** Execute an infinitely blocking single-threaded runloop */
void run() {
while (this.keepGoing) {
this.queue.pop { HookRequest request ->
this.publisher.publish(request)
}
}
}
}

View File

@ -0,0 +1,30 @@
package com.github.lookout.whoas;
/**
* The SequentialHookRunner is will dequeue HookRequest items from the
* configured AbstractHookQueue and publish those webhooks sequentially.
*
* This is the simplest and slowest hook runner
*/
public class SequentialHookRunner extends AbstractHookRunner {
public SequentialHookRunner(AbstractHookQueue hookQueue) {
super(hookQueue);
}
public SequentialHookRunner(AbstractHookQueue hookQueue,
Publisher hookPublisher) {
super(hookQueue, hookPublisher);
}
/** Execute an infinitely blocking single-threaded runloop */
public void run() throws Exception {
while (this.keepGoing) {
this.queue.pop(new QueueAction() {
@Override
public void call(HookRequest request) throws InterruptedException {
publisher.publish(request);
}
});
}
}
}