Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1052)

Delta Between Two Patch Sets: state/state.go

Issue 92630043: cleanup code to remove pending Actions (Closed)
Left Patch Set: cleanup code to remove pending Actions Created 10 years, 10 months ago
Right Patch Set: cleanup code to remove pending Actions Created 10 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « state/service.go ('k') | state/state_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2012, 2013 Canonical Ltd. 1 // Copyright 2012, 2013 Canonical Ltd.
2 // Licensed under the AGPLv3, see LICENCE file for details. 2 // Licensed under the AGPLv3, see LICENCE file for details.
3 3
4 // Package state enables reading, observing, and changing 4 // Package state enables reading, observing, and changing
5 // the state stored in MongoDB of a whole environment 5 // the state stored in MongoDB of a whole environment
6 // managed by juju. 6 // managed by juju.
7 package state 7 package state
8 8
9 import ( 9 import (
10 "fmt" 10 "fmt"
(...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 } 1404 }
1405 if err != nil { 1405 if err != nil {
1406 return nil, fmt.Errorf("cannot get action %q: %v", id, err) 1406 return nil, fmt.Errorf("cannot get action %q: %v", id, err)
1407 } 1407 }
1408 return newAction(st, doc), nil 1408 return newAction(st, doc), nil
1409 } 1409 }
1410 1410
1411 // UnitActions returns a list of pending actions for a unit named name 1411 // UnitActions returns a list of pending actions for a unit named name
1412 func (st *State) UnitActions(name string) ([]*Action, error) { 1412 func (st *State) UnitActions(name string) ([]*Action, error) {
1413 actions := []*Action{} 1413 actions := []*Action{}
1414 » actionId := actionPrefix(unitGlobalKey(name)) 1414 » prefix := actionPrefix(unitGlobalKey(name))
fwereade 2014/05/27 06:59:54 `prefix :=` perhaps?
johnweldon4 2014/05/27 17:53:18 Done.
1415 » sel := bson.D{{"_id", bson.D{{"$regex", "^" + actionId}}}} 1415 » sel := bson.D{{"_id", bson.D{{"$regex", "^" + prefix}}}}
1416 iter := st.actions.Find(sel).Iter() 1416 iter := st.actions.Find(sel).Iter()
1417 doc := actionDoc{} 1417 doc := actionDoc{}
1418 for iter.Next(&doc) { 1418 for iter.Next(&doc) {
1419 actions = append(actions, newAction(st, doc)) 1419 actions = append(actions, newAction(st, doc))
1420 } 1420 }
1421 if err := iter.Err(); err != nil { 1421 if err := iter.Err(); err != nil {
1422 return actions, err 1422 return actions, err
1423 } 1423 }
1424 return actions, nil 1424 return actions, nil
1425 } 1425 }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1599 func tagForGlobalKey(key string) (string, bool) { 1599 func tagForGlobalKey(key string) (string, bool) {
1600 if len(key) < 3 || key[1] != '#' { 1600 if len(key) < 3 || key[1] != '#' {
1601 return "", false 1601 return "", false
1602 } 1602 }
1603 p, ok := tagPrefix[key[0]] 1603 p, ok := tagPrefix[key[0]]
1604 if !ok { 1604 if !ok {
1605 return "", false 1605 return "", false
1606 } 1606 }
1607 return p + key[2:], true 1607 return p + key[2:], true
1608 } 1608 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b