Skip to content

Commit 6b70007

Browse files
committed
1.2.0, build, documentation
1 parent 702c6e8 commit 6b70007

File tree

5 files changed

+87
-26
lines changed

5 files changed

+87
-26
lines changed

.github/workflows/build-main.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: GitHub Merge Or Release Build Actions For Nats Server Runner
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
env:
12+
BUILD_EVENT: ${{ github.event_name }}
13+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
14+
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
15+
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
16+
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
17+
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
18+
steps:
19+
- name: Setup JDK 8
20+
uses: actions/setup-java@v2
21+
with:
22+
java-version: '8'
23+
distribution: 'adopt'
24+
- name: Setup GO
25+
uses: actions/setup-go@v2
26+
with:
27+
go-version: 1.19.1
28+
- name: Install Nats Server
29+
run: |
30+
cd $GITHUB_WORKSPACE
31+
git clone https://github.com/nats-io/nats-server.git
32+
cd nats-server
33+
go get
34+
go build main.go
35+
mkdir -p ~/.local/bin
36+
cp main ~/.local/bin/nats-server
37+
cd ..
38+
rm -rf nats-server
39+
nats-server -v
40+
- name: Check out code
41+
uses: actions/checkout@v2
42+
- name: Build and Test
43+
run: chmod +x gradlew && ./gradlew clean test
44+
- name: Verify Javadoc
45+
run: ./gradlew javadoc
46+
- name: Verify and Publish Snapshot
47+
if: ${{ success() && github.event_name == 'push' }}
48+
run: ./gradlew -i publishToSonatype

.github/workflows/build-merge-or-release.yml renamed to .github/workflows/build-release.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name: GitHub Merge Or Release Build Actions For Nats Server Runner
22

33
on:
4-
push:
5-
branches:
6-
- main
74
release:
85
branches:
96
- main
@@ -47,9 +44,6 @@ jobs:
4744
run: chmod +x gradlew && ./gradlew clean test
4845
- name: Verify Javadoc
4946
run: ./gradlew javadoc
50-
- name: On Merge to Main, Verify and Publish Snapshot
51-
if: ${{ success() && github.event_name == 'push' }}
52-
run: ./gradlew -i publishToSonatype
53-
- name: On Tag Release Main, Verify, Sign and Publish Release
47+
- name: Verify, Sign and Publish Release
5448
if: ${{ success() && github.event_name == 'release' }}
5549
run: ./gradlew -i signArchives signMavenJavaPublication publishToSonatype closeAndReleaseSonatypeStagingRepository

