Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update apiVersion in K8s objects, fix path #131

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7efe007
Update to work on k8s
pulnara Apr 20, 2021
388b8e3
Merge pull request #1 from pulnara/update
pulnara Apr 20, 2021
a819a81
Update to work on k8s
pulnara Apr 21, 2021
69d6d17
Merge pull request #2 from pulnara/update
pulnara Apr 21, 2021
cbe0d8e
Update deployment files
pulnara Apr 21, 2021
7eb32f3
Update deployment files
pulnara Apr 21, 2021
6515f63
Update apiVersion in K8s objects, fix path
pulnara Apr 20, 2021
0f5ecf6
create tables on startup
May 12, 2021
60ecfd5
Fix Kafka port number in CDC Service
pulnara May 13, 2021
78759ff
Update database details and credentials, add Order History Service to…
pulnara May 13, 2021
b50f6bc
create tables on startup
May 12, 2021
d701540
Merge pull request #3 from pulnara/fix-docker-compose
pulnara May 19, 2021
3aed814
Add consumer ID to the get endpoint
pulnara May 19, 2021
fe44b02
Add endpoint for getting all consumers
pulnara May 19, 2021
c2bee97
Add endpoint for getting all restaurants
pulnara May 19, 2021
3d47ded
Add endpoint for getting all orders
pulnara May 19, 2021
8d441f2
add balance to account
vanillaxx May 20, 2021
8f9c742
Merge pull request #4 from pulnara/dev-pulnara
pulnara May 20, 2021
3e1cb1c
Merge remote-tracking branch 'origin/master' into pp-add-more-logic-test
vanillaxx May 20, 2021
fa5f31e
throw exception when account limit exceeds
vanillaxx May 20, 2021
1de764a
set initial balance
vanillaxx May 21, 2021
f2c794d
remove bintray from dependencies as repo does not exist
May 25, 2021
0c596ff
remove bintray from dependencies as repo does not exist
May 25, 2021
47fea1c
Implement restaurant capacity
pulnara May 26, 2021
8bdcf0c
Refactor
pulnara May 27, 2021
171ab9d
Fixes to make saga compensation work
pulnara May 27, 2021
18e0130
Merge pull request #6 from pulnara/restaurant-service-efficiency
pulnara Jun 7, 2021
508007b
Merge remote-tracking branch 'origin/master' into temporary-delete-no…
vanillaxx Jun 7, 2021
191f96b
change balance on authorize
vanillaxx Jun 7, 2021
e61bcc6
return account info properly
vanillaxx Jun 10, 2021
c20dc0e
Merge pull request #7 from pulnara/temporary-delete-nonexisting-bintray
pulnara Jun 10, 2021
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
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ subprojects {
group = "net.chrisrichardson.ftgo"

repositories {
eventuateMavenRepoUrl.split('[ ,]').each { repoUrl -> maven { url repoUrl.trim() } }

mavenCentral()
jcenter()
eventuateMavenRepoUrl.split('[ ,]').each { repoUrl -> maven { url repoUrl.trim() } }



maven {
url 'https://jitpack.io'
Expand Down
9 changes: 6 additions & 3 deletions deployment/kubernetes/cdc-service/ftgo-cdc-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ spec:
selector:
svc: ftgo-cdc-service
---
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
name: ftgo-cdc-service
labels:
application: ftgo
spec:
selector:
matchLabels:
svc: ftgo-cdc-service
replicas: 1
strategy:
rollingUpdate:
Expand All @@ -27,7 +30,7 @@ spec:
spec:
containers:
- name: ftgo-cdc-service
image: eventuateio/eventuate-cdc-service:0.4.0.RELEASE
image: eventuateio/eventuate-cdc-service:0.6.0.RC3
imagePullPolicy: Always
ports:
- containerPort: 8080
Expand All @@ -37,7 +40,7 @@ spec:
- name: JAVA_OPTS
value: "-Dsun.net.inetaddr.ttl=30"
- name: EVENTUATELOCAL_KAFKA_BOOTSTRAP_SERVERS
value: ftgo-kafka:29092
value: ftgo-kafka:9092
- name: EVENTUATELOCAL_ZOOKEEPER_CONNECTION_STRING
value: ftgo-zookeeper:2181
- name: EVENTUATE_CDC_PIPELINE_PIPELINE1_TYPE
Expand Down
4 changes: 3 additions & 1 deletion deployment/kubernetes/scripts/kubernetes-deploy-all.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#! /bin/bash -e

set -vx

kubectl apply -f <(cat deployment/kubernetes/stateful-services/*.yml)

./deployment/kubernetes/scripts/kubernetes-wait-for-ready-pods.sh ftgo-mysql-0 ftgo-kafka-0 ftgo-dynamodb-local-0 ftgo-zookeeper-0

kubectl apply -f <(cat deployment/kubernetes/cdc-services/*.yml)
kubectl apply -f <(cat deployment/kubernetes/cdc-service/*.yml)

kubectl apply -f <(cat */src/deployment/kubernetes/*.yml)
2 changes: 1 addition & 1 deletion deployment/kubernetes/scripts/port-forwards.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ doforward() {


doforward 'ftgo-accounting-service' 8085 8080

doforward 'ftgo-order-history-service' 8086 8080
doforward 'ftgo-consumer-service' 8081 8080
doforward 'ftgo-api-gateway' 8087 8080
doforward 'ftgo-order-service' 8082 8080
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ spec:
selector:
svc: ftgo-dynamodb-local
---
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: ftgo-dynamodb-local
labels:
application: ftgo
spec:
selector:
matchLabels:
svc: ftgo-dynamodb-local
serviceName: "ftgo-dynamodb"
replicas: 1
template:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ spec:
selector:
role: ftgo-kafka
---
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: ftgo-kafka
spec:
selector:
matchLabels:
role: ftgo-kafka
serviceName: "kafka"
replicas: 1
template:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ spec:
selector:
role: ftgo-mysql
---
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: ftgo-mysql
spec:
selector:
matchLabels:
role: ftgo-mysql
serviceName: "mysql"
replicas: 1
template:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ spec:
selector:
role: ftgo-zookeeper
---
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: ftgo-zookeeper
spec:
selector:
matchLabels:
role: ftgo-zookeeper
serviceName: "zookeeper"
replicas: 1
template:
Expand Down
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ services:
- kafka
- zookeeper
- cdc-service
- zipkin
environment:
SPRING_DATASOURCE_URL: jdbc:mysql://mysql/ftgo_accounting_service
SPRING_DATASOURCE_USERNAME: ftgo_accounting_service_user
Expand All @@ -169,6 +170,9 @@ services:
EVENTUATELOCAL_KAFKA_BOOTSTRAP_SERVERS: kafka:29092
EVENTUATELOCAL_ZOOKEEPER_CONNECTION_STRING: zookeeper:2181
EVENTUATE_DATABASE_SCHEMA: ftgo_accounting_service
SPRING_SLEUTH_ENABLED: "true"
SPRING_SLEUTH_SAMPLER_PROBABILITY: 1
SPRING_ZIPKIN_BASE_URL: http://zipkin:9411/
ftgo-delivery-service:
build: ./ftgo-delivery-service
ports:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package net.chrisrichardson.ftgo.accountservice.api;

public class AccountLimitExceededReply {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package net.chrisrichardson.ftgo.accountservice.api;

import io.eventuate.tram.commands.common.Command;
import net.chrisrichardson.ftgo.common.Money;

public class CheckAccountLimitCommand implements Command {

private Money money;
private Long consumerId;
private Long orderId;

private CheckAccountLimitCommand() {
}

public CheckAccountLimitCommand(Long consumerId, Long orderId, Money money) {
this.money = money;
this.consumerId = consumerId;
this.orderId = orderId;
}

public Money getMoney() {
return money;
}

public Long getConsumerId() {
return consumerId;
}

public Long getOrderId() {
return orderId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ spec:
selector:
svc: ftgo-accounting-service
---
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
name: ftgo-accounting-service
labels:
application: ftgo
spec:
selector:
matchLabels:
svc: ftgo-accounting-service
replicas: 1
strategy:
rollingUpdate:
Expand All @@ -37,23 +40,19 @@ spec:
- name: JAVA_OPTS
value: "-Dsun.net.inetaddr.ttl=30"
- name: SPRING_DATASOURCE_URL
value: jdbc:mysql://ftgo-mysql/eventuate
value: jdbc:mysql://ftgo-mysql/ftgo_accounting_service
- name: SPRING_DATASOURCE_USERNAME
valueFrom:
secretKeyRef:
name: ftgo-db-secret
key: username
value: ftgo_accounting_service_user
- name: SPRING_DATASOURCE_PASSWORD
valueFrom:
secretKeyRef:
name: ftgo-db-secret
key: password
value: ftgo_accounting_service_password
- name: SPRING_DATASOURCE_DRIVER_CLASS_NAME
value: com.mysql.jdbc.Driver
- name: EVENTUATELOCAL_KAFKA_BOOTSTRAP_SERVERS
value: ftgo-kafka:9092
- name: EVENTUATELOCAL_ZOOKEEPER_CONNECTION_STRING
value: ftgo-zookeeper:2181
- name: EVENTUATE_DATABASE_SCHEMA
value: ftgo_accounting_service
livenessProbe:
httpGet:
path: /actuator/health
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,54 @@
import io.eventuate.Event;
import io.eventuate.ReflectiveMutableCommandProcessingAggregate;
import io.eventuate.tram.sagas.eventsourcingsupport.SagaReplyRequestedEvent;
import net.chrisrichardson.ftgo.common.Money;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import static io.eventuate.EventUtil.events;

public class Account extends ReflectiveMutableCommandProcessingAggregate<Account, AccountCommand> {

public Money getBalance() {
return balance;
}
public boolean accountLimitSufficient(Money money){
return balance.isGreaterThanOrEqual(money);
}

public void setBalance(Money balance) {
this.balance = balance;
}

private final Logger logger = LoggerFactory.getLogger(getClass());

private Money balance;

public List<Event> process(CreateAccountCommand command) {
return events(new AccountCreatedEvent());
logger.info(command.getCustomerId().toString());
return events(new AccountCreatedEvent(command.getCustomerId(), command.getInitialBalance()));
}

public void apply(AccountCreatedEvent event) {

this.balance = event.getInitialBalance();
logger.info(this.balance.asString());
logger.info(event.getCustomerId().toString());
}

public List<Event> process(CheckAccountLimitCommandInternal command) {
if(balance.isGreaterThanOrEqual(command.getMoney())){
return events(new AccountLimitSufficientEvent());
}
return events(new AccountLimitExceededEvent());
}

public List<Event> process(AuthorizeCommandInternal command) {
return events(new AccountAuthorizedEvent());
return events(new AccountAuthorizedEvent(command.getOrderTotal()));
}

public List<Event> process(ReverseAuthorizationCommandInternal command) {
Expand All @@ -32,7 +61,15 @@ public List<Event> process(ReviseAuthorizationCommandInternal command) {
}

public void apply(AccountAuthorizedEvent event) {
if(balance.isGreaterThanOrEqual(event.getMoney())) {
setBalance(getBalance().subtract(event.getMoney()));
}
}

public void apply(AccountLimitSufficientEvent event) {
}

public void apply(AccountLimitExceededEvent event) {
}

public void apply(SagaReplyRequestedEvent event) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
package net.chrisrichardson.ftgo.accountingservice.domain;

import io.eventuate.Event;
import net.chrisrichardson.ftgo.common.Money;

public class AccountAuthorizedEvent implements Event {
private Money money;

public AccountAuthorizedEvent() {
}

public AccountAuthorizedEvent(Money money) {
this.money = money;
}

public Money getMoney() {
return money;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
package net.chrisrichardson.ftgo.accountingservice.domain;

import io.eventuate.Event;
import net.chrisrichardson.ftgo.common.Money;

import java.math.BigDecimal;

public class AccountCreatedEvent implements Event {
private Money initialBalance;

private Long customerId;

private AccountCreatedEvent() {}

public AccountCreatedEvent(Long customerId, Money initialBalance){
this.customerId = customerId;
this.initialBalance = initialBalance;
}

public Money getInitialBalance() {
return initialBalance;
}

public Long getCustomerId() {
return customerId;
}

public void setCustomerId(Long customerId) {
this.customerId = customerId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package net.chrisrichardson.ftgo.accountingservice.domain;

import io.eventuate.Event;

public class AccountLimitExceededEvent implements Event {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package net.chrisrichardson.ftgo.accountingservice.domain;

public class AccountLimitExceededException extends RuntimeException {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package net.chrisrichardson.ftgo.accountingservice.domain;

import io.eventuate.Event;

public class AccountLimitSufficientEvent implements Event {
}
Loading