mirror of https://github.com/reiseburo/whoas
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:
parent
1b44cd2c1e
commit
aa84bad7b9
|
@ -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
|
||||
|
|
|
@ -2,5 +2,5 @@ package com.github.lookout.whoas;
|
|||
|
||||
|
||||
public interface QueueAction {
|
||||
public void call(HookRequest request);
|
||||
public void call(HookRequest request) throws Exception;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue