Skip to content

Commit

Permalink
feat(jzero): release v0.9.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jaronnie committed Apr 28, 2024
1 parent 42bd040 commit 21cdc7c
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 7 deletions.
63 changes: 57 additions & 6 deletions docs/src/guide/gensdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,63 @@ icon: lightbulb
order: 5
---

::: tip 努力开发中...
## 自动生成客户端 sdk

::: code-tabs#shell

@tab jzero

```bash
cd app1
jzero gensdk --module=github.com/jaronnie/app1-go --dir=app1-go
```

@tab Docker(amd64)

```bash
docker run --rm \
-v ./app1:/app/app1 jaronnie/jzero:latest \
gensdk --module=github.com/jaronnie/app1-go --dir=app1-go
```

@tab Docker(arm64)

```bash
docker run --rm \
-v ./app1:/app/app1 jaronnie/jzero:latest-arm64 \
gensdk --module=github.com/jaronnie/app1-go --dir=app1-go
```
:::

目标:
## sdk 使用实例

```go
package main

import (
"context"
"fmt"

"github.com/jaronnie/app1-go"
"github.com/jaronnie/app1-go/model/app1/types"
"github.com/jaronnie/app1-go/rest"
)

func main() {
clientset, err := app1.NewClientWithOptions(
rest.WithAddr("127.0.0.1"),
rest.WithPort("8001"),
rest.WithProtocol("http"))
if err != nil {
panic(err)
}

* 根据 proto 文件中的 options 和 api 文件生成 http sdk
* 根据 proto 文件生成 grpc 客户端
* 仿照 k8s client-go 的设计进行链式调用
* 支持多语言客户端 sdk 的生成, 默认生成 go 语言
result, err := clientset.Hello().HelloPathHandler(context.Background(), &types.PathRequest{
Name: "jzero",
})
if err != nil {
panic(err)
}
fmt.Println(result.Message)
}
```
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"embed"

"github.com/jaronnie/jzero/cmd"
"github.com/jaronnie/jzero/embeded"
)
Expand All @@ -23,7 +24,7 @@ var (

// ldflags
var (
version string = "0.9.2"
version string = "0.9.3"
commit string
date string
)
Expand Down

0 comments on commit 21cdc7c

Please sign in to comment.