All Projects → metosin → Kekkonen

metosin / Kekkonen

Licence: epl-2.0
A remote (CQRS) API library for Clojure.

Programming Languages

clojure
4091 projects

Projects that are alternatives of or similar to Kekkonen

Jimu
.netcore micro service framework
Stars: ✭ 315 (+56.72%)
Mutual labels:  swagger, rpc
Equinoxproject
Full ASP.NET Core 5 application with DDD, CQRS and Event Sourcing concepts
Stars: ✭ 5,120 (+2447.26%)
Mutual labels:  swagger, cqrs
Rpc Websockets
JSON-RPC 2.0 implementation over WebSockets for Node.js and JavaScript/TypeScript
Stars: ✭ 344 (+71.14%)
Mutual labels:  rpc, messaging
psr-container-messenger
Message bus and queue for Mezzio with Symfony Messenger + Enqueue
Stars: ✭ 24 (-88.06%)
Mutual labels:  cqrs, messaging
Simpletcp
Simple wrapper for TCP client and server in C# with SSL support
Stars: ✭ 99 (-50.75%)
Mutual labels:  rpc, messaging
WatsonWebsocket
A simple C# async websocket server and client for reliable transmission and receipt of data
Stars: ✭ 158 (-21.39%)
Mutual labels:  messaging, rpc
Service Bus
PHP Lightweight Message Bus supporting CQRS.
Stars: ✭ 431 (+114.43%)
Mutual labels:  messaging, cqrs
Watsontcp
WatsonTcp is the easiest way to build TCP-based clients and servers in C#.
Stars: ✭ 209 (+3.98%)
Mutual labels:  rpc, messaging
Aspnetcore Ddd
Full ASP.NET Core 3.1 LTS application with DDD, CQRS and Event Sourcing
Stars: ✭ 88 (-56.22%)
Mutual labels:  swagger, cqrs
Remit
RabbitMQ-backed microservices supporting RPC, pubsub, automatic service discovery and scaling with no code changes.
Stars: ✭ 24 (-88.06%)
Mutual labels:  rpc, messaging
SuperSimpleTcp
Simple wrapper for TCP client and server in C# with SSL support
Stars: ✭ 263 (+30.85%)
Mutual labels:  messaging, rpc
Ginrpc
gin auto binding,grpc, and annotated route,gin 注解路由, grpc,自动参数绑定工具
Stars: ✭ 157 (-21.89%)
Mutual labels:  swagger, rpc
dotnetcqs
Command/Query separation for .NET
Stars: ✭ 14 (-93.03%)
Mutual labels:  cqrs, messaging
silky
The Silky framework is designed to help developers quickly build a microservice development framework through simple code and configuration under the .net platform.
Stars: ✭ 146 (-27.36%)
Mutual labels:  swagger, rpc
microservice framework version 6
A Java framework to support applications utilising CQRS and Event Sourcing architectures
Stars: ✭ 25 (-87.56%)
Mutual labels:  cqrs, messaging
Go Api Boilerplate
Go Server/API boilerplate using best practices DDD CQRS ES gRPC
Stars: ✭ 373 (+85.57%)
Mutual labels:  rpc, cqrs
Netdevpack
A smart set of common classes and implementations to improve your development productivity.
Stars: ✭ 220 (+9.45%)
Mutual labels:  messaging, cqrs
Phpboot
☕️ 🚀 tiny & fast PHP framework for building Microservices/RESTful APIs, with useful features: IOC, Hook, ORM, RPC, Swagger, Annotation, Parameters binding, Validation, etc.
Stars: ✭ 638 (+217.41%)
Mutual labels:  swagger, rpc
Go Micro Boilerplate
The boilerplate of the GoLang application with a clear microservices architecture.
Stars: ✭ 147 (-26.87%)
Mutual labels:  swagger, rpc
Magiconion
Unified Realtime/API framework for .NET platform and Unity.
Stars: ✭ 2,505 (+1146.27%)
Mutual labels:  swagger, rpc

Kekkonen Build Status

A lightweight, data-driven library for creating and consuming remote service with Clojure(Script). Key features:

  • not dependent on Ring/HTTP/REST, just your domain functions & data
  • enables apis over HTTP, Web Sockets, Message Queues or whatever
  • supports multiple api styles: Messaging, CQRS & HTTP
  • Schema input & output coercion
  • live & secure api-docs with Swagger
  • besides invoking handlers, clients are enable to:
    • securely browse the api namespaces at runtime
    • check & validate single or multiple handlers without side-effects
    • extract public handler meta-data for client-side reasoning
  • highly extensible via options, interceptors and meta-handlers
    • ships with sensible defaults