README.md

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ Run the [NATS messaging system](https://nats.io) Server from your Java code.
77
[![License Apache 2](https://img.shields.io/badge/License-Apache2-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
88
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.nats/jnats-server-runner/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.nats/jnats-server-runner)
99
[![Javadoc](http://javadoc.io/badge/io.nats/jnats-server-runner.svg?branch=main)](http://javadoc.io/doc/io.nats/jnats-server-runner?branch=main)
10-
[![Release Badge](https://github.com/nats-io/java-nats-server-runner/actions/workflows/build.yml/badge.svg?event=push)](https://github.com/nats-io/java-nats-server-runner/actions/workflows/build.yml)
10+
[![Build Main Badge](https://github.com/nats-io/java-nats-server-runner/actions/workflows/build-main.yml/badge.svg?event=push)](https://github.com/nats-io/java-nats-server-runner/actions/workflows/build-main.yml)
11+
[![Release Badge](https://github.com/nats-io/java-nats-server-runner/actions/workflows/build-release.yml/badge.svg?event=release)](https://github.com/nats-io/java-nats-server-runner/actions/workflows/build-release.yml)
1112

1213
Useful for running unit or integration tests on the localhost.
1314

15+
### Executable
16+
1417
By default, the server is found in your path in this order:
1518
- the `executablePath` set in the builder
1619
- the path found in the `nats_server_path` environment variable
@@ -27,19 +30,35 @@ try (NatsServerRunner server = new NatsServerRunner()) {
2730

2831
For more complicated setup, use the `NatsServerRunnerBuilder`
2932
```java
30-
try (NatsServerRunner server = NatsServerRunner.builder()
33+
String[] customInserts = new String[] {
34+
"server_name=srv1",
35+
"cluster {",
36+
" name: testcluster",
37+
" listen: 127.0.0.1:4222",
38+
" routes: [",
39+
" nats-route://127.0.0.2:4222",
40+
" nats-route://127.0.0.3:4222",
41+
" ]",
42+
"}",
43+
""
44+
};
45+
46+
NatsServerRunner.Builder builder = NatsServerRunner.builder()
3147
.port(4567)
32-
.debugLevel(DebugLevel.DEBUG)
48+
.debugLevel(DebugLevel.DEBUG_TRACE)
3349
.jetstream(true)
34-
.configFilePath("/custom/nats-server")
35-
.build())
36-
{
37-
System.out.println("Server running on port: " + server.getPort())
38-
Connection c = Nats.connect(server.getURI());
39-
...
50+
.executablePath("/this/run/only/nats-server")
51+
.configFilePath("/mypath/custom.conf")
52+
.configInserts(customInserts);
53+
54+
try (NatsServerRunner server = builder.build()) {
55+
}
56+
catch (Exception e) {
57+
throw new RuntimeException(e);
4058
}
4159
```
4260

61+
4362
## License
4463

4564
Unless otherwise noted, the NATS source files are distributed

src/main/java/nats/io/NatsServerRunner.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public NatsServerRunner(boolean debug) throws IOException {
103103
* @throws IOException thrown when the server cannot start
104104
*/
105105
public NatsServerRunner(boolean debug, boolean jetstream) throws IOException {
106-
this(builder().debug(debug).jetStream(jetstream));
106+
this(builder().debug(debug).jetstream(jetstream));
107107
}
108108

109109
/**
@@ -137,7 +137,7 @@ public NatsServerRunner(int port, boolean debug) throws IOException {
137137
* @throws IOException thrown when the server cannot start
138138
*/
139139
public NatsServerRunner(int port, boolean debug, boolean jetstream) throws IOException {
140-
this(builder().port(port).debug(debug).jetStream(jetstream));
140+
this(builder().port(port).debug(debug).jetstream(jetstream));
141141
}
142142

143143
/**
@@ -173,7 +173,7 @@ public NatsServerRunner(String configFilePath, boolean debug) throws IOException
173173
* @throws IOException thrown when the server cannot start
174174
*/
175175
public NatsServerRunner(String configFilePath, boolean debug, boolean jetstream) throws IOException {
176-
this(builder().debug(debug).jetStream(jetstream).configFilePath(configFilePath));
176+
this(builder().debug(debug).jetstream(jetstream).configFilePath(configFilePath));
177177
}
178178

179179
/**
@@ -263,7 +263,7 @@ public NatsServerRunner(String[] customArgs, boolean debug) throws IOException {
263263
* @throws IOException thrown when the server cannot start
264264
*/
265265
public NatsServerRunner(String[] customArgs, boolean debug, boolean jetstream) throws IOException {
266-
this(builder().debug(debug).jetStream(jetstream).customArgs(customArgs));
266+
this(builder().debug(debug).jetstream(jetstream).customArgs(customArgs));
267267
}
268268

269269
/**
@@ -296,7 +296,7 @@ public NatsServerRunner(String[] customArgs, int port, boolean debug) throws IOE
296296
* @throws IOException thrown when the server cannot start
297297
*/
298298
public NatsServerRunner(int port, boolean debug, boolean jetstream, String configFilePath, String[] configInserts, String[] customArgs) throws IOException {
299-
this(builder().port(port).debug(debug).jetStream(jetstream).configFilePath(configFilePath).configInserts(configInserts).customArgs(customArgs));
299+
this(builder().port(port).debug(debug).jetstream(jetstream).configFilePath(configFilePath).configInserts(configInserts).customArgs(customArgs));
300300
}
301301

302302
public NatsServerRunner(NatsServerRunnerOptions natsServerRunnerOptions) throws Exception {
@@ -531,7 +531,7 @@ public void shutdown() throws InterruptedException {
531531
* For AutoCloseable, calls shutdown(true).
532532
*/
533533
@Override
534-
public void close() throws InterruptedException {
534+
public void close() throws Exception {
535535
shutdown(true);
536536
}
537537

@@ -568,12 +568,12 @@ public Builder debug(boolean trueForDebugTraceFalseForNoDebug) {
568568
return this;
569569
}
570570

571-
public Builder jetStream() {
571+
public Builder jetstream() {
572572
this.jetstream = true;
573573
return this;
574574
}
575575

576-
public Builder jetStream(boolean jetStream) {
576+
public Builder jetstream(boolean jetStream) {
577577
this.jetstream = jetStream;
578578
return this;
579579
}
@@ -660,7 +660,7 @@ public NatsServerRunner build() throws IOException {
660660
public Builder runnerOptions(NatsServerRunnerOptions nsro) {
661661
port(nsro.port())
662662
.debugLevel(nsro.debugLevel())
663-
.jetStream(nsro.jetStream())
663+
.jetstream(nsro.jetStream())
664664
.configFilePath(nsro.configFilePath())
665665
.configInserts(nsro.configInserts())
666666
.customArgs(nsro.customArgs())

src/test/java/nats/io/NatsServerRunnerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public void testWithoutDebugAndJetStream(boolean debug, boolean jetStream) throw
5959
public void testWithoutDebugAndJetStreamBuilder(boolean debug, boolean jetStream) throws IOException, InterruptedException {
6060
try (NatsServerRunner runner = NatsServerRunner.builder()
6161
.debug(debug)
62-
.jetStream(jetStream)
62+
.jetstream(jetStream)
6363
.build())
6464
{
6565
validateBasics(runner, debug, jetStream);

0 commit comments

Comments
 (0)