Skip to content

Commit

Permalink
Make service setup at runtime match the protocol's
Browse files Browse the repository at this point in the history
documentation. (Issue #12.)
  • Loading branch information
mtnygard committed Aug 4, 2014
1 parent 8ef99b3 commit 75282da
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/simulant/sim.clj
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ need to use.")
[conn process]
(reduce
(fn [m svc-definition]
(assoc m (getx svc-definition :service/key) (doto (create-service conn svc-definition)
(start-service process))))
(assoc m (getx svc-definition :service/key)
(start-service (create-service conn svc-definition) process)))
{}
(services process)))

Expand Down Expand Up @@ -116,7 +116,7 @@ process."

(defrecord ActionLogService [conn ^File temp-file writer]
Service
(start-service [this process])
(start-service [this process] this)

(finalize-service [this process]
(send-off serializer identity)
Expand All @@ -136,7 +136,7 @@ process."
(pr tx-data))
nil))))

(defn construct-action-log
(defn construct-action-log
[conn svc-definition]
(let [f (File/createTempFile "actionLog" "edn")
writer (io/writer f)]
Expand All @@ -159,9 +159,10 @@ process."
(connect [this]))

(defrecord ProcessStateService [uri]
Service
Service
(start-service [this process]
(d/create-database uri))
(d/create-database uri)
this)

(finalize-service [this process])

Expand Down Expand Up @@ -281,7 +282,7 @@ process."

;; The default implementation of process-agent-ids assumes that all
;; processes in the sim should have agents allocated round-robin
;; across them.
;; across them.
(defmethod process-agent-ids :default
[process]
(let [sim (-> process :sim/_processes only)
Expand Down Expand Up @@ -440,6 +441,3 @@ process."
(if-let [process (run-sim-process sim-uri (safe-read-string sim-id))]
(println "Joined sim " sim-id " as process " (:db/id process))
(println "Unable to join sim " sim-id)))



0 comments on commit 75282da

Please sign in to comment.