Esempio n. 1
0
func handleWrite(ctx context.Context, c *client.Client) error {
	n, err := c.Write(ctx, writeName, writeOffset, []byte(writeData), writeAppend)
	if err != nil {
		log.Fatalf("Write err (%v)", err)
	}
	log.Infof("%d bytes written to %s at offset %d", n, writeName, writeOffset)

	return nil
}
Esempio n. 2
0
func handleRemove(ctx context.Context, c *client.Client) error {
	err := c.Remove(ctx, removeName, removeAll)
	if err != nil {
		log.Fatalf("Read err (%v)", err)
	}
	log.Info("remove succeeded")

	return nil
}
Esempio n. 3
0
func handleRename(ctx context.Context, c *client.Client) error {
	err := c.Rename(ctx, renameOld, renameNew)
	if err != nil {
		log.Fatalf("Rename err (%v)", err)
	}
	log.Infof("rename %s into %s", renameOld, renameNew)

	return nil
}
Esempio n. 4
0
func handleMkdir(ctx context.Context, c *client.Client) error {
	err := c.Mkdir(ctx, mkdirName, mkdirAll)
	if err != nil {
		log.Fatalf("Mkdir err (%v)", err)
	}

	fmt.Printf("mkdir %s succeeded\n", mkdirName)
	return nil
}
Esempio n. 5
0
func handleRead(ctx context.Context, c *client.Client) error {
	_, data, _, err := c.Read(ctx, readName, readOffset, readLen, readExpChecksum)
	if err != nil {
		log.Fatalf("Read err (%v)", err)
	}
	log.Info(string(data))

	return nil
}
Esempio n. 6
0
func handleReadDir(ctx context.Context, c *client.Client) error {
	fInfos, err := c.ReadDir(ctx, readDirName)
	if err != nil {
		log.Fatalf("ReadDir err (%v)", err)
	}

	for _, stats := range fInfos {
		fmt.Printf("%s: %d %t\n", stats.Name, stats.TotalSize, stats.IsDir == true)
	}

	return nil
}
Esempio n. 7
0
func handleStats(ctx context.Context, c *client.Client) error {
	info, err := c.ContainerInfo(ctx)
	if err != nil {
		log.Printf("ContainerInfo err (%v)", err)
	} else {
		log.Printf("Container Info: %+v", info)
	}
	ms, err := c.Metrics(ctx)
	if err != nil {
		log.Printf("Metrics err (%v)", err)
	} else {
		log.Printf("Metrics: %+v", ms)
	}
	return nil
}