/
githubmirror
/
GoFrame
Обзор
Документация
Войти
/
githubmirror
/
GoFrame
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
example/registry/polaris/server/main.go
30 строк
805 B
houseme
add golangci feature to guarantee codes quality (#2229)
01 ноя 2022, 15:12
Не верифицирован
01 ноя 2022, 15:12
1793bf0
Код
Авторство
О чём код?
package main import ( "context" "github.com/gogf/gf/contrib/registry/polaris/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/net/gsvc" "github.com/polarismesh/polaris-go/api" "github.com/polarismesh/polaris-go/pkg/config" ) func main() { conf := config.NewDefaultConfiguration([]string{"192.168.100.222:8091"}) conf.Consumer.LocalCache.SetPersistDir("/tmp/polaris/backup") if err := api.SetLoggersDir("/tmp/polaris/log"); err != nil { g.Log().Fatal(context.Background(), err) } // TTL egt 2*time.Second gsvc.SetRegistry(polaris.NewWithConfig(conf, polaris.WithTTL(10))) s := g.Server(`hello.svc`) s.BindHandler("/", func(r *ghttp.Request) { g.Log().Info(r.Context(), `request received`) r.Response.Write(`Hello world`) }) s.Run() }