Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: tokenserver/appengine/impl/utils/revocation/id.go

Issue 2951393002: [errors] de-specialize Transient in favor of Tags. (Closed)
Patch Set: more refactor Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The LUCI Authors. All rights reserved. 1 // Copyright 2017 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package revocation 5 package revocation
6 6
7 import ( 7 import (
8 "golang.org/x/net/context" 8 "golang.org/x/net/context"
9 9
10 "github.com/luci/gae/service/datastore" 10 "github.com/luci/gae/service/datastore"
11 » "github.com/luci/luci-go/common/errors" 11 » "github.com/luci/luci-go/common/retry/transient"
12 ) 12 )
13 13
14 // GenerateTokenID produces an int64 that can be used as a token identifier. 14 // GenerateTokenID produces an int64 that can be used as a token identifier.
15 // 15 //
16 // We reuse datastore ID generator to produce token ids. The tokens are not 16 // We reuse datastore ID generator to produce token ids. The tokens are not
17 // actually stored in the datastore. The generated ID sequence is associated 17 // actually stored in the datastore. The generated ID sequence is associated
18 // with some entity kind (indicated via 'kind'). If we ever need to restart the 18 // with some entity kind (indicated via 'kind'). If we ever need to restart the
19 // ID sequence, this kind can be changed. 19 // ID sequence, this kind can be changed.
20 func GenerateTokenID(c context.Context, kind string) (int64, error) { 20 func GenerateTokenID(c context.Context, kind string) (int64, error) {
21 // Note: AllocateIDs modifies passed slice in place, by replacing the ke ys 21 // Note: AllocateIDs modifies passed slice in place, by replacing the ke ys
22 // there. 22 // there.
23 keys := []*datastore.Key{ 23 keys := []*datastore.Key{
24 datastore.NewKey(c, kind, "", 0, nil), 24 datastore.NewKey(c, kind, "", 0, nil),
25 } 25 }
26 if err := datastore.AllocateIDs(c, keys); err != nil { 26 if err := datastore.AllocateIDs(c, keys); err != nil {
27 » » return 0, errors.WrapTransient(err) 27 » » return 0, transient.Tag.Apply(err)
28 } 28 }
29 return keys[0].IntID(), nil 29 return keys[0].IntID(), nil
30 } 30 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698