diff --git a/CHANGELOG.md b/CHANGELOG.md index 34395ac5..18029ea2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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: diff --git a/src/clj/lambdacd/state/internal/pipeline_state_updater.clj b/src/clj/lambdacd/state/internal/pipeline_state_updater.clj index fc30f81d..30a5c128 100644 --- a/src/clj/lambdacd/state/internal/pipeline_state_updater.clj +++ b/src/clj/lambdacd/state/internal/pipeline_state_updater.clj @@ -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] diff --git a/test/clj/lambdacd/state/internal/pipeline_state_updater_test.clj b/test/clj/lambdacd/state/internal/pipeline_state_updater_test.clj index 3e59332d..36b0d0c5 100644 --- a/test/clj/lambdacd/state/internal/pipeline_state_updater_test.clj +++ b/test/clj/lambdacd/state/internal/pipeline_state_updater_test.clj @@ -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