Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add kratos quick start #4

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions docs/quick-start/quick-start-kratos.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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)