示例#1
0
//
// convert IndexInst to protobuf format
//
func convertIndexInstToProtoMsg(inst *IndexInstDistribution,
	protoDefn *protobuf.IndexDefn,
	port string) *protobuf.Instance {

	//
	// message IndexInst {
	//	required uint64          instId     = 1;
	//	required IndexState      state      = 2;
	//	required IndexDefn       definition = 3; // contains DDL
	//	optional TestPartition   tp         = 4;
	// }
	//
	instance := &protobuf.IndexInst{
		InstId:     proto.Uint64(uint64(inst.InstId)),
		State:      protobuf.IndexState(inst.State).Enum(),
		Definition: protoDefn}

	// accumulate endpoints for this instance
	var endpoints []string
	endpoints = append(endpoints, port)

	//
	//	message TestPartition {
	//		repeated string endpoints     = 1; // endpoint address
	//		optional string coordEndpoint = 2;
	//  }
	//
	instance.Tp = &protobuf.TestPartition{
		Endpoints: endpoints,
	}

	return &protobuf.Instance{IndexInstance: instance}
}
示例#2
0
func convertIndexInstToProtobuf(cfg c.Config, indexInst c.IndexInst,
	protoDefn *protobuf.IndexDefn) *protobuf.IndexInst {

	state := protobuf.IndexState(int32(indexInst.State)).Enum()
	instance := &protobuf.IndexInst{
		InstId:     proto.Uint64(uint64(indexInst.InstId)),
		State:      state,
		Definition: protoDefn,
	}
	return instance
}