Skip to content

Commit

Permalink
remove elasticsearch references
Browse files Browse the repository at this point in the history
  • Loading branch information
henrod committed May 18, 2018
1 parent 89a6a4e commit 4bde3ea
Show file tree
Hide file tree
Showing 13 changed files with 7 additions and 199 deletions.
3 changes: 0 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ WORKDIR /go/src/github.com/topfreegames/mqtt-history
RUN dep ensure
RUN go install github.com/topfreegames/mqtt-history

ENV MQTTHISTORY_ELASTICSEARCH_HOST http://localhost:9200
ENV MQTTHISTORY_ELASTICSEARCH_SNIFF false

ENV MQTTHISTORY_REDIS_HOST localhost
ENV MQTTHISTORY_REDIS_PORT 6379
ENV MQTTHISTORY_REDIS_DB 0
Expand Down
14 changes: 1 addition & 13 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@
branch = "v2"
name = "gopkg.in/mgo.v2"

[[constraint]]
name = "gopkg.in/olivere/elastic.v5"
version = "5.0.39"

[[constraint]]
name = "github.com/topfreegames/extensions"
version = "v5.18.1"
6 changes: 0 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,10 @@ build:

run-containers:
@cd test_containers && docker-compose up -d && cd ..
@/bin/bash -c "until docker exec test_containers_elasticsearch_1 curl localhost:9200; do echo 'Waiting for Elasticsearch...' && sleep 1; done"

kill-containers:
@cd test_containers && docker-compose stop && cd ..

create-es-index-template:
@bash create_es_index_template.sh

CASSANDRA_CONTAINER := mqtt-history_cassandra_1
create-cassandra-table:
@until docker exec $(CASSANDRA_CONTAINER) cqlsh -e 'describe cluster'; do echo 'Waiting for Cassandra...' && sleep 2; done
Expand All @@ -33,8 +29,6 @@ create-cassandra-table:
@echo 'Done'

run-tests: run-containers
@/bin/bash -c "until docker exec test_containers_elasticsearch_1 curl localhost:9200; do echo 'Waiting for Elasticsearch...' && sleep 1; done"
@make create-es-index-template
@make CASSANDRA_CONTAINER=test_containers_cassandra_1 create-cassandra-table
@make coverage
@make kill-containers
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Build Status](https://travis-ci.org/topfreegames/mqtt-history.svg?branch=master)](https://travis-ci.org/topfreegames/mqtt-history)
[![Coverage Status](https://coveralls.io/repos/github/topfreegames/mqtt-history/badge.svg?branch=master)](https://coveralls.io/github/topfreegames/mqtt-history?branch=master)

An MQTT-based history handler for messages recorded by [mqttbot](https://github.com/topfreegames/mqttbot) in elasticsearch
An MQTT-based history handler for messages recorded by [mqttbot](https://github.com/topfreegames/mqttbot) in Cassandra


## Features
Expand All @@ -18,7 +18,7 @@ The bot is capable of:

Make sure you have go installed on your machine.

You also need to have access to running instances of elasticsearch and Redis.
You also need to have access to running instances of Cassandra and Mongo.

## Running the application

Expand All @@ -29,8 +29,8 @@ make setup
make run
```

You may need to change the configurations to point to your MQTT, ElasticSearch
and Redis servers, or you can use the provided containers, they can be run
You may need to change the configurations to point to your MQTT, Cassandra
and Mongo servers, or you can use the provided containers, they can be run
by executing `make run-containers`

## Running the tests
Expand Down
29 changes: 1 addition & 28 deletions app/util.go
Original file line number Diff line number Diff line change
@@ -1,33 +1,6 @@
package app

import (
"bytes"
"context"
"fmt"
"strings"
"time"

"github.com/topfreegames/mqtt-history/es"
"gopkg.in/olivere/elastic.v5"
)

func getLimitedIndexString(days int) string {
var buffer bytes.Buffer
t := time.Now().Local().Format("2006-01-02")
buffer.WriteString(fmt.Sprintf("chat-%s*", t))
for cnt := 1; cnt <= days; cnt++ {
t := time.Now().Local().Add(time.Duration(cnt*-24) * time.Hour).Format("2006-01-02")
buffer.WriteString(fmt.Sprintf(",chat-%s*", t))
}
return buffer.String()
}

// DoESQuery does a query
func DoESQuery(ctx context.Context, numberOfDaysToSearch int, boolQuery *elastic.BoolQuery, from, limit int) (*elastic.SearchResult, error) {
esclient := es.GetESClient()
return esclient.Search().Index(getLimitedIndexString(numberOfDaysToSearch)).Query(boolQuery).
Sort("timestamp", false).From(from).Size(limit).Do(ctx)
}
import "strings"

// IsNotFoundError returns true if error is of not found type
func IsNotFoundError(err error) bool {
Expand Down
5 changes: 0 additions & 5 deletions config/local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
numberOfDaysToSearch: 7
healthcheck:
workingText: "WORKING"
elasticsearch:
host: "http://localhost:9123"
sniff: false
indexMappings:
chat: '{ "mappings": { "message":{}}}'
cassandra:
hosts: "localhost:9042"
keyspace: "chat"
Expand Down
5 changes: 0 additions & 5 deletions config/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
numberOfDaysToSearch: 7
healthcheck:
workingText: "WORKING"
elasticsearch:
host: "http://localhost:9123"
sniff: false
indexMappings:
chat: '{ "mappings": { "message":{}}}'
cassandra:
hosts: "localhost:9042"
keyspace: "chat"
Expand Down
14 changes: 0 additions & 14 deletions create_es_index_template.sh

This file was deleted.

11 changes: 1 addition & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@ services:
image: cassandra:3.11
ports:
- 9042:9042
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:5.4.1
ports:
- "9200:9200"
environment:
- http.host=0.0.0.0
- transport.host=127.0.0.1
- xpack.security.enabled=false
mosquitto:
image: eclipse-mosquitto:1.4.12
mqtt-history:
Expand All @@ -21,13 +13,12 @@ services:
environment:
- MQTTHISTORY_MQTTSERVER_HOST=mosquitto
- MQTTHISTORY_MQTTSERVER_PORT=1883
- MQTTHISTORY_ELASTICSEARCH_HOST=http://elasticsearch:9200
ports:
- "8888:80"
- "8883:443"
depends_on:
- mosquitto
- elasticsearch
- cassandra
mongo:
image: mongo:3.0.15-wheezy
ports:
Expand Down
81 changes: 0 additions & 81 deletions es/es_client.go

This file was deleted.

17 changes: 0 additions & 17 deletions es/es_client_test.go

This file was deleted.

9 changes: 0 additions & 9 deletions test_containers/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@ services:
environment:
- DOMAIN=example.local
- PORT=8080
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:5.4.1
ports:
- "9123:9200"
- "9300:9300"
environment:
- http.host=0.0.0.0
- transport.host=127.0.0.1
- xpack.security.enabled=false
mongo:
image: mongo:3.0.15-wheezy
ports:
Expand Down

0 comments on commit 4bde3ea

Please sign in to comment.