-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnats.go
More file actions
37 lines (30 loc) · 688 Bytes
/
nats.go
File metadata and controls
37 lines (30 loc) · 688 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package syslog2nats
import (
"os"
"github.com/nats-io/nats-server/v2/server"
natsserver "github.com/nats-io/nats-server/v2/test"
)
const (
NATSPORT = 4222
CONFPATH = "./conf"
)
func RunBasicJetStreamServer(port int) *server.Server {
opts := natsserver.DefaultTestOptions
opts.Port = port
opts.JetStream = true
return RunServerWithOptions(opts)
}
func RunServerWithOptions(opts server.Options) *server.Server {
return natsserver.RunServer(&opts)
}
func ShutdownJSServerAndRemoveStorage(s *server.Server) {
var sd string
if config := s.JetStreamConfig(); config != nil {
sd = config.StoreDir
}
s.Shutdown()
if sd != "" {
os.RemoveAll(sd)
}
s.WaitForShutdown()
}