MCPcopy Create free account
hub / github.com/Agelessbaby/BloomBlog / initUserRpc

Function initUserRpc

cmd/api/rpc/user.go:26–61  ·  view source on GitHub ↗
(config *viper.Viper)

Source from the content-addressed store, hash-verified

24}
25
26func initUserRpc(config *viper.Viper) {
27 ServiceName := GetEndPoint(config)
28 //TODO Add tracing in future
29 //p := provider.NewOpenTelemetryProvider(
30 // provider.WithServiceName(ServiceName),
31 // provider.WithExportEndpoint("localhost:4317"),
32 // provider.WithInsecure(),
33 //)
34 //ch := make(chan os.Signal, 1)
35 //signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)
36 //
37 //go func() {
38 // <-ch
39 // p.Shutdown(context.Background())
40 // os.Exit(0)
41 //}()
42
43 c, err := usersrv.NewClient(
44 ServiceName,
45 //TODO Add middleware
46 //client.WithMiddleware(middleware.CommonMiddleware),
47 //client.WithInstanceMW(middleware.ClientMiddleware),
48 client.WithMuxConnection(1), // mux
49 client.WithRPCTimeout(30*time.Second), // rpc timeout
50 client.WithConnectTimeout(30000*time.Millisecond), // conn timeout
51 client.WithFailureRetry(retry.NewFailurePolicy()), // retry
52 //client.WithSuite(tracing.NewClientSuite()), // tracer
53 client.WithResolver(dns.NewDNSResolver()), // resolver
54 // Please keep the same as provider.WithServiceName
55 client.WithClientBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: ServiceName}),
56 )
57 if err != nil {
58 panic(err)
59 }
60 userClient = c
61}
62
63// using rpc client to register,return the resp of rpc server
64func Register(ctx context.Context, req *user.BloomBlogUserRegisterRequest) (resp *user.BloomBlogUserRegisterResponse, err error) {

Callers 1

InitRPCFunction · 0.85

Calls 2

NewClientFunction · 0.92
GetEndPointFunction · 0.85

Tested by

no test coverage detected