_example

command
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

README

example

output

run

# pub origin 1
$ go run example/master1.go 

# pub origin 2
$ go run example/master2.go 

# new pub origin
$ go run example/relay-master.go

# relay start
$ go run cmd/main.go --relay-yaml example/relay.yaml

without yaml

import

import(
  "context"
  "github.com/octu0/nats-relay"
)

configuration and run

topics            := make(map[string]nrelay.RelayClientConfig)
topics["foo.>"]    = nrelay.RelayClientConfig{ WorkerNum: 2 }
topics["bar.*"]    = nrelay.RelayClientConfig{ WorkerNum: 2 }
topics["baz.quux"] = nrelay.RelayClientConfig{ WorkerNum: 2 }

conf := nrelay.RelayConfig{
  PrimaryUrl: "nats://192.168.0.1:4201",
  SecondaryUrl: "nats://192.168.0.2:4201",
  NatsUrl: "nats://127.0.0.1:4222",
  Topics: topics,
}

ctx := context.Background()
ctx  = context.WithValue(ctx, "relay.config", conf)

svr := nrelay.NewRelayServer(rctx)
svr.Start(context.TODO())

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL