import asyncio

from aioes import Elasticsearch
from muffin.plugins import BasePlugin


__version__ = "0.0.1"
__project__ = "muffin-elasticsearch"
__author__ = "Diego Garcia <drgarcia1986@gmail.com>"
__license__ = "MIT"


class Plugin(BasePlugin):

    """ Connect to ElasticSearch. """

    name = 'elasticsearch'
    defaults = {
        'endpoins': ['localhost:9200'],
    }

    def __init__(self, *args, **kwargs):
        """ Initialize the Plugin. """
        super().__init__(*args, **kwargs)
        self.conn = None

    def setup(self, app):
        """ Setup self. """
        super().setup(app)
        if not isinstace(list, self.cfg):
            raise TypeError('Invalid endpoints configuration format')

    @asyncio.coroutine
    def start(self, app):
        """ Connect to ElasticSearch. """
        self.conn = Elasticsearch(self.cfg.endpoins)

    def finish(self, app):
        """ Close self connections. """
        self.conn.close()

    def __getattr__(self, name):
        """ Proxy attribute to self connection. """
        return getattr(self.conn, name)

@@ -341,16 +341,17 @@
 'endpoin
+t
 s': %5B'lo
@@ -624,16 +624,17 @@
  isinsta
+n
 ce(list,
@@ -642,16 +642,26 @@
 self.cfg
+.endpoints
 ):%0A     
@@ -867,16 +867,17 @@
 .endpoin
+t
 s)%0A%0A    

fix typo