diff --git a/docs/quick-start/quick-start-kratos.md b/docs/quick-start/quick-start-kratos.md index 5a84004..e81b5d4 100644 --- a/docs/quick-start/quick-start-kratos.md +++ b/docs/quick-start/quick-start-kratos.md @@ -5,3 +5,41 @@ sidebar_position: 2 # Use Opensergo with Kratos T.B.D. +--- +sidebar_position: 2 +--- + +# Use Opensergo with Kratos + +## Kratos Overview +[Kratos](github.com/go-kratos/kratos) Kratos is a microservice-oriented governance framework implemented by Golang, which offers convenient capabilities to help you quickly build a bulletproof application from scratch. + +> The name is inspired by the game God of War which is based on Greek myths, tells the adventures of Kratos who became a god of war from a mortal and launched a god-killing slaughter. + +## Access OpenSergo in Kratos + +Kratos design concept is highly customizable. Users can introduce different implementations according to their own needs. Therefore, when we access OpenSergo, we only need to introduce OpenSergo contrib to report the service information to OpenSergo. The code is as follows: +``` +// ... + app := kratos.New( + kratos.Name(Name), + kratos.Server( + httpSrv, + grpcSrv, + ), + ) + osg, err := opensergo.New(opensergo.WithEndpoint("locahost:9090")) + if err != nil { + log.Fatal(err) + } + if err = osg.ReportMetadata(context.Background(), app); err != nil { + log.Fatal(err) + } + if err := app.Run(); err != nil { + log.Fatal(err) + } +``` + +# References +- [Kratos docs](https://go-kratos.dev/docs/) +- [OpenSergo example](https://github.com/go-kratos/examples/tree/main/opensergo) \ No newline at end of file diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/current/quick-start/quick-start-kratos.md b/i18n/zh-cn/docusaurus-plugin-content-docs/current/quick-start/quick-start-kratos.md index 128dbfd..b4362b5 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/current/quick-start/quick-start-kratos.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/current/quick-start/quick-start-kratos.md @@ -3,3 +3,36 @@ sidebar_position: 2 --- # Kratos 快速接入 OpenSergo + +## Kratos 简介 +[Kratos](github.com/go-kratos/kratos) 是一套轻量级 Go 微服务框架,包含大量微服务相关框架及工具。 + +> 名字来源于:《战神》游戏以希腊神话为背景,讲述奎托斯(Kratos)由凡人成为战神并展开弑神屠杀的冒险经历。 + +## 在 Kratos中接入 OpenSergo + +Kratos 的设计理念就是高度的可定制化,用户可以根据自己的需求引入不同的实现,所以我们接入OpenSergo只需要引入 OpenSergo contrib 即可将服务信息上报到 OpenSergo 中, 代码如下: +``` +// ... + app := kratos.New( + kratos.Name(Name), + kratos.Server( + httpSrv, + grpcSrv, + ), + ) + osg, err := opensergo.New(opensergo.WithEndpoint("locahost:9090")) + if err != nil { + log.Fatal(err) + } + if err = osg.ReportMetadata(context.Background(), app); err != nil { + log.Fatal(err) + } + if err := app.Run(); err != nil { + log.Fatal(err) + } +``` + +# 相关资料 +- [Kratos 文档](https://go-kratos.dev/docs/) +- [OpenSergo 接入示例](https://github.com/go-kratos/examples/tree/main/opensergo) \ No newline at end of file