From 79d0e006d3bd02080b1b63a32a6691dca4535523 Mon Sep 17 00:00:00 2001 From: Alexander Zhebrak Date: Wed, 23 Nov 2016 21:48:47 +0300 Subject: [PATCH] minor fix and comments --- .gitignore | 2 ++ raftos/replicator.py | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 81dde9d..a06a609 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +.idea/* + env/* build/* dist/* diff --git a/raftos/replicator.py b/raftos/replicator.py index ea27f91..f9ae478 100644 --- a/raftos/replicator.py +++ b/raftos/replicator.py @@ -2,8 +2,13 @@ class Replicated: - """Replication descriptor makes sure data changes are all applied to State Machine""" + """ + Replication class makes sure data changes are all applied to State Machine + You can create your own Storage by subclassing it + """ + DEFAULT_VALUE = None + def __init__(self, name, default='REPLICATED_DEFAULT'): self.name = name @@ -41,6 +46,8 @@ async def length(self): class ReplicatedDict(ReplicatedContainer): + """Replication class with dict-like methods""" + DEFAULT_VALUE = {} async def update(self, kwargs): @@ -60,7 +67,7 @@ async def items(self): data = await self.get() return data.items() - async def pop(self, key, defaul): + async def pop(self, key, default): data = await self.get() item = data.pop(key, default) await self.set(data) @@ -73,6 +80,8 @@ async def delete(self, key): class ReplicatedList(ReplicatedContainer): + """Replication class with list-like methods""" + DEFAULT_VALUE = [] async def append(self, kwargs):