The ClojureWerkz Blog

News and updates about ClojureWerkz projects

Major Breaking Public API Changes Coming in Our Projects

TL;DR

If you use a ClojureWerkz project (or two), please beware that libraries that rely on dynamic vars (e.g. Monger or Elastisch) will undergo a major API revision soon. We generally try to keep things as backwards compatible as possible but this is the right thing to do.

Everything Should Be Made As Easy As Possible

The ClojureWerkz philosophy has always been: easy matters. With all the focus on simplicity in the Clojure community, ease of use is often seen as a secondary concern or outright ignored.

To paraphrase Albert Einstein, “everything should be made as easy as possible”. This is why some of our projects (Monger, Elastisch, Neocons, Cassaforte) historically relied on a shared dynamic var for some commonly global state (e.g. database connection).

This makes it very easy to get started with the project and (we believe) helped some people adopt Clojure faster and with less frustration.

…But Not Easier

Unfortunately, the kind of problems you face early on in software engineering are not exactly the same as problems that arise as your project grows.

A lot of the problems have to do with scale but no the “bajillion request per second” kind. Rather, it’s about scaling your development team, product features, and making things operationally sane.

This is where some of the library aspects that are incredibly valuable to complete beginners are not very valuable or outright annoying to more experienced teams.

Overreliance on dynamic vars is by far the most common complaint we hear about Elastisch, Monger and so on. Over time we introduced alternative APIs (“monger.multi”) or overloaded function arities to make it easier for developers to use multiple connections when needed. But the complaints did not end. We need to act more boldly and we will.

Breaking Public APIs

So here’s the news: next versions of Monger, Elastisch, Neocons, and Cassaforte will make db/connection/client a mandatory explicit argument across the entire public API.

In other words, instead of

1
(a-fn arg1 arg2)

you will have to use

1
(a-fn conn arg1 arg2)

To demonstrate this with a snippet of code that uses Elastisch, before the change:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(ns clojurewerkz.elastisch.docs.examples
  (:require [clojurewerkz.elastisch.rest  :as esr]
            [clojurewerkz.elastisch.rest.index :as esi]
            [clojurewerkz.elastisch.rest.document :as esd]))

(defn -main
  [& args]
  (esr/connect! "http://127.0.0.1:9200")
  (let [mapping-types {"person" {:properties {:username   {:type "string" :store "yes"}
                                              :first-name {:type "string" :store "yes"}
                                              :last-name  {:type "string"}
                                              :age        {:type "integer"}
                                              :title      {:type "string" :analyzer "snowball"}
                                              :planet     {:type "string"}
                                              :biography  {:type "string" :analyzer "snowball" :term_vector "with_positions_offsets"}}}}
        doc           {:username "happyjoe" :first-name "Joe" :last-name "Smith" :age 30 :title "Teh Boss" :planet "Earth" :biography "N/A"}]
    (esi/create "myapp2_development" :mappings mapping-types)
    (esd/create "myapp2_development" "person" doc)))

After the change:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(ns clojurewerkz.elastisch.docs.examples
  (:require [clojurewerkz.elastisch.rest  :as esr]
            [clojurewerkz.elastisch.rest.index :as esi]
            [clojurewerkz.elastisch.rest.document :as esd]))

(defn -main
  [& args]
  (let [conn          (esr/connect "http://127.0.0.1:9200")
        mapping-types {"person" {:properties {:username   {:type "string" :store "yes"}
                                              :first-name {:type "string" :store "yes"}
                                              :last-name  {:type "string"}
                                              :age        {:type "integer"}
                                              :title      {:type "string" :analyzer "snowball"}
                                              :planet     {:type "string"}
                                              :biography  {:type "string" :analyzer "snowball" :term_vector "with_positions_offsets"}}}}
        doc           {:username "happyjoe" :first-name "Joe" :last-name "Smith" :age 30 :title "Teh Boss" :planet "Earth" :biography "N/A"}]
    (esi/create conn "myapp2_development" :mappings mapping-types)
    (esd/create conn "myapp2_development" "person" doc)))

The change is quite small but both radical enough to make upgrading harder for some people and radically simplify app architecture for others (no more shared state you have to work around all the time).

Two libraries are already updated: Elastisch 2.0 and Neocons 3.0.

Thank You, Contributors

We’d like to thank Rohit Aggarwal for making all the changes described above for Neocons 3.0. Contributors like Rohit is why open source software works as well as it does.

About the Author

Michael on behalf of the ClojureWerkz Team

Meltdown 1.0.0-beta10 Is Released

TL;DR

Meltdown is a Clojure interface to Reactor, an asynchronous programming, event passing and stream processing toolkit for the JVM.

1.0.0-beta10 is a development milestone with minor improvements.

Changes between 1.0.0-beta9 and 1.0.0-beta10

Reactor Update

Reactor is updated to 1.1.0.M3.

2-arity of clojurewerkz.meltdown.reactor/on is Removed

Reactor 1.1.0.M3 no longer supports default key (selector), so 2-arity of clojurewerkz.meltdown.reactor/on was removed.

Clojure 1.6

Meltdown now depends on org.clojure/clojure version 1.6.0. It is still compatible with Clojure 1.4 and if your project.clj depends on a different version, it will be used, but 1.6 is the default now.

Changes between 1.0.0-beta8 and 1.0.0-beta9

Consumer and Selector Introspection

clojurewerkz.meltdown.selectors/selectors-on is a new function that returns a list of selectors registered on a reactor:

