• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang trace.Tracer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/harlow/go-micro-services/trace.Tracer的典型用法代码示例。如果您正苦于以下问题:Golang Tracer类的具体用法?Golang Tracer怎么用?Golang Tracer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Tracer类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: GetHotels

// VerifyToken finds a customer by authentication token.
func (s *profileServer) GetHotels(ctx context.Context, args *profile.Args) (*profile.Reply, error) {
	md, _ := metadata.FromContext(ctx)
	t := trace.Tracer{TraceID: strings.Join(md["traceID"], ",")}
	t.In(serverName, strings.Join(md["from"], ","))
	defer t.Out(strings.Join(md["from"], ","), serverName, time.Now())

	reply := new(profile.Reply)
	for _, i := range args.HotelIds {
		reply.Hotels = append(reply.Hotels, s.hotels[i])
	}

	return reply, nil
}
开发者ID:isaiah,项目名称:go-micro-services,代码行数:14,代码来源:main.go


示例2: VerifyToken

// VerifyToken finds a customer by authentication token.
func (s *authServer) VerifyToken(ctx context.Context, args *pb.Args) (*pb.Customer, error) {
	md, _ := metadata.FromContext(ctx)

	t := trace.Tracer{TraceID: md["traceID"]}
	t.In(serverName, args.From)
	defer t.Out(args.From, serverName, time.Now())

	customer := s.customers[args.AuthToken]
	if customer == nil {
		return &pb.Customer{}, errors.New("Invalid Token")
	}

	return customer, nil
}
开发者ID:jonahglover,项目名称:go-micro-services,代码行数:15,代码来源:main.go


示例3: 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
}
开发者ID:jonahglover,项目名称:go-micro-services,代码行数:15,代码来源:client.go


示例4: BoundedBox

// BoundedBox returns all hotels contained within a given rectangle.
func (s *geoServer) BoundedBox(ctx context.Context, rect *pb.Rectangle) (*pb.Reply, error) {
	md, _ := metadata.FromContext(ctx)
	t := trace.Tracer{TraceID: md["traceID"]}
	t.In(serverName, md["from"])
	defer t.Out(md["from"], serverName, time.Now())

	reply := new(pb.Reply)
	for _, loc := range s.locations {
		if inRange(loc.Point, rect) {
			reply.HotelIds = append(reply.HotelIds, loc.HotelID)
		}
	}

	return reply, nil
}
开发者ID:jonahglover,项目名称:go-micro-services,代码行数:16,代码来源:main.go


示例5: GetProfiles

// VerifyToken finds a customer by authentication token.
func (s *profileServer) GetProfiles(ctx context.Context, args *profile.ProfileRequest) (*profile.ProfileReply, error) {
	md, _ := metadata.FromContext(ctx)
	traceID := strings.Join(md["traceID"], ",")
	fromName := strings.Join(md["fromName"], ",")

	t := trace.Tracer{TraceID: traceID}
	t.In(s.serverName, fromName)
	defer t.Out(fromName, s.serverName, time.Now())

	reply := new(profile.ProfileReply)
	for _, i := range args.HotelIds {
		reply.Hotels = append(reply.Hotels, s.hotels[i])
	}

	return reply, nil
}
开发者ID:BobbWu,项目名称:go-micro-services,代码行数:17,代码来源:main.go


示例6: GetRates

// GetRates gets rates for hotels for specific date range.
func (s *rateServer) GetRates(ctx context.Context, args *pb.Args) (*pb.Reply, error) {
	md, _ := metadata.FromContext(ctx)
	t := trace.Tracer{TraceID: md["traceID"]}
	t.In(serverName, md["from"])
	defer t.Out(md["from"], serverName, time.Now())

	reply := new(pb.Reply)
	for _, hotelID := range args.HotelIds {
		k := stay{hotelID, args.InDate, args.OutDate}
		if s.rates[k] == nil {
			continue
		}
		reply.RatePlans = append(reply.RatePlans, s.rates[k])
	}

	return reply, nil
}
开发者ID:jonahglover,项目名称:go-micro-services,代码行数:18,代码来源:main.go


示例7: 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
}
开发者ID:jonahglover,项目名称:go-micro-services,代码行数:17,代码来源:client.go


示例8: BoundedBox

// BoundedBox returns all hotels contained within a given rectangle.
func (s *geoServer) BoundedBox(ctx context.Context, rect *geo.GeoRequest) (*geo.GeoReply, error) {
	md, _ := metadata.FromContext(ctx)
	traceID := strings.Join(md["traceID"], ",")
	fromName := strings.Join(md["fromName"], ",")

	t := trace.Tracer{TraceID: traceID}
	t.In(s.serverName, fromName)
	defer t.Out(fromName, s.serverName, time.Now())

	reply := new(geo.GeoReply)
	for _, loc := range s.locations {
		if inRange(loc.Point, rect) {
			reply.HotelIds = append(reply.HotelIds, loc.HotelID)
		}
	}

	return reply, nil
}
开发者ID:BobbWu,项目名称:go-micro-services,代码行数:19,代码来源:main.go


示例9: VerifyToken

// VerifyToken finds a customer by authentication token.
func (s *authServer) VerifyToken(ctx context.Context, args *auth.AuthRequest) (*auth.AuthReply, error) {
	md, _ := metadata.FromContext(ctx)
	traceID := strings.Join(md["traceID"], ",")
	fromName := strings.Join(md["fromName"], ",")

	t := trace.Tracer{TraceID: traceID}
	t.In(s.serverName, fromName)
	defer t.Out(fromName, s.serverName, time.Now())

	customer := s.customers[args.AuthToken]
	if customer == nil {
		return &auth.AuthReply{}, errors.New("Invalid Token")
	}

	reply := new(auth.AuthReply)
	reply.Customer = customer
	return reply, nil
}
开发者ID:BobbWu,项目名称:go-micro-services,代码行数:19,代码来源:main.go


示例10: 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
}
开发者ID:jonahglover,项目名称:go-micro-services,代码行数:19,代码来源:client.go


示例11: 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
}
开发者ID:jonahglover,项目名称:go-micro-services,代码行数:19,代码来源:client.go


示例12: GetRates

// GetRates gets rates for hotels for specific date range.
func (s *rateServer) GetRates(ctx context.Context, args *rate.RateRequest) (*rate.RateReply, error) {
	md, _ := metadata.FromContext(ctx)
	traceID := strings.Join(md["traceID"], ",")
	fromName := strings.Join(md["fromName"], ",")

	t := trace.Tracer{TraceID: traceID}
	t.In(s.serverName, fromName)
	defer t.Out(fromName, s.serverName, time.Now())

	reply := new(rate.RateReply)
	for _, hotelID := range args.HotelIds {
		k := stay{hotelID, args.InDate, args.OutDate}
		if s.rates[k] == nil {
			continue
		}
		reply.RatePlans = append(reply.RatePlans, s.rates[k])
	}

	return reply, nil
}
开发者ID:BobbWu,项目名称:go-micro-services,代码行数:21,代码来源:main.go



注:本文中的github.com/harlow/go-micro-services/trace.Tracer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang archive.CreateArchive函数代码示例发布时间:2022-05-23
下一篇:
Golang assert.Equal函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap