Skip to content

Commit

Permalink
Some fixes in base publisher.
Browse files Browse the repository at this point in the history
  • Loading branch information
rtnpro committed Jul 10, 2016
1 parent 2cf918e commit 6883f7e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
11 changes: 9 additions & 2 deletions ircb/publishers/base.py
Expand Up @@ -2,6 +2,7 @@

import asyncio
import logging
from collections import deque

logger = logging.getLogger('publisher')

Expand All @@ -11,13 +12,19 @@ class BasePublisher(object):
store = None
name = None

def __init__(self, *args, **kwargs):
def __init__(self):
self.fetched = False
self.callbacks = {
'update': set(),
'create': set(),
'fetch': set()
}
self.limit = None
self.results = deque(maxlen=self.limit) if self.limit else \
deque()
self.results_count = 0
self.fields = []
self.index = {}

@property
def id(self):
Expand Down Expand Up @@ -82,7 +89,7 @@ def handle_create(self, data):
logger.debug('skipping create data: {}'.format(data))
return

if self.results_count == self.limit:
if self.limit and self.results_count == self.limit:
logger.debug('Removing id: %s from index', self.results[0])
self.index.pop(self.results[0], None)
else:
Expand Down
8 changes: 2 additions & 6 deletions ircb/publishers/logs.py
Expand Up @@ -26,15 +26,11 @@ class MessageLogPublisher(BasePublisher):
store = MessageLogStore

def __init__(self, hostname, roomname, user_id, limit=30):
super().__init__()
self.limit = limit
self.hostname = hostname
self.roomname = roomname
self.user_id = user_id
self.limit = limit
self.results = deque(maxlen=self.limit)
self.results_count = 0
self.index = {}
self.fields = []
super().__init__()

@property
def id(self):
Expand Down

0 comments on commit 6883f7e

Please sign in to comment.