Developing lightweight computation at the DSG edge

Commit 925abfc4 authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[goclidote] Port AntidoteReadRegisterInBucket


Signed-off-by: Roger Pueyo Centelles's avatarRoger Pueyo Centelles <rpueyo@ac.upc.edu>
parent e6aaef53
......@@ -48,24 +48,22 @@ func AntidoteAddItemToSetInBucket(bucketName string, setName string, itemValue s
}
// AntidoteReadRegisterInBucket read a LWWW register in a bucket
func AntidoteReadRegisterInBucket(bucket string, register string) string {
request := fmt.Sprintf("http://%s/register/read/%s/%s", api_host_port, bucket, register)
response, err := http.Get(request)
errCheck(err, "")
func AntidoteReadRegisterInBucket(bucketName string, registerName string) string {
var value string
client, err := antidoteclient.NewClient(antidoteclient.Host{Name: DatabaseHost, Port: DatabasePort})
errCheck(err, "")
defer client.Close()
defer response.Body.Close()
tx, err := client.StartTransaction()
errCheck(err, "")
if response.StatusCode == http.StatusOK {
bodyBytes, err := ioutil.ReadAll(response.Body)
errCheck(err, "")
bucket := antidoteclient.Bucket{Bucket: []byte(bucketName)}
key := antidoteclient.Key(registerName)
value = fmt.Sprintf("%s", bodyBytes)
errCheck(err, "")
}
setVal, err := bucket.ReadReg(tx, key)
errCheck(err, "")
return value
return string(setVal)
}
// AntidoteSetRegisterInBucket set a LWWW register in a bucket
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment