Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/koslib/go-nats-demo

Super basic nats example project
https://github.com/koslib/go-nats-demo

go nats nats-messaging

Last synced: about 2 months ago
JSON representation

Super basic nats example project

Awesome Lists containing this project

README

        

# go-nats-demo

Me, playing around with [nats](https://nats.io/).

Just a simple playground for exploring nats, try proto code and experiment before actually using something in prod.

In the `main.go` file you can find examples for:

1. Setting up a consumer/producer for an async example
2. Setting up a request/reply model example for synchronous messages consumption

## Running it
For running locally a nats server through docker:
```
docker run --name nats -p 6222:6222 -p 4222:4222 -p 8222:8222 nats:latest
```

For a demonstration of the whole functionality (just logs printing, nothing fancy), you can run:
```
docker-compose up
```

and remember to rebuild if you change the code while experimenting:
```
docker-compose up --build
```

and when you're done tear down:
```
docker-compose down
```

> Note: the docker-compose setup includes two nats services, to showcase a cluster example.

## Nats-operator

### Deploy dummy service on k8s

#### Deploy with custom helm chart

```
helm upgrade --install test http://www.koslib.com/mycharts/servicetpl-0.5.3.tgz -f .chart/values.yaml --wait --set image.tag=
```

#### Deploy with simple kubernetes deployment

```bash
kubectl create deployment test --image=
```

### Deploying the nats operator and cluster

nats-operator [link](https://github.com/nats-io/nats-operator). Will do the namespace-scope installation.

When the operator has been installed, create a nats cluster:
```bash
cat <