From: | "Shulgin, Oleksandr" <oleksandr(dot)shulgin(at)zalando(dot)de> |
---|---|
To: | psycopg(at)postgresql(dot)org, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Streaming replication for psycopg2 |
Date: | 2015-06-04 15:49:26 |
Message-ID: | CACACo5Rb1A6rpjFJ9aOad2THF1RksbH6u8Bt7P6Dx_H3JK+OvA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers psycopg |
On Tue, Jun 2, 2015 at 2:23 PM, Shulgin, Oleksandr <
oleksandr(dot)shulgin(at)zalando(dot)de> wrote:
>
> Hello,
>
> I've submitted a patch to psycopg2 to support streaming replication
protocol (COPY_BOTH): https://github.com/psycopg/psycopg2/pull/322
>
> It would be great if more people had a chance to take a look and provide
feedback about it. In particular, please see example usage at this github
comment[1]. Some bikeshedding is really needed here. :-)
I've been suggested that instead of putting the sync/stop methods into the
replication message class like this
class ReplicationMessage(str):
> #wal_end
> #data_start
> #send_time
> #def commit(self):
> #def stop(self):
> ...
it would make more sense to put them into the cursor, like this:
class ReplicationCursor(...):
def sync_server(self, msg):
...
def stop_replication(self):
...
The client code will be able then to do this:
class LogicalWriter(object):
def __init__(self, cursor):
self.cursor = cursor
def write(self, msg): # receives instance of ReplicationMessage
if should_stop_replication():
self.cursor.stop_replication()
return
self.actually_store_the_message(msg)
if stored_reliably() and want_to_report_now():
self.cursor.sync_server(msg)
# return value not examined by caller
That seems like a more sane interface to me.
--
Alex
From | Date | Subject | |
---|---|---|---|
Next Message | Joshua D. Drake | 2015-06-04 15:49:50 | Re: RFC: Remove contrib entirely |
Previous Message | Jim Nasby | 2015-06-04 15:33:21 | Re: Further issues with jsonb semantics, documentation |
From | Date | Subject | |
---|---|---|---|
Next Message | Dan Sawyer | 2015-06-08 15:23:40 | how to update specific cells |
Previous Message | Shulgin, Oleksandr | 2015-06-02 12:23:03 | Streaming replication for psycopg2 |