Developing lightweight computation at the DSG edge

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

[fetch] Add antidoteAddItemToSetInBucket function



This function writes an item to a set in a bucket.
Signed-off-by: default avatarRoger Pueyo Centelles <roger.pueyo@guifi.net>
parent e88c2ca0
......@@ -640,6 +640,26 @@ func saveDeviceIpv4ToAntidote(ID int, Ipv4 string) bool {
return false
}
// Antidote: save an item to a set in a bucket
func antidoteAddItemToSetInBucket(bucket string, set string, item string) bool {
request := fmt.Sprintf("http://localhost:3000/set/add/%s/%s/%s", bucket, set, item)
response, err := http.Get(request)
errCheck(err)
defer response.Body.Close()
if response.StatusCode == http.StatusOK {
bodyBytes, err := ioutil.ReadAll(response.Body)
errCheck(err)
restReply := string(bodyBytes)
if restReply == "ok" {
}
return true
}
return false
}
// Check if an int item is in an ints array
func isDeviceIPv4AddressesInArray(device DeviceIpv4Adddresses, devices []DeviceIpv4Adddresses) bool {
for _, v := range devices {
......
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