本文整理匯總了Golang中github.com/harlow/go-micro-services/trace.Tracer.Req方法的典型用法代碼示例。如果您正苦於以下問題:Golang Tracer.Req方法的具體用法?Golang Tracer.Req怎麽用?Golang Tracer.Req使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/harlow/go-micro-services/trace.Tracer
的用法示例。
在下文中一共展示了Tracer.Req方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetHotels
func (c Client) GetHotels(ctx context.Context, hotelIDs []int32) ([]*pb.Hotel, error) {
md, _ := metadata.FromContext(ctx)
t := trace.Tracer{TraceID: md["traceID"]}
t.Req(md["from"], "service.profile", "GetHotels")
defer t.Rep("service.profile", md["from"], time.Now())
args := &pb.Args{HotelIds: hotelIDs}
reply, err := c.client.GetHotels(ctx, args)
if err != nil {
return []*pb.Hotel{}, err
}
return reply.Hotels, nil
}
示例2: VerifyToken
func (c Client) VerifyToken(ctx context.Context, serverName string, authToken string) error {
md, _ := metadata.FromContext(ctx)
t := trace.Tracer{TraceID: md["traceID"]}
t.Req(md["from"], "service.auth", "VerifyToken")
defer t.Rep("service.auth", md["from"], time.Now())
args := &auth.Args{
From: serverName,
AuthToken: authToken,
}
if _, err := c.client.VerifyToken(ctx, args); err != nil {
return err
}
return nil
}
示例3: GetRatePlans
func (c Client) GetRatePlans(ctx context.Context, hotelIDs []int32, inDate string, outDate string) ([]*pb.RatePlan, error) {
md, _ := metadata.FromContext(ctx)
t := trace.Tracer{TraceID: md["traceID"]}
t.Req(md["from"], "service.rate", "GetRatePlans")
defer t.Rep("service.rate", md["from"], time.Now())
args := &pb.Args{
HotelIds: hotelIDs,
InDate: inDate,
OutDate: outDate,
}
reply, err := c.client.GetRates(ctx, args)
if err != nil {
return []*pb.RatePlan{}, err
}
return reply.RatePlans, nil
}
示例4: HotelsWithinBoundedBox
func (c Client) HotelsWithinBoundedBox(ctx context.Context, latitude int32, longitude int32) ([]int32, error) {
md, _ := metadata.FromContext(ctx)
t := trace.Tracer{TraceID: md["traceID"]}
t.Req(md["from"], "service.geo", "BoundedBox")
defer t.Rep("service.geo", md["from"], time.Now())
rect := &pb.Rectangle{
Lo: &pb.Point{Latitude: 400000000, Longitude: -750000000},
Hi: &pb.Point{Latitude: 420000000, Longitude: -730000000},
}
reply, err := c.client.BoundedBox(ctx, rect)
if err != nil {
return []int32{}, err
}
return reply.HotelIds, nil
}