Developing lightweight computation at the DSG edge

Commit dde15701 authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[apidote] Add AntidoteAddItemToSetInBucket function


Signed-off-by: default avatarRoger Pueyo Centelles <roger.pueyo@guifi.net>
parent f0bea33a
......@@ -31,8 +31,29 @@ func AntidoteAddItemToSetInBucket(bucket string, set string, item string) bool {
return false
}
// AntidoteSetRegisterInInBucket set a LWWW register in a bucket
func AntidoteSetRegisterInInBucket(bucket string, register string, value string) bool {
// AntidoteReadRegisterInBucket read a LWWW register in a bucket
func AntidoteReadRegisterInBucket(bucket string, register string) string {
request := fmt.Sprintf("http://localhost:3000/register/read/%s/%s", bucket, register)
response, err := http.Get(request)
errCheck(err)
var value string
defer response.Body.Close()
if response.StatusCode == http.StatusOK {
bodyBytes, err := ioutil.ReadAll(response.Body)
errCheck(err)
value = fmt.Sprintf("%s", bodyBytes)
errCheck(err)
}
return value
}
// AntidoteSetRegisterInBucket set a LWWW register in a bucket
func AntidoteSetRegisterInBucket(bucket string, register string, value string) bool {
request := fmt.Sprintf("http://localhost:3000/register/set/%s/%s/%s", bucket, register, value)
response, err := http.Get(request)
errCheck(err)
......
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