Commit df429e05 authored by Pavel Kuzmenko's avatar Pavel Kuzmenko
Browse files

Merge branch 'kpn/171/hiden_doc' into 'master'

fix: not sync hidden doc

See merge request !189
parents 6461a135 ca27ca62
......@@ -44,26 +44,26 @@ class MirrorClient:
"""Get the dateModified value of the last document."""
return None
async def upsert(self, ts, data):
async def upsert(self, ts, data=None):
"""Insert data, if data exists, update it."""
self._ts = ts
LOG.info(f'upsert {data}')
async def update(self, ts, data):
async def update(self, ts, data=None):
"""Update data."""
self._ts = ts
LOG.info(f'update {data}')
async def delete(self, ts, data):
async def delete(self, ts, data=None):
"""Delete data."""
self._ts = ts
LOG.info(f'delete {data}')
async def noop(self, ts, data):
async def noop(self, ts, data=None):
"""Update timestamp."""
LOG.info(f'noop {data}')
async def get_ids_since_timestamp(self, ts, data):
async def get_ids_since_timestamp(self, ts, data=None):
"""Get ids list since given timestamp."""
LOG.info(f'get_ids_since_timestamp {data}')
......@@ -144,25 +144,27 @@ class SocketMirrorClientSimpleProtocol(BaseSocketMirrorClient):
raise IncorrectInitPoint(init_point)
return response_data['data']
async def upsert(self, ts, data):
LOG.info(f"Upsert operation for object id: {data['_id']}, timestamp: {ts}")
await self.ws.send_json({
'type': 'upsert',
'data': data,
'ts': ts
}, dumps=ujson.dumps)
async def noop(self, ts, data):
await self.ws.send_json({
'type': 'noop',
'data': {},
'ts': ts
}, dumps=ujson.dumps)
async def update(self, ts, data):
async def upsert(self, ts, data=None):
if data is not None:
LOG.info(f"Upsert operation for object id: {data['_id']}, timestamp: {ts}")
await self.ws.send_json({
'type': 'upsert',
'data': data,
'ts': ts
}, dumps=ujson.dumps)
async def noop(self, ts, data=None):
if data is not None:
await self.ws.send_json({
'type': 'noop',
'data': {},
'ts': ts
}, dumps=ujson.dumps)
async def update(self, ts, data=None):
"""Not available for the simple protocol."""
async def delete(self, ts, data):
async def delete(self, ts, data=None):
"""Not available for the simple protocol."""
async def _send_error(self, error_message, error_code=4000, ts=None, **extra_data):
......@@ -186,31 +188,34 @@ class SocketMirrorClientSimpleProtocol(BaseSocketMirrorClient):
class SocketMirrorClientFullProtocol(SocketMirrorClientSimpleProtocol):
"""Full protocol realization."""
async def update(self, ts, data):
async def update(self, ts, data=None):
"""Update data."""
LOG.info(f"Update operation for object id: {data['_id']}, timestamp: {ts}")
await self.ws.send_json({
'type': 'update',
'data': data,
'ts': ts
}, dumps=ujson.dumps)
async def delete(self, ts, data):
if data is not None:
LOG.info(f"Update operation for object id: {data['_id']}, timestamp: {ts}")
await self.ws.send_json({
'type': 'update',
'data': data,
'ts': ts
}, dumps=ujson.dumps)
async def delete(self, ts, data=None):
"""Delete data."""
LOG.info(f"Delete operation for object id: {data['_id']}, timestamp: {ts}")
await self.ws.send_json({
'type': 'delete',
'data': data,
'ts': ts
}, dumps=ujson.dumps)
async def get_ids_since_timestamp(self, ts, data):
await self.ws.send_json({
'type': 'ids-since-timestamp-request',
'data': data,
'ts': ts
}, dumps=ujson.dumps)
response_data = await self.receive_json()
if response_data['type'] != 'ids-since-timestamp-request':
raise MirrorUnexpectedResponse('Ids since ts', response_data)
return response_data['data']
if data is not None:
LOG.info(f"Delete operation for object id: {data['_id']}, timestamp: {ts}")
await self.ws.send_json({
'type': 'delete',
'data': data,
'ts': ts
}, dumps=ujson.dumps)
async def get_ids_since_timestamp(self, ts, data=None):
if data is not None:
await self.ws.send_json({
'type': 'ids-since-timestamp-request',
'data': data,
'ts': ts
}, dumps=ujson.dumps)
response_data = await self.receive_json()
if response_data['type'] != 'ids-since-timestamp-request':
raise MirrorUnexpectedResponse('Ids since ts', response_data)
return response_data['data']
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment