Giter Site home page Giter Site logo

clj-nakadi-java's Introduction

clj-nakadi-java

Build Status Clojars Project

Nakadi client in Clojure. Thin wrapper around nakadi-java.

[me.dryewo/clj-nakadi-java "0.0.8"]

Usage

Recommended way:

project.clj:

(defproject my/project "0.1.0-SNAPSHOT"
    ...
  :dependencies [[org.clojure/clojure "1.9.0"]
                 [functionalbytes/mount-lite "2.1.1"]
                 [cyrus/config "0.2.2"]
                 [me.dryewo/clj-nakadi-java "0.0.8"]])

my-project.clj:

(ns my.project.events
  (:require [cyrus-config.core :as cfg]
            [mount.lite :as m]
            [clojure.string :as str]
            [clj-nakadi-java.core :as nakadi]))


(cfg/def NAKADI_URL {:required true})
(cfg/def SUBSCRIPTION_ID {:required true})
(cfg/def ACCESS_TOKEN {:required true})
(cfg/def BATCH_LIMIT)


(m/defstate client
  :start (nakadi/make-client NAKADI_URL (fn [] ACCESS_TOKEN)))


(defn callback [event]
  (println "Processed" (pr-str event)))


(m/defstate consumer
  :start (do
           (nakadi/consume-subscription @client SUBSCRIPTION_ID callback)
           ;(nakadi/consume-subscription @client {:subscription-id SUBSCRIPTION_ID :batch-limit BATCH_LIMIT} callback)
           ;(nakadi/consume-subscription @client stream-config callback)
           ;(nakadi/consume-raw-events @client "foobar.event" callback)
           )
  :stop (time (@consumer)))


(comment
  (nakadi/publish-events @client "foobar.event" [{:foo "bar"}])
  (nakadi/publish-events @client "foobar.event" (for [i (range 10)]
                                                      {:x i})))

License

Copyright © 2018 Dmitrii Balakhonskii

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

clj-nakadi-java's People

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.