Code Monkey home page Code Monkey logo

immutant-spec's Introduction

immutant-spec

Caches and queue specifications as data for immutant 1.1.x

Usage

#Lein

["immutant-spec" "0.1.0-SNAPSHOT"]

#Cache specs

A cache spec is just a map

(def my-cache
  {:name "my-cache"
   :encoding :none
   :persist false})

A minimal set of the immutant cache api is offered that take cache-specs as arguments. Find these in immutant-spec.cache. If you offer these fn's a spec where a cache hasn't been assoc'd then immutant-spec will try to lookup the cache from immutants global registry, if that fails - it creates the cache.

e.g

(put! my-cache :foo 1) ;; => will create the cache if it doesn't exist, and add the value 1 @ :foo
(at my-cache :foo) ;; => 1, will lookup the cache (they are global in immutant) and retrieve the value @ :foo
(with-cache [c my-cache]
  (put! c :bar 2)
  (put! c :bar 3)) ;; => re-uses the cache reference across calls

#Queue (or Topic) specs

A queue/topic spec is just a map

(def my-queue
  {:name "queue.mine"
   :durable false})

A minimal set of the immutant messaging api is offered that take queue-specs as arguments. Find these in immutant-spec.messaging. If you offer these fn's a spec where the queue or topic hasn't been assoc'd then immutant-spec will try to lookup the queue or topic, if that fails - it will start the queue.

(listen! my-queue println) ;; => starts the queue if it hasn't been started and registers a listener.
(publish! my-queue :foo) ;; => publishes foo to the queue
(stop! my-queue {:force true) ;; => stops the queue, notice options can still be passed
(with-queue [q my-queue]
  (publish! my-queue :bar)
  (publish! my-queue :baz));; => re-uses the underlying connection to HornetQ

License

Copyright © 2014 Dan Stone

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

immutant-spec's People

Contributors

wotbrew avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.