当前位置: 首页>>代码示例>>Golang>>正文


Golang protobuf.Domain类代码示例

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


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

示例1: createDom

func createDom(id string) *pb.Domain {
	dom := new(pb.Domain)
	dom.Name = utils.Stringp(id)
	types := []pb.SketchType{pb.SketchType_MEMB, pb.SketchType_FREQ, pb.SketchType_RANK, pb.SketchType_CARD}
	for _, ty := range types {
		sketch := &pb.Sketch{}
		sketch.Name = dom.Name
		sketch.Type = &ty
		sketch.Properties = &pb.SketchProperties{
			Size:           utils.Int64p(100),
			MaxUniqueItems: utils.Int64p(10),
		}
		dom.Sketches = append(dom.Sketches, sketch)
	}
	return dom
}
开发者ID:liuzl,项目名称:skizze,代码行数:16,代码来源:aof_test.go

示例2: createDomain

func createDomain(fields []string, in *pb.Domain) error {
	if len(fields) > 5 {
		return fmt.Errorf("Too many argumets, expected 4 got %d", len(fields))
	}

	// FIXME make last 2 arguments optional
	capa, err := strconv.Atoi(fields[3])
	if err != nil {
		return fmt.Errorf("Expected 3rd argument to be of type int: %q", err)
	}

	size, err := strconv.Atoi(fields[4])
	if err != nil {
		return fmt.Errorf("Expected last argument to be of type int: %q", err)
	}

	types := []pb.SketchType{pb.SketchType_MEMB, pb.SketchType_FREQ, pb.SketchType_RANK, pb.SketchType_CARD}
	for _, ty := range types {
		sketch := &pb.Sketch{}
		sketch.Name = proto.String("")
		sketch.Type = &ty
		sketch.Properties = &pb.SketchProperties{
			Size:           proto.Int64(int64(size)),
			MaxUniqueItems: proto.Int64(int64(capa)),
		}
		in.Sketches = append(in.Sketches, sketch)
	}

	_, err = client.CreateDomain(context.Background(), in)
	return err
}
开发者ID:njpatel,项目名称:skizze,代码行数:31,代码来源:domain.go

示例3: createDomain

func (s *serverStruct) createDomain(ctx context.Context, in *pb.Domain) (*pb.Domain, error) {
	info := datamodel.NewEmptyInfo()
	info.Name = in.Name
	// FIXME: A Domain's info should have an array of properties for each Sketch (or just an array
	// of Sketches, like what the proto has). This is just a hack to choose the first Sketch and
	// use it's info for now
	info.Properties.MaxUniqueItems = in.GetSketches()[0].GetProperties().MaxUniqueItems
	info.Properties.Size = in.GetSketches()[0].GetProperties().Size
	if info.Properties.Size == nil || *info.Properties.Size == 0 {
		var defaultSize int64 = 100
		info.Properties.Size = &defaultSize
	}
	// FIXME: We should be passing a pb.Domain and not a datamodel.Info to manager.CreateDomain
	err := s.manager.CreateDomain(info)
	if err != nil {
		return nil, err
	}
	return in, nil
}
开发者ID:njpatel,项目名称:skizze,代码行数:19,代码来源:domain.go

示例4: GetDomain

func (s *serverStruct) GetDomain(ctx context.Context, in *pb.Domain) (*pb.Domain, error) {
	return s.manager.GetDomain(in.GetName())
}
开发者ID:njpatel,项目名称:skizze,代码行数:3,代码来源:domain.go

示例5: deleteDomain

func (s *serverStruct) deleteDomain(ctx context.Context, in *pb.Domain) (*pb.Empty, error) {
	return &pb.Empty{}, s.manager.DeleteDomain(in.GetName())
}
开发者ID:njpatel,项目名称:skizze,代码行数:3,代码来源:domain.go


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