Skip to content
This repository has been archived by the owner on Jun 15, 2024. It is now read-only.

Commit

Permalink
Add event :step-result-update-consumed after an update has been consu…
Browse files Browse the repository at this point in the history
…med by the pipeline-state component #136
  • Loading branch information
flosell committed Oct 23, 2016
1 parent 8b690d0 commit cc4ac78
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ The official release will have a defined and more stable API. If you are already
## 0.11.0

* Improvements:
* Keeps a history of pipeline structure if persistence component supports it (#131, #6); Implemented for default persistence
* Keeps a history of pipeline structure if persistence component supports it (#131, #6); Implemented for default persistence
* Introduced event `:step-result-update-consumed` to indicate that a step update was consumed and is available in the pipeline state #136
* Bug fixes:
* Fix deadlock occurring when steps write a lot of step-results in quick succession and step results are inherited by their parents (as in chaining) (#135)
* API changes:
Expand Down
1 change: 1 addition & 0 deletions src/clj/lambdacd/state/internal/pipeline_state_updater.clj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
build-number (:build-number step-result-update)
step-id (:step-id step-result-update)]
(state/consume-step-result-update ctx build-number step-id step-result)
(event-bus/publish! ctx :step-result-update-consumed step-result-update)
(recur)))))))

(defn stop-pipeline-state-updater [ctx]
Expand Down
13 changes: 13 additions & 0 deletions test/clj/lambdacd/state/internal/pipeline_state_updater_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@
(is (= [[1 [1 2] {:status :running}]
[2 [1 2] {:status :success}]
[1 [1 2] {:status :running :foo :bar}]] @updates))))
(testing "that after a step result is consumed, an event is sent to inform about this"
(let [updates (atom [])
pipeline-state (reify protocols/StepResultUpdateConsumer
(consume-step-result-update [self build-number step-id step-result]
(swap! updates #(conj %1 [build-number step-id step-result]))))
ctx (some-ctx-with :pipeline-state-component pipeline-state)
consume-events (event-bus/only-payload
(event-bus/subscribe ctx :step-result-update-consumed))
update-event {:build-number 1 :step-id [1 2] :step-result {:status :running}}]

(event-bus/publish ctx :step-result-updated update-event)

(is (= [update-event] (slurp-chan-with-size 1 consume-events)))))
(testing "shutdown behavior"
(testing "that the pipeline-state-updater can be stopped with a message on the event bus"
(let [pipeline-state (reify protocols/StepResultUpdateConsumer
Expand Down

0 comments on commit cc4ac78

Please sign in to comment.