Skip to content

Instantly share code, notes, and snippets.

@chischaschos
Created November 5, 2014 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chischaschos/578174cd58d8503195bb to your computer and use it in GitHub Desktop.
Save chischaschos/578174cd58d8503195bb to your computer and use it in GitHub Desktop.
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