/
index.html
146 lines (130 loc) · 4.7 KB
/
index.html
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
body {
background: black;
color: rgb(80, 80, 80);
}
body, pre, #legend span {
font-family: Menlo, monospace;
font-weight: bold;
}
#topbar {
background: black;
position: fixed;
top: 0; left: 0; right: 0;
height: 42px;
border-bottom: 1px solid rgb(80, 80, 80);
}
#content {
margin-top: 50px;
}
#nav, #legend {
float: left;
margin-left: 10px;
}
#legend {
margin-top: 12px;
}
#nav {
margin-top: 10px;
}
#legend span {
margin: 0 5px;
}
.cov0 { color: rgb(192, 0, 0) }
.cov1 { color: rgb(128, 128, 128) }
.cov2 { color: rgb(116, 140, 131) }
.cov3 { color: rgb(104, 152, 134) }
.cov4 { color: rgb(92, 164, 137) }
.cov5 { color: rgb(80, 176, 140) }
.cov6 { color: rgb(68, 188, 143) }
.cov7 { color: rgb(56, 200, 146) }
.cov8 { color: rgb(44, 212, 149) }
.cov9 { color: rgb(32, 224, 152) }
.cov10 { color: rgb(20, 236, 155) }
</style>
</head>
<body>
<div id="topbar">
<div id="nav">
<select id="files">
<option value="file0">github.com\0xor1\gus\gus.go (100.0%)</option>
</select>
</div>
<div id="legend">
<span>not tracked</span>
<span class="cov0">not covered</span>
<span class="cov8">covered</span>
</div>
</div>
<div id="content">
<pre class="file" id="file0" >package gus
import(
`github.com/0xor1/sus`
`github.com/qedus/nds`
`golang.org/x/net/context`
`google.golang.org/appengine/datastore`
)
// Creates and configures a store that stores entities in Google AppEngines memcache and datastore.
// github.com/qedus/nds is used for strongly consistent automatic caching.
func NewGaeStore(kind string, ctx context.Context, idf sus.IdFactory, vf sus.VersionFactory, ei sus.EntityInitializer) sus.Store <span class="cov8" title="1">{
getKey := func(ctx context.Context, id string) *datastore.Key </span><span class="cov8" title="1">{
return datastore.NewKey(ctx, kind, id, 0, nil)
}</span>
<span class="cov8" title="1">getMulti := func(ids []string) (vs []sus.Version, err error) </span><span class="cov8" title="1">{
count := len(ids)
vs = make([]sus.Version, count, count)
ks := make([]*datastore.Key, count, count)
for i := 0; i < count; i++ </span><span class="cov8" title="1">{
vs[i] = vf()
ks[i] = getKey(ctx, ids[i])
}</span>
<span class="cov8" title="1">err = nds.GetMulti(ctx, ks, vs)
return</span>
}
<span class="cov8" title="1">putMulti := func(ids []string, vs []sus.Version) (err error) </span><span class="cov8" title="1">{
count := len(ids)
ks := make([]*datastore.Key, count, count)
for i := 0; i < count; i++ </span><span class="cov8" title="1">{
ks[i] = getKey(ctx, ids[i])
}</span>
<span class="cov8" title="1">_, err = nds.PutMulti(ctx, ks, vs)
return</span>
}
<span class="cov8" title="1">delMulti := func(ids []string) error </span><span class="cov8" title="1">{
count := len(ids)
ks := make([]*datastore.Key, count, count)
for i := 0; i < count; i++ </span><span class="cov8" title="1">{
ks[i] = getKey(ctx, ids[i])
}</span>
<span class="cov8" title="1">return nds.DeleteMulti(ctx, ks)</span>
}
<span class="cov8" title="1">isNonExtantError := func(err error) bool </span><span class="cov8" title="1">{
return err.Error() == datastore.ErrNoSuchEntity.Error()
}</span>
<span class="cov8" title="1">rit := func(tran sus.Transaction) error </span><span class="cov8" title="1">{
return nds.RunInTransaction(ctx, func(ctx context.Context)error</span><span class="cov8" title="1">{
return tran()
}</span>, &datastore.TransactionOptions{XG:true})
}
<span class="cov8" title="1">return sus.NewStore(getMulti, putMulti, delMulti, idf, vf, ei, isNonExtantError, rit)</span>
}</pre>
</div>
</body>
<script>
(function() {
var files = document.getElementById('files');
var visible = document.getElementById('file0');
files.addEventListener('change', onChange, false);
function onChange() {
visible.style.display = 'none';
visible = document.getElementById(files.value);
visible.style.display = 'block';
window.scrollTo(0, 0);
}
})();
</script>
</html>