Skip to content

Instantly share code, notes, and snippets.

@xeqi
Created November 7, 2015 11:51
Show Gist options
  • Save xeqi/89560d11bd4181ec1ca7 to your computer and use it in GitHub Desktop.
Save xeqi/89560d11bd4181ec1ca7 to your computer and use it in GitHub Desktop.
(defrecord JimFSFactory []
component/Lifecycle
(start [t] (Jimfs/newFileSystem (Configuration/unix))))
(extend-protocol component/Lifecycle
Jimfs
(stop [t] (.close t)))
(defrecord PathFactory [fs]
component/Lifecycle
(start [t]
(doto (.getPath fs "some-file" (make-array String 0))
(Files/createFile (make-array FileAttribute 0)))))
(-> (component/system-map
:fs (->JimFSFactory)
:path (map->PathFactory {}))
(component/system-using
{:path [:fs]})
(component/start)
(doto (-> :path
(Files/exists (make-array LinkOption 0))
prn))
(component/stop))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment