mirror of https://github.com/reiseburo/whoas
Start adding some stub classes with the needed data attached to them
Relates to #2
This commit is contained in:
parent
9abf01cc04
commit
d9ee4411dc
10
build.gradle
10
build.gradle
|
@ -24,7 +24,17 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
compile 'org.codehaus.groovy:groovy-all:2.3.9+'
|
||||
compile 'org.glassfish.jersey.core:jersey-client:2.6+'
|
||||
|
||||
/* Needed for serializing requests to JSON and back */
|
||||
compile 'com.fasterxml.jackson.core:jackson-databind:2.3.3+'
|
||||
/* Needed for better time management/sanity */
|
||||
compile 'joda-time:joda-time:2.6+'
|
||||
|
||||
|
||||
testCompile 'org.spockframework:spock-core:0.7-groovy-2.0'
|
||||
testCompile 'cglib:cglib-nodep:2.2.+'
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package com.github.lookout.whoas
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import org.joda.time.DateTime
|
||||
|
||||
class HookRequest {
|
||||
private Long retries
|
||||
private String url
|
||||
private String postData
|
||||
private DateTime deliverAfter
|
||||
|
||||
|
||||
/* Constructor for Jackson */
|
||||
HookRequest() { }
|
||||
|
||||
@JsonProperty
|
||||
Long getRetries() {
|
||||
return this.retries
|
||||
}
|
||||
|
||||
@JsonProperty
|
||||
String getUrl() {
|
||||
return this.url
|
||||
}
|
||||
|
||||
@JsonProperty
|
||||
String getPostData() {
|
||||
return this.postData
|
||||
}
|
||||
|
||||
@JsonProperty
|
||||
String getDeliverAfter() {
|
||||
return this.deliverAfter.toString()
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.github.lookout.whoas
|
||||
|
||||
|
||||
/**
|
||||
* Interface defining how 'HookQueue' providers should behave
|
||||
*
|
||||
* This allows for different queueing implementations behind whoas
|
||||
*/
|
||||
interface IHookQueue {
|
||||
/**
|
||||
* Return the size of the queue, may not be implemented by some providers
|
||||
* in which case it will return -1
|
||||
*/
|
||||
Long getSize()
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void pop(Closure action)
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
Boolean enqueue(HookRequest request)
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.github.lookout.whoas
|
||||
|
||||
|
||||
import java.util.concurrent.LinkedBlockingQueue
|
||||
|
||||
/**
|
||||
* A simple in-memory queue that offers no persistence between process restarts
|
||||
*/
|
||||
class InMemoryQueue implements IHookQueue {
|
||||
private LinkedBlockingQueue internalQueue
|
||||
|
||||
InMemoryQueue() {
|
||||
this.internalQueue = new LinkedBlockingQueue()
|
||||
}
|
||||
|
||||
Long getSize() {
|
||||
return this.internalQueue.size()
|
||||
}
|
||||
|
||||
void pop(Closure action) {
|
||||
}
|
||||
|
||||
Boolean enqueue(HookRequest request) {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package com.github.lookout.whoas
|
||||
|
||||
import spock.lang.*
|
||||
|
||||
class HookRequestSpec extends Specification {
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.github.lookout.whoas
|
||||
|
||||
import spock.lang.*
|
||||
|
||||
class InMemoryQueueSpec extends Specification {
|
||||
|
||||
def "getSize() should return 0 by default"() {
|
||||
given:
|
||||
InMemoryQueue queue = new InMemoryQueue()
|
||||
|
||||
expect:
|
||||
queue.size == 0
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue