Skip to content

Commit 811af73

Browse files
Librarize (#12)
* Refactor into a library
1 parent ff8264e commit 811af73

11 files changed

Lines changed: 459 additions & 406 deletions

.github/workflows/release.yaml

Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,51 @@
11
name: Publish
2+
23
on:
34
release:
45
types: [created]
56

67
jobs:
7-
build:
8+
upload:
9+
name: Upload
810
runs-on: ubuntu-latest
9-
permissions:
10-
contents: write
1111

1212
steps:
13-
- uses: actions/checkout@v3
14-
with:
15-
fetch-depth: 0
16-
17-
- name: Set up JDK 8
18-
uses: actions/setup-java@v3
19-
with:
20-
java-version: '8'
21-
distribution: 'temurin'
22-
server-id: github
23-
settings-path: ${{ github.workspace }}
24-
25-
- name: Build jar
26-
run: mvn --batch-mode -Drevision=${{ github.event.release.tag_name }} -Dsha1= -Dchangelist= clean package
27-
env:
28-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29-
30-
- name: Pack RPM
31-
run: cd rpm/ && mvn --batch-mode -Drevision=${{ github.event.release.tag_name }} -Dsha1= -Dchangelist= -f rpm.pom.xml package
32-
env:
33-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34-
35-
- name: Attach rpm to release
36-
uses: softprops/action-gh-release@v1
37-
with:
38-
files: |
39-
rpm/target/rpm/com.teragrep-rlp_09/RPMS/noarch/com.teragrep-rlp_09-*.noarch.rpm
40-
target/rlp_09-*-jar-with-dependencies.jar
13+
- uses: actions/checkout@v2
14+
15+
- name: Cache Local Maven Repository
16+
uses: actions/cache@v2
17+
with:
18+
path: ~/.m2/repository
19+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
20+
21+
- name: Setup Maven Central
22+
uses: actions/setup-java@v2
23+
with:
24+
java-version: 8.0.292+10
25+
distribution: 'adopt'
26+
27+
server-id: ossrh
28+
server-username: MAVEN_CENTRAL_USERNAME
29+
server-password: MAVEN_CENTRAL_TOKEN
30+
31+
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
32+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
33+
34+
- name: Publish to Maven Central
35+
run: mvn --batch-mode -Drevision=${{ github.event.release.tag_name }} -Dsha1= -Dchangelist= clean deploy -Ppublish-maven-central
36+
env:
37+
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
38+
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
39+
40+
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
41+
42+
- name: Setup GitHub Packages
43+
uses: actions/setup-java@v2
44+
with:
45+
java-version: 8.0.292+10
46+
distribution: 'adopt'
47+
48+
- name: Publish to GitHub Packages
49+
run: mvn --batch-mode -Drevision=${{ github.event.release.tag_name }} -Dsha1= -Dchangelist= clean deploy -Ppublish-github-packages
50+
env:
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.adoc

Lines changed: 47 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,68 @@
1-
# RELP Flooder rlp_09
1+
= RELP Flooder library rlp_09
22

3-
Simple but scalable RELP flooder
3+
Simple but scalable RELP flooder library
44

5-
## Features
5+
== Features
66

7-
- Simple to set up
87
- Simple to use
9-
- Gives statistics
108
- Scales to as many threads as wanted
9+
- Supports user-supplied record providers to make dynamic content
1110

12-
## Limitations
11+
== Limitations
1312

14-
- No structured data support yet
13+
- Minimal failure tolerance, mostly meant for testing
14+
- Limited usability outside specific testing situations
15+
- Supports only one record per RELP batch
1516
- No TLS support yet
16-
- No customizable message support yet
17-
- Supports only RFC5424
1817

19-
## How to compile
18+
== How to use
2019

21-
`mvn clean package`
20+
[sourcecode,java]
21+
----
22+
// Set all settings
23+
RelpFlooderConfig relpFlooderConfig = new RelpFlooderConfig(target, port, record, threads);
2224
23-
## How to run
25+
// Alternatively use setters
26+
RelpFlooderConfig relpFlooderConfig = new RelpFlooderConfig();
27+
relpFlooderConfig.setTarget("127.0.0.1");
28+
relpFlooderConfig.setPort(601);
29+
relpFlooderConfig.setThreads(4);
2430
25-
`java -jar rlp_09.jar`
31+
// Provide config and Iterator<byte[]> provider to RelpFlooder, here is example implementation
32+
ExampleRelpFlooderIteratorFactory exampleRelpFlooderIteratorFactory = new ExampleRelpFlooderIteratorFactory();
33+
RelpFlooder relpFlooder = new RelpFlooder(relpFlooderConfig, exampleRelpFlooderIteratorFactory);
34+
relpFlooder.start();
35+
relpFlooder.stop();
2636
27-
## Configurations
37+
// Get total records and bytes sent
38+
LOGGER.info("Sent <{}> records", relpFlooder.getTotalRecordsSent());
39+
LOGGER.info("Sent <{}> bytes", relpFlooder.getTotalBytesSent());
2840
41+
// Get total records and bytes sent per thread;
42+
LOGGER.info("Sent <{}> records per thread", relpFlooder.getRecordsSentPerThread());
43+
LOGGER.info("Sent <{}> bytes per thread", relpFlooder.getTotalBytesSentPerThread());
44+
----
2945

30-
[cols="3"]
46+
Example Iterator will send only static records like as
47+
48+
[source,sh]
49+
----
50+
<14>1 2024-02-29T13:58:05.605Z localhost rlp_09 - - - Example rlo_09 event
51+
----
52+
53+
== Configurations
54+
55+
[cols="4"]
3156
|===
32-
|System property|Default value|Usage
57+
|Configuration key|Setter|Default value|Usage
3358

34-
|hostname|localhost|Sets hostname for the event
35-
|appname|rlp_09|Sets used appname for the event
36-
|target|127.0.0.1|RELP target server
37-
|port|1601|RELP target port
38-
|threads|4|RELP Flooder thread count
39-
|useTls|false|Is TLS used for connections
40-
|payloadSize|10|Event message payload size (excludes any headers)
41-
|batchSize|1|How many events is sent in one batch
59+
|target|setTarget(String target)|127.0.0.1|Sets RELP target
60+
|port|setPort(int port)|601|Sets RELP port
61+
|threads|setThreads(int threads)|1|Flooder thread count
4262

4363
|===
4464

45-
## Contributing
65+
== Contributing
4666

4767
You can involve yourself with our project by https://github.com/teragrep/rlp_09/issues/new/choose[opening an issue] or submitting a pull request.
4868

@@ -55,8 +75,9 @@ Contribution requirements:
5575

5676
Read more in our https://github.com/teragrep/teragrep/blob/main/contributing.adoc[Contributing Guideline].
5777

58-
### Contributor License Agreement
78+
=== Contributor License Agreement
5979

6080
Contributors must sign https://github.com/teragrep/teragrep/blob/main/cla.adoc[Teragrep Contributor License Agreement] before a pull request is accepted to organization's repositories.
6181

6282
You need to submit the CLA only once. After submitting the CLA you can contribute to all Teragrep's repositories.
83+
----

pom.xml

Lines changed: 76 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,10 @@
1313
<revision>0.0.1</revision>
1414
<changelist>-SNAPSHOT</changelist>
1515
<sha1/>
16-
<dropwizard-metrics.version>4.2.25</dropwizard-metrics.version>
16+
<env.GITHUB_REPOSITORY>INVALID_GITHUB_REPOSITORY</env.GITHUB_REPOSITORY>
1717
<rlp_01.version>4.0.1</rlp_01.version>
1818
</properties>
1919
<dependencies>
20-
<!-- dropwizard metrics -->
21-
<dependency>
22-
<groupId>io.dropwizard.metrics</groupId>
23-
<artifactId>metrics-core</artifactId>
24-
<version>${dropwizard-metrics.version}</version>
25-
</dependency>
2620
<!-- RELP -->
2721
<dependency>
2822
<groupId>com.teragrep</groupId>
@@ -77,14 +71,13 @@
7771
<exclude>toolchains.xml</exclude>
7872
<exclude>settings.xml</exclude>
7973
<exclude>rpm/**</exclude>
80-
<!-- assembly file -->
81-
<exclude>src/main/assembly/jar-with-dependencies.xml</exclude>
8274
<!-- readme -->
8375
<exclude>README.adoc</exclude>
8476
</excludes>
8577
</configuration>
8678
</plugin>
8779
<plugin>
80+
<groupId>org.apache.maven.plugins</groupId>
8881
<artifactId>maven-enforcer-plugin</artifactId>
8982
<version>3.4.1</version>
9083
<executions>
@@ -117,44 +110,80 @@
117110
<target>${java.version}</target>
118111
</configuration>
119112
</plugin>
120-
<plugin>
121-
<groupId>org.apache.maven.plugins</groupId>
122-
<artifactId>maven-jar-plugin</artifactId>
123-
<version>3.3.0</version>
124-
<configuration>
125-
<archive>
126-
<manifest>
127-
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
128-
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
129-
</manifest>
130-
</archive>
131-
</configuration>
132-
</plugin>
133-
<plugin>
134-
<groupId>org.apache.maven.plugins</groupId>
135-
<artifactId>maven-assembly-plugin</artifactId>
136-
<version>3.6.0</version>
137-
<configuration>
138-
<descriptors>
139-
<descriptor>src/main/assembly/jar-with-dependencies.xml</descriptor>
140-
</descriptors>
141-
<archive>
142-
<manifest>
143-
<mainClass>com.teragrep.rlp_09.Main</mainClass>
144-
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
145-
</manifest>
146-
</archive>
147-
</configuration>
148-
<executions>
149-
<execution>
150-
<id>make-assembly</id>
151-
<phase>package</phase>
152-
<goals>
153-
<goal>single</goal>
154-
</goals>
155-
</execution>
156-
</executions>
157-
</plugin>
158113
</plugins>
159114
</build>
115+
<profiles>
116+
<profile>
117+
<id>publish-maven-central</id>
118+
<build>
119+
<plugins>
120+
<plugin>
121+
<groupId>org.apache.maven.plugins</groupId>
122+
<artifactId>maven-gpg-plugin</artifactId>
123+
<version>1.6</version>
124+
<executions>
125+
<execution>
126+
<id>sign-artifacts</id>
127+
<phase>verify</phase>
128+
<goals>
129+
<goal>sign</goal>
130+
</goals>
131+
<configuration>
132+
<gpgArguments>
133+
<arg>--pinentry-mode</arg>
134+
<arg>loopback</arg>
135+
</gpgArguments>
136+
</configuration>
137+
</execution>
138+
</executions>
139+
</plugin>
140+
</plugins>
141+
</build>
142+
<distributionManagement>
143+
<snapshotRepository>
144+
<id>ossrh</id>
145+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
146+
</snapshotRepository>
147+
<repository>
148+
<id>ossrh</id>
149+
<name>Central Repository OSSRH</name>
150+
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
151+
</repository>
152+
</distributionManagement>
153+
</profile>
154+
<profile>
155+
<id>publish-github-packages</id>
156+
<build>
157+
<plugins>
158+
<plugin>
159+
<groupId>org.apache.maven.plugins</groupId>
160+
<artifactId>maven-gpg-plugin</artifactId>
161+
<version>1.6</version>
162+
<executions>
163+
<execution>
164+
<id>sign-artifacts</id>
165+
<phase>verify</phase>
166+
<goals>
167+
<goal>sign</goal>
168+
</goals>
169+
<configuration>
170+
<gpgArguments>
171+
<arg>--pinentry-mode</arg>
172+
<arg>loopback</arg>
173+
</gpgArguments>
174+
</configuration>
175+
</execution>
176+
</executions>
177+
</plugin>
178+
</plugins>
179+
</build>
180+
<distributionManagement>
181+
<repository>
182+
<id>github</id>
183+
<name>GitHub Packages</name>
184+
<url>https://maven.pkg.github.com/${env.GITHUB_REPOSITORY}</url>
185+
</repository>
186+
</distributionManagement>
187+
</profile>
188+
</profiles>
160189
</project>

0 commit comments

Comments
 (0)