Skip to content

Commit

Permalink
docs: Sample of edge initiated replicated event sourcing (#1083)
Browse files Browse the repository at this point in the history
  • Loading branch information
johanandren authored Dec 14, 2023
1 parent 9dfbd0e commit da6ef14
Show file tree
Hide file tree
Showing 45 changed files with 2,097 additions and 84 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,12 @@ jobs:
run: |-
cd samples/grpc/iot-service-scala
sbt test -Dakka-projection.version=`cat ~/.version`
- name: gRPC sample Java charger RES identical impl check
run: |-
diff samples/grpc/local-drone-control-java/src/main/java/charging/ChargingStation.java samples/grpc/restaurant-drone-deliveries-service-java/src/main/java/charging/ChargingStation.java
- name: gRPC sample Scala charger RES identical impl check
run: |-
# RES sample should be identical
diff samples/grpc/local-drone-control-scala/src/main/scala/charging/ChargingStation.scala samples/grpc/restaurant-drone-deliveries-service-scala/src/main/scala/charging/ChargingStation.scala
13 changes: 13 additions & 0 deletions samples/grpc/local-drone-control-java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@ Inspect the current state of the local delivery queue
grpcurl -plaintext 127.0.0.1:8080 local.drones.DeliveriesQueueService.GetCurrentQueue
```

Ask to charge the drone, with a charging station first created in the restaurant-drone-deliveries service:

```shell
grpcurl -d '{"drone_id":"drone1","charging_station_id":"station1"}' -plaintext 127.0.0.1:8080 local.drones.DroneService.GoCharge
```

Use the restaurant-drone-deliveries charge station inspection command to see the charging drones, and that they eventually
complete their charging:

```shell
grpcurl -d '{"charging_station_id":"station1"}' -plaintext localhost:8101 charging.ChargingStationService.GetChargingStationState
```

## Running the sample as a multi node service

It is also possible to run this sample service as a multi node Akka Cluster, for that you need to start a PostgreSQL
Expand Down
52 changes: 51 additions & 1 deletion samples/grpc/local-drone-control-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
<akka-persistence-r2dbc.version>1.2.0</akka-persistence-r2dbc.version>
<akka-management.version>1.5.0</akka-management.version>
<akka-diagnostics.version>2.1.0</akka-diagnostics.version>
<akka-http.version>10.5.1</akka-http.version>
<akka-http.version>10.6.0</akka-http.version>
<akka-grpc.version>2.4.0</akka-grpc.version>
<akka-grpc-maven-plugin.version>2.4.0</akka-grpc-maven-plugin.version>
<logback.version>1.2.13</logback.version>
<prometheus.client.version>0.16.0</prometheus.client.version>
<junit.version>4.13.1</junit.version>
<scala.binary.version>2.13</scala.binary.version>
<protobuf-java.version>3.22.2</protobuf-java.version>
<native.maven.plugin.version>0.9.26</native.maven.plugin.version>
<mainClass>local.drones.Main</mainClass>
<!-- needs to be defined to allow for overriding through mvn exec:exec -DAPP_CONFIG=local1.conf -->
Expand Down Expand Up @@ -166,6 +167,13 @@
<version>${logback.version}</version>
</dependency>

<!-- for using predefined protobuf message types, see also maven dependency plugin config below -->
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>${protobuf-java.version}</version>
</dependency>

<!-- Prometheus client for custom metrics -->
<dependency>
<groupId>io.prometheus</groupId>
Expand Down Expand Up @@ -244,12 +252,54 @@
</configuration>
</plugin>

<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>getClasspathFilenames</id>
<goals>
<!-- provides the jars of the classpath as properties inside of maven
so that we can refer to one of the jars in the exec plugin config below -->
<goal>properties</goal>
</goals>
</execution>
<execution>
<id>unpack</id>
<phase>generate-sources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>${protobuf-java.version}</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/proto</outputDirectory>
<includes>**/*.proto</includes>
</artifactItem>
</artifactItems>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>com.lightbend.akka.grpc</groupId>
<artifactId>akka-grpc-maven-plugin</artifactId>
<version>${akka-grpc-maven-plugin.version}</version>
<configuration>
<language>Java</language>
<protoPaths>
<!-- include predefined google protobuf message types -->
<protoPath>target/proto</protoPath>
<!-- our own protobuf messages and gRPC services -->
<protoPath>src/main/protobuf</protoPath>
</protoPaths>
</configuration>
<executions>
<execution>
Expand Down
Loading

0 comments on commit da6ef14

Please sign in to comment.