Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
g41797 committed Oct 17, 2023
1 parent 06bc1e2 commit d7d9a63
Showing 1 changed file with 74 additions and 3 deletions.
77 changes: 74 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,76 @@
# syslog2nats

[![Go](https://github.com/g41797/syslog2nats/actions/workflows/go.yml/badge.svg)](https://github.com/g41797/syslog2nats/actions/workflows/go.yml)
# syslog2nats [![Go](https://github.com/g41797/syslog2nats/actions/workflows/go.yml/badge.svg)](https://github.com/g41797/syslog2nats/actions/workflows/go.yml)

Example of using [syslogsidecar](https://github.com/g41797/syslogsidecar#readme) with [NATS](https://nats.io)

## Plugins

In order to supply NATS specific functionality, 3 plugins to syslogsidecar were developed:
- connector
- producer
- consumer (used for the tests)


### Connector

Configuration file: connector.json
```json
{
"CONN_URL": "nats://127.0.0.1:4222"
}
```
The rest of connection options are default.

Connector creates sharable _*nats.Conn*_ for:
- periodic validation of connectivity with memphis
- using by producer (production) and consumer (e2e test)

### Producer

Configuration file: syslogproducer.json
```json
{
"STREAM": "syslog"
}
```

Producer uses received from connector _*nats.Conn*_.
It created JETSTREAM with name from configuration, the rest of stream options are default.

syslog messages are produced to jetstream as *Header* with _*empty payload*_:
```go
.................................
msg := &nats.Msg{
Subject: name,
Header: make(nats.Header),
}

for k, v := range inmsg {
vstr, ok := v.(string)
if !ok {
continue
}
msg.Header.Add(k, vstr)
}
.................................
```

## e2e test

- TCP/IP
- 1000000 syslog messages
- received
- produced(published)
- consumed
- compared

Build and run under vscode:
```bash
go clean -cache -testcache
go build ./cmd/syslog-e2e/
./syslog-e2e -cf ./cmd/syslog-e2e/conf/
```
nats server runs as embedded within syslog-e2e process.

Report:
20.59306566s Was send 1000000 messages. Successfully consumed 1000000 Received 1000000

0 comments on commit d7d9a63

Please sign in to comment.