/
client.go
39 lines (33 loc) · 1015 Bytes
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package rpc_client
import (
"context"
"os"
"github.com/castbox/go-guru/pkg/client"
"github.com/castbox/go-guru/pkg/util/appinfo"
"github.com/castbox/go-guru/pkg/util/logger"
"github.com/castbox/go-guru/pkg/util/otlp"
"github.com/go-kratos/kratos/v2/log"
"github.com/google/wire"
p "github.com/wesleywu/ri-service-provider/api/video_collection/v1"
"google.golang.org/grpc"
)
var ProviderSet = wire.NewSet(newAppMetadata, logger.NewLogger, otlp.NewTracer, client.NewGrpcConnection, NewClients)
type Clients struct {
logger log.Logger
VideoCollection p.VideoCollectionClient
}
func newAppMetadata() *appinfo.AppMetadata {
hostname, _ := os.Hostname()
return &appinfo.AppMetadata{
AppName: "rpc_client_test",
AppVersion: "v0.0.1",
HostName: hostname,
}
}
// NewClients .
func NewClients(ctx context.Context, conn *grpc.ClientConn, logger log.Logger) (*Clients, error) {
return &Clients{
logger: logger,
VideoCollection: p.NewVideoCollectionClient(conn),
}, nil
}