本文整理匯總了Golang中lzbgt/go-losapi/pub.WebApiStub.Hset方法的典型用法代碼示例。如果您正苦於以下問題:Golang WebApiStub.Hset方法的具體用法?Golang WebApiStub.Hset怎麽用?Golang WebApiStub.Hset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類lzbgt/go-losapi/pub.WebApiStub
的用法示例。
在下文中一共展示了WebApiStub.Hset方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ReleaseRes
func ReleaseRes(stub *pub.WebApiStub, id, resName string, ver int) (err error) {
if ver == 0 {
ver, err = pub.O2Int(stub.Hget(id, resName, pub.FD_LastVer))
if err != nil {
ver = 0
}
}
if _, err = stub.Hset(id, resName, pub.FD_Release, ver); err != nil {
return err
}
fmt.Printf("set res[%s] version to [%d]\r\n", resName, ver)
return nil
}
示例2: uploadNodeMainifest
func (nm *NodeManifest) uploadNodeMainifest(stub *pub.WebApiStub, ID string) error {
//生成json格式
buf, err := json.Marshal(nm)
if err != nil {
return err
}
_, err = stub.Hset(ID, FieldApplist, nm.AppName, string(buf))
if err != nil {
return err
}
fmt.Println("uploadManifest ok")
return nil
}
示例3: ReleaseRes
func ReleaseRes(stub *pub.WebApiStub, id, resName string, ver int) error {
lastVer, err := pub.O2Int(stub.Hget(id, resName, pub.FD_LastVer))
if err != nil {
return errors.New("failed to get version for this resouce \"" + resName + "\"\nerror:" + err.Error())
}
if ver == -1 {
ver = lastVer
}
if _, err = stub.Hset(id, resName, pub.FD_Release, ver); err != nil {
return err
}
fmt.Printf("released res \"%s\" version %d \r\n", resName, ver)
return nil
}
示例4: PushRes
func PushRes(stub *pub.WebApiStub, BID, name, filename string, ver int) (ID string, err error) {
log.V(" push", name, filename)
if name == "" {
return "", errName.Format("is null")
}
var oldver int
var oldId string
oldver, err = pub.O2Int(stub.Hget(BID, name, pub.FD_LastVer))
if err != nil {
oldver = 0
}
log.V("last version:", oldver)
if ver > 0 && ver <= oldver {
return "", errVer.Format(ver, oldver)
}
strVer := fmt.Sprint(oldver)
if oldId, err = pub.O2Str(stub.Hget(BID, name, strVer)); err != nil {
fmt.Fprintln(os.Stderr, err.Error())
oldId = ""
}
log.V("last id:", oldId)
//讀取文件
var rd []byte
rd, err = ioutil.ReadFile(filename)
if err != nil {
return
}
ID, err = stub.Setdata(BID, rd)
if err != nil {
return
}
log.V("new id:", ID)
if ID == oldId {
log.V("resource not changed")
return
}
ver = oldver + 1
strver := fmt.Sprintf("%d", oldver+1)
stub.Hset(BID, name, strver, ID)
stub.Hset(BID, name, pub.FD_LastVer, ver)
return
}