本文整理汇总了Golang中github.com/c-fs/cfs/client.Client类的典型用法代码示例。如果您正苦于以下问题:Golang Client类的具体用法?Golang Client怎么用?Golang Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Client类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: handleWrite
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
}
示例2: handleRemove
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
}
示例3: handleRename
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
}
示例4: handleMkdir
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
}
示例5: handleRead
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
}
示例6: handleReadDir
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
}
示例7: handleStats
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
}