add nats to env
This commit is contained in:
parent
651a7ecac6
commit
8bcb0dd653
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
/build
|
/build
|
||||||
|
/tmp
|
||||||
|
16
Makefile
16
Makefile
@ -5,13 +5,23 @@ build: $(GO_FILES)
|
|||||||
go build -o build/zadmin-server ./cmd/server/main.go
|
go build -o build/zadmin-server ./cmd/server/main.go
|
||||||
go build -o build/zadmin-client ./cmd/client/main.go
|
go build -o build/zadmin-client ./cmd/client/main.go
|
||||||
|
|
||||||
server: ./build/zadmin-server
|
docker-up:
|
||||||
|
mkdir -p ./tmp
|
||||||
|
docker compose -f ./deployments/compose-dev.yaml up
|
||||||
|
|
||||||
|
docker-down:
|
||||||
|
docker compose -f ./deployments/compose-dev.yaml down
|
||||||
|
|
||||||
|
docker-clean: docker-down
|
||||||
|
rm -rf ./tmp
|
||||||
|
|
||||||
|
server: build
|
||||||
./build/zadmin-server
|
./build/zadmin-server
|
||||||
|
|
||||||
client: ./build/zadmin-client
|
client: build
|
||||||
./build/zadmin-client
|
./build/zadmin-client
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -r build
|
rm -r build
|
||||||
|
|
||||||
.PHONY: clean run-server run-client
|
.PHONY: clean run-server run-client docker-up
|
||||||
|
@ -1,7 +1,26 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"github.com/nats-io/nats.go"
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
fmt.Println("Hello, World!")
|
nc, err := nats.Connect(nats.DefaultURL)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("failed to connect to nats-server: %s\n", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Println("connected to nats-server")
|
||||||
|
|
||||||
|
// simply print to the console for now
|
||||||
|
nc.Subscribe("*", func(msg *nats.Msg) {
|
||||||
|
log.Printf("got message: %s\n", msg.Data)
|
||||||
|
})
|
||||||
|
|
||||||
|
shouldExit := false
|
||||||
|
for !shouldExit {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
5
deployments/compose-dev.yaml
Normal file
5
deployments/compose-dev.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
services:
|
||||||
|
nats-server:
|
||||||
|
image: nats:latest
|
||||||
|
ports:
|
||||||
|
- 4222:4222
|
10
go.mod
10
go.mod
@ -1,3 +1,13 @@
|
|||||||
module git.mziesel.nl/mans/zadmin
|
module git.mziesel.nl/mans/zadmin
|
||||||
|
|
||||||
go 1.23.0
|
go 1.23.0
|
||||||
|
|
||||||
|
require github.com/nats-io/nats.go v1.37.0
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/klauspost/compress v1.17.2 // indirect
|
||||||
|
github.com/nats-io/nkeys v0.4.7 // indirect
|
||||||
|
github.com/nats-io/nuid v1.0.1 // indirect
|
||||||
|
golang.org/x/crypto v0.18.0 // indirect
|
||||||
|
golang.org/x/sys v0.16.0 // indirect
|
||||||
|
)
|
||||||
|
12
go.sum
Normal file
12
go.sum
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
github.com/klauspost/compress v1.17.2 h1:RlWWUY/Dr4fL8qk9YG7DTZ7PDgME2V4csBXA8L/ixi4=
|
||||||
|
github.com/klauspost/compress v1.17.2/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
|
||||||
|
github.com/nats-io/nats.go v1.37.0 h1:07rauXbVnnJvv1gfIyghFEo6lUcYRY0WXc3x7x0vUxE=
|
||||||
|
github.com/nats-io/nats.go v1.37.0/go.mod h1:Ubdu4Nh9exXdSz0RVWRFBbRfrbSxOYd26oF0wkWclB8=
|
||||||
|
github.com/nats-io/nkeys v0.4.7 h1:RwNJbbIdYCoClSDNY7QVKZlyb/wfT6ugvFCiKy6vDvI=
|
||||||
|
github.com/nats-io/nkeys v0.4.7/go.mod h1:kqXRgRDPlGy7nGaEDMuYzmiJCIAAWDK0IMBtDmGD0nc=
|
||||||
|
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
|
||||||
|
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
|
||||||
|
golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc=
|
||||||
|
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
|
||||||
|
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
|
||||||
|
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
Loading…
x
Reference in New Issue
Block a user