You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
564 B
26 lines
564 B
5 years ago
|
package api
|
||
|
import (
|
||
|
"context"
|
||
|
"fmt"
|
||
|
|
||
|
"github.com/bilibili/kratos/pkg/net/rpc/warden"
|
||
|
|
||
|
"google.golang.org/grpc"
|
||
|
)
|
||
|
|
||
|
// AppID .
|
||
|
const AppID = "TODO: ADD APP ID"
|
||
|
|
||
|
// NewClient new grpc client
|
||
|
func NewClient(cfg *warden.ClientConfig, opts ...grpc.DialOption) (DemoClient, error) {
|
||
|
client := warden.NewClient(cfg, opts...)
|
||
|
cc, err := client.Dial(context.Background(), fmt.Sprintf("discovery://default/%s", AppID))
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return NewDemoClient(cc), nil
|
||
|
}
|
||
|
|
||
|
// 生成 gRPC 代码
|
||
|
//go:generate kratos tool protoc --grpc --bm api.proto
|