本文整理匯總了Golang中github.com/xtracdev/xavi/kvstore.KVStore.Flush方法的典型用法代碼示例。如果您正苦於以下問題:Golang KVStore.Flush方法的具體用法?Golang KVStore.Flush怎麽用?Golang KVStore.Flush使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/xtracdev/xavi/kvstore.KVStore
的用法示例。
在下文中一共展示了KVStore.Flush方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: PutDefinition
//PutDefinition creates or updates a server definition
func (ServerDef) PutDefinition(kvs kvstore.KVStore, resp http.ResponseWriter, req *http.Request) (interface{}, error) {
body, err := ioutil.ReadAll(req.Body)
req.Body.Close()
log.Info(fmt.Sprintf("Put request with payload %s", string(body)))
if err != nil {
resp.WriteHeader(http.StatusInternalServerError)
return nil, nil
}
serverName := resourceIDFromURI(req.RequestURI)
log.Info(serverName)
if serverName == "" {
resp.WriteHeader(http.StatusNotFound)
return nil, errServiceResourceMissing
}
serverConfig := new(config.ServerConfig)
err = json.Unmarshal(body, serverConfig)
if err != nil {
log.Warn("Error unmarshaling request body")
resp.WriteHeader(http.StatusBadRequest)
return nil, err
}
serverConfig.Name = serverName
err = serverConfig.Store(kvs)
if err != nil {
log.Warn("Error persisting server definition")
resp.WriteHeader(http.StatusInternalServerError)
return nil, err
}
err = kvs.Flush()
if err != nil {
return nil, err
}
return nil, nil
}