本文整理匯總了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
}