EzDevInfo.com

lamina

not under active development - event-driven workflows for clojure

Clojure core.async and Lamina

Is core.async a replacement to Lamina or does it intend to become a replacement for Lamina?

If not, are there clear situations where one is preferable over the other?


Source: (StackOverflow)

How to install lamina / aleph to Clojure?

Currently, I use Leiningen 2.1.3 on Java 1.6.0_45

Clojure 1.5.1 connected LightTable IDE 0.4.11

I want to install lamina, but looking at Installation-

[lamina "0.5.0-rc3"]

doesn't make sense to me since I'm fairly new.

Please advice how to install, and some good resource for the library management system.

Thanks!


Source: (StackOverflow)

Advertisements

Lamina undo siphon - Clojure

I'm using Lamina to implement a basic pubsub pattern.

When a client subscribes to a topic I create a new channel for it (if it doesn't already exist) and then siphon it to the client's channel. However, I can't figure out how to reverse this to let the client unsubscribe. I've been searching the docs and googling but can't find anything.

How do I undo what siphon does?


Source: (StackOverflow)

Lamina vs Storm

I am designing a prototype realtime monitor for processing fairly large amounts (>30G/day) of streaming numeric data. I would like to write this in Clojure, as the language seems to be well suited to the kind of "Observer + state machine" system that this will probably end up as.

The two main candidates I have found for a framework are Lamina and Storm. There is also Riemann and Pulse, but the former seems to be more of a full solution rather than a framework, and I'd rather not commit to a final design yet; Pulse's repo looks a little unmaintained?

What I would like to know is; what kinds of data- and work flow are these two projects optimised for? Storm seems to be more mature, but Lamina seems more composable and "Clojureic" (my background is Python, so I tend to rate this highly).

What I've found from reading online:

  • Storm seems to be Big Data(stream) focussed, the core is straight Java with a Clojure DSL. It appears to have pre=built handlers for a number of existing data sources.

  • Lamina is more a lightweight, reusable component that does the Clojure thing of coding to abstractions, meaning it can be reused as a base for other eventing systems. The data sources need to be handled in code.

  • Both have a useful set of aggregation/splitting/computation library functions out of the box. Lamina's graphviz integration is a nice touch.


Source: (StackOverflow)

Asynchronous job queue for web service in Clojure

At the moment I'm trying to construct a web service with a RESTful API that handles some long running tasks (jobs).

The idea is that a user submits a job by doing a POST which returns some URL for checking the job status which also contains a url for the results. Once the job is complete (i.e. some value was written to a database) the results URL will return the appropriate information (instead of no results) and the job url will indicate a completed status.

Unfortunately the calculations are quite intensive so only one can be run at a time, therefore the jobs need to be queued.

In pseudo something like this would be needed

(def job-queue (atom queue)) ;; some queue 
(def jobs (atom {}))

(defn schedule-job [params] 
  ;; schedules the job into the queue and 
  ;; adds the job to a jobs map for checking status via GET
  ;; note that the job should not  be evaluated until popped from the queue
)

(POST "/analyze" [{params :params}] 
 (schedulde-job params))

(GET "job/:id" [:d] 
 (get @jobs id))

;; Some function that pops the next item from the queue 
;; and evaluates it when the previous item is complete
;; Note: should not terminate when queue is empty! 

I've looked into Lamina which allows asynchronous processing but it didn't seem to suit my needs.

My question is how to dequeue the jobs-queue and execute its task after the previous one has finished, without terminating when the queue is empty i.e. perpetually processing the incoming jobs.


Source: (StackOverflow)

Clojure Functional reactive programming (FRP) with Lamina: Simple clock code?

I'm using Lamina to implement Functional reactive programming (FRP).

As a starter, I try to code a very simple clock in order to understand the library basics.

According to the Lamina 0.5.0-rc4 API documentation, there is lamina.time API: http://ideolalia.com/lamina/lamina.time.html#var-now

I want to implement a very simple clock where:

  • Interval of every second as Observable time Streaming Collection/List/Seq (I don't quite understand the difference yet) (EDIT: now I understood it's called Channels on Lamina)

  • Now as Observable Streaming data

  • Println Now on every second (subscribe or for-each Observable time Collection)

Any feedback is welcome. Thanks.

EDIT: I quit.

After some research, I conclude the best way to code FRP is ClojureScript with RxJs(ReactiveExtention from MS).

See the example Code for ClojureScript + RxJs + node.js in my related Qestion Here: ClojureScript on node.js, code


Source: (StackOverflow)

Lamina Batched Queue

I'm trying to write a web service that takes requests, puts them into a queue, and then processes them in batches of 2. The response can be sent straight away, and I'm trying to use Lamina as follows (though not sure it's the right choice)...

(def ch (channel))

(def loop-forever
  (comp doall repeatedly))

(defn consumer []
  (loop-forever
    (fn []
      (process-batch
        @(read-channel ch)
        @(read-channel ch)))))

(def handler [req]
  (enqueue ch req)
  {:status 200
   :body "ok"})

But this doesn't work... :( I've been through all the Lamina docs but can't get my head around how to use these channels. Can anyone confirm if Lamina supports this kind of behaviour and advise on a possible solution?


Source: (StackOverflow)

Async access to MongoDB using Aleph/Lamina

I have been reading about Clojure for some time and I'm considering it as a replacement to Node.js (which I have used for another project). The most promising library seems to be Aleph/Lamina, which unfortunately doesn't have nearly as many examples as Node. My questions are:

  1. How can I process requests with a chain of async operations, such as reading a document from MongoDB, doing some calculations, saving the new document and sending it in the response? I was not able to write it from the examples in Lamina wiki page. It sounds like a pretty common use case and I was surprised not to found any code showing it. It would be great if you could show me some sample code.

  2. Is this setup adequate for a heavy-load server (say, tens of thousands requests per second)? I can't afford to create one thread for each new request, so I need something similar to the Node approach.

  3. Is there any example of a medium- or large-sized company out there using any of this?

  4. Is there any better Clojure replacement to Node (besides Aleph/Lamina)? Perhaps Clojurescript targetting Node? My client is not written in Javascript, so using the same language in both client and server is not an advantage in my case.

Thanks!


Source: (StackOverflow)