> Hi,
>
> i started to discuss some details wrt the primitives in restkits
> socketpools and couchdbkits consumers for change watching with beonit
> on irc,
>
> since we had to depart i will dump some basic summary of my ideas here
> for later followup
>
> first is the need of a spawn and sleep primitive,
>
> since it allows the connection reaper to be expressed as
> spawn(reaper_func, pool, sleep)
>
> where the reaper loop is simply::
>
> def reaper(pool, sleep):
> while True:
> sleep(delay)
> pool.reap_connections()
>
I'm not sure about that. Some people may fail to handle it in their own code using other way to do it. Actually a reaper is a class with a methode ensure_started that we use to start it.
class ConnectionReaper(Object):
def __init__(self, pool, delay=600):
pass
def ensure_started(self):
pass
Then the reaper call the function `murder_connections` in the pool instance. It make it easy to use any kind of class and way to train a reaper.
> it would also allow to unify all the couchdbkit consumer backends,
> since the managers already handle the async connections, and if they
> also had a spawn directive, the async calls would be doable that way
>
>
> the other part is expressing the basic fetching within the consumer as
> iterator
>
> to get that one first has to understand the basic modes of operation
>
> of
>
> couchdb vs restkit | type of response
> poll !unused | document with a list of changes
> longpoll wait_once | document with a list of changes
> continuous wait | http chunks of json documents for each
> change
>
> given that knowledge , wait/wait_once can tell fetch how to create a
> iterator over the lines
>
> continuous -> json.loads(line) for line in body_file
> feed -> json.load(body_file)['changes']
>
> and since we are supposed to have a spawn primitive,
>
> the $method_async methods are basically working as spawn($method,
> args)
>
> as additional bonus the wait/wait_once methods can return a iterator
> when not given a callback,
> this be used nicely in the middle of a spawned worker
Not sure what you want here ? Any fake api in mind?
Btw the continuous async is already doing that (spawning the callback). The thing is that people may want to have synchrnous handling of changes even if it take times.
- benoit
I'm not convinced it would give more possibilities than the current one. One thing howerver that should be change is the way we are using gevent, eventlet or anything. We should just like you suggest pass a backend to the pool just like we pass a connector to the pool. The backend could return a socket class and a the correct way to run a reaper. Not sure how it would work right now, but that something we should investigate before any release. I will have a look later in the day.
I think that what you realy want is a way to detect capabilities depending on the backend. Ie having one class and choose the backend . That's actually maybe possible by even using a threaded pool of worker in the consumer. In fact introducing the concept of orker may be better than the current API. What do you think?
- benoît