forked from GoogleCloudPlatform/golang-samples
/
consistency.go
48 lines (37 loc) · 1.11 KB
/
consistency.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright 2011 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package sample
import (
"golang.org/x/net/context"
"google.golang.org/appengine/datastore"
)
type Greeting struct{}
var ctx context.Context
func guestbookKey(ctx context.Context) *datastore.Key {
return nil
}
func example() {
// [START master_slave_data_definition_code]
g := Greeting{ /* ... */ }
key := datastore.NewIncompleteKey(ctx, "Greeting", nil)
// [END master_slave_data_definition_code]
// [START master_slave_query_code]
q := datastore.NewQuery("Greeting").Order("-Date").Limit(10)
// [END master_slave_query_code]
_ = g
_ = key
_ = q
}
func example2() {
// [START high_replication_data_definition_code]
g := Greeting{ /* ... */ }
key := datastore.NewIncompleteKey(ctx, "Greeting", guestbookKey(ctx))
// [END high_replication_data_definition_code]
// [START high_replication_query_code]
q := datastore.NewQuery("Greeting").Ancestor(guestbookKey(ctx)).Order("-Date").Limit(10)
// [END high_replication_query_code]
_ = g
_ = key
_ = q
}