Skip to content

Commit

Permalink
initial example
Browse files Browse the repository at this point in the history
  • Loading branch information
zambrovski committed Jan 14, 2024
1 parent e8053d7 commit 4f8475b
Show file tree
Hide file tree
Showing 38 changed files with 571 additions and 181 deletions.
12 changes: 12 additions & 0 deletions .docker/config/axonserver.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
axoniq:
axonserver:
name: eventstore-transformations-local
hostname: localhost
#standalone: true
autocluster:
first:
contexts: default
accesscontrol:
enabled: false
devmode:
enabled: true
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Please use one of the following templates:

https://github.com/GITHUB_ORGANIZATION/GITHUB_REPOSITORY/issues/new/choose
https://github.com/holixon/axon-event-transformation-example/issues/new/choose
19 changes: 0 additions & 19 deletions .github/workflows/development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ name: Development branches

on:
push:
branches:
- '*'
- '**/*'
- '!master'
pull_request:

jobs:
Expand Down Expand Up @@ -36,18 +32,3 @@ jobs:
- name: Build with Maven
run: ./mvnw clean verify -U -B -T4 -ntp

# I-test
- name: Run itest
run: ./mvnw integration-test failsafe:verify -Pitest -U -B -T4 -ntp

# - name: Upload coverage to Codecov
# if: github.event_name == 'push' && github.actor != 'dependabot[bot]'
# uses: codecov/codecov-action@v1.0.2
# with:
# token: ${{secrets.CODECOV_TOKEN}}

# - name: Upload test coverage to Codacy
# if: github.event_name == 'push' && github.actor != 'dependabot[bot]'
# run: bash <(curl -Ls https://coverage.codacy.com/get.sh)
# env:
# CODACY_PROJECT_TOKEN: "${{secrets.CODACY_PROJECT_TOKEN}}"
58 changes: 0 additions & 58 deletions .github/workflows/master.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.docker/data/
.docker/events/
target/

pom.xml.tag
Expand Down
2 changes: 1 addition & 1 deletion .java-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
17
17.0
15 changes: 3 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
# BASE_ARTIFACT_ID
# axon-event-transformation-example

Template repository for usage in organizations: toolisticon, holunda-io, holixon...

