Skip to content

Commit

Permalink
[ADDED] GetNATSOptions() to return an empty NATS Options structure
Browse files Browse the repository at this point in the history
This is required for users wanting to embed NATS Streaming.

Resolves #499
  • Loading branch information
kozlovic committed Mar 7, 2018
1 parent 21451b3 commit 13d0a26
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
7 changes: 7 additions & 0 deletions server/server.go
Expand Up @@ -4955,3 +4955,10 @@ func (s *StanServer) Snapshot() (raft.FSMSnapshot, error) {
func (s *StanServer) Restore(snapshot io.ReadCloser) error {
return s.restoreFromSnapshot(snapshot)
}

// GetNATSOptions returns an empty NATS Options structure that one can
// use to configure and then pass to RunServerWithOpts()
func GetNATSOptions() *server.Options {
opts := server.Options{}
return &opts
}
17 changes: 17 additions & 0 deletions server/server_run_test.go
Expand Up @@ -818,3 +818,20 @@ func TestGhostDurableSubs(t *testing.T) {
s = runServerWithOpts(t, opts, nil)
check(false)
}

func TestGetNATSOptions(t *testing.T) {
opts := GetDefaultOptions()
nopts := GetNATSOptions()
nopts.Host = "127.0.0.1"
nopts.Port = 4567
s, err := RunServerWithOpts(opts, nopts)
if err != nil {
t.Fatalf("Error running server: %v", err)
}
defer s.Shutdown()
sc, err := stan.Connect(clusterName, clientName, stan.NatsURL("nats://127.0.0.1:4567"))
if err != nil {
t.Fatalf("Error on connect: %v", err)
}
sc.Close()
}

0 comments on commit 13d0a26

Please sign in to comment.