# Path: stator/http.py
#     UNICODE_TYPE = unicode
#     UNICODE_TYPE = str
# class CantBindAddress(Exception):
# class HttpRequest(Socket):
# class Http(Socket):
#     def __init__(self, id, dic):
#     def reply(self, status, headers, body):
#     def parse_message(self, input):
#     def __init__(self, host, port):
# 
# Path: stator/redis.py
# class Item(Structure):
# class CantCreateConnection(Exception):
# def connect_ip(host='127.0.0.1', port=6379, db=0):
# def command(conn_id, args):
# 
# Path: stator/loop.py
#     INT_TYPES = (int, long)
#     INT_TYPES = int
# TABLE = SocketTable()
# class Socket(object):
# class SocketTable(object):
#     def __init__(self, id):
#     def close(self):
#     def parse_message(self, input):
#     def __repr__(self):
#     def __init__(self):
#     def add(self, item):
#     def get(self, id):
#     def remove(self, id):
# def parse_message(sock_id, buf, buf_len):
# def no_message():
# def blocking_io():
# def events():
# 
# Path: stator/aio.py
# LOOP = None
# FUTURES = {}
#     LOOP = loop
# class Redis(Socket):
#     def __init__(self, *, host='127.0.0.1', port=6379, db=0):
#     def execute(self, args):
#     def parse_message(self, input):
# def dispatch_messages(loop, callback):
# def start(callback, *, loop=None):


import asyncio
from stator import http, redis, loop, aio


def main():
    loop = asyncio.get_event_loop()
    red = aio.Redis(port=3001)

    @asyncio.coroutine
    def dispatch(loop, req):
        n = yield from red.execute([b"INCR", b"hello-world-counter"])
        req.reply(
            [200, u"OK"],
            {u"Content-Type": b"text/html"},
            "Hello page opened {} times".format(n).encode('utf-8'))

    sock = http.Http('0.0.0.0', 3000)

# Path: stator/http.py
#     UNICODE_TYPE = unicode
#     UNICODE_TYPE = str
# class CantBindAddress(Exception):
# class HttpRequest(Socket):
# class Http(Socket):
#     def __init__(self, id, dic):
#     def reply(self, status, headers, body):
#     def parse_message(self, input):
#     def __init__(self, host, port):
# 
# Path: stator/redis.py
# class Item(Structure):
# class CantCreateConnection(Exception):
# def connect_ip(host='127.0.0.1', port=6379, db=0):
# def command(conn_id, args):
# 
# Path: stator/loop.py
#     INT_TYPES = (int, long)
#     INT_TYPES = int
# TABLE = SocketTable()
# class Socket(object):
# class SocketTable(object):
#     def __init__(self, id):
#     def close(self):
#     def parse_message(self, input):
#     def __repr__(self):
#     def __init__(self):
#     def add(self, item):
#     def get(self, id):
#     def remove(self, id):
# def parse_message(sock_id, buf, buf_len):
# def no_message():
# def blocking_io():
# def events():
# 
# Path: stator/aio.py
# LOOP = None
# FUTURES = {}
#     LOOP = loop
# class Redis(Socket):
#     def __init__(self, *, host='127.0.0.1', port=6379, db=0):
#     def execute(self, args):
#     def parse_message(self, input):
# def dispatch_messages(loop, callback):
# def start(callback, *, loop=None):


# Path: examples/redis_asyncio.py
import asyncio
from stator import http, redis, loop, aio



def main():
    loop = asyncio.get_event_loop()
    red = aio.Redis(port=3001)

    @asyncio.coroutine
    def dispatch(loop, req):
        n = yield from red.execute([b"INCR", b"hello-world-counter"])
        req.reply(
            [200, u"OK"],
            {u"Content-Type": b"text/html"},
            "Hello page opened {} times".format(n).encode('utf-8'))

    sock = http.Http('0.0.0.0', 3000)

    aio.start(dispatch, loop=loop)