-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from dartartem/master
Added reactive version of customer service.
- Loading branch information
Showing
82 changed files
with
2,397 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
pull_request: | ||
types: | ||
- opened | ||
- edited | ||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout source | ||
uses: actions/checkout@v2 | ||
- uses: actions/setup-java@v1 | ||
with: | ||
java-version: '11' # The JDK version to make available on the path. | ||
java-package: jdk # (jre, jdk, or jdk+fx) - defaults to jdk | ||
architecture: x64 # (x64 or x86) - defaults to x64 | ||
|
||
- name: Build | ||
run: ./build-and-test-all-mysql-binlog.sh | ||
|
||
- name: Save test results | ||
if: ${{ always() }} | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: test-reports | ||
path: ./end-to-end-tests/build/reports | ||
|
||
- name: print messages | ||
run: ./.github/workflows/dump-messages.sh | ||
if: ${{ failure() }} | ||
|
||
- name: get container logs | ||
run: ./.github/workflows/print-container-logs.sh | ||
if: ${{ always() }} | ||
|
||
- name: Save container logs | ||
if: ${{ always() }} | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: container-logs | ||
path: ~/container-logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#! /bin/bash | ||
|
||
set -e | ||
|
||
echo 'select * from eventuate.message\G' | ./mysql-cli.sh -i | ||
echo 'select * from eventuate.received_messages\G' | ./mysql-cli.sh -i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#! /bin/bash -e | ||
|
||
CONTAINER_IDS=$(docker ps -a -q) | ||
|
||
for id in $CONTAINER_IDS ; do | ||
echo "\n--------------------" | ||
echo "logs of:\n" | ||
docker ps -a -f "id=$id" | ||
echo "\n" | ||
docker logs $id | ||
echo "--------------------\n" | ||
done | ||
|
||
mkdir -p ~/container-logs | ||
|
||
docker ps -a > ~/container-logs/containers.txt | ||
|
||
for name in $(docker ps -a --format "{{.Names}}") ; do | ||
docker logs $name > ~/container-logs/${name}.log | ||
done |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#! /bin/bash | ||
|
||
set -e | ||
|
||
dockerall="./gradlew ${DATABASE?}${MODE?}Compose" | ||
dockerinfrastructure="./gradlew ${DATABASE?}${MODE?}infrastructureCompose" | ||
|
||
./gradlew testClasses | ||
|
||
${dockerall}Down -P removeContainers=true | ||
${dockerinfrastructure}Up | ||
|
||
./gradlew -x :end-to-end-tests:test build | ||
|
||
#Testing db cli | ||
if [ "${DATABASE}" == "mysql" ]; then | ||
echo 'show databases;' | ./mysql-cli.sh -i | ||
elif [ "${DATABASE}" == "postgres" ]; then | ||
echo '\l' | ./postgres-cli.sh -i | ||
elif [ "${DATABASE}" == "mssql" ]; then | ||
./mssql-cli.sh "SELECT name FROM master.sys.databases;" | ||
else | ||
echo "Unknown Database" | ||
exit 99 | ||
fi | ||
|
||
|
||
${dockerall}Build | ||
${dockerall}Up | ||
|
||
#Testing mongo cli | ||
echo 'show dbs' | ./mongodb-cli.sh -i | ||
|
||
./gradlew :end-to-end-tests:cleanTest :end-to-end-tests:test | ||
|
||
${dockerall}Down -P removeContainers=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#! /bin/bash | ||
|
||
set -e | ||
|
||
export DATABASE=mysql | ||
export MODE=binlog | ||
export READER=MySqlReader | ||
|
||
./_build-and-test-all.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#! /bin/bash -e | ||
|
||
set -o pipefail | ||
|
||
SCRIPTS="./build-and-test-all-*" | ||
|
||
date > build-and-test-everything.log | ||
|
||
for script in $SCRIPTS ; do | ||
echo '****************************************** Running' $script | ||
date >> build-and-test-everything.log | ||
echo '****************************************** Running' $script >> build-and-test-everything.log | ||
$script | tee -a build-and-test-everything.log | ||
done | ||
|
||
echo 'Finished successfully!!!' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
buildscript { | ||
repositories { | ||
jcenter() | ||
mavenCentral() | ||
mavenLocal() | ||
} | ||
dependencies { | ||
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}" | ||
classpath "com.avast.gradle:gradle-docker-compose-plugin:0.12.0" | ||
} | ||
} | ||
|
||
apply plugin: 'docker-compose' | ||
|
||
subprojects { | ||
|
||
apply plugin: "java" | ||
|
||
sourceCompatibility = 1.8 | ||
targetCompatibility = 1.8 | ||
|
||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
jcenter() | ||
maven { | ||
url "https://dl.bintray.com/eventuateio-oss/eventuate-maven-release" | ||
} | ||
eventuateMavenRepoUrl.split(',').each { repoUrl -> maven { url repoUrl } } | ||
} | ||
|
||
dependencies { | ||
implementation(platform("io.eventuate.platform:eventuate-platform-dependencies:$eventuatePlatformVersion")) | ||
testCompile "junit:junit:4.12" | ||
} | ||
|
||
} | ||
|
||
dockerCompose { | ||
environment.put "EVENTUATE_COMMON_VERSION", eventuateCommonImageVersion | ||
environment.put "EVENTUATE_CDC_VERSION", eventuateCdcImageVersion | ||
environment.put "EVENTUATE_CDC_KAFKA_ENABLE_BATCH_PROCESSING", eventuateCdcKafkaEnableBatchProcessing | ||
environment.put "EVENTUATE_JAVA_BASE_IMAGE_VERSION", eventuateExamplesBaseImageVersion | ||
environment.put "EVENTUATE_PROXY_VERSION", eventuateProxyImageVersion | ||
|
||
removeOrphans = true | ||
|
||
mysqlbinlog { | ||
projectName = null | ||
useComposeFiles = ["docker-compose-mysql-binlog.yml"] | ||
removeContainers = project.ext.removeContainers | ||
} | ||
|
||
mysqlbinloginfrastructure { | ||
projectName = null | ||
useComposeFiles = ["docker-compose-mysql-binlog.yml"] | ||
startedServices = ["cdc-service", "zipkin"] | ||
removeContainers = project.ext.removeContainers | ||
} | ||
} | ||
|
||
subprojects.each { | ||
if (it.name.endsWith("-service") || it.name.endsWith("-gateway")) { | ||
mysqlbinlogComposeUp.dependsOn(":" + it.name + ":assemble") | ||
} | ||
} | ||
|
||
mysqlbinlogComposeUp.dependsOn(mysqlbinloginfrastructureComposeUp) | ||
|
||
task buildAndStartServicesMySql(type: GradleBuild) { | ||
tasks = ["mysqlbinlogComposeUp"] | ||
} | ||
|
||
task endToEndTests(type: GradleBuild) { | ||
tasks = [":end-to-end-tests:test"] | ||
} | ||
|
||
endToEndTests.dependsOn(mysqlbinlogComposeUp) | ||
endToEndTests.dependsOn(":end-to-end-tests:cleanTest") | ||
|
||
task stopServicesMySql(type: GradleBuild) { | ||
tasks = ["mysqlbinlogComposeDown"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
|
||
class ServicePlugin implements Plugin<Project> { | ||
|
||
@Override | ||
void apply(Project project) { | ||
|
||
project.apply(plugin: 'org.springframework.boot') | ||
project.apply(plugin: "io.spring.dependency-management") | ||
|
||
project.dependencyManagement { | ||
imports { | ||
mavenBom "org.springframework.cloud:spring-cloud-starter-sleuth:${project.ext.springCloudSleuthVersion}" | ||
} | ||
} | ||
|
||
|
||
project.dependencies { | ||
|
||
compile 'org.springframework.cloud:spring-cloud-starter-sleuth' | ||
compile 'org.springframework.cloud:spring-cloud-starter-zipkin:2.2.8.RELEASE' | ||
compile 'io.zipkin.brave:brave-bom:4.17.1' | ||
|
||
compile "io.eventuate.tram.core:eventuate-tram-spring-cloud-sleuth-integration" | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dependencies { | ||
compile "io.eventuate.util:eventuate-util-spring-swagger:$eventuateUtilVersion" | ||
} |
13 changes: 13 additions & 0 deletions
13
.../eventuate/examples/tram/ordersandcustomers/commonswagger/CommonSwaggerConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.eventuate.examples.tram.ordersandcustomers.commonswagger; | ||
|
||
import io.eventuate.util.spring.swagger.EventuateSwaggerConfig; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class CommonSwaggerConfiguration { | ||
@Bean | ||
public EventuateSwaggerConfig eventuateSwaggerConfig() { | ||
return () -> "io.eventuate.examples.tram.ordersandcustomers"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
dependencies { | ||
compile "io.eventuate.tram.core:eventuate-tram-events" | ||
compile "commons-lang:commons-lang:2.6" | ||
} |
61 changes: 61 additions & 0 deletions
61
common/src/main/java/io/eventuate/examples/tram/ordersandcustomers/common/domain/Money.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package io.eventuate.examples.tram.ordersandcustomers.common.domain; | ||
|
||
import org.apache.commons.lang.builder.EqualsBuilder; | ||
import org.apache.commons.lang.builder.HashCodeBuilder; | ||
import org.apache.commons.lang.builder.ToStringBuilder; | ||
|
||
import java.math.BigDecimal; | ||
|
||
public class Money { | ||
|
||
public static final Money ZERO = new Money(0); | ||
private BigDecimal amount; | ||
|
||
public Money() { | ||
} | ||
|
||
public Money(int i) { | ||
this.amount = new BigDecimal(i); | ||
} | ||
public Money(String s) { | ||
this.amount = new BigDecimal(s); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return ToStringBuilder.reflectionToString(this); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
return EqualsBuilder.reflectionEquals(this, obj); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return HashCodeBuilder.reflectionHashCode(this); | ||
} | ||
|
||
public Money(BigDecimal amount) { | ||
this.amount = amount; | ||
} | ||
|
||
public BigDecimal getAmount() { | ||
return amount; | ||
} | ||
|
||
public void setAmount(BigDecimal amount) { | ||
this.amount = amount; | ||
} | ||
|
||
public boolean isGreaterThanOrEqual(Money other) { | ||
return amount.compareTo(other.amount) >= 0; | ||
} | ||
|
||
public Money add(Money other) { | ||
return new Money(amount.add(other.amount)); | ||
} | ||
public Money subtract(Money other) { | ||
return new Money(amount.subtract(other.amount)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
dependencies { | ||
compile project(":common") | ||
} | ||
|
20 changes: 20 additions & 0 deletions
20
.../examples/tram/ordersandcustomers/customers/domain/events/AbstractCustomerOrderEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.eventuate.examples.tram.ordersandcustomers.customers.domain.events; | ||
|
||
public abstract class AbstractCustomerOrderEvent implements CustomerEvent { | ||
protected Long orderId; | ||
|
||
protected AbstractCustomerOrderEvent(Long orderId) { | ||
this.orderId = orderId; | ||
} | ||
|
||
protected AbstractCustomerOrderEvent() { | ||
} | ||
|
||
public Long getOrderId() { | ||
return orderId; | ||
} | ||
|
||
public void setOrderId(Long orderId) { | ||
this.orderId = orderId; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...ntuate/examples/tram/ordersandcustomers/customers/domain/events/CustomerCreatedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package io.eventuate.examples.tram.ordersandcustomers.customers.domain.events; | ||
|
||
import io.eventuate.examples.tram.ordersandcustomers.common.domain.Money; | ||
|
||
public class CustomerCreatedEvent implements CustomerEvent { | ||
private String name; | ||
private Money creditLimit; | ||
|
||
public CustomerCreatedEvent() { | ||
} | ||
|
||
public CustomerCreatedEvent(String name, Money creditLimit) { | ||
this.name = name; | ||
this.creditLimit = creditLimit; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public Money getCreditLimit() { | ||
return creditLimit; | ||
} | ||
|
||
public void setCreditLimit(Money creditLimit) { | ||
this.creditLimit = creditLimit; | ||
} | ||
} |
Oops, something went wrong.