Re: Edn, Fressian, Transit: which of these formats have a future?

2015-03-15 Thread Alex Miller
Hi Ryan, To answer the big question, all of these data formats are in active use at Cognitect and while I make no promises, I expect them all to be alive and active for the knowable future. Each of them targets a different niche but all of them share the qualities of transmitting extensible typ

Edn, Fressian, Transit: which of these formats have a future?

2015-03-15 Thread Ryan Schmitt
I'm the author of dynamic-object , an open source library that makes Clojure's data modeling power available to Java programmers. This includes features like serialization and deserialization. I'll copy this small usage example from the README to give

Re: "Easier" Idempotent Component Lifecycles?

2015-03-15 Thread Colin Yates
I won't presume to speak for the Clojure norm, but nice solution - it seems idiomatic to me at least. I think I might still consider the macro approach but can't justify one over the other without some more naval gazing, particularly around composibility. On 15 Mar 2015 19:20, "Andrew Oberstar" wr

Re: "Easier" Idempotent Component Lifecycles?

2015-03-15 Thread Andrew Oberstar
I was able to do this without a macro. Here's what I have now: (defprotocol IdempotentLifecycle (-started? [this]) (-start [this]) (-stop [this])) (defn extend-lifecycle [atype] (extend atype component/Lifecycle {:start (fn [this] (if (-started? this)

Re: "Easier" Idempotent Component Lifecycles?

2015-03-15 Thread Andrew Oberstar
Sure, that makes sense. I'll give that a go along with a few other ideas, and see what works out best. Thanks for the help! Andrew Oberstar On Sun, Mar 15, 2015 at 1:22 PM Colin Yates wrote: > I don't have one at hand (as I literally wrote my first macro last > week ;)) but the way it could wor

Re: "Easier" Idempotent Component Lifecycles?

2015-03-15 Thread Colin Yates
I don't have one at hand (as I literally wrote my first macro last week ;)) but the way it could work is something like: (defmacro idempotent-component [{:keys [name start started? stop]}] `(defrecord (symbol name) [...] component/Lifecycle (start [this#] (if (~'started? this#) t

Re: How do I access components of a system map

2015-03-15 Thread Colin Yates
If you haven't already then you might want to watch: https://www.youtube.com/watch?v=13cmHf_kt-Q If it helps: (defn a-real-worker [db] ...) (defrecord ARealWorkerComponent [db registry] components/Lifecycle (start [this] (registry-api/register registry (partial a-real-worker-fn db))

Re: "Easier" Idempotent Component Lifecycles?

2015-03-15 Thread Andrew Oberstar
Thanks, Colin. Macros hadn't crossed my mind, so it's good to have them pointed out. Do you have a macro you could post that is a good example of enforcing a pattern as an implementation detail? I think that's a good general consideration, but I don't believe it fits this use case. Though an exampl

Re: How do I access components of a system map

2015-03-15 Thread Torsten Uhlmann
Colin, thanks for the thoughtful explanation! I still have a problem understanding the flow. Say I want to call a component function (like "get-user") from another component that depends on the database component. I still don't understand how a component function accesses it's dependencies? T

Re: "Easier" Idempotent Component Lifecycles?

2015-03-15 Thread Colin Yates
In OO we tend to solve the 'copy and paste' problem with abstract classes. In Clojure we also have macros, easily overused, sure, but worth knowing about. They turn the problem on its head and allow truly composable functionality. I am not stating they _are_ appropriate here, only that you might wa

Re: How do I access components of a system map

2015-03-15 Thread Colin Yates
Hi Torsten, It works best when it is all-or-nothing, so the caller of get-user would itself be a component that is dependant upon the db component. The way I visualise it is that the components are a very thin layer at the outer edge of the system that delegate to actual worker functions. Those w

"Easier" Idempotent Component Lifecycles?

2015-03-15 Thread Andrew Oberstar
I'm fairly new to Clojure, so I'm still struggling to unlearn the habits of OO-programming. While using Stuart Sierra's component library, I've found the recommendation in the docs of using idempotent lifecycles very helpful. The unfortunate result is that every component then has the same pattern

Re: How do I access components of a system map

2015-03-15 Thread Torsten Uhlmann
Hi Walter, thanks for the quick reply. Now, what does the other side of the call look like, where does the caller of "get-user" get the database component from? That's what I don't get. Thanks, Torsten. Am Sonntag, 15. März 2015 16:51:51 UTC+1 schrieb Walter van der Laan: > > Hi, > > This is a

Re: How do I access components of a system map

2015-03-15 Thread Walter van der Laan
Hi, This is an example from http://github.com/stuartsierra/component (defn get-user [database username] (execute-query (:connection database) "SELECT * FROM users WHERE username = ?" username)) Here 'database' is a component which is passed to 'get-user' as an argument. The component

How do I access components of a system map

2015-03-15 Thread Torsten Uhlmann
Hi, I'm tapping my toes in component land and I think I lack some conceptual understanding, probably done too much OO. Please forgive me if this is a stupid question (and I get a feel that it is)... Suppose I create a Lifecycle component with some state, say, a database component that creates