本文整理汇总了Golang中github.com/harlow/go-micro-services/trace.Tracer.Rep方法的典型用法代码示例。如果您正苦于以下问题:Golang Tracer.Rep方法的具体用法?Golang Tracer.Rep怎么用?Golang Tracer.Rep使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/harlow/go-micro-services/trace.Tracer
的用法示例。
在下文中一共展示了Tracer.Rep方法的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
}