|
| 1 | +package main |
| 2 | + |
| 3 | +import ( |
| 4 | + "io" |
| 5 | + |
| 6 | + "net/http" |
| 7 | + |
| 8 | + "golang.org/x/net/context" |
| 9 | + "google.golang.org/appengine/datastore" |
| 10 | + "google.golang.org/appengine/log" |
| 11 | + |
| 12 | + "github.com/captaincodeman/datastore-mapper" |
| 13 | +) |
| 14 | + |
| 15 | +type ( |
| 16 | + // lifecycle notifications |
| 17 | + example4 struct{} |
| 18 | +) |
| 19 | + |
| 20 | +func init() { |
| 21 | + mapper.RegisterJob(&example4{}) |
| 22 | +} |
| 23 | + |
| 24 | +func (x *example4) Query(r *http.Request) (*mapper.Query, error) { |
| 25 | + q := mapper.NewQuery("photo") |
| 26 | + q = q.Namespace("") |
| 27 | + return q, nil |
| 28 | +} |
| 29 | + |
| 30 | +// Next processes the next item |
| 31 | +func (x *example4) Next(c context.Context, w io.Writer, counters mapper.Counters, key *datastore.Key) error { |
| 32 | + return nil |
| 33 | +} |
| 34 | + |
| 35 | +// job lifecycle notifications |
| 36 | +func (x *example4) JobStarted(c context.Context, id string) { |
| 37 | + log.Debugf(c, "JobStarted %s", id) |
| 38 | +} |
| 39 | +func (x *example4) JobCompleted(c context.Context, id string) { |
| 40 | + log.Debugf(c, "JobCompleted %s", id) |
| 41 | +} |
| 42 | +func (x *example4) NamespaceStarted(c context.Context, id string, namespace string) { |
| 43 | + log.Debugf(c, "NamespaceStarted %s %s", id, namespace) |
| 44 | +} |
| 45 | +func (x *example4) NamespaceCompleted(c context.Context, id string, namespace string) { |
| 46 | + log.Debugf(c, "NamespaceCompleted %s %s", id, namespace) |
| 47 | +} |
| 48 | +func (x *example4) ShardStarted(c context.Context, id string, namespace string, shard int) { |
| 49 | + log.Debugf(c, "ShardStarted %s %s %d", id, namespace, shard) |
| 50 | +} |
| 51 | +func (x *example4) ShardCompleted(c context.Context, id string, namespace string, shard int) { |
| 52 | + log.Debugf(c, "ShardCompleted %s %s %d", id, namespace, shard) |
| 53 | +} |
| 54 | +func (x *example4) SliceStarted(c context.Context, id string, namespace string, shard, slice int) { |
| 55 | + log.Debugf(c, "SliceStarted %s %s %d %d", id, namespace, shard, slice) |
| 56 | +} |
| 57 | +func (x *example4) SliceCompleted(c context.Context, id string, namespace string, shard, slice int) { |
| 58 | + log.Debugf(c, "SliceCompleted %s %s %d %d", id, namespace, shard, slice) |
| 59 | +} |
0 commit comments