Skip to content

Commit ab469f2

Browse files
authored
Merge pull request #1 from dartartem/master
Added reactive version of customer service.
2 parents a026734 + afe3d41 commit ab469f2

File tree

82 files changed

+2397
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+2397
-0
lines changed

Diff for: .github/workflows/build.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
pull_request:
6+
types:
7+
- opened
8+
- edited
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout source
16+
uses: actions/checkout@v2
17+
- uses: actions/setup-java@v1
18+
with:
19+
java-version: '11' # The JDK version to make available on the path.
20+
java-package: jdk # (jre, jdk, or jdk+fx) - defaults to jdk
21+
architecture: x64 # (x64 or x86) - defaults to x64
22+
23+
- name: Build
24+
run: ./build-and-test-all-mysql-binlog.sh
25+
26+
- name: Save test results
27+
if: ${{ always() }}
28+
uses: actions/upload-artifact@v2
29+
with:
30+
name: test-reports
31+
path: ./end-to-end-tests/build/reports
32+
33+
- name: print messages
34+
run: ./.github/workflows/dump-messages.sh
35+
if: ${{ failure() }}
36+
37+
- name: get container logs
38+
run: ./.github/workflows/print-container-logs.sh
39+
if: ${{ always() }}
40+
41+
- name: Save container logs
42+
if: ${{ always() }}
43+
uses: actions/upload-artifact@v2
44+
with:
45+
name: container-logs
46+
path: ~/container-logs

Diff for: .github/workflows/dump-messages.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#! /bin/bash
2+
3+
set -e
4+
5+
echo 'select * from eventuate.message\G' | ./mysql-cli.sh -i
6+
echo 'select * from eventuate.received_messages\G' | ./mysql-cli.sh -i

Diff for: .github/workflows/print-container-logs.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#! /bin/bash -e
2+
3+
CONTAINER_IDS=$(docker ps -a -q)
4+
5+
for id in $CONTAINER_IDS ; do
6+
echo "\n--------------------"
7+
echo "logs of:\n"
8+
docker ps -a -f "id=$id"
9+
echo "\n"
10+
docker logs $id
11+
echo "--------------------\n"
12+
done
13+
14+
mkdir -p ~/container-logs
15+
16+
docker ps -a > ~/container-logs/containers.txt
17+
18+
for name in $(docker ps -a --format "{{.Names}}") ; do
19+
docker logs $name > ~/container-logs/${name}.log
20+
done

Diff for: .gitignore

100644100755
File mode changed.

Diff for: LICENSE.md

100644100755
File mode changed.

Diff for: README.adoc

100644100755
File mode changed.

Diff for: _build-and-test-all.sh

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#! /bin/bash
2+
3+
set -e
4+
5+
dockerall="./gradlew ${DATABASE?}${MODE?}Compose"
6+
dockerinfrastructure="./gradlew ${DATABASE?}${MODE?}infrastructureCompose"
7+
8+
./gradlew testClasses
9+
10+
${dockerall}Down -P removeContainers=true
11+
${dockerinfrastructure}Up
12+
13+
./gradlew -x :end-to-end-tests:test build
14+
15+
#Testing db cli
16+
if [ "${DATABASE}" == "mysql" ]; then
17+
echo 'show databases;' | ./mysql-cli.sh -i
18+
elif [ "${DATABASE}" == "postgres" ]; then
19+
echo '\l' | ./postgres-cli.sh -i
20+
elif [ "${DATABASE}" == "mssql" ]; then
21+
./mssql-cli.sh "SELECT name FROM master.sys.databases;"
22+
else
23+
echo "Unknown Database"
24+
exit 99
25+
fi
26+
27+
28+
${dockerall}Build
29+
${dockerall}Up
30+
31+
#Testing mongo cli
32+
echo 'show dbs' | ./mongodb-cli.sh -i
33+
34+
./gradlew :end-to-end-tests:cleanTest :end-to-end-tests:test
35+
36+
${dockerall}Down -P removeContainers=true

Diff for: build-and-test-all-mysql-binlog.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#! /bin/bash
2+
3+
set -e
4+
5+
export DATABASE=mysql
6+
export MODE=binlog
7+
export READER=MySqlReader
8+
9+
./_build-and-test-all.sh

