Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run: ./.circleci/upgrade-docker-compose.sh
- run: cd single-module && ./gradlew dependencies
- run: cd multi-module && ./gradlew dependencies

Expand Down
10 changes: 10 additions & 0 deletions .circleci/upgrade-docker-compose.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#! /bin/bash -e

docker-compose version
docker version
URL="https://github.com/docker/compose/releases/download/1.25.4/docker-compose-`uname -s`-`uname -m`"
echo Downloading from $URL
curl -L $URL > ~/docker-compose
chmod +x ~/docker-compose
sudo mv ~/docker-compose /usr/local/bin/docker-compose
docker-compose version
28 changes: 8 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,6 @@ You just need to have Java 8 installed.
# Building and running the application

The steps for building both versions of the application are identical.
However, the details of how to build and run the services depend slightly on whether you are using Eventuate SaaS or Eventuate Local.

## Building and running using Eventuate SaaS

First, must [sign up to get your credentials](https://signup.eventuate.io/) in order to get free access to the SaaS version.

Next, build the application

```
./gradlew assemble
```

Next, you can launch the services using [Docker Compose](https://docs.docker.com/compose/):

```
docker-compose build
docker-compose up -d
```

## Building and running using Eventuate Local

Expand All @@ -84,10 +66,16 @@ Next, launch the services using [Docker Compose](https://docs.docker.com/compose

```
export DOCKER_HOST_IP=...
docker-compose -f docker-compose-eventuate-local.yml build
docker-compose -f docker-compose-eventuate-local.yml up -d
./gradlew <database-mode>ComposeBuild
./gradlew <database-mode>ComposeUp
```

Where `database-mode` is one of:

* `mysqlbinlog` - use MySQL with Binlog-based event publishing
* `postgreswal` - use Postgres with Postgres WAL-based event publishing
* `postgrespolling` - use Postgres with generic JDBC polling-based event publishing

Note: You need to set `DOCKER_HOST_IP` before running Docker Compose.
This must be an IP address or resolvable hostname.
It cannot be `localhost`.
Expand Down
16 changes: 0 additions & 16 deletions multi-module/_build-and-test-all-eventuate-local-postgres.sh

This file was deleted.

42 changes: 8 additions & 34 deletions multi-module/_build-and-test-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,10 @@

set -e

if [ -z "$DOCKER_HOST_IP" ] ; then
if [ -z "$DOCKER_HOST" ] ; then
export DOCKER_HOST_IP=`hostname`
else
echo using ${DOCKER_HOST?}
XX=${DOCKER_HOST%\:*}
export DOCKER_HOST_IP=${XX#tcp\:\/\/}
fi
echo set DOCKER_HOST_IP $DOCKER_HOST_IP
fi

DOCKER_COMPOSE="docker-compose -p java-spring-todo-list"

while [ "$1" = "-f" ] ; do
shift;
DOCKER_COMPOSE="$DOCKER_COMPOSE -f ${1?}"
shift
done

if [ "$1" = "--use-existing" ] ; then
shift;
else
${DOCKER_COMPOSE?} stop
${DOCKER_COMPOSE?} rm -v --force
./gradlew ${database}${mode}ComposeDown
fi


Expand All @@ -36,7 +16,10 @@ if [ "$1" = "--no-rm" ] ; then
shift
fi

${DOCKER_COMPOSE?} up -d mysql $EXTRA_INFRASTRUCTURE_SERVICES
if [ ! -z "$EXTRA_INFRASTRUCTURE_SERVICES" ]; then
./gradlew ${EXTRA_INFRASTRUCTURE_SERVICES}ComposeBuild
./gradlew ${EXTRA_INFRASTRUCTURE_SERVICES}ComposeUp
fi

if [ -z "$SPRING_DATASOURCE_URL" ] ; then
export SPRING_DATASOURCE_URL=jdbc:mysql://${DOCKER_HOST_IP}/es-test
Expand All @@ -45,22 +28,13 @@ fi

./gradlew $BUILD_AND_TEST_ALL_EXTRA_GRADLE_ARGS $* build -x :e2etest:test

if [ -z "$EVENTUATE_LOCAL" ] && [ -z "$EVENTUATE_API_KEY_ID" -o -z "$EVENTUATE_API_KEY_SECRET" ] ; then
echo You must set EVENTUATE_API_KEY_ID and EVENTUATE_API_KEY_SECRET
exit -1
fi

./gradlew $BUILD_AND_TEST_ALL_EXTRA_GRADLE_ARGS --offline $* :e2etest:cleanTest :e2etest:testClasses

${DOCKER_COMPOSE?} build

${DOCKER_COMPOSE?} up -d commandsideservice querysideservice

./wait-for-services.sh $DOCKER_HOST_IP 8081 8082 $EXTRA_PORTS_TO_WAIT_FOR
./gradlew ${database}${mode}ComposeBuild
./gradlew ${database}${mode}ComposeUp

./gradlew $BUILD_AND_TEST_ALL_EXTRA_GRADLE_ARGS --offline $* -P ignoreE2EFailures=false :e2etest:cleanTest :e2etest:test

if [ $NO_RM = false ] ; then
${DOCKER_COMPOSE?} stop
${DOCKER_COMPOSE?} rm -v --force
./gradlew ${database}${mode}ComposeDown
fi
15 changes: 0 additions & 15 deletions multi-module/_set-env.sh

This file was deleted.

8 changes: 3 additions & 5 deletions multi-module/build-and-test-all-eventuate-local-mysql.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#! /bin/bash

export EXTRA_INFRASTRUCTURE_SERVICES=cdcservice
export EVENTUATE_LOCAL=yes
export EXTRA_PORTS_TO_WAIT_FOR=8099
export database=mysql
export mode=binlog

. ./set-env-mysql.sh
./_build-and-test-all.sh -f docker-compose-eventuate-local-mysql.yml $BUILD_AND_TEST_ALL_EVENTUATE_LOCAL_EXTRA_COMPOSE_ARGS $* -P eventuateDriver=local
./_build-and-test-all.sh $* -P eventuateDriver=local
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#! /bin/bash

export MODE=polling
export database=postgres
export mode=wal

./_build-and-test-all-eventuate-local-postgres.sh
./_build-and-test-all.sh $* -P eventuateDriver=local
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#! /bin/bash

export MODE=wal
export database=postgres
export mode=polling

./_build-and-test-all-eventuate-local-postgres.sh
./_build-and-test-all.sh $* -P eventuateDriver=local
2 changes: 2 additions & 0 deletions multi-module/build-and-test-all.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#! /bin/bash

export COMPOSE_HTTP_TIMEOUT=240

./_build-and-test-all.sh $*
45 changes: 42 additions & 3 deletions multi-module/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion")
classpath "com.avast.gradle:gradle-docker-compose-plugin:0.9.2"
}
}

task wrapper(type: Wrapper) {
gradleVersion = '3.5'
}
apply plugin: 'docker-compose'

subprojects {
apply plugin: 'java'
Expand All @@ -21,4 +21,43 @@ subprojects {
jcenter()
eventuateMavenRepoUrl.split(',').each { repoUrl -> maven { url repoUrl } }
}
}

dockerCompose {
environment.put "EVENTUATE_COMMON_VERSION", eventuateCommonImageVersion
environment.put "EVENTUATE_CDC_VERSION", eventuateCdcImageVersion
environment.put "EVENTUATE_JAVA_BASE_IMAGE_VERSION", eventuateExamplesBaseImageVersion

mysqlbinlog {
projectName = null
useComposeFiles = ["docker-compose-eventuate-local-mysql.yml"]
}

mysqlbinlogcdc {
projectName = null
useComposeFiles = ["docker-compose-eventuate-local-mysql.yml"]
startedServices = ["cdc-service"]
}

postgrespolling {
projectName = null
useComposeFiles = ["docker-compose-eventuate-local-postgres-polling.yml"]
}

postgrespollingcdc {
projectName = null
useComposeFiles = ["docker-compose-eventuate-local-postgres-polling.yml"]
startedServices = ["cdc-service"]
}

postgreswal {
projectName = null
useComposeFiles = ["docker-compose-eventuate-local-postgres-wal.yml"]
}

postgreswalcdc {
projectName = null
useComposeFiles = ["docker-compose-eventuate-local-postgres-wal.yml"]
startedServices = ["cdc-service"]
}
}

This file was deleted.

4 changes: 2 additions & 2 deletions multi-module/common-hateoas/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ apply plugin: 'java'
dependencies {
compile project(":common")

compile "io.eventuate.client.java:eventuate-client-java-spring:$eventuateClientVersion"
compile "io.eventuate.local.java:eventuate-client-java-spring:$eventuateLocalVersion"

compile("org.springframework.boot:spring-boot-starter-data-jpa:$springBootVersion")
compile("org.springframework.boot:spring-boot-starter-web:$springBootVersion")
compile "org.springframework.boot:spring-boot-starter-actuator:$springBootVersion"
compile("org.springframework.hateoas:spring-hateoas:$springHateoasVersion")
compile "org.springframework.boot:spring-boot-starter-hateoas:$springBootVersion"

testCompile 'junit:junit:4.12'
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

import java.util.concurrent.CompletableFuture;

import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
import static org.springframework.hateoas.server.mvc.ControllerLinkBuilder.linkTo;
import static org.springframework.hateoas.server.mvc.ControllerLinkBuilder.methodOn;
import static org.springframework.web.bind.annotation.RequestMethod.GET;

/**
Expand Down
3 changes: 1 addition & 2 deletions multi-module/common-swagger/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
dependencies {
compile "io.springfox:springfox-swagger2:2.2.2"
compile 'io.springfox:springfox-swagger-ui:2.2.2'
compile "io.eventuate.util:eventuate-util-spring-swagger:$eventuateUtilVersion"
}
Original file line number Diff line number Diff line change
@@ -1,43 +1,14 @@
package net.chrisrichardson.eventstore.examples.todolist.commonswagger;

import com.fasterxml.classmate.TypeResolver;
import org.springframework.beans.factory.annotation.Autowired;
import io.eventuate.util.spring.swagger.EventuateSwaggerConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.ResponseEntity;
import org.springframework.web.context.request.async.DeferredResult;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.schema.WildcardType;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.concurrent.CompletableFuture;

import static springfox.documentation.schema.AlternateTypeRules.newRule;

@Configuration
@EnableSwagger2
public class CommonSwaggerConfiguration {

@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("net.chrisrichardson.eventstore.examples.todolist"))
.build()
.pathMapping("/")
.genericModelSubstitutes(ResponseEntity.class, CompletableFuture.class)
.alternateTypeRules(
newRule(typeResolver.resolve(DeferredResult.class,
typeResolver.resolve(ResponseEntity.class, WildcardType.class)),
typeResolver.resolve(WildcardType.class))
)
.useDefaultResponseMessages(false)
;
public EventuateSwaggerConfig eventuateSwaggerConfig() {
return () -> "net.chrisrichardson.eventstore.examples.todolist.web";
}

@Autowired
private TypeResolver typeResolver;

}
2 changes: 1 addition & 1 deletion multi-module/common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'java'

dependencies {
compile "io.eventuate.client.java:eventuate-client-java-spring:$eventuateClientVersion"
compile "io.eventuate.local.java:eventuate-client-java-spring:$eventuateLocalVersion"
compile "org.springframework.boot:spring-boot-starter-web:$springBootVersion"
compile("org.springframework.boot:spring-boot-starter-data-jpa:$springBootVersion")

Expand Down
Loading