refactor logging options

This commit is contained in:
Jeff
2019-09-17 15:52:35 +08:00
parent fa1e62f6ac
commit f61c5e09ba
20 changed files with 444 additions and 259 deletions

View File

@@ -14,16 +14,16 @@ type Elastic struct {
index string
}
func New(address string, index string) Elastic {
func New(address string, index string) *Elastic {
client, _ := elasticsearch.NewClient(elasticsearch.Config{
Addresses: []string{address},
})
return Elastic{client: client, index: index}
return &Elastic{client: client, index: index}
}
func (e Elastic) Search(body []byte) ([]byte, error) {
func (e *Elastic) Search(body []byte) ([]byte, error) {
response, err := e.client.Search(
e.client.Search.WithContext(context.Background()),
@@ -49,7 +49,7 @@ func (e Elastic) Search(body []byte) ([]byte, error) {
return ioutil.ReadAll(response.Body)
}
func (e Elastic) GetTotalHitCount(v interface{}) int64 {
func (e *Elastic) GetTotalHitCount(v interface{}) int64 {
f, _ := v.(float64)
return int64(f)
}