Merge lp:~themue/juju-core/026-transaction-resumer into lp:~go-bot/juju-core/trunk
Proposed by
Frank Mueller
Status: | Merged |
---|---|
Approved by: | Frank Mueller |
Approved revision: | no longer in the source branch. |
Merged at revision: | 1312 |
Proposed branch: | lp:~themue/juju-core/026-transaction-resumer |
Merge into: | lp:~go-bot/juju-core/trunk |
Diff against target: |
175 lines (+149/-0) 4 files modified
state/state.go (+5/-0) worker/resumer/export_test.go (+16/-0) worker/resumer/resumer.go (+71/-0) worker/resumer/resumer_test.go (+57/-0) |
To merge this branch: | bzr merge lp:~themue/juju-core/026-transaction-resumer |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+169234@code.launchpad.net |
Commit message
resumer: periodically resume transaction
The resumer is a periodically worker which is
resuming pending transactions in state each
minute.
Description of the change
resumer: periodically resume transaction
The resumer is a periodically worker which is
resuming pending transactions in state each
minute.
To post a comment you must log in.
Reviewers: mp+169234_ code.launchpad. net,
Message:
Please take a look.
Description:
resumer: periodically resume transaction
The resumer is a periodically worker which is
resuming pending transactions in state each
minute.
https:/ /code.launchpad .net/~themue/ juju-core/ 026-transaction -resumer/ +merge/ 169234
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/10266043/
Affected files: resumer/ resumer. go resumer/ resumer_ test.go
A [revision details]
M state/state.go
A worker/
A worker/
Index: [revision details] 20130613115315- e58eqa122kc07o1 a
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-
+New revision: <email address hidden>
Index: state/state.go
=== modified file 'state/state.go'
--- state/state.go 2013-06-12 02:45:22 +0000
+++ state/state.go 2013-06-13 15:29:49 +0000
@@ -1123,6 +1123,11 @@
return nil
}
+// ResumeTransactions resumes all pending transactions. ons() error { ResumeAll( )
+func (st *State) ResumeTransacti
+ return st.runner.
+}
+
var tagPrefix = map[byte]string{
'm': "machine-",
's': "service-",
Index: worker/ resumer/ resumer. go resumer/ resumer. go' resumer/ resumer. go 1970-01-01 00:00:00 +0000 resumer/ resumer. go 2013-06-13 15:29:49 +0000 net/juju- core/log" net/juju- core/state" net/tomb" Kill(rr. loop()) "resumer" ) After(interval) : nsactions( ); err != nil { "worker/ resumer: cannot resume transactions: %v", err) unreachable" )
=== added file 'worker/
--- worker/
+++ worker/
@@ -0,0 +1,62 @@
+// Copyright 2012, 2013 Canonical Ltd.
+// Licensed under the AGPLv3, see LICENCE file for details.
+
+package resumer
+
+import (
+ "fmt"
+ "launchpad.
+ "launchpad.
+ "launchpad.
+ "time"
+)
+
+// interval sets how often the resuming is called.
+const interval = time.Minute
+
+// Resumer is responsible for a periodical resuming of pending
transactions.
+type Resumer struct {
+ tomb tomb.Tomb
+ st *state.State
+}
+
+// NewResumer ...
+func NewResumer(st *state.State) *Resumer {
+ rr := &Resumer{st: st}
+ go func() {
+ defer rr.tomb.Done()
+ rr.tomb.
+ }()
+ return rr
+}
+
+func (rr *Resumer) String() string {
+ return fmt.Sprintf(
+}
+
+func (rr *Resumer) Kill() {
+ rr.tomb.Kill(nil)
+}
+
+func (rr *Resumer) Stop() error {
+ rr.tomb.Kill(nil)
+ return rr.tomb.Wait()
+}
+
+func (rr *Resumer) Wait() error {
+ return rr.tomb.Wait()
+}
+
+func (rr *Resumer) loop() error {
+ for {
+ select {
+ case <-rr.tomb.Dying():
+ return tomb.ErrDying
+ case <-time.
+ if err := rr.st.ResumeTra
+ log.Errorf(
+ }
+ }
+ }
+ panic("
+}
Index: worker/ resumer/ resumer_ test.go resumer/ resumer_ test.go' resumer/ resumer_ test.go 1970-01-01 00:00:00 +0000 resumer/ resumer_ test.go 2013-06-13 15:29:49 +0000 net/gocheck" net/juju- core/juju/ testing" net/juju- core/testing" net/juju- c...
=== added file 'worker/
--- worker/
+++ worker/
@@ -0,0 +1,28 @@
+// Copyright 2013 Canonical Ltd.
+// Licensed under the AGPLv3, see LICENCE file for details.
+
+package resumer_test
+
+import (
+ . "launchpad.
+ "launchpad.
+ coretesting "launchpad.
+ "launchpad.