示例#1
0
func main() {
	log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
	flag.Parse()

	conn, err := grpc.Dial(*connectAddress, grpc.WithInsecure())
	if err != nil {
		log.Fatalf("Error connecting to %s: %s", *connectAddress, err)
	}
	defer conn.Close()

	request := &oproto.SplitBlockRequest{
		Block: &oproto.Block{},
	}
	if *endKey != "" {
		request.Block.EndKey = *endKey
	} else if *ID != "" {
		request.Block.Id = *ID
	} else if len(os.Args) > 1 {
		request.Block.Id = os.Args[1]
	} else {
		log.Fatal("Specify either --end_key or --id")
	}

	stub := oproto.NewStoreClient(conn)
	response, err := stub.SplitBlock(context.Background(), request)
	if err != nil {
		log.Fatal(err)
	}

	log.Println(openinstrument.ProtoText(response))
}
示例#2
0
func main() {
	log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
	flag.Parse()

	conn, err := grpc.Dial(*connectAddress, grpc.WithInsecure())
	if err != nil {
		log.Fatalf("Error connecting to %s: %s", *connectAddress, err)
	}
	defer conn.Close()

	request := &oproto.LookupBlockRequest{}
	if *varName != "" {
		request.Variable = variable.NewFromString(*varName).AsProto()
	} else if *ID != "" {
		request.BlockId = *ID
	} else if len(os.Args) > 1 {
		request.BlockId = os.Args[1]
	} else {
		log.Fatal("Specify either --variable or --id")
	}

	stub := oproto.NewStoreClient(conn)
	response, err := stub.LookupBlock(context.Background(), request)
	if err != nil {
		log.Fatal(err)
	}

	log.Println(openinstrument.ProtoText(response))
}
示例#3
0
func main() {
	log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
	flag.Parse()

	ctx := context.Background()

	conn, err := grpc.Dial(*connectAddress, grpc.WithInsecure())
	if err != nil {
		log.Fatalf("Error connecting to %s: %s", *connectAddress, err)
	}
	defer conn.Close()
	stub := oproto.NewStoreClient(conn)

	request := &oproto.UpdateRetentionPolicyRequest{
		Item: &oproto.RetentionPolicyItem{},
	}

	if len(os.Args) < 2 {
		log.Fatalf("Invalid command (append/insert/delete)")
	}

	switch os.Args[1] {
	case "append":
		request.Op = oproto.UpdateRetentionPolicyRequest_APPEND
		request.Item = readAndParsePolicy()
	case "insert":
		if len(os.Args) < 3 {
			log.Fatalf("Specify position (0-indexed)")
		}
		position, err := strconv.Atoi(os.Args[2])
		if err != nil {
			log.Fatalf("Invalid position: %s", err)
		}
		request.Op = oproto.UpdateRetentionPolicyRequest_INSERT
		request.Position = uint32(position)
		request.Item = readAndParsePolicy()
	case "delete":
		if len(os.Args) < 3 {
			log.Fatalf("Specify position (0-indexed)")
		}

		position, err := strconv.Atoi(os.Args[2])
		if err != nil {
			log.Fatalf("Invalid position: %s", err)
		}
		request.Op = oproto.UpdateRetentionPolicyRequest_REMOVE
		request.Position = uint32(position)
	default:
		log.Fatalf("Invalid command (append/insert/delete)")
	}

	response, err := stub.UpdateRetentionPolicy(ctx, request)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(openinstrument.ProtoText(response))
}
示例#4
0
func NewRpcClient(ctx context.Context, addr string) (*RpcClient, error) {
	conn, err := grpc.Dial(addr, grpc.WithInsecure())
	if err != nil {
		return nil, err
	}
	c := &RpcClient{
		conn: conn,
		stub: oproto.NewStoreClient(conn),
	}
	//go c.watchCluster(ctx)
	return c, nil
}