Browse Source

added example using compojure api

tags/0.2.16
Guillaume Buisson 7 years ago
parent
commit
f1b9d5e316
  1. 1
      .gitignore
  2. 15
      examples/project.clj
  3. 41
      examples/src/handler.clj
  4. 2
      project.clj
  5. 9
      src/clj_druid/schemas/query.clj

1
.gitignore

@ -1,3 +1,4 @@
examples/target
target
.lein-failures
.lein-history

15
examples/project.clj

@ -0,0 +1,15 @@
(defproject y42/clj-druid-examples "0.2.3"
:description "clj-druid-examples"
:dependencies [[org.clojure/clojure "1.6.0"]
[clj-time "0.9.0"] ;; needed as `lein ring` is broken
[metosin/compojure-api "0.20.3"]
[metosin/ring-http-response "0.6.1"]
[metosin/ring-swagger-ui "2.1.1-M2"]
[y42/clj-druid "0.2.3"]]
:ring {:handler handler/app}
:uberjar-name "examples.jar"
:uberwar-name "examples.war"
:profiles {:uberjar {:resource-paths ["swagger-ui"]
:aot :all}
:dev {:dependencies [[javax.servlet/servlet-api "2.5"]]
:plugins [[lein-ring "0.9.4"]]}})

41
examples/src/handler.clj

@ -0,0 +1,41 @@
(ns handler
(:require [compojure.api.sweet :refer :all]
[ring.util.http-response :refer :all]
[clj-druid.schemas.query :refer :all]))
(defapi app
(swagger-ui)
(swagger-docs
{:info {:title "clj-druid + Compojure API"
:description "clj-druid sample application"}})
(context* "/druid" []
:tags ["query"]
(POST* "/groupBy" []
:body [q groupBy]
:summary "Issue a groupBy query"
(ok true))
(POST* "/topN" []
:body [q topN]
:summary "Issue a topN query"
(ok true))
(POST* "/timeseries" []
:body [q timeseries]
:summary "Issue a timeseries query"
(ok true))
(POST* "/search" []
:body [q search]
:summary "Issue a search query"
(ok true))
(POST* "/timeBoundary" []
:body [q timeBoundary]
:summary "Issue a timeBoundary query"
(ok true))
(POST* "/segmentMetadata" []
:body [q segmentMetadata]
:summary "Issue a segmentMetadata query"
(ok true))))

2
project.clj

@ -1,4 +1,4 @@
(defproject y42/clj-druid "0.2.2"
(defproject y42/clj-druid "0.2.3"
:description "Clojure library for Druid.io"
:url "http://github.com/y42/clj-druid"
:license {:name "MIT"

9
src/clj_druid/schemas/query.clj

@ -95,6 +95,15 @@
(s/optional-key :bound) (s/enum :minTime :maxTime)
(s/optional-key :context) context})
(s/defschema query
(s/either groupBy
search
segmentMetadata
timeBoundary
timeseries
topN
select))
(def queries {:groupBy groupBy
:search search
:segmentMetadata segmentMetadata

Loading…
Cancel
Save