[![incubating](https://img.shields.io/badge/lifecycle-INCUBATING-orange.svg)](https://github.com/holisticon#open-source-lifecycle)
[![Build Status](https://github.com/GITHUB_ORGANIZATION/GITHUB_REPOSITORY/workflows/Development%20branches/badge.svg)](https://github.com/GITHUB_ORGANIZATION/GITHUB_REPOSITORY/actions)
[![Build Status](https://github.com/holixon/axon-event-transformation-example/workflows/Development%20branches/badge.svg)](https://github.com/holixon/axon-event-transformation-example/actions)
[![sponsored](https://img.shields.io/badge/sponsoredBy-Holisticon-RED.svg)](https://holisticon.de/)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/BASE_GROUP_ID/BASE_ARTIFACT_ID/badge.svg)](https://maven-badges.herokuapp.com/maven-central/BASE_GROUP_ID/BASE_ARTIFACT_ID)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.holixon.example.axon-event-transformation/axon-event-transformation-example/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.holixon.example.axon-event-transformation/axon-event-transformation-example)

This repository is a **template repository** designed to be a template for the next project.

## How to use

* create a new repo on github (can be in any organization). Choose this project as template repository. Copy all branches, so the `master`exists in your repo (for the github actions)
* on the command line: clone your new repo locally
* in the `setup.sh` script: set your organization, repository and base package
* run the `setup.sh` script, all placeholders are filled with your information
* delete the setup-script
* Update the `README.md`
* in the `developers` section of the `pom.xml`: mention yourself ... it is your project.

## Things to change after usage of template

Expand Down
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: "3.5"

services:
axonserver:
image: axoniq/axonserver:2023.2.1-jdk-11
container_name: eventstore-transformations-axonserver
ports:
- "8024:8024"
- "8124:8124"
volumes:
- .docker/config:/axonserver/config:ro
- .docker/data:/axonserver/data
- .docker/events:/axonserver/events
96 changes: 63 additions & 33 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,43 @@
<relativePath/>
</parent>

<groupId>BASE_GROUP_ID</groupId>
<artifactId>BASE_ARTIFACT_ID</artifactId>
<groupId>io.holixon.example.axon-event-transformation</groupId>
<artifactId>axon-event-transformation-example</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>${project.artifactId}</name>
<description>BASE_DESCRIPTION</description>
<url>https://github.com/GITHUB_ORGANIZATION/GITHUB_REPOSITORY/</url>
<description>axon-event-transformation-example</description>
<url>https://github.com/holixon/axon-event-transformation-example/</url>

<properties>
<!-- TEST -->
<mockito.version>5.2.1</mockito.version>
<assertj.version>3.24.2</assertj.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>3.1.2</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.axonframework</groupId>
<artifactId>axon-bom</artifactId>
<version>4.9.1</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<!-- KOTLIN -->
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<artifactId>kotlin-stdlib</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
Expand All @@ -37,6 +56,23 @@
<artifactId>kotlin-logging-jvm</artifactId>
<version>${kotlin-logging.version}</version>
</dependency>
<dependency>
<groupId>org.axonframework</groupId>
<artifactId>axon-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-kotlin</artifactId>
</dependency>

<!-- TEST -->
<dependency>
Expand Down Expand Up @@ -71,6 +107,25 @@
<build>
<defaultGoal>clean jacoco:prepare-agent package</defaultGoal>

<pluginManagement>
<plugins>
<plugin>
<!-- kotlin compiler -->
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<configuration>
<jvmTarget>17</jvmTarget>
<compilerPlugins>
<plugin>spring</plugin>
<plugin>no-arg</plugin>
<plugin>all-open</plugin>
</compilerPlugins>
</configuration>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
<groupId>org.jacoco</groupId>
Expand All @@ -80,10 +135,6 @@
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
Expand All @@ -99,34 +150,13 @@
</licenses>

<scm>
<connection>scm:git:git@github.com:GITHUB_ORGANIZATION/GITHUB_REPOSITORY.git</connection>
<url>scm:git:git@github.com:GITHUB_ORGANIZATION/GITHUB_REPOSITORY.git</url>
<developerConnection>scm:git:git@github.com:GITHUB_ORGANIZATION/GITHUB_REPOSITORY.git</developerConnection>
<connection>scm:git:git@github.com:holixon/axon-event-transformation-example.git</connection>
<url>scm:git:git@github.com:holixon/axon-event-transformation-example.git</url>
<developerConnection>scm:git:git@github.com:holixon/axon-event-transformation-example.git</developerConnection>
<tag>HEAD</tag>
</scm>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>

<developers>
<developer>
<id>jangalinski</id>
<name>Jan Galinski</name>
<roles>
<role>Product Owner</role>
<role>Developer</role>
</roles>
<organization>Holisticon AG</organization>
<organizationUrl>https://holisticon.de</organizationUrl>
</developer>
<developer>
<id>zambrovski</id>
<name>Simon Zambrovski</name>
Expand Down
25 changes: 0 additions & 25 deletions setup.sh

This file was deleted.

8 changes: 0 additions & 8 deletions src/main/kotlin/KotlinLibTemplate.kt

This file was deleted.

11 changes: 11 additions & 0 deletions src/main/kotlin/SensorApplication.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.holixon.example.axon.event.transformation

import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication

fun main(args: Array<String>) {
runApplication<SensorApplication>(*args).let { Unit }
}

@SpringBootApplication
class SensorApplication
35 changes: 35 additions & 0 deletions src/main/kotlin/adapter/in/BatchUpdater.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package io.holixon.example.axon.event.transformation.adapter.`in`

import io.holixon.example.axon.event.transformation.application.port.`in`.Measurement
import io.holixon.example.axon.event.transformation.application.port.`in`.SensorMeasurements
import io.holixon.example.axon.event.transformation.application.port.`in`.UpdateMeasurementInPort
import org.springframework.stereotype.Component
import java.time.LocalDate
import kotlin.random.Random

@Component
class BatchUpdater(
val updateMeasurementInPort: UpdateMeasurementInPort
) {

fun runBatchUpdate(sensorId: String = "temp1") {
(0L..365L).forEach { offset ->
val updateDate = LocalDate.now().plusDays(offset)
generateForecast(sensorId, updateDate)
}
}

fun generateForecast(sensorId: String, updateDate: LocalDate) {
updateMeasurementInPort.updateSensorMeasurements(
SensorMeasurements(
sensorId = sensorId,
values = (0L..365L).associate { forecastOffset ->
updateDate.plusDays(forecastOffset) to Measurement(randomFloat(), "°C")
}
)
)

}

private fun randomFloat(): Float = Random.nextFloat() * 30
}
Loading

0 comments on commit 4f8475b

Please sign in to comment.