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

Function initCommentRpc

cmd/api/rpc/comment.go:18–54  ·  view source on GitHub ↗
(config *viper.Viper)

Source from the content-addressed store, hash-verified

16var commentClient commentsrv.Client
17
18func initCommentRpc(config *viper.Viper) {
19 ServiceName := GetEndPoint(config)
20
21 //TODO Add tracing in future
22 //p := provider.NewOpenTelemetryProvider(
23 // provider.WithServiceName(ServiceName),
24 // provider.WithExportEndpoint("localhost:4317"),
25 // provider.WithInsecure(),
26 //)
27 //ch := make(chan os.Signal, 1)
28 //signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)
29 //
30 //go func() {
31 // <-ch
32 // p.Shutdown(context.Background())
33 // os.Exit(0)
34 //}()
35
36 c, err := commentsrv.NewClient(
37 ServiceName,
38 //TODO Add middleware
39 //client.WithMiddleware(middleware.CommonMiddleware),
40 //client.WithInstanceMW(middleware.ClientMiddleware),
41 client.WithMuxConnection(1), // mux
42 client.WithRPCTimeout(30*time.Second), // rpc timeout
43 client.WithConnectTimeout(30000*time.Millisecond), // conn timeout
44 client.WithFailureRetry(retry.NewFailurePolicy()), // retry
45 //client.WithSuite(tracing.NewClientSuite()), // tracer
46 client.WithResolver(dns.NewDNSResolver()),
47 // Please keep the same as provider.WithServiceName
48 client.WithClientBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: ServiceName}),
49 )
50 if err != nil {
51 panic(err)
52 }
53 commentClient = c
54}
55
56func CommentAction(ctx context.Context, req *comment.BloomblogCommentActionRequest) (*comment.BloomblogCommentActionResponse, error) {
57 resp, err := commentClient.CommentAction(ctx, req)

Callers 1

InitRPCFunction · 0.85

Calls 2

NewClientFunction · 0.92
GetEndPointFunction · 0.85

Tested by

no test coverage detected