diff --git a/cmd/nats/comet/main.go b/cmd/nats/comet/main.go index 6558f78..456f8bf 100644 --- a/cmd/nats/comet/main.go +++ b/cmd/nats/comet/main.go @@ -48,10 +48,10 @@ func main() { } cfg.Env = &conf.Env{ - Region: "test", - Zone: "test", - DeployEnv: "test", - Host: "test_server", + Region: "china", + Zone: "gd", + DeployEnv: "dev", + Host: "comet", } rand.Seed(time.Now().UTC().UnixNano()) @@ -64,9 +64,9 @@ func main() { resolver.Register(dis) // new comet server srv := comet.NewServer(cfg) - // if err := comet.InitWhitelist(cfg.Whitelist); err != nil { - // panic(err) - // } + if err := comet.InitWhitelist(cfg.Whitelist); err != nil { + panic(err) + } if err := comet.InitTCP(srv, cfg.TCP.Bind, runtime.NumCPU()); err != nil { panic(err) } diff --git a/cmd/nats/job/main.go b/cmd/nats/job/main.go index c87954b..d477335 100644 --- a/cmd/nats/job/main.go +++ b/cmd/nats/job/main.go @@ -32,10 +32,10 @@ func main() { cfg = conf.Default() env := &conf.Env{ - Region: "test", - Zone: "test", - DeployEnv: "test", - Host: "localhost", + Region: "china", + Zone: "gd", + DeployEnv: "dev", + Host: "job", } cfg.Env = env diff --git a/cmd/nats/logic/main.go b/cmd/nats/logic/main.go index 534b808..4a6cff2 100644 --- a/cmd/nats/logic/main.go +++ b/cmd/nats/logic/main.go @@ -2,12 +2,13 @@ package main import ( "context" - "flag" + "net" "os" "os/signal" "strconv" "syscall" + "github.com/sanity-io/litter" "github.com/tsingson/discovery/naming" resolver "github.com/tsingson/discovery/naming/grpc" "github.com/tsingson/fastx/utils" @@ -27,37 +28,40 @@ const ( appid = "goim.logic" ) -var cfg *conf.NatsConfig +var cfg *conf.LogicConfig func main() { - path, _ := utils.GetCurrentExecDir() confPath := path + "/logic-config.toml" - flag.Parse() var err error - cfg, err = conf.Init(confPath) + cfg, err = conf.LoadToml(confPath) if err != nil { panic(err) } - env := &conf.Env{ - Region: "test", - Zone: "test", - DeployEnv: "test", - Host: "localhost", + litter.Dump( cfg ) + + { + // env := &conf.Env{ + // Region: "china", + // Zone: "gd", + // DeployEnv: "sz", + // Host: "logic", + // } + // cfg.Env = env } - cfg.Env = env - // log.Infof("goim-logic [version: %s env: %+v] start", ver, cfg.Env) - // grpc register naming - dis := naming.New(cfg.Discovery) - resolver.Register(dis) + var dis *naming.Discovery + + { + log.Infof("goim-logic [version: %s env: %+v] start", ver, cfg.Env) + // grpc register naming + dis = naming.New(cfg.Discovery) + resolver.Register(dis) + } - // grpc register naming - // dis := naming.New(cfg.Discovery) - // resolver.Register(dis) // logic srv := logic.New(cfg) httpSrv := http.New(cfg.HTTPServer, srv) @@ -87,11 +91,11 @@ func main() { } } -func register(dis *naming.Discovery, srv *logic.NatsLogic) context.CancelFunc { +func register(dis *naming.Discovery, srv *logic.Logic) context.CancelFunc { env := cfg.Env - addr := "10.0.0.11" // ip.InternalIP() - // _, port, _ := net.SplitHostPort(cfg.RPCServer.Addr) - port := "3119" + addr := "127.0.0.1" // ip.InternalIP() + _, port, _ := net.SplitHostPort(cfg.RPCServer.Addr) + // port := "3119" ins := &naming.Instance{ Region: env.Region, Zone: env.Zone, diff --git a/examples/websocket/index.html b/examples/websocket/index.html index 8100bd2..46f11e1 100644 --- a/examples/websocket/index.html +++ b/examples/websocket/index.html @@ -23,9 +23,9 @@

status:

push

-

curl -d 'mid message' http://127.0.0.1:3101/goim/push/mids?operation=1000&mids=123

-

curl -d 'room message' http://127.0.0.1:3101/goim/push/room?operation=1000&type=live&room=1000

-

curl -d 'broadcast message' http://127.0.0.1:3101/goim/push/all?operation=1000

+

curl -d 'mid message' http://127.0.0.1:3111/goim/push/mids?operation=1000&mids=123

+

curl -d 'room message' http://127.0.0.1:3111/goim/push/room?operation=1000&type=live&room=1000

+

curl -d 'broadcast message' http://127.0.0.1:3111/goim/push/all?operation=1000

message:

diff --git a/examples/websocket/main.go b/examples/websocket/main.go index 7778b62..48f5101 100644 --- a/examples/websocket/main.go +++ b/examples/websocket/main.go @@ -7,5 +7,5 @@ import ( func main() { // Simple static webserver: - log.Fatal(http.ListenAndServe(":1998", http.FileServer(http.Dir("./")))) + log.Fatal(http.ListenAndServe(":1999", http.FileServer(http.Dir("./")))) } diff --git a/go.mod b/go.mod index 843d141..11ab69b 100644 --- a/go.mod +++ b/go.mod @@ -7,11 +7,13 @@ require ( github.com/Workiva/go-datastructures v1.0.50 // indirect github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da // indirect github.com/boltdb/bolt v1.3.1 // indirect + github.com/bsm/sarama-cluster v2.1.15+incompatible github.com/dustin/go-humanize v1.0.0 // indirect github.com/gin-gonic/gin v1.3.0 github.com/gogo/protobuf v1.2.1 github.com/golang/protobuf v1.3.1 github.com/gomodule/redigo v2.0.0+incompatible + github.com/google/uuid v1.1.1 github.com/hako/durafmt v0.0.0-20180520121703-7b7ae1e72ead // indirect github.com/hashicorp/go-immutable-radix v1.0.0 // indirect github.com/hashicorp/go-msgpack v0.5.3 // indirect @@ -27,6 +29,7 @@ require ( github.com/nats-io/nuid v1.0.0 // indirect github.com/nsip/gommap v0.0.0-20181229045655-f7881c3a959f // indirect github.com/pascaldekloe/goe v0.1.0 // indirect + github.com/sanity-io/litter v1.1.0 github.com/sirupsen/logrus v1.4.0 // indirect github.com/stretchr/testify v1.3.0 github.com/tsingson/discovery v0.1.0 diff --git a/go.sum b/go.sum index d21e143..d2b29a6 100644 --- a/go.sum +++ b/go.sum @@ -2,10 +2,13 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT github.com/AndreasBriese/bbloom v0.0.0-20180913140656-343706a395b7/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/DataDog/zstd v1.3.5 h1:DtpNbljikUepEPD16hD4LvIcmhnhdLTiW/5pHgbmp14= github.com/DataDog/zstd v1.3.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/NetWatcher/service v0.0.0-20170526123706-12236803cddf h1:TKizf/caqRAmi8ctrzoPTjZNFV8RnlY8aAve8Qw8nu4= github.com/NetWatcher/service v0.0.0-20170526123706-12236803cddf/go.mod h1:/qXMWgh5hccv5xCa/Fq6UF0msHhpTOV7gh3GYN47rBo= +github.com/Shopify/sarama v1.21.0 h1:0GKs+e8mn1RRUzfg9oUXv3v7ZieQLmOZF/bfnmmGhM8= github.com/Shopify/sarama v1.21.0/go.mod h1:yuqtN/pe8cXRWG5zPaO7hCfNJp5MwmkoJEoLjkm5tCQ= +github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWsokNbMijUGhmcoBJc= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/Workiva/go-datastructures v1.0.50 h1:slDmfW6KCHcC7U+LP3DDBbm4fqTwZGn1beOFPfGaLvo= github.com/Workiva/go-datastructures v1.0.50/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA= @@ -16,6 +19,8 @@ github.com/boltdb/bolt v1.3.1 h1:JQmyP4ZBrce+ZQu0dY660FMfatumYDLun9hBCUVIkF4= github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= github.com/bsm/go-guid v1.0.0 h1:E3M8Rmd8WEVQ3w7pFXemZaKApnHGnSXuiu9ALE1xnj8= github.com/bsm/go-guid v1.0.0/go.mod h1:N5CP3axb8BxDAfWR2mlBNASD66YjIlI3LXqoaRSGGE4= +github.com/bsm/sarama-cluster v2.1.15+incompatible h1:RkV6WiNRnqEEbp81druK8zYhmnIgdOjqSVi0+9Cnl2A= +github.com/bsm/sarama-cluster v2.1.15+incompatible/go.mod h1:r7ao+4tTNXvWm+VRpRJchr2kQhqxgmAp2iEX5W96gMM= github.com/btcsuite/btcutil v0.0.0-20190207003914-4c204d697803 h1:j3AgPKKZtZStM2nyhrDSLSYgT7YHrZKdSkq1OYeLjvM= github.com/btcsuite/btcutil v0.0.0-20190207003914-4c204d697803/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= @@ -27,8 +32,11 @@ github.com/dgraph-io/badger v1.5.4/go.mod h1:VZxzAIRPHRVNRKRo6AXrX9BJegn6il06VMT github.com/dgryski/go-farm v0.0.0-20190104051053-3adb47b1fb0f/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/eapache/go-resiliency v1.1.0 h1:1NtRmCAqadE2FN4ZcN6g90TP3uk8cg9rn9eNK2197aU= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= +github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 h1:YEetp8/yCZMuEPMUDHG0CW/brkkEp8mzqk2+ODEitlw= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= +github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/elazarl/goproxy v0.0.0-20181111060418-2ce16c963a8a/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= @@ -51,6 +59,7 @@ github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfb github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db h1:woRePGFeVFfLKN/pOkfl+p/TAqKOfFu+7KPlMVpok/w= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/gomodule/redigo v2.0.0+incompatible h1:K/R+8tc58AaqLkqG2Ol3Qk+DR/TlNuhuh457pBFPtt0= github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= @@ -140,15 +149,18 @@ github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa github.com/parnurzeal/gorequest v0.2.15/go.mod h1:3Kh2QUMJoqw3icWAecsyzkpY7UzRfDhbRdTjtNwNiUE= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pierrec/lz4 v2.0.5+incompatible h1:2xWsjqPFWcplujydGg4WmhC/6fZqK42wMM8aXeqhl0I= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a h1:9ZKAASQSHhDYGoxY8uLVpewe1GDZ2vu2Tr/vTdVAkFQ= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rs/zerolog v1.12.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= github.com/rs/zerolog v1.13.0 h1:hSNcYHyxDWycfePW7pUI8swuFkcSMPKh3E63Pokg1Hk= github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= +github.com/sanity-io/litter v1.1.0 h1:BllcKWa3VbZmOZbDCoszYLk7zCsKHz5Beossi8SUcTc= github.com/sanity-io/litter v1.1.0/go.mod h1:CJ0VCw2q4qKU7LaQr3n7UOSHzgEMgcGco7N/SkZQPjw= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= diff --git a/internal/nats/comet/conf/conf.go b/internal/nats/comet/conf/conf.go index 9553ba3..37d5791 100644 --- a/internal/nats/comet/conf/conf.go +++ b/internal/nats/comet/conf/conf.go @@ -143,7 +143,6 @@ func Init(path string) (cfg *Config, err error) { _, err = toml.DecodeFile(confPath, &cfg) } Conf = cfg - return } @@ -152,20 +151,20 @@ func Default() *Config { return &Config{ Debug: true, Env: &Env{ - Region: "test", - Zone: "test", - DeployEnv: "test", - Host: "test_server", + Region: "china", + Zone: "gd", + DeployEnv: "dev", + Host: "comet", Weight: 100, Addrs: []string{"127.0.0.1:3101"}, Offline: false, }, Discovery: &naming.Config{ Nodes: []string{"127.0.0.1:7171"}, - Region: "test", - Zone: "test", - Env: "test", - Host: "test_server", + Region: "china", + Zone: "gd", + Env: "dev", + Host: "discovery", }, RPCClient: &RPCClient{ Dial: xtime.Duration(time.Second), diff --git a/internal/nats/dao/nats.go b/internal/nats/dao/nats.go index 2993200..243d564 100644 --- a/internal/nats/dao/nats.go +++ b/internal/nats/dao/nats.go @@ -19,7 +19,7 @@ import ( // NatsDao dao for nats type Dao struct { - c *conf.NatsConfig + c *conf.LogicConfig natsClient *nats.Conn liftClient liftbridge.Client redis *redis.Pool @@ -28,7 +28,7 @@ type Dao struct { type NatsDao = Dao -// NatsConfig configuration for nats / liftbridge queue +// LogicConfig configuration for nats / liftbridge queue type Config struct { Channel string ChannelID string @@ -40,7 +40,7 @@ type Config struct { type NatsConfig = Config // New new a dao and return. -func New(c *conf.NatsConfig) *Dao { +func New(c *conf.LogicConfig) *Dao { conn, err := newNatsClient(c.Nats.NatsAddr, c.Nats.LiftAddr, c.Nats.Channel, c.Nats.ChannelID) if err != nil { diff --git a/internal/nats/job/conf/conf.go b/internal/nats/job/conf/conf.go index d2268dc..cdefe44 100644 --- a/internal/nats/job/conf/conf.go +++ b/internal/nats/job/conf/conf.go @@ -56,6 +56,8 @@ type Nats struct { LiftAddr string } +type NatsConfig = Nats + var ( confPath string region string @@ -108,14 +110,14 @@ func Default() *Config { Region: "china", Zone: "gd", DeployEnv: "dev", - Host: "test_server", + Host: "job", }, Discovery: &naming.Config{ Nodes: []string{"127.0.0.1:7171"}, Region: "china", Zone: "gd", Env: "dev", - Host: "test_server", + Host: "discovery", }, Comet: &Comet{ RoutineChan: 1024, diff --git a/internal/nats/logic/conf/conf.go b/internal/nats/logic/conf/conf.go index 7e7fb3c..c25e3d7 100644 --- a/internal/nats/logic/conf/conf.go +++ b/internal/nats/logic/conf/conf.go @@ -5,51 +5,28 @@ import ( "github.com/BurntSushi/toml" "github.com/tsingson/discovery/naming" + "golang.org/x/xerrors" xtime "github.com/tsingson/goim/pkg/time" ) -var ( - confPath string - region string - zone string - deployEnv string - host string - weight int64 - - // Conf config - Conf *NatsConfig -) - -func init() { - Conf = Default() - // var ( - // defHost, _ = os.Hostname() - // defWeight, _ = strconv.ParseInt(os.Getenv("WEIGHT"), 10, 32) - // ) - // flag.StringVar(&confPath, "conf", "logic-example.toml", "default config path") - // flag.StringVar(®ion, "region", os.Getenv("REGION"), "avaliable region. or use REGION env variable, value: sh etc.") - // flag.StringVar(&zone, "zone", os.Getenv("ZONE"), "avaliable zone. or use ZONE env variable, value: sh001/sh002 etc.") - // flag.StringVar(&deployEnv, "deploy.env", os.Getenv("DEPLOY_ENV"), "deploy env. or use DEPLOY_ENV env variable, value: dev/fat1/uat/pre/prod etc.") - // flag.StringVar(&host, "host", defHost, "machine hostname. or use default machine hostname.") - // flag.Int64Var(&weight, "weight", defWeight, "load balancing weight, or use WEIGHT env variable, value: 10 etc.") -} - -// NatsConfig config. -type NatsConfig struct { +// LogicConfig config. +type Config struct { Env *Env Discovery *naming.Config RPCClient *RPCClient RPCServer *RPCServer HTTPServer *HTTPServer - Kafka *Kafka - Nats *Nats - Redis *Redis - Node *Node - Backoff *Backoff - Regions map[string][]string + // Kafka *Kafka + Nats *Nats + Redis *Redis + Node *Node + Backoff *Backoff + Regions map[string][]string } +type LogicConfig = Config + // Env is env config. type Env struct { Region string @@ -107,6 +84,7 @@ type Nats struct { ChannelID string // "channel-stream" AckInbox string // "acks" } +type NatsConfig = Nats // RPCClient is RPC client config. type RPCClient struct { @@ -134,8 +112,34 @@ type HTTPServer struct { WriteTimeout xtime.Duration } +var ( + confPath string + region string + zone string + deployEnv string + host string + weight int64 + + // Conf config + Conf *Config +) + +func init() { + Conf = Default() + // var ( + // defHost, _ = os.Hostname() + // defWeight, _ = strconv.ParseInt(os.Getenv("WEIGHT"), 10, 32) + // ) + // flag.StringVar(&confPath, "conf", "logic-example.toml", "default config path") + // flag.StringVar(®ion, "region", os.Getenv("REGION"), "avaliable region. or use REGION env variable, value: sh etc.") + // flag.StringVar(&zone, "zone", os.Getenv("ZONE"), "avaliable zone. or use ZONE env variable, value: sh001/sh002 etc.") + // flag.StringVar(&deployEnv, "deploy.env", os.Getenv("DEPLOY_ENV"), "deploy env. or use DEPLOY_ENV env variable, value: dev/fat1/uat/pre/prod etc.") + // flag.StringVar(&host, "host", defHost, "machine hostname. or use default machine hostname.") + // flag.Int64Var(&weight, "weight", defWeight, "load balancing weight, or use WEIGHT env variable, value: 10 etc.") +} + // Init init config. -func Init(path string) (cfg *NatsConfig, err error) { +func Init(path string) (cfg *Config, err error) { Conf = Default() if len(path) > 0 { _, err = toml.DecodeFile(path, &Conf) @@ -145,22 +149,38 @@ func Init(path string) (cfg *NatsConfig, err error) { return Conf, nil } +// Init init config. +func LoadToml(path string) (cfg *Config, err error) { + Conf = Default() + if len(path) == 0 { + return Conf, xerrors.New("no configuration") + } +// + _, err = toml.DecodeFile(path, &Conf) + + return Conf, nil +} + + + + + // Default new a config with specified defualt value. -func Default() *NatsConfig { - cfg := &NatsConfig{ +func Default() *Config { + cfg := &Config{ Env: &Env{ - Region: "test", - Zone: "test", - DeployEnv: "test", - Host: "test_server", + Region: "china", + Zone: "gd", + DeployEnv: "dev", + Host: "logic", Weight: 100, }, Discovery: &naming.Config{ Nodes: []string{"127.0.0.1:7171"}, - Region: "test", - Zone: "test", - Env: "test", - Host: "test_server", + Region: "china", + Zone: "gd", + Env: "dev", + Host: "discovery", }, Nats: &Nats{ NatsAddr: "nats://localhost:4222", diff --git a/internal/nats/logic/logic.go b/internal/nats/logic/logic.go index aaa0b4b..34c6a28 100755 --- a/internal/nats/logic/logic.go +++ b/internal/nats/logic/logic.go @@ -20,7 +20,7 @@ const ( // NatsLogic struct type NatsLogic struct { - c *conf.NatsConfig + c *conf.LogicConfig dis *naming.Discovery dao *dao.NatsDao // online @@ -34,7 +34,7 @@ type NatsLogic struct { } // New init -func New(c *conf.NatsConfig) (l *NatsLogic) { +func New(c *conf.LogicConfig) (l *NatsLogic) { l = &NatsLogic{ c: c, dao: dao.New(c),