Diff for: build-and-test-everything.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#! /bin/bash -e
2+
3+
set -o pipefail
4+
5+
SCRIPTS="./build-and-test-all-*"
6+
7+
date > build-and-test-everything.log
8+
9+
for script in $SCRIPTS ; do
10+
echo '****************************************** Running' $script
11+
date >> build-and-test-everything.log
12+
echo '****************************************** Running' $script >> build-and-test-everything.log
13+
$script | tee -a build-and-test-everything.log
14+
done
15+
16+
echo 'Finished successfully!!!'

Diff for: build.gradle

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
buildscript {
2+
repositories {
3+
jcenter()
4+
mavenCentral()
5+
mavenLocal()
6+
}
7+
dependencies {
8+
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
9+
classpath "com.avast.gradle:gradle-docker-compose-plugin:0.12.0"
10+
}
11+
}
12+
13+
apply plugin: 'docker-compose'
14+
15+
subprojects {
16+
17+
apply plugin: "java"
18+
19+
sourceCompatibility = 1.8
20+
targetCompatibility = 1.8
21+
22+
repositories {
23+
mavenLocal()
24+
mavenCentral()
25+
jcenter()
26+
maven {
27+
url "https://dl.bintray.com/eventuateio-oss/eventuate-maven-release"
28+
}
29+
eventuateMavenRepoUrl.split(',').each { repoUrl -> maven { url repoUrl } }
30+
}
31+
32+
dependencies {
33+
implementation(platform("io.eventuate.platform:eventuate-platform-dependencies:$eventuatePlatformVersion"))
34+
testCompile "junit:junit:4.12"
35+
}
36+
37+
}
38+
39+
dockerCompose {
40+
environment.put "EVENTUATE_COMMON_VERSION", eventuateCommonImageVersion
41+
environment.put "EVENTUATE_CDC_VERSION", eventuateCdcImageVersion
42+
environment.put "EVENTUATE_CDC_KAFKA_ENABLE_BATCH_PROCESSING", eventuateCdcKafkaEnableBatchProcessing
43+
environment.put "EVENTUATE_JAVA_BASE_IMAGE_VERSION", eventuateExamplesBaseImageVersion
44+
environment.put "EVENTUATE_PROXY_VERSION", eventuateProxyImageVersion
45+
46+
removeOrphans = true
47+
48+
mysqlbinlog {
49+
projectName = null
50+
useComposeFiles = ["docker-compose-mysql-binlog.yml"]
51+
removeContainers = project.ext.removeContainers
52+
}
53+
54+
mysqlbinloginfrastructure {
55+
projectName = null
56+
useComposeFiles = ["docker-compose-mysql-binlog.yml"]
57+
startedServices = ["cdc-service", "zipkin"]
58+
removeContainers = project.ext.removeContainers
59+
}
60+
}
61+
62+
subprojects.each {
63+
if (it.name.endsWith("-service") || it.name.endsWith("-gateway")) {
64+
mysqlbinlogComposeUp.dependsOn(":" + it.name + ":assemble")
65+
}
66+
}
67+
68+
mysqlbinlogComposeUp.dependsOn(mysqlbinloginfrastructureComposeUp)
69+
70+
task buildAndStartServicesMySql(type: GradleBuild) {
71+
tasks = ["mysqlbinlogComposeUp"]
72+
}
73+
74+
task endToEndTests(type: GradleBuild) {
75+
tasks = [":end-to-end-tests:test"]
76+
}
77+
78+
endToEndTests.dependsOn(mysqlbinlogComposeUp)
79+
endToEndTests.dependsOn(":end-to-end-tests:cleanTest")
80+
81+
task stopServicesMySql(type: GradleBuild) {
82+
tasks = ["mysqlbinlogComposeDown"]
83+
}

Diff for: buildSrc/src/main/groovy/ServicePlugin.groovy

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import org.gradle.api.Plugin
2+
import org.gradle.api.Project
3+
4+
class ServicePlugin implements Plugin<Project> {
5+
6+
@Override
7+
void apply(Project project) {
8+
9+
project.apply(plugin: 'org.springframework.boot')
10+
project.apply(plugin: "io.spring.dependency-management")
11+
12+
project.dependencyManagement {
13+
imports {
14+
mavenBom "org.springframework.cloud:spring-cloud-starter-sleuth:${project.ext.springCloudSleuthVersion}"
15+
}
16+
}
17+
18+
19+
project.dependencies {
20+
21+
compile 'org.springframework.cloud:spring-cloud-starter-sleuth'
22+
compile 'org.springframework.cloud:spring-cloud-starter-zipkin:2.2.8.RELEASE'
23+
compile 'io.zipkin.brave:brave-bom:4.17.1'
24+
25+
compile "io.eventuate.tram.core:eventuate-tram-spring-cloud-sleuth-integration"
26+
}
27+
28+
}
29+
}

