Skip to content

Commit

Permalink
v0.6.30: improved metadata handling in scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasn committed Jan 24, 2018
1 parent 6a90e2a commit f13264f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).


## [0.6.30] - 2018-01-24
### Changed
- improved metadata handling in scheduler

## [0.6.29] - 2018-01-05
### Changed
- record tag creation timestamp
Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject matthiasn/systems-toolbox "0.6.29"
(defproject matthiasn/systems-toolbox "0.6.30"
:description "Toolbox for building Systems in Clojure"
:url "https://github.com/matthiasn/systems-toolbox"
:license {:name "Eclipse Public License"
Expand Down
18 changes: 12 additions & 6 deletions src/cljc/matthiasn/systems_toolbox/scheduler.cljc
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
(ns matthiasn.systems-toolbox.scheduler
#?(:cljs (:require-macros [cljs.core.async.macros :refer [go-loop]]))
(:require [matthiasn.systems-toolbox.component :as comp]
#?(:clj [clojure.tools.logging :as l]
(:require [matthiasn.systems-toolbox.component :as comp]
#?(:clj
[clojure.tools.logging :as l]
:cljs [matthiasn.systems-toolbox.log :as l])
#?(:clj [clojure.core.async :refer [<! go-loop timeout]])
#?(:clj
[clojure.core.async :refer [<! go-loop timeout]])
#?(:cljs [cljs.core.async :refer [<! timeout]])))

;;; Systems Toolbox - Scheduler Subsystem
Expand Down Expand Up @@ -36,8 +38,12 @@
"Starts a loop for sending messages at set intervals."
[{:keys [current-state cmp-state put-fn msg-meta msg-payload]}]
(let [timeout-ms (:timeout msg-payload)
msg-to-send (with-meta (:message msg-payload)
(update-in msg-meta [:cmp-seq] #(vec (take-last 2 %))))
msg-to-send (:message msg-payload)
msg-meta (merge
(update-in msg-meta [:cmp-seq] #(vec (take-last 2 %)))
(meta msg-to-send)
(:msg-meta msg-payload))
msg-to-send (with-meta msg-to-send msg-meta)
scheduler-id (or (:id msg-payload) (first msg-to-send))]
(if (get-in current-state [:active-timers scheduler-id])
(l/debug (str "Timer " scheduler-id " already scheduled - ignoring."))
Expand Down Expand Up @@ -65,7 +71,7 @@
[_put-fn]
(let [initial-state {:active-timers {}}
state-atom (atom initial-state)]
{:state state-atom
{:state state-atom
:shutdown-fn #(reset! state-atom initial-state)}))

(defn cmp-map
Expand Down

0 comments on commit f13264f

Please sign in to comment.