This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-27
Channels
- # bangalore-clj (1)
- # beginners (50)
- # boot (23)
- # cider (19)
- # clara (28)
- # cljsrn (4)
- # clojure (93)
- # clojure-greece (67)
- # clojure-spec (14)
- # clojure-uk (11)
- # clojurebridge (1)
- # clojurescript (151)
- # community-development (1)
- # core-async (19)
- # core-matrix (1)
- # cursive (3)
- # emacs (1)
- # klipse (5)
- # leiningen (5)
- # luminus (3)
- # lumo (22)
- # nyc (1)
- # off-topic (17)
- # om (12)
- # onyx (16)
- # pedestal (5)
- # re-frame (20)
- # reagent (5)
- # spacemacs (10)
- # uncomplicate (2)
- # unrepl (11)
- # untangled (8)
- # vim (1)
i'm researching server-side development + clojure. I'm currently looking at pedestal and luminus. does anyone know of some good resources to break out the differences between them, and other libs/frameworks?
are agents safe choice for new development? are they still embraced by community or cognitect?
They're only recommended for specific classes of problems, but cognitect still supports them, as well as all of the other reference types Clojure ships with, AFAIAA.
great, thank you
my use case is: bunch of subjects sending each other messages reacting on those which in result could end up with new messages
I guess this is perfect match 🙂
btw, is it ok to mix these two? say use core.async to implement action with would be sent with send-off ?
One of the many benefits of core.async is a kind of light weight thread mechanism, obviating the need for real threads. Agent's send-off is going to depend on a thread pool.
So if you were using it for that, you wouldn't want to mix those two concerns, at least. But you could def use them together.
If hundreds of agents are DOSing a few agents with thousands of messages each, and you need to spawn off additional threads from within the agent action, but you'd rather not spawn those many threads, you could implement the action with core.async, yeah.
I thought of using agents to manage state and core.async to do IO
There's many ways to manage state in Clojure. Agents are good when you need to serialize access to the mutation of a particular piece of state.
And using send
with agents is for mostly cpu bound work, while send-off
is better for io bound work.
@dragoncube one thing to watch out for in your description is that agents don't own any logic - all they own is their current state and optional validator, watcher, error-handler
they aren't a black box entity that handles messages, they are a transparent data structure that you send any function to that you like
@noisesmith what's your take on the mixing of agents with core.async. Are there any gotchas with regard to threads inside go blocks, etc.?
don't call await inside a go block ?
core.async mixes better with async/thread (which you can park on), but I guess you could try to do something fancy with a validator or watcher that sends messages to a channel... it feels like it would get messy though
(ring.adapter.jetty/run-jetty
(ring.middleware.resource/wrap-resource #'app "prod")
{:port 5000
:join false})
@branch14 it makes more sense to implement each of the interfaces / protocols that hashmaps implement (there's a bunch) - ztellman made a library to simplify this
proxy doesn't fall back on superclass behaviors automatically iirc - you have to explicitly use proxy-super for each method
clojure makes concrete inheritance difficult, it's intentional
@noisesmith Thx for the hint. I guess you're referring to def-map-type
of potemkin
. I'll look into it.
you could also try defrecord, implementing invoke on the IFn interface - it would be simpler if it works
@branch14 just use a defrecord
+user=> (defrecord Foo [] clojure.lang.IFn (invoke [this key] (or (get this key) (str "no value for " key " in map."))))
user.Foo
+user=> ((map->Foo {:a 0}) :a)
0
+user=> ((map->Foo {:a 0}) :b)
"no value for :b in map."
@noisesmith Oh nice! I've to try this and see how it pans out.
@qqq what benefit would ratom
have over atom
in Clojure?
Oh, you mean outside of the DOM?
I wrote an FRP library, Reagi, a while back. But it convinced me that FRP suffers from complexity at scale.
java.net.URLClassLoader$1.run URLClassLoader.java: 362
java.net.URLClassLoader$1.run URLClassLoader.java: 368
java.net.URLClassLoader.access$100 URLClassLoader.java: 73
java.net.URLClassLoader.defineClass URLClassLoader.java: 467
java.security.SecureClassLoader.defineClass SecureClassLoader.java: 142
java.lang.ClassLoader.defineClass ClassLoader.java: 763
java.lang.ClassLoader.defineClass1 ClassLoader.java
java.lang.ClassLoader.loadClass ClassLoader.java: 357
java.lang.ClassLoader.loadClass ClassLoader.java: 424
java.net.URLClassLoader.findClass URLClassLoader.java: 381
java.lang.ClassNotFoundException: com.fasterxml.jackson.core.FormatFeature
java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/FormatFeature
clojure.lang.Compiler$CompilerException: java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/FormatFeature, compiling:(cheshire/factory.clj:53:5)
clojure.lang.ExceptionInfo: java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/FormatFeature, compiling:(cheshire/factory.clj:53:5)
file: "/tmp/boot.user5060282787292643425.clj"
this is me trying to build a jar -- how do I figure out what's using fasterxml.jackson.core ... and how do get rid of it?It’s likely a dependency conflict. Check lein deps :tree
, @qqq
Usually it happens when one library depends on Java library version X, and another library depends on version Y.
One library wants an older version of Jackson that doesn’t have FormatFeature
, and because the dependency is “closer” it’s overriding the later Jackson dependency.
I'm a big fan of http://shaffner.us/cs/papers/tarpit.pdf ... which is basically a FRP system where eacn node is a db
@weavejester : yeah, Jackson issue resolved; thanks!
(require 'foo.core :reload)
:reload-all
will reload the file and dependencies.
i'm trying to follow http://pedestal.io/guides/developing-at-the-repl and the instructions are not helpful
There’s also the tools.namespace library: https://github.com/clojure/tools.namespace
Which has a refresh
function. That deletes, then reloads, any changed namespaces.
@lilactown Have you looked into the reloaded workflow?
@lilactown Cider has a cider-refresh
function that can work well with that.
There might be a pedestal template for it.
Or maybe pedestal supports it natively…
I’m not sure. I don’t use Pedestal I’m afraid 🙂
If you decide to use Ring, then I can give you options 🙂
You might also want to ask in the #pedestal channel
i'm researching using clojure + graphql, and the lacinia project has an integration with pedestal: https://github.com/walmartlabs/lacinia-pedestal
lilactown: i try lacinia with ring https://github.com/tentamen/try-lacinia
I’m somewhat biased, but my general impression of the difference is that Ring started from a synchronous approach to HTTP, and Pedestal started from an asynchronous approach.
They both have similar goals. Pedestal includes things like its own router, whereas Ring foists that off onto third-party libraries.
I’d tentatively suggest that Ring is easier to get going with.
Lacinia has support for Ring as well as Pedestal, it looks like.
partition-all and a count based filter?
(comp (partition-all 3) (filter #(= (count %) 3)))