Created
November 5, 2014 17:40
-
-
Save chischaschos/578174cd58d8503195bb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package default_module | |
import ( | |
"appengine" | |
"appengine/datastore" | |
"appengine/delay" | |
"net/http" | |
) | |
func GtinSynchronizeDeleterHandler(context appengine.Context, w http.ResponseWriter, r *http.Request) { | |
f := delay.Func("productsDeleter", productsDeleter) | |
f.Call(context, 1) | |
} | |
func productsDeleter(context appengine.Context, index int) { | |
key := datastore.NewKey(context, "Catalog_v1", "Product", 0, nil) | |
query := datastore.NewQuery("Product"). | |
Ancestor(key). | |
Limit(200).KeysOnly() | |
keys, err := query.GetAll(context, nil) | |
context.Infof("C: %#v %d", len(keys), index) | |
if len(keys) == 0 { | |
context.Infof("DELETE_DONE") | |
return | |
} | |
if err != nil { | |
context.Errorf("DELETE_ERROR 1 %#v", err) | |
return | |
} | |
err = datastore.DeleteMulti(context, keys) | |
if err != nil { | |
context.Errorf("DELETE_ERROR 2 %#v", err) | |
return | |
} | |
f := delay.Func("productsDeleter", productsDeleter) | |
f.Call(context, index+1) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment