Developing lightweight computation at the DSG edge

Commit 41d2e679 authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[fetch] Add antidoteReadItemsFromSetInBucket function



This function gets the items from a set in a bucket.
Signed-off-by: default avatarRoger Pueyo Centelles <roger.pueyo@guifi.net>
parent e9c1078e
......@@ -660,6 +660,27 @@ func antidoteAddItemToSetInBucket(bucket string, set string, item string) bool {
return false
}
// Antidote: read items from a set in a bucket
func antidoteReadItemsFromSetInBucket(bucket string, set string) []string {
request := fmt.Sprintf("http://localhost:3000/set/read/%s/%s", bucket, set)
response, err := http.Get(request)
errCheck(err)
var items []string
defer response.Body.Close()
if response.StatusCode == http.StatusOK {
bodyBytes, err := ioutil.ReadAll(response.Body)
errCheck(err)
err = json.Unmarshal(bodyBytes, &items)
errCheck(err)
}
return items
}
// 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