Skip to content

Commit 04df769

Browse files
committed
Updated to gradle 4 and started the transformation into its own project
1 parent fd653d0 commit 04df769

25 files changed

+1361
-1072
lines changed

README.md

Lines changed: 34 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
# Vert.x `DataLoader`
22

3-
[![Build Status](https://travis-ci.org/engagingspaces/vertx-dataloader.svg?branch=master)](https://travis-ci.org/engagingspaces/vertx-dataloader/)  
4-
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/ec906aa3a12147e28b69b93e3a9d9bf7)](https://www.codacy.com/app/engagingspaces/vertx-dataloader?utm_source=github.com&utm_medium=referral&utm_content=engagingspaces/vertx-dataloader&utm_campaign=Badge_Grade)  
5-
[![Apache licensed](https://img.shields.io/hexpm/l/plug.svg?maxAge=2592000)](https://github.com/engagingspaces/vertx-dataloader/blob/master/LICENSE)  
6-
[ ![Download](https://api.bintray.com/packages/engagingspaces/maven/vertx-dataloader/images/download.svg) ](https://bintray.com/engagingspaces/maven/vertx-dataloader/_latestVersion)
3+
[![Build Status](https://travis-ci.org/bbakerman/java-dataloader.svg?branch=master)](https://travis-ci.org/bbakerman/java-dataloader/)  
4+
[![Apache licensed](https://img.shields.io/hexpm/l/plug.svg?maxAge=2592000)](https://github.com/bbakerman/java-dataloader/blob/master/LICENSE)  
5+
[ ![Download](https://api.bintray.com/packages/bbakerman/maven/kava-dataloader/images/download.svg) ](https://bintray.com/bbakerman/maven/java-dataloader/_latestVersion)
76

8-
![vertx-dataloader-concepts](https://cloud.githubusercontent.com/assets/5111931/17837825/f5748bfc-67bd-11e6-9c7a-d407bb92c3d9.png)
97

10-
This small and simple utility library is a port of [Facebook DataLoader](https://github.com/facebook/dataloader)
11-
to Java 8 for use with [Vert.x](http://vertx.io). It can serve as integral part of your application's data layer to provide a
8+
This small and simple utility library is a Pure Java 8 port of [Facebook DataLoader](https://github.com/facebook/dataloader).
9+
It can serve as integral part of your application's data layer to provide a
1210
consistent API over various back-ends and reduce message communication overhead through batching and caching.
1311

14-
An important use case for `DataLoader` is improving the efficiency of GraphQL query execution, but there are
12+
An important use case for `java-dataloader` is improving the efficiency of GraphQL query execution, but there are
1513
many other use cases where you can benefit from using this utility.
1614

1715
Most of the code is ported directly from Facebook's reference implementation, with one IMPORTANT adaptation to make
18-
it work for Java 8 and Vert.x. ([more on this below](manual-dispatching)).
16+
it work for Java 8. ([more on this below](manual-dispatching)).
1917

2018
But before reading on, be sure to take a short dive into the
2119
[original documentation](https://github.com/facebook/dataloader/blob/master/README.md) provided by Lee Byron (@leebyron)
@@ -40,24 +38,24 @@ and Nicholas Schrock (@schrockn) from [Facebook](https://www.facebook.com/), the
4038

4139
## Features
4240

43-
Vert.x `DataLoader` is a feature-complete port of the Facebook reference implementation with [one major difference](#manual-dispatching). These features are:
41+
`java-dataloader` is a feature-complete port of the Facebook reference implementation with [one major difference](#manual-dispatching). These features are:
4442

4543
- Simple, intuitive API, using generics and fluent coding
4644
- Define batch load function with lambda expression
4745
- Schedule a load request in queue for batching
4846
- Add load requests from anywhere in code
49-
- Request returns [`Future<V>`](http://vertx.io/docs/apidocs/io/vertx/core/Future.html) of requested value
50-
- Can create multiple requests at once, returns [`CompositeFuture`](http://vertx.io/docs/apidocs/io/vertx/core/CompositeFuture.html)
47+
- Request returns a [`CompleteableFuture<V>`](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html) of the requested value
48+
- Can create multiple requests at once, returns a `CombinedFutures` object
5149
- Caches load requests, so data is only fetched once
5250
- Can clear individual cache keys, so data is fetched on next batch queue dispatch
5351
- Can prime the cache with key/values, to avoid data being fetched needlessly
5452
- Can configure cache key function with lambda expression to extract cache key from complex data loader key types
55-
- Dispatch load request queue after batch is prepared, also returns [`CompositeFuture`](http://vertx.io/docs/apidocs/io/vertx/core/CompositeFuture.html)
53+
- Dispatch load request queue after batch is prepared, also returns `CombinedFutures`
5654
- Individual batch futures complete / resolve as batch is processed
57-
- `CompositeFuture`s results are ordered according to insertion order of load requests
55+
- `CombinedFutures` results are ordered according to insertion order of load requests
5856
- Deals with partial errors when a batch future fails
5957
- Can disable batching and/or caching in configuration
60-
- Can supply your own [`CacheMap<K, V>`](https://github.com/engagingspaces/vertx-dataloader/blob/master/src/main/java/io/engagingspaces/vertx/dataloader/CacheMap.java) implementations
58+
- Can supply your own [`CacheMap<K, V>`](https://github.com/bbakerman/java-dataloader/blob/master/src/main/java/io/engagingspaces/vertx/dataloader/CacheMap.java) implementations
6159
- Has very high test coverage (see [Acknowledgements](#acknowlegdements))
6260

6361
## Differences to reference implementation
@@ -68,10 +66,6 @@ The original data loader was written in Javascript for NodeJS. NodeJS is single-
6866
asynchronous logic by invoking functions on separate threads in an event loop, as explained
6967
[in this post](http://stackoverflow.com/a/19823583/3455094) on StackOverflow.
7068

71-
[Vert.x](http://vertx.io) on the other hand also uses an event loop ([that you should not block!!](http://vertx.io/docs/vertx-core/java/#golden_rule)), but comes
72-
with actor-like [`Verticle`](http://vertx.io/docs/vertx-core/java/#_verticles)s and a
73-
distributed [`EventBus`](http://vertx.io/docs/vertx-core/java/#event_bus) that make it inherently asynchronous, and non-blocking.
74-
7569
Now in NodeJS generates so-call 'ticks' in which queued functions are dispatched for execution, and Facebook `DataLoader` uses
7670
the `nextTick()` function in NodeJS to _automatically_ dequeue load requests and send them to the batch execution function for processing.
7771

@@ -80,10 +74,10 @@ And here there is an **IMPORTANT DIFFERENCE** compared to how _this_ data loader
8074
In NodeJS the batch preparation will not affect the asynchronous processing behaviour in any way. It will just prepare
8175
batches in 'spare time' as it were.
8276

83-
This is different in Vert.x as you will actually _delay_ the execution of your load requests, until the moment where you make a call
77+
This is different in Java as you will actually _delay_ the execution of your load requests, until the moment where you make a call
8478
to `dataLoader.dispatch()` in comparison to when you would just handle futures directly.
8579

86-
Does this make Java `DataLoader` any less useful than the reference implementation? I would argue this is not the case,
80+
Does this make Java `DataLoader` any less useful than the reference implementation? We would argue this is not the case,
8781
and there are also gains to this different mode of operation:
8882

8983
- In contrast to the NodeJS implementation _you_ as developer are in full control of when batches are dispatched
@@ -97,7 +91,7 @@ in the load request queue will never be batched, and thus _will never complete_!
9791

9892
### Installing
9993

100-
Gradle users configure the `vertx-dataloader` dependency in `build.gradle`:
94+
Gradle users configure the `java-dataloader` dependency in `build.gradle`:
10195

10296
```
10397
repositories {
@@ -107,7 +101,7 @@ repositories {
107101
}
108102
109103
dependencies {
110-
compile 'io.engagingspaces:vertx-dataloader:1.0.0'
104+
compile 'org.dataloader:java-dataloader:1.0.0'
111105
}
112106
```
113107

@@ -119,36 +113,8 @@ To build from source use the Gradle wrapper:
119113
./gradlew clean build
120114
```
121115

122-
Or when using Maven add the following repository to your `pom.xml`:
123-
124-
```
125-
<repositories>
126-
<repository>
127-
<snapshots>
128-
<enabled>false</enabled>
129-
</snapshots>
130-
<id>central</id>
131-
<name>bintray</name>
132-
<url>http://jcenter.bintray.com</url>
133-
</repository>
134-
</repositories>
135-
```
136-
137-
And add the dependency to `vertx-dataloader`:
138-
139-
```
140-
<dependency>
141-
<groupId>io.engagingspaces</groupId>
142-
<artifactId>vertx-dataloader</artifactId>
143-
<version>1.0.0</version>
144-
<type>pom</type>
145-
</dependency>
146-
```
147-
148116
### Using
149117

150-
Please take a look at the example project [vertx-graphql-example](https://github.com/bmsantos/vertx-graphql-example)
151-
created by [Bruno Santos](https://github.com/bmsantos).
152118

153119
## Project plans
154120

@@ -160,9 +126,6 @@ created by [Bruno Santos](https://github.com/bmsantos).
160126

161127
- Tests on job queue ordering need refactoring to Futures, one test currently omitted
162128

163-
### Future ideas
164-
165-
- `CompletableFuture` implementation
166129

167130
## Other information sources
168131

@@ -178,21 +141,31 @@ enhancement requests, or better yet, contribute directly by creating a PR.
178141
When reporting an issue, please add a detailed instruction, and if possible a code snippet or test that can be used
179142
as a reproducer of your problem.
180143

181-
When creating a pull request, please adhere to the Vert.x coding style where possible, and create tests with your
144+
When creating a pull request, please adhere to the current coding style where possible, and create tests with your
182145
code so it keeps providing an excellent test coverage level. PR's without tests may not be accepted unless they only
183146
deal with minor changes.
184147

185148
## Acknowledgements
186149

150+
This library was originally written for use within a [VertX world](http://vertx.io/) and it used the vertx-core `Future` classes to implement
151+
itself. All the heavy lifting has been done by this project : [vertx-dataloader](https://github.com/engagingspaces/vertx-dataloader)
152+
including the extensive testing.
153+
154+
187155
This library is entirely inspired by the great works of [Lee Byron](https://github.com/leebyron) and
188-
[Nicholas Schrock](https://github.com/schrockn) from [Facebook](https://www.facebook.com/) whom I like to thank, and
156+
[Nicholas Schrock](https://github.com/schrockn) from [Facebook](https://www.facebook.com/) whom we would like to thank, and
189157
especially @leebyron for taking the time and effort to provide 100% coverage on the codebase. A set of tests which
190-
I also ported.
158+
were also ported.
159+
160+
This particular port was done to reduce the dependency on Vertx and to write a pure Java 8 implementation with no dependencies and also
161+
to use the more normative Java CompletableFuture. [vertx-core](http://vertx.io/docs/vertx-core/java/) is not a lightweight library by any means
162+
so having a pure Java 8 implementation is very desirable.
163+
191164

192165
## Licensing
193166

194-
This project [vertx-dataloader](https://github.com/engagingspaces/vertx-dataloader) is licensed under the
195-
[Apache Commons v2.0](https://github.com/engagingspaces/vertx-dataloader/LICENSE) license.
167+
This project is licensed under the
168+
[Apache Commons v2.0](https://www.apache.org/licenses/LICENSE-2.0) license.
196169

197-
Copyright &copy; 2016 Arnold Schrijver and other
198-
[contributors](https://github.com/engagingspaces/vertx-dataloader/graphs/contributors)
170+
Copyright &copy; 2016 Arnold Schrijver and others
171+
[contributors](https://github.com/bbakerman/java-dataloader/graphs/contributors)

build.gradle

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@ publishing {
1818
}
1919

2020
ext {
21-
vertxVersion = '3.4.0'
2221
junitVersion = '4.12'
2322
}
2423

2524
apply plugin: 'java'
26-
apply from: "$projectDir/gradle/coverage.gradle"
2725
apply from: "$projectDir/gradle/publishing.gradle"
2826

2927
repositories {
@@ -35,39 +33,22 @@ repositories {
3533
}
3634
}
3735

38-
group = 'io.engagingspaces'
36+
group = 'org.dataloader'
3937
version = '1.0.0'
4038

41-
task docProcessing(type: JavaCompile, group: 'build') {
42-
source = sourceSets.main.java
43-
classpath = configurations.compile + configurations.compileOnly
44-
destinationDir = project.file('src/main/asciidoc')
45-
options.compilerArgs = [
46-
"-proc:only",
47-
"-processor", "io.vertx.docgen.JavaDocGenProcessor",
48-
"-Adocgen.output=$buildDir/asciidoc",
49-
"-Adocgen.source=$projectDir/src/main/asciidoc/index.adoc"
50-
]
51-
}
52-
5339
compileJava {
5440
sourceCompatibility = 1.8
5541
targetCompatibility = 1.8
5642

57-
dependsOn project.tasks.docProcessing
58-
options.compilerArgs = [ "-Xlint:unchecked", "-Xdiags:verbose" ]
43+
options.compilerArgs = ["-Xlint:unchecked", "-Xdiags:verbose"]
5944
}
6045

6146
dependencies {
62-
compile "io.vertx:vertx-core:$vertxVersion"
63-
compileOnly "io.vertx:vertx-docgen:$vertxVersion"
64-
6547
testCompile "junit:junit:$junitVersion"
6648
testCompile 'org.awaitility:awaitility:2.0.0'
67-
testCompile "io.vertx:vertx-unit:$vertxVersion"
6849
}
6950

7051
task wrapper(type: Wrapper) {
71-
gradleVersion = '2.14'
72-
distributionUrl = "http://services.gradle.org/distributions/gradle-2.14-all.zip"
52+
gradleVersion = '4.0'
53+
distributionUrl = "http://services.gradle.org/distributions/gradle-4.0-all.zip"
7354
}

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
projectTitle = Vert.x Dataloader
2-
projectDescription = Port of Facebook Dataloader for Java and Vert.x
1+
projectTitle = Java Dataloader
2+
projectDescription = Port of Facebook Dataloader for Java

gradle/coverage.gradle

Lines changed: 0 additions & 19 deletions
This file was deleted.

gradle/publishing.gradle

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apply plugin: 'com.jfrog.bintray'
44
publishing {
55
repositories {
66
maven {
7-
url 'https://dl.bintray.com/engagingspaces/maven'
7+
url 'http://dl.bintray.com/bbakerman/java-dataloader'
88
}
99
}
1010
}
@@ -41,7 +41,7 @@ publishing {
4141
def builder = delegate
4242
builder.name projectTitle
4343
builder.description projectDescription
44-
builder.url 'https://github.com/engagingspaces/vertx-dataloader'
44+
builder.url 'https://github.com/bbakerman/java-dataloader'
4545
builder.licenses {
4646
builder.license {
4747
builder.name 'The Apache Software License, Version 2.0'
@@ -50,18 +50,9 @@ publishing {
5050
}
5151
}
5252
builder.scm {
53-
builder.url 'scm:[email protected]/engagingspaces/vertx-dataloader.git'
54-
builder.connection '[email protected]/engagingspaces/vertx-dataloader.git'
55-
builder.developerConnection '[email protected]/engagingspaces/vertx-dataloader.git'
56-
}
57-
builder.developers {
58-
builder.developer {
59-
builder.id 'aschrijver'
60-
builder.name 'Arnold Schrijver'
61-
builder.url 'https://github.com/aschrijver/'
62-
builder.organization 'engagingspaces'
63-
builder.organizationUrl 'https://github.com/engagingspaces/'
64-
}
53+
builder.url 'scm:[email protected]:bbakerman/java-dataloader.git'
54+
builder.connection '[email protected]:bbakerman/java-dataloader.git'
55+
builder.developerConnection '[email protected]:bbakerman/java-dataloader.git'
6556
}
6657
}
6758
}
@@ -78,14 +69,14 @@ bintray {
7869
repo = 'maven'
7970
name = "$project.name"
8071
desc = projectDescription
81-
userOrg = 'engagingspaces'
82-
websiteUrl = 'https://github.com/engagingspaces/vertx-dataloader'
83-
issueTrackerUrl = 'https://github.com/engagingspaces/vertx-dataloader/issues'
72+
userOrg = 'bbakerman'
73+
websiteUrl = 'https://github.com/bbakerman/java-dataloader'
74+
issueTrackerUrl = 'https://github.com/bbakerman/java-dataloader/issues'
8475
licenses = ['Apache-2.0']
85-
vcsUrl = 'https://github.com/engagingspaces/vertx-dataloader.git'
86-
labels = ['vertx', 'batch', 'batch-loading', 'completablefuture', 'future', 'asynchronous',
76+
vcsUrl = 'https://github.com/bbakerman/java-dataloader.git'
77+
labels = ['batch', 'batch-loading', 'completablefuture', 'future', 'asynchronous',
8778
'data-loader', 'dataloader', 'java', 'port', 'facebook', 'graphql']
88-
githubRepo = 'engagingspaces/vertx-dataloader'
79+
githubRepo = 'bbakerman/java-dataloader'
8980
githubReleaseNotesFile = 'README.md'
9081
version {
9182
released = new Date()

gradle/wrapper/gradle-wrapper.jar

1.35 KB
Binary file not shown.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Sat Aug 20 09:54:51 CEST 2016
1+
#Wed Jun 21 10:10:06 AEST 2017
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-all.zip
6+
distributionUrl=http\://services.gradle.org/distributions/gradle-4.0-all.zip

gradlew

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/env sh
22

33
##############################################################################
44
##
@@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
3333
# Use the maximum available, or set MAX_FD != -1 to use that value.
3434
MAX_FD="maximum"
3535

36-
warn ( ) {
36+
warn () {
3737
echo "$*"
3838
}
3939

40-
die ( ) {
40+
die () {
4141
echo
4242
echo "$*"
4343
echo
@@ -154,11 +154,19 @@ if $cygwin ; then
154154
esac
155155
fi
156156

157-
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158-
function splitJvmOpts() {
159-
JVM_OPTS=("$@")
157+
# Escape application args
158+
save () {
159+
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160+
echo " "
160161
}
161-
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162-
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
162+
APP_ARGS=$(save "$@")
163163

164-
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
164+
# Collect all arguments for the java command, following the shell quoting and substitution rules
165+
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166+
167+
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168+
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169+
cd "$(dirname "$0")"
170+
fi
171+
172+
exec "$JAVACMD" "$@"

0 commit comments

Comments
 (0)