# Path: xwing/exceptions.py
# class HeartbeatFailureError(Exception):
#     pass
# 
# class ConnectionAlreadyExists(Exception):
#     pass


import asyncio
import time
import logging
from xwing.exceptions import HeartbeatFailureError, ConnectionAlreadyExists
log = logging.getLogger(__name__)


EOL = b'\n'
HEARTBEAT = b'HEARTBEAT'
HEARTBEAT_SIGNAL = b'HEARTBEAT_SIGNAL'
HEARTBEAT_ACK = b'HEARTBEAT_ACK'

INITIAL_HEARBEAT_LIVENESS = 3


class Repository:

    def __init__(self):
        self.connections = {}

    def get(self, identity):
        return self[identity]

    def add(self, connection, identity):
        log.debug('Adding new connection to {0}'.format(identity))
        if self.connections.get(identity):

# Path: xwing/exceptions.py
# class HeartbeatFailureError(Exception):
#     pass
# 
# class ConnectionAlreadyExists(Exception):
#     pass


# Path: xwing/network/connection.py
import asyncio
import time
import logging
from xwing.exceptions import HeartbeatFailureError, ConnectionAlreadyExists

log = logging.getLogger(__name__)


EOL = b'\n'
HEARTBEAT = b'HEARTBEAT'
HEARTBEAT_SIGNAL = b'HEARTBEAT_SIGNAL'
HEARTBEAT_ACK = b'HEARTBEAT_ACK'

INITIAL_HEARBEAT_LIVENESS = 3


class Repository:

    def __init__(self):
        self.connections = {}

    def get(self, identity):
        return self[identity]

    def add(self, connection, identity):
        log.debug('Adding new connection to {0}'.format(identity))
        if self.connections.get(identity):

            raise ConnectionAlreadyExists