Bubblin' Under:

  • all interceptors, fully async
  • support for speculative transactions
  • client-side bundled reads & writes

Picture of UKK © Pressfoton Etyk 1975 -team, Museovirasto

See Live demo & Wiki.

Latest version

Clojars Project

Quickstart: lein new kekkonen kakkonen

Basic building blocks

Handler

{:name ::plus
 :type :handler
 :interceptors []
 :input {:data {:y s/Int
                :x s/Int}}
 :output s/Int
 :handle (fn [{{:keys [x y]} :data}]
           (+ x y))}

Interceptor

{:name ::require-roles
 :enter (fn [context]
          (let [roles (-> context :user :roles)]
            (if (seq (clojure.set/intersection roles required))
              context)))}

Hello World (local dispatch)

(require '[kekkonen.core :as k])

(def dispatcher
  (k/dispatcher
    {:handlers
     {:api (k/handler {:name :hello
                       :handle (constantly "hello world"))}}}))

(k/invoke dispatcher :api/hello)
; => "hello world"

Hello World (ring-based Query API)

(require '[kekkonen.cqrs :refer :all])
(require '[org.httpkit.server :as server])

(defn ^:query hello
  {:input {:data {:name String}}}
  [ctx]
  (success (str "Hello, " (-> ctx :data :name))))

(server/run-server
  (cqrs-api {:core {:handlers #'hello}}})
  {:port 4000})

you can invoke the hello api with http://localhost:4000/hello?name=World

CQRS API with Swagger Docs

(ns example.api
  (:require [org.httpkit.server :as server]
            [kekkonen.cqrs :refer :all]
            [plumbing.core :refer [defnk]]
            [schema.core :as s]))

;;
;; Schemas
;;

(s/defschema Pizza
  {:name s/Str
   (s/optional-key :description) s/Str
   :size (s/enum :S :M :L)
   :origin {:country (s/enum :FI :PO)}})

;;
;; Handlers
;;

(defnk ^:query ping []
  (success {:ping "pong"}))

(defnk ^:command echo-pizza
  "Echoes a pizza"
  {:responses {:default {:schema Pizza}}}
  [data :- Pizza]
  (success data))

(defnk ^:query plus
  [[:data x :- s/Int, y :- s/Int]]
  (success {:result (+ x y)}))

(defnk ^:command inc! [counter]
  (success {:result (swap! counter inc)}))

;;
;; Application
;;

(def app
  (cqrs-api
    {:swagger {:ui "/api-docs"
               :spec "/swagger.json"
               :data {:info {:title "Kekkonen example"}}}
     :core {:handlers {:api {:pizza #'echo-pizza
                             :example [#'ping #'inc! #'plus]}}
            :context {:counter (atom 0)}}}))

;;
;; Start it
;;

(comment
  (server/run-server #'app {:port 3000}))

Start the server and browse to http://localhost:3000/api-docs and you should see the following:

swagger-example

More examples at /examples and info in the Wiki.

Roadmap

Mostly written as issues. Biggest things:

  • Create namespaces with handlers from external sources (db, file, actors)
  • Adapter for Websockets
  • (ClojureScript) api-docs beyond Swagger
  • Support for Om Next Remotes
  • Clojure(Script) client & project template (re-kekkonen)
  • Opinionated CQRS reference implementation, with eventing
  • Graph-based dependency management
  • Handler mutations & hot-swapping
  • Go Async

Presentations

Thinking aloud

Why not just use multimethods for dispatch?

Clojure multimethods introduce mutable implicit state. With multimethods, by requiring a namespace x you could get an extra methods for a multimethod as a side-effect. For internal functionality (like in the cljs frontends), it's totally awesome and polymorphic.

For remoting, things should be explicit and secure. With Kekkonen, handler registration is explicit and security works like the UNIX directory structure: by not having access to namespace :api.admin, you can't have access to any anything (sub-namespaces or handler) under that, regardless of their access policies.

HTTP is awesome, why hide it?

Yes, it is awesome, and is used as a transport. But do you really want to handcraft you domain into POSTs, PUTs and PATCHes do reverse-engineer back in the client? Is it easy to consume APIs that return status codes 451 or the 226?

Kekkonen tries to keep things simple. By abstracting the HTTP we can use plain clojure, websockets or queues without change in the interaction semantics.

Looks similar to Fnhouse?

Yes, we have reused many great ideas from fnhouse, see Special Thanks. Initial version of Kekkonen was supposed to be built on top of fnhouse but the we realized that most of the fnhouse internals would have had to be overridden due to difference in opinions.

Is this an actor lib?

No. But we might integrate into Pulsar.

Special thanks

License

Copyright © 2015-2018 Metosin Oy

Distributed under the Eclipse Public License 2.0.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].