Diff for: common-swagger/build.gradle

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dependencies {
2+
compile "io.eventuate.util:eventuate-util-spring-swagger:$eventuateUtilVersion"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package io.eventuate.examples.tram.ordersandcustomers.commonswagger;
2+
3+
import io.eventuate.util.spring.swagger.EventuateSwaggerConfig;
4+
import org.springframework.context.annotation.Bean;
5+
import org.springframework.context.annotation.Configuration;
6+
7+
@Configuration
8+
public class CommonSwaggerConfiguration {
9+
@Bean
10+
public EventuateSwaggerConfig eventuateSwaggerConfig() {
11+
return () -> "io.eventuate.examples.tram.ordersandcustomers";
12+
}
13+
}

Diff for: common/build.gradle

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dependencies {
2+
compile "io.eventuate.tram.core:eventuate-tram-events"
3+
compile "commons-lang:commons-lang:2.6"
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package io.eventuate.examples.tram.ordersandcustomers.common.domain;
2+
3+
import org.apache.commons.lang.builder.EqualsBuilder;
4+
import org.apache.commons.lang.builder.HashCodeBuilder;
5+
import org.apache.commons.lang.builder.ToStringBuilder;
6+
7+
import java.math.BigDecimal;
8+
9+
public class Money {
10+
11+
public static final Money ZERO = new Money(0);
12+
private BigDecimal amount;
13+
14+
public Money() {
15+
}
16+
17+
public Money(int i) {
18+
this.amount = new BigDecimal(i);
19+
}
20+
public Money(String s) {
21+
this.amount = new BigDecimal(s);
22+
}
23+
24+
@Override
25+
public String toString() {
26+
return ToStringBuilder.reflectionToString(this);
27+
}
28+
29+
@Override
30+
public boolean equals(Object obj) {
31+
return EqualsBuilder.reflectionEquals(this, obj);
32+
}
33+
34+
@Override
35+
public int hashCode() {
36+
return HashCodeBuilder.reflectionHashCode(this);
37+
}
38+
39+
public Money(BigDecimal amount) {
40+
this.amount = amount;
41+
}
42+
43+
public BigDecimal getAmount() {
44+
return amount;
45+
}
46+
47+
public void setAmount(BigDecimal amount) {
48+
this.amount = amount;
49+
}
50+
51+
public boolean isGreaterThanOrEqual(Money other) {
52+
return amount.compareTo(other.amount) >= 0;
53+
}
54+
55+
public Money add(Money other) {
56+
return new Money(amount.add(other.amount));
57+
}
58+
public Money subtract(Money other) {
59+
return new Money(amount.subtract(other.amount));
60+
}
61+
}

Diff for: customer-service-api-messaging/build.gradle

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dependencies {
2+
compile project(":common")
3+
}
4+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package io.eventuate.examples.tram.ordersandcustomers.customers.domain.events;
2+
3+
public abstract class AbstractCustomerOrderEvent implements CustomerEvent {
4+
protected Long orderId;
5+
6+
protected AbstractCustomerOrderEvent(Long orderId) {
7+
this.orderId = orderId;
8+
}
9+
10+
protected AbstractCustomerOrderEvent() {
11+
}
12+
13+
public Long getOrderId() {
14+
return orderId;
15+
}
16+
17+
public void setOrderId(Long orderId) {
18+
this.orderId = orderId;
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package io.eventuate.examples.tram.ordersandcustomers.customers.domain.events;
2+
3+
import io.eventuate.examples.tram.ordersandcustomers.common.domain.Money;
4+
5+
public class CustomerCreatedEvent implements CustomerEvent {
6+
private String name;
7+
private Money creditLimit;
8+
9+
public CustomerCreatedEvent() {
10+
}
11+
12+
public CustomerCreatedEvent(String name, Money creditLimit) {
13+
this.name = name;
14+
this.creditLimit = creditLimit;
15+
}
16+
17+
public String getName() {
18+
return name;
19+
}
20+
21+
public void setName(String name) {
22+
this.name = name;
23+
}
24+
25+
public Money getCreditLimit() {
26+
return creditLimit;
27+
}
28+
29+
public void setCreditLimit(Money creditLimit) {
30+
this.creditLimit = creditLimit;
31+
}
32+
}

0 commit comments

Comments
 (0)