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 }
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 }
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 }
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 }
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 }
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 }
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 }