1
2
3
4
5
6
(require '[clojurewerkz.meltdown.reactor   :as mr])
(require '[clojurewerkz.meltdown.selectors :as ms :refer [$])

(let [r   (mr/create)]
  (mr/on r ($ "a.key) (fn [evt]))
  (ms/selectors-on r))

clojurewerkz.meltdown.consumers/consumer-count is a new function that returns a number of consumers registered on a reactor:

1
2
3
4
5
6
7
(require '[clojurewerkz.meltdown.reactor   :as mr])
(require '[clojurewerkz.meltdown.selectors :refer [$])
(require '[clojurewerkz.meltdown.consumers :as mc])

(let [r   (mr/create)]
  (mr/on r ($ "a.key) (fn [evt]))
  (mc/consumer-count r))

Change log

Meltodwn change log is available on GitHub.

Meltdown is a ClojureWerkz Project

Meltdown is part of the group of libraries known as ClojureWerkz, together with

  • Langohr, a Clojure client for RabbitMQ that embraces the AMQP 0.9.1 model
  • Elastisch, a Clojure client for ElasticSearch
  • Monger, a Clojure MongoDB client for a more civilized age
  • Cassaforte, a Clojure Cassandra client
  • Titanium, a Clojure graph library
  • Neocons, a client for the Neo4J REST API
  • Quartzite, a powerful scheduling library

and several others. If you like Meltdown, you may also like our other projects.

Let us know what you think on Twitter or on the Clojure mailing list.

About the Author

Michael on behalf of the ClojureWerkz Team

Elastisch 2.0.0-beta4 Is Released

TL;DR

Elastisch is a battle tested, small but feature rich and well documented Clojure client for ElasticSearch. It supports virtually every Elastic Search feature and has solid documentation.

2.0.0-beta4 is a preview release of Elastisch 2.0, which focuses on the new features in ElasticSearch 1.0 and 1.1 as well as some API refinements.

Changes between Elastisch 2.0.0-beta3 and 2.0.0-beta4

Options As Maps

Elastisch has tranditionally accepted options as (pseudo) keywrod arguments, e.g.

1
(doc/search index-name mapping-type :query (q/term :biography "say"))

Starting with 2.0.0-beta4, passing a single map of arguments is now also supported by nearly all document, index, admin and percolation functions:

1
(doc/search index-name mapping-type {:query (q/term :biography "say")})

As a new design rule, all new API elements (e.g. aggregations) will accept a single map of options.

GH issue: #59.

Percolation of Existing Documents (REST API)

REST API client now supports percolation of existing documents:

1
2
3
(require '[clojurewerkz.elastisch.rest.percolation :as pcl])

(pcl/percolate-existing "articles" "article" "123")

Changes between Elastisch 2.0.0-beta2 and 2.0.0-beta3

ElasticSearch Client Update

ElasticSearch client has been upgraded to 1.1.0.

Clojure 1.6

Elastisch now depends on org.clojure/clojure version 1.6.0. It is still compatible with Clojure 1.4 and if your project.clj depends on a different version, it will be used, but 1.6 is the default now.

Type Exists Operation

types-exists support in both rest and native clients:

1
2
3
(require '[clojurewerkz.elastisch.rest.index :as esi])

(esi/type-exists? "an-index" "a-type")

Contributed by Halit Olali.

Full Change Log

Elastisch change log is available on GitHub.

Thank You, Contributors

Kudos to Halit Olali, shmish111, and Richie Vos for contributing to this release.

Elastisch is a ClojureWerkz Project

Elastisch is part of the group of libraries known as ClojureWerkz, together with

  • Langohr, a Clojure client for RabbitMQ that embraces the AMQP 0.9.1 model
  • Monger, a Clojure MongoDB client for a more civilized age
  • Cassaforte, a Clojure Cassandra client
  • Titanium, a Clojure graph library
  • Neocons, a client for the Neo4J REST API
  • Welle, a Riak client with batteries included
  • Quartzite, a powerful scheduling library

and several others. If you like Elastisch, you may also like our other projects.

Let us know what you think on Twitter or on the Clojure mailing list.

About the Author

Michael on behalf of the ClojureWerkz Team

Langohr 2.9.0 Is Released

TL;DR

Langohr is a small Clojure RabbitMQ client.

2.9.0 is a minor feature release.

Changes between Langohr 2.8.x and 2.9.0

Configurable Default and Per-Operation Options in HTTP API Client

Most HTTP API client functions now have an additional optional arguments, which is a map of options passed to clj-http functions. This lets you fine tune certain HTTP requests as needed.

In addition, langohr.http/connect! now accepts one more argument which serves as default HTTP client options merged with the options provided per langohr.http function call:

1
2
3
4
5
6
7
8
9
10
11
12
(require '[langohr.http :as hc])

;; non-20x/30x statuses will now throw exceptions
(hc/connect! "http://127.0.0.1:15673" "guest" "guest" {:throw-exceptions true})

;; disable throwing exceptions for an individual operation,
;; because 404 is an expected HTTP response in this case
(hc/vhost-exists? "myapp-production" {:throw-exceptions false})
;= false

;; disabling peer verification for HTTPS requests
(hc/connect! "http://127.0.0.1:15673" "guest" "guest" {:insecure? true})

Thread Factory Customization

It is now possible to customize a java.util.concurrent.ThreadFactory used by Langohr connections. The factory will be used to instantiate all threads created by the client under the hood.

The primary use case for this is running on Google App Engine which prohibits direct thread instantiation and requires apps to use thread manager (or thread factory) from GAE SDK instead.

To provide a custom thread factory, pass it as :thread-factory to langohr.core/connect. To reify a thread factory with a Clojure function, use langohr.core/thread-factory-from:

1
2
3
4
5
6
(require '[langohr.core :as lc])

(let [tf (lc/thread-factory-from
            (fn [^Runnable r]
              (Thread. r)))]
  (lc/connect {:thread-factory tf}))

com.rabbitmq.client.TopologyRecoveryException is Used

Langohr now uses com.rabbitmq.client.TopologyRecoveryException instead of reinventing its own exception to indicate topology recovery failure.

RabbitMQ Java Client Compatibility

A few RabbitMQ Java client interface compatibility issues are resolved.

Change Log

Langohr change log is available on GitHub.

Langohr is a ClojureWerkz Project

Langohr is part of the group of libraries known as ClojureWerkz, together with

  • Elastisch, a minimalistic well documented Clojure client for ElasticSearch
  • Cassaforte, a Clojure Cassandra client built around CQL 3.0
  • Monger, a Clojure MongoDB client for a more civilized age
  • Neocons, a client for the Neo4J REST API
  • Quartzite, a powerful scheduling library

and several others. If you like Langohr, you may also like our other projects.

Let us know what you think on Twitter or on the Clojure mailing list.

About The Author

Michael on behalf of the ClojureWerkz Team

Langohr 2.8.1 Is Released

TL;DR

Langohr is a small Clojure RabbitMQ client.

2.8.1 is a minor feature release.

Changes between Langohr 2.7.x and 2.8.1

Client-side Channel Flow Removed

langohr.channel/flow and langohr.channel/flow? were removed. Client-side flow control has been deprecated for a while and was removed in RabbitMQ Java client 3.3.0.

RabbitMQ Java Client Upgrade

RabbitMQ Java client dependency has been updated to 3.3.0.

Clojure 1.6 By Default

Langohr now depends on org.clojure/clojure version 1.6.0. It is still compatible with Clojure 1.4 and if your project.clj depends on a different version, it will be used, but 1.6 is the default now.

We encourage all users to upgrade to 1.6, it is a drop-in replacement for the majority of projects out there.

langohr.http/protocol-ports

langohr.http/protocol-ports is a new function that returns a map of protocol names to protocol ports. The protocols are listed with langohr.http/list-enabled-protocols.

Change Log

Langohr change log is available on GitHub.

Langohr is a ClojureWerkz Project

Langohr is part of the group of libraries known as ClojureWerkz, together with

  • Elastisch, a minimalistic well documented Clojure client for ElasticSearch
  • Cassaforte, a Clojure Cassandra client built around CQL 3.0
  • Monger, a Clojure MongoDB client for a more civilized age
  • Neocons, a client for the Neo4J REST API
  • Quartzite, a powerful scheduling library

and several others. If you like Langohr, you may also like our other projects.

Let us know what you think on Twitter or on the Clojure mailing list.

About The Author

Michael on behalf of the ClojureWerkz Team

Propertied 1.2.0 Is Released

TL;DR

Propertied is a tiny Clojure library for working with Java property lists (java.util.Properties).

Changes Between 1.1.0 and 1.2.0

Keywords Support

properties/map->properties now supports keywords keys. properties/properties->map got a new arity that converts keys to keywords:

1
2
3
4
(require '[clojurewerkz.propertied.properties :as p])

;; converts keys to keywords
(p/properties->map props true)

Clojure 1.6 By Default

The project now depends on org.clojure/clojure version 1.6.0. It is still compatible with Clojure 1.4 and if your project.clj depends on a different version, it will be used, but 1.6 is the default now.

We encourage all users to upgrade to 1.6, it is a drop-in replacement for the majority of projects out there.

Full Change Log

Propertied change log is available on GitHub.

Propertied is a ClojureWerkz Project

Propertied is part of the group of libraries known as ClojureWerkz, together with

  • Langohr, a Clojure client for RabbitMQ that embraces the AMQP 0.9.1 model
  • Monger, a Clojure MongoDB client for a more civilized age
  • Elastisch, a minimalistic Clojure client for ElasticSearch
  • Cassaforte, a Clojure Cassandra client built around CQL
  • Neocons, a client for the Neo4J REST API
  • Welle, a Riak client with batteries included
  • Quartzite, a powerful scheduling library

and several others. If you like Propertied, you may also like our other projects.

Let us know what you think on Twitter or on the Clojure mailing list.

About The Author

Michael on behalf of the ClojureWerkz Team

Validateur 2.0.0 Is Released

TL;DR

Validateur is a functional validations library inspired by Ruby’s ActiveModel. Validateur 2.0 is a feature release.

Changes Between 1.7.0 and 2.0.0

Clojure 1.6

Validateur now depends on org.clojure/clojure version 1.6.0. It is still compatible with Clojure 1.4 and if your project.clj depends on a different version, it will be used, but 1.6 is the default now.

Validator Predicates (Guards)

It is now possible to wrap a validator into a function that will check a condition before applying the validator.

To do so, use validate-when:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(require '[validateur.validation])

(defn new?
  [user]
  (nil? (:id user)))

(defn unique-email?
  [user]
  (if-let [existing (find-by-email (:email user)]
    (= (:id user) (:id existing))
    true))

(def validate
  (validation-set
    (presence-of :email)
    (validate :email unique-email? :message "is already taken")
    (validate-when new? (presence-of :password))
    (validate-when #(contains? % :password) (presence-of :password))))

If provided predicate returns false, the validator it guards is not executed.

Contributed by Scott Nelson.

Generic Validator

Generic validator uses a predicate function and attaches errors to specified attribute:

1
2
3
(require '[validateur.validation])

(validate-with-predicate :id unique? :message "ID is not unique")

Contributed by Scott Nelson.

ClojureWerkz Support Dependency Dropped

ClojureWerkz Support is no longer a dependency of Validateur. This makes it easier to use Validateur in ClojureScript projects.

Contributed by hura.

Validation Set Composition

Validateur now supports composition of validation sets. To compose several sets, use validateur.validation/compose-sets:

1
2
3
4
5
6
7
(let [vn (vr/validation-set
           (vr/presence-of :name))
      va (vr/validation-set
           (vr/presence-of :age))
      v  (vr/compose-sets va vn)]
  ;= true
  (vr/valid? v { :name "Joe" :age 28 }))

Contributed by hura.

Full Change Log

Validateur change log is available on GitHub.

Validateur is a ClojureWerkz Project

Validateur is part of the group of libraries known as ClojureWerkz, together with

  • Langohr, a Clojure client for RabbitMQ that embraces the AMQP 0.9.1 model
  • Monger, a Clojure MongoDB client for a more civilized age
  • Elastisch, a minimalistic Clojure client for ElasticSearch
  • Cassaforte, a Clojure Cassandra client built around CQL
  • Neocons, a client for the Neo4J REST API
  • Welle, a Riak client with batteries included
  • Quartzite, a powerful scheduling library

and several others. If you like Validateur, you may also like our other projects.

Let us know what you think on Twitter or on the Clojure mailing list.

About The Author

Michael on behalf of the ClojureWerkz Team

Elastisch 2.0.0-beta2 Is Released

TL;DR

Elastisch is a battle tested, small but feature rich and well documented Clojure client for ElasticSearch. It supports virtually every Elastic Search feature and has solid documentation.

2.0.0-beta2 is a preview release of Elastisch 2.0, which focuses on the new features in ElasticSearch 1.0.

Changes between Elastisch 2.0.0-beta1 and 2.0.0-beta2

(Improved) Aggregation Support

Elastisch 2.0 features multiple convenience functions for working with ElasticSearch aggregations.

clojurewerkz.elastisch.aggregation is a new namespace that contains helper functions that produce various types of aggregations. Just like clojurewerkz.elastisch.query, all of the functions return maps and are optional.

clojurewerkz.elastisch.rest.response/aggregations-from is a new function that returns aggregations from a search response:

1
2
3
4
5
6
7
8
9
10
11
12
(require '[clojurewerkz.elastisch.rest.document :as doc])
(require '[clojurewerkz.elastisch.query :as q])
(require '[clojurewerkz.elastisch.aggregation :as a])
(require '[clojurewerkz.elastisch.rest.response :refer [aggregations-from]])

(let [index-name   "people"
        mapping-type "person"
        response     (doc/search index-name mapping-type
                                 :query (q/match-all)
                                 :aggregations {:min_age (a/min "age")})
        agg          (aggregation-from response :min_age)]
    (is (= {:value 22.0} agg)))

Aggregations support is primarily focused on REST client at the moment.

clj-http Update

clj-http dependency has been upgraded to version 0.9.1.

Full Change Log

Elastisch change log is available on GitHub.

Thank You, Contributors

Kudos to Richie Vos for contributing to this release.

Elastisch is a ClojureWerkz Project

Elastisch is part of the group of libraries known as ClojureWerkz, together with

  • Langohr, a Clojure client for RabbitMQ that embraces the AMQP 0.9.1 model
  • Monger, a Clojure MongoDB client for a more civilized age
  • Cassaforte, a Clojure Cassandra client
  • Titanium, a Clojure graph library
  • Neocons, a client for the Neo4J REST API
  • Welle, a Riak client with batteries included
  • Quartzite, a powerful scheduling library

and several others. If you like Elastisch, you may also like our other projects.

Let us know what you think on Twitter or on the Clojure mailing list.

About the Author

Michael on behalf of the ClojureWerkz Team

Meltdown 1.0.0-beta8 Is Released

TL;DR

Meltdown is a Clojure interface to Reactor, an asynchronous programming, event passing and stream processing toolkit for the JVM.

1.0.0-beta8 is a development milestone with minor improvements.

Changes between 1.0.0-beta7 and 1.0.0-beta8

Key in Event Payload

Meltdown now includes event key when transforming them into Clojure maps.

Example event map:

1
{:data {:event delivered}, :reply-to nil, :headers {}, :key events.dummy, :id #uuid "5714bb01-ac7e-11e3-64b3-6b2c231ad83a"}

Changes between 1.0.0-beta6 and 1.0.0-beta7

Match-All Selector

clojurewerkz.meltdown.selectors/predicate is a new function that creates a match-all selector (a predicate selector that unconditionally returns true).

Predicate Selectors

clojurewerkz.meltdown.selectors/predicate is a new function that creates a predicate selector:

1
2
3
4
5
6
7
8
(require '[clojurewerkz.meltdown.reactor   :as mr])
(require '[clojurewerkz.meltdown.selectors :as ms])

(let [r   (mr/create)
      ;; will filter out events with keys that are
      ;; odd numbers
      sel (ms/predicate even?)]
)

Changes between 1.0.0-beta5 and 1.0.0-beta6

Reactor Update

Reactor is updated to 1.1.0.M2.

Change log

Meltodwn change log is available on GitHub.

Meltdown is a ClojureWerkz Project

Meltdown is part of the group of libraries known as ClojureWerkz, together with

  • Langohr, a Clojure client for RabbitMQ that embraces the AMQP 0.9.1 model
  • Elastisch, a Clojure client for ElasticSearch
  • Monger, a Clojure MongoDB client for a more civilized age
  • Cassaforte, a Clojure Cassandra client
  • Titanium, a Clojure graph library
  • Neocons, a client for the Neo4J REST API
  • Quartzite, a powerful scheduling library

and several others. If you like Meltdown, you may also like our other projects.

Let us know what you think on Twitter or on the Clojure mailing list.

About the Author

Michael on behalf of the ClojureWerkz Team

Langohr 2.7.1 Is Released

TL;DR

Langohr is a small Clojure RabbitMQ client.

2.7.1 is a minor feature release.

Changes between Langohr 2.6.x and 2.7.1

langohr.http/list-enabled-protocols

langohr.http/list-enabled-protocols is a new function that lists the protocols a RabbitMQ installation supports, e.g. "amqp" or "mqtt". Note that this currently does not include WebSTOMP (due to certain technical decisions in RabbitMQ Web STOMP plugin).

Changes between Langohr 2.5.x and 2.6.0

langohr.http/list-connections-from, /close-connections-from

langohr.http/list-connections-from and langohr.http/close-connections-from are two new functions that list and close connections for a given username, respectively:

1
2
3
4
5
6
7
(require '[langohr.http :as hc])

(hc/list-connections-from "guest")
;= a list of connections with username "guest"

;; closes all connections from "guest"
(hc/close-connections-from "guest")

clj-http Upgrade

clj-http dependency has been updated to 0.9.0.

Change Log

Langohr change log is available on GitHub.

Langohr is a ClojureWerkz Project

Langohr is part of the group of libraries known as ClojureWerkz, together with

  • Elastisch, a minimalistic well documented Clojure client for ElasticSearch
  • Cassaforte, a Clojure Cassandra client built around CQL 3.0
  • Monger, a Clojure MongoDB client for a more civilized age
  • Neocons, a client for the Neo4J REST API
  • Quartzite, a powerful scheduling library

and several others. If you like Langohr, you may also like our other projects.

Let us know what you think on Twitter or on the Clojure mailing list.

About The Author

Michael on behalf of the ClojureWerkz Team