on master help sign in
Add a very inefficient POC elasticsearch backend
commit20a319247a206fd534d0369968a9a87a75100c04 authorOzgun Ataman <ozgun.ataman@soostone.com> dateSun 1 Mar 2015, 21:59 (12 years ago) parent55bfa46
4 files changed+94
katip-elasticsearch/LICENSE+30 katip-elasticsearch/Setup.hs+2 katip-elasticsearch/katip-elasticsearch.cabal+26 katip-elasticsearch/src/Katip/Scribes/ElasticSearch.hs+36
katip-elasticsearch/LICENSEnew file+30
@@ -0,0 +1,30 @@
1+Copyright (c) 2015, Soostone Inc
2+
3+All rights reserved.
4+
5+Redistribution and use in source and binary forms, with or without
6+modification, are permitted provided that the following conditions are met:
7+
8+ * Redistributions of source code must retain the above copyright
9+ notice, this list of conditions and the following disclaimer.
10+
11+ * Redistributions in binary form must reproduce the above
12+ copyright notice, this list of conditions and the following
13+ disclaimer in the documentation and/or other materials provided
14+ with the distribution.
15+
16+ * Neither the name of Ozgun Ataman nor the names of other
17+ contributors may be used to endorse or promote products derived
18+ from this software without specific prior written permission.
19+
20+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
katip-elasticsearch/Setup.hsnew file+2
@@ -0,0 +1,2 @@
1+import Distribution.Simple
2+main = defaultMain
katip-elasticsearch/katip-elasticsearch.cabalnew file+26
@@ -0,0 +1,26 @@
1+name: katip-elasticsearch
2+version: 0.1.0.0
3+-- synopsis:
4+-- description:
5+license: BSD3
6+license-file: LICENSE
7+author: Ozgun Ataman
8+maintainer: ozgun.ataman@soostone.com
9+copyright: Soostone Inc, 2015
10+category: Data
11+build-type: Simple
12+cabal-version: >=1.10
13+
14+library
15+ exposed-modules:
16+ Katip.Scribes.ElasticSearch
17+ -- other-modules:
18+ -- other-extensions:
19+ build-depends:
20+ base >=4.6 && <4.7
21+ , katip
22+ , bloodhound >= 0.5 && < 0.6
23+ , random >= 1.0 && < 1.2
24+ , uuid >= 1.3 && < 1.4
25+ hs-source-dirs: src
26+ default-language: Haskell2010
katip-elasticsearch/src/Katip/Scribes/ElasticSearch.hsnew file+36
@@ -0,0 +1,36 @@
1+module Katip.Scribes.ElasticSearch where
2+
3+
4+-------------------------------------------------------------------------------
5+import Control.Monad
6+import Data.UUID
7+import Database.Bloodhound
8+import System.Random
9+-------------------------------------------------------------------------------
10+import Katip.Core
11+-------------------------------------------------------------------------------
12+
13+
14+-------------------------------------------------------------------------------
15+mkEsScribe
16+ :: Server
17+ -> IndexName
18+ -> MappingName
19+ -> Severity
20+ -> Verbosity
21+ -> IO Scribe
22+mkEsScribe server ix mapping sev verb = return $ Scribe $ \ i -> do
23+ did <- mkDocId
24+ void $ indexDocument server ix mapping i did
25+
26+
27+-------------------------------------------------------------------------------
28+mkDocId :: IO DocId
29+mkDocId = (DocId . toString) `fmap` randomIO
30+
31+
32+
33+
34+
35+
36+