Skip to content

Commit 9475eab

Browse files
committed
docs(executor/nats): add README.md
Signed-off-by: LuBashQ <[email protected]>
1 parent 74b30c9 commit 9475eab

File tree

1 file changed

+117
-0
lines changed

1 file changed

+117
-0
lines changed

executors/nats/README.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Venom - Executor NATS
2+
3+
Step to publish and subscribe to NATS subjects.
4+
5+
## Input
6+
7+
### Defaults
8+
9+
This step includes some default values:
10+
11+
- `url`: defaults to `nats://localhost:4222`
12+
- `messageLimit`: defaults to 1
13+
- `deadline`: defaults to 1 second
14+
15+
### Authentication
16+
17+
This step allows for connection with and without TLS. Without TLS, the step does not require additional options.
18+
19+
To connect to a NATS server with TLS, declare:
20+
21+
```yaml
22+
tls:
23+
selfSigned: true
24+
serverVerify: true
25+
certificatePath: "/path/to/client_certificate"
26+
keyPath: "/path/to/client_key"
27+
caPath: ""/path/to/ca_certificate""
28+
```
29+
30+
Enable `selfSigned` only if the NATS server uses self-signed certificates. If enabled, `caPath` is mandatory.
31+
32+
Enable `serverVerify` only if the NATS server verifies the client certificates. If enabled `certificatePath` and `keyPath` are mandatory.
33+
34+
### publish
35+
36+
The publish command allows to publish a payload to a specific NATS subject. Optionally it can wait for a reply.
37+
38+
Full configuration example:
39+
40+
```yaml
41+
- type: nats
42+
url: "{{.url}}" # defaults to nats://localhost:4222 if not set
43+
command: publish
44+
subject: "{{.subject}}" # mandatory
45+
payload: '{{.message}}'
46+
headers:
47+
customHeader:
48+
- "some-value"
49+
assertions:
50+
- result.error ShouldBeEmpty
51+
```
52+
53+
Full configuration with reply example:
54+
55+
```yaml
56+
- type: nats
57+
url: "{{.url}}" # defaults to nats://localhost:4222 if not set
58+
command: publish
59+
request: true
60+
subject: "{{.subject}}" # mandatory
61+
replySubject: "{{.subject}}.reply" # mandatory if `request = true`
62+
payload: '{{.message}}'
63+
assertions:
64+
- result.error ShouldBeEmpty
65+
- result.messages.__Len__ ShouldEqual 1
66+
```
67+
68+
It is possible to publish to a Jetstream stream by declaring `jetstream: true` in the step.
69+
70+
For example:
71+
72+
```yaml
73+
- type: nats
74+
command: publish
75+
subject: "{{.subject}}.hello" # mandatory
76+
deadline: 2
77+
jetstream:
78+
enabled: true
79+
assertions:
80+
- result.error ShouldNotBeEmpty
81+
```
82+
83+
### subscribe
84+
85+
The subscribe command allows to receive messages from a subject or a stream.
86+
87+
Full configuration example:
88+
89+
```yaml
90+
- type: nats
91+
command: subscribe
92+
subject: "{{.subject}}.>" # mandatory
93+
messageLimit: 2 # defaults to 1
94+
deadline: 10 # in seconds, defaults to 1
95+
assertions:
96+
- result.error ShouldBeEmpty
97+
- result.messages.__Len__ ShouldEqual 2
98+
```
99+
100+
Full configuration example with Jetstream:
101+
102+
```yaml
103+
- type: nats
104+
command: subscribe
105+
subject: "{{.subject}}.>" # mandatory
106+
messageLimit: 2 # defaults to 1
107+
deadline: 10 # in seconds, defaults to 1
108+
jetstream:
109+
enabled: true
110+
stream: TEST # mandatory, stream must exist
111+
filterSubjects:
112+
- "{{.subject}}.js.hello"
113+
- "{{.subject}}.js.world"
114+
assertions:
115+
- result.error ShouldBeEmpty
116+
- result.messages.__Len__ ShouldEqual 2
117+
```

0 commit comments

Comments
 (0)