Liking cljdoc? Tell your friends :D

oops-base-clj

A clojure rpc framework

include rpc server(client), json-schema

Installation

lein

[org.clojars.lilin/clo-soa-base "0.1.1"]

Usage

RPC

Init a rpc-instance:

(def rpc-instance (rpc-base/init-instance "amqp://lemming:123456@127.0.0.1:5672/tube" "wormhole" "echo"))

which wormhole is a topic exchange and echo is a direct one

Define a view function func

(defn func [{:keys [name age]}]
  (println name age)
  {:response "got it !"})

Bind a func to route with parameter schema

(def-view "route" [{:field-name :name :field-type string?} # arg name is string
                    {:field-name :age :field-type number?}] # arg age is number
          #'func
          rpc-instance)

call it:

(defn go [route]
  (rpc-client/ask-json rpc-instance route {:name "123" :age 123}))
  
(go "route")
=> {:code 0, :msg "ok", :data {:response "got it !"}}

Bugs

...

License

Copyright © 2018 LILIN

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

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close