Skip to content

DarkAngel7/go-kratos-nacos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kratos Nacos


example

sc := []constant.ServerConfig{
	*constant.NewServerConfig("127.0.0.1", 8848),
}

cc := &constant.ClientConfig{
	NamespaceId:         "public", //namespace id
	TimeoutMs:           5000,
	NotLoadCacheAtStart: true,
	LogDir:              "/tmp/nacos/log",
	CacheDir:            "/tmp/nacos/cache",
	RotateTime:          "1h",
	MaxAge:              3,
	LogLevel:            "debug",
}

// a more graceful way to create naming client
client, err := clients.NewNamingClient(
	vo.NacosClientParam{
		ClientConfig:  cc,
		ServerConfigs: sc,
	},
)
if err != nil {
	log.Panic(err)
}

r := registry.New(client)

// server
app := kratos.New(
	kratos.Name("helloworld"),
	kratos.Registrar(r),
)
if err := app.Run(); err != nil {
	log.Fatal(err)
}

// client
conn, err := grpc.DialInsecure(
	context.Background(),
	grpc.WithEndpoint("discovery:///helloworld"),
	grpc.WithDiscovery(r),
)

About

fork of go-kratos/nacos

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages