MCPcopy
hub / github.com/uber/aresdb / addEntity

Function addEntity

controller/mutators/etcd/common.go:26–51  ·  view source on GitHub ↗
(entityList pb.EntityList, name string)

Source from the content-addressed store, hash-verified

24)
25
26func addEntity(entityList pb.EntityList, name string) (res pb.EntityList, incarnation int, exist bool) {
27 nowTs := utils.Now().UnixNano()
28 for _, entityName := range entityList.Entities {
29 if name == entityName.Name {
30 if !entityName.Tomstoned {
31 exist = true
32 return
33 }
34 entityName.Incarnation++
35 incarnation = int(entityName.Incarnation)
36 entityName.Tomstoned = false
37 entityName.LastUpdatedAt = nowTs
38 entityList.LastUpdatedAt = nowTs
39 return entityList, incarnation, false
40 }
41 }
42
43 entityList.Entities = append(entityList.Entities, &pb.EntityName{
44 Name: name,
45 Tomstoned: false,
46 Incarnation: 0,
47 LastUpdatedAt: nowTs,
48 })
49 entityList.LastUpdatedAt = nowTs
50 return entityList, incarnation, false
51}
52
53func readValue(etcdStore kv.TxnStore, key string, out proto.Message) (version int, err error) {
54 var value kv.Value

Callers 4

AddJobMethod · 0.85
CreateNamespaceMethod · 0.85
CreateTableMethod · 0.85

Calls 1

NowFunction · 0.92

Tested by

no test coverage detected