Skip to content

Commit

Permalink
0.1.0-dev (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
lumber1000 authored Sep 17, 2024
1 parent 6cf0fc6 commit 29126ec
Show file tree
Hide file tree
Showing 24 changed files with 17,382 additions and 2 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/build-dev-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Build and publish dev release Docker image to Github Container Registry ghcr.io

on: workflow_dispatch

jobs:
build:
uses: th2-net/.github/.github/workflows/compound-java.yml@main
with:
build-target: 'Docker'
devRelease: true
createTag: true
docker-username: ${{ github.actor }}
secrets:
docker-password: ${{ secrets.GITHUB_TOKEN }}
nvd-api-key: ${{ secrets.NVD_APIKEY }}
15 changes: 15 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Build and publish release Docker image to Github Container Registry ghcr.io

on: workflow_dispatch

jobs:
build:
uses: th2-net/.github/.github/workflows/compound-java.yml@main
with:
build-target: 'Docker'
devRelease: false
createTag: true
docker-username: ${{ github.actor }}
secrets:
docker-password: ${{ secrets.GITHUB_TOKEN }}
nvd-api-key: ${{ secrets.NVD_APIKEY }}
20 changes: 20 additions & 0 deletions .github/workflows/build-sanpshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Build and publish Docker image to Github Container Registry ghcr.io

on:
push:
branches-ignore:
- master
- version-*
- dependabot**
paths-ignore:
- README.md

jobs:
build-job:
uses: th2-net/.github/.github/workflows/compound-java-dev.yml@main
with:
build-target: 'Docker'
docker-username: ${{ github.actor }}
secrets:
docker-password: ${{ secrets.GITHUB_TOKEN }}
nvd-api-key: ${{ secrets.NVD_APIKEY }}
23 changes: 23 additions & 0 deletions .github/workflows/ci-unwelcome-words.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: CI

on:
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
- name: Checkout tool
uses: actions/checkout@v4
with:
repository: exactpro-th2/ci-github-action
ref: master
token: ${{ secrets.PAT_CI_ACTION }}
path: ci-github-action
- name: Run CI action
uses: ./ci-github-action
with:
ref: ${{ github.sha }}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
build/
shared/
.gradle/
.idea/
logs/
out/
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM gradle:8.7-jdk11 AS build
ARG release_version
COPY ./ .
RUN gradle --no-daemon clean build dockerPrepare -Prelease_version=${release_version}

FROM adoptopenjdk/openjdk11:alpine
WORKDIR /home
COPY --from=build /home/gradle/build/docker .
ENTRYPOINT ["/home/service/bin/service"]
59 changes: 57 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,57 @@
# th2-codec-fix-ng
Yet another FIX codec
# th2-codec-fix-ng 0.1.0

This codec can be used in dirty mode for decoding and encoding messages via the FIX protocol.

## Configuration

### Codec factory

To use the FIX codec you will need to specify the following codec factory:
**com.exactpro.th2.codec.fixng.FixNgCodecFactory**

### Configuration parameters
Configuration example.
```yaml
beginString: FIXT.1.1
dictionary: fix_dictionary.xml
charset: US_ASCII
dirtyMode: false
decodeValuesToStrings: true
decodeComponentsToNestedMaps: true
```
#### beginString
default value: `FIXT.1.1`. Value to put into the `BeginString` field (tag: 8) when encoding messages.

#### dictionary
required value. XML file containing the FIX dictionary.

#### charset
default value: `US_ASCII`. Charset for reading and writing FIX fields.

#### dirtyMode
default value: `false`. If `true`, processes all messages in dirty mode (generates warnings on invalid messages and continues processing). If `false`, only messages that contain the `encode-mode: dirty` property will be processed in dirty mode.

#### decodeValuesToStrings
default value: `true`. If `true`, decodes all values to strings instead of typed values.

#### decodeComponentsToNestedMaps
default value: `true`. If `true`, decodes `components` to nested maps instead of unwrap component's map to message's main map.

## Performance
Component benchmark results available [here](docs/benchmarks/jmh-benchmark.md).

## Release notes
### 0.1.0
+ Dirty mode added.
+ `dirtyMode` setting option added.
+ `decodeValuesToStrings` setting option added.
+ JMH benchmarks added
+ Migrate to th2 gradle plugin `0.1.2` (th2-bom:4.7.0)
+ Updated th2-common: `5.11.0-dev`
+ Updated th2-codec: `5.5.0-dev`
+ Updated sailfish: `3.3.241`
+ Workflows updated

### 0.0.1
+ Initial release
105 changes: 105 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
plugins {
id "application"
id "com.exactpro.th2.gradle.component" version "0.1.2"
id "org.jetbrains.kotlin.jvm" version "$kotlin_version"
id "org.jetbrains.kotlin.kapt" version "$kotlin_version"
id "me.champeau.jmh" version "0.7.2"
}

ext {
sailfishVersion = '3.3.241'
commonVersion = '5.14.0-dev'
jmhVersion = '1.37'
}

group = 'com.exactpro.th2'
version = release_version

ext.excludeSailfish = { rcd ->
rcd.excludeModule("com.exactpro.sf", "sailfish-core")
rcd.excludeModule("com.exactpro.sf", "sailfish-common")
rcd.excludeModule("com.exactpro.sf", "sailfish-rest-api-client")
rcd.excludeModule("com.exactpro.sf", "service-http")
}

repositories {
maven {
name 'Sonatype_snapshots'
url 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
content {
excludeSailfish(it)
}
}

// ignoreGradleMetadataRedirection is used for sonatype because
// Sailfish dependencies have constrains that interfere with our BOM
// so we exclude Gradle metadata for this repositories.
// We've checked these versions - they are compatible and safe to use
maven {
name 'Sonatype_snapshots'
url 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
metadataSources {
mavenPom()
artifact()
ignoreGradleMetadataRedirection()
}
}

maven {
name 'Sonatype_releases'
url 'https://s01.oss.sonatype.org/content/repositories/releases/'
content {
excludeSailfish(it)
}
}

maven {
name 'Sonatype_releases'
url 'https://s01.oss.sonatype.org/content/repositories/releases/'
metadataSources {
mavenPom()
artifact()
ignoreGradleMetadataRedirection()
}
}

mavenCentral()
mavenLocal()

configurations.configureEach {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
resolutionStrategy.cacheDynamicVersionsFor 0, 'seconds'
}
}

dependencies {
implementation "com.exactpro.th2:common:$commonVersion"
implementation "com.exactpro.th2:codec:5.5.0-dev"

implementation ("com.exactpro.sf:sailfish-common:$sailfishVersion") {
exclude group: "commons-configuration", module: "commons-configuration" // because of the vulnerability
exclude group: "com.fasterxml.jackson.dataformat", module: "jackson-dataformat-yaml" // because of the vulnerability
exclude group: "com.exactpro.mina", module: "apache-mina-core" // because of the vulnerability
exclude group: "javax.activation", module: "javax.activation-api" // because of the license
}

implementation "io.netty:netty-buffer"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation "io.github.oshai:kotlin-logging:5.1.4"

compileOnly "com.google.auto.service:auto-service:1.1.1"
annotationProcessor "com.google.auto.service:auto-service:1.1.1"
kapt "com.google.auto.service:auto-service:1.1.1"

jmh "org.openjdk.jmh:jmh-core:$jmhVersion"
jmh "org.openjdk.jmh:jmh-generator-annprocess:$jmhVersion"
jmh "org.openjdk.jmh:jmh-generator-bytecode:$jmhVersion"

testImplementation "org.junit.jupiter:junit-jupiter:5.11.0"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit5"
testImplementation "org.assertj:assertj-core:3.26.3"
}

test.useJUnitPlatform()
application.mainClass = "com.exactpro.th2.codec.MainKt"
dependencyCheck.suppressionFile = "suppressions.xml"
84 changes: 84 additions & 0 deletions docs/benchmarks/jmh-benchmark.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# JMH benchmark

encode the following FIX message:

```kotlin
ParsedMessage(
MessageId("test_alias", Direction.OUTGOING, 0L, Instant.now(), emptyList()),
EventId("test_id", "test_book", "test_scope", Instant.now()),
"ExecutionReport",
mutableMapOf("encode-mode" to "dirty"),
PROTOCOL,
mutableMapOf(
"header" to mutableMapOf(
"MsgSeqNum" to 10947,
"SenderCompID" to "SENDER",
"SendingTime" to LocalDateTime.parse("2023-04-19T10:36:07.415088"),
"TargetCompID" to "RECEIVER",
"BeginString" to "FIXT.1.1",
"BodyLength" to 295,
"MsgType" to "8"
),
"ExecID" to "495504662",
"ClOrdID" to "zSuNbrBIZyVljs",
"OrigClOrdID" to "zSuNbrBIZyVljs",
"OrderID" to "49415882",
"ExecType" to '0',
"OrdStatus" to '0',
"LeavesQty" to BigDecimal(500),
"CumQty" to BigDecimal(500),
"SecurityID" to "NWDR",
"SecurityIDSource" to "8",
"TradingParty" to mutableMapOf(
"NoPartyIDs" to mutableListOf(
mutableMapOf(
"PartyID" to "NGALL1FX01",
"PartyIDSource" to 'D',
"PartyRole" to 76
),
mutableMapOf(
"PartyID" to "0",
"PartyIDSource" to 'P',
"PartyRole" to 3
)
)
),
"Account" to "test",
"OrdType" to 'A',
"TimeInForce" to '0',
"Side" to 'B',
"Symbol" to "ABC",
"OrderQty" to BigDecimal(500),
"Price" to BigDecimal(1000),
"Unknown" to "500",
"TransactTime" to LocalDateTime.parse("2018-02-05T10:38:08.000008"),
"trailer" to mutableMapOf(
"CheckSum" to "191"
)
)
)
```

decode the same FIX message:

8=FIXT.1.19=29535=849=SENDER56=RECEIVER34=1094752=20230419-10:36:07.41508817=49550466211=zSuNbrBIZyVljs41=zSuNbrBIZyVljs37=49415882150=039=0151=50014=50048=NWDR22=8453=2448=NGALL1FX01447=D452=76448=0447=P452=31=test40=A59=054=B55=ABC38=50044=100047=50060=20180205-10:38:08.00000810=191

Testing is carried out in two formats of parsed messages: String values and Typed values.

## benchmark results for version 0.1.0-dev

dirty mode:

Benchmark Mode Cnt Score Error Units
FixNgCodecBenchmark.encodeFixMessageString thrpt 25 178479.225 ± 2851.079 ops/s
FixNgCodecBenchmark.encodeFixMessageTyped thrpt 25 263077.629 ± 3967.905 ops/s
FixNgCodecBenchmark.parseFixMessageString thrpt 25 173370.305 ± 1878.013 ops/s
FixNgCodecBenchmark.parseFixMessageTyped thrpt 25 186232.291 ± 1295.186 ops/s

strict mode:

Benchmark Mode Cnt Score Error Units
FixNgCodecBenchmark.encodeFixMessageString thrpt 25 179523.040 ± 3084.493 ops/s
FixNgCodecBenchmark.encodeFixMessageTyped thrpt 25 265769.868 ± 3893.223 ops/s
FixNgCodecBenchmark.parseFixMessageString thrpt 25 165978.593 ± 6474.860 ops/s
FixNgCodecBenchmark.parseFixMessageTyped thrpt 25 186475.155 ± 1548.224 ops/s
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kotlin.code.style=official
kotlin_version=1.8.22
release_version=0.1.0

vcs_url=https://github.com/th2-net/th2-codec-fix-ng
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Loading

0 comments on commit 29126ec

Please sign in to comment.