Skip to content

Commit

Permalink
minor fix and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zhebrak committed Nov 23, 2016
1 parent 74ed141 commit 79d0e00
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.idea/*

env/*
build/*
dist/*
Expand Down
13 changes: 11 additions & 2 deletions raftos/replicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -41,6 +46,8 @@ async def length(self):


class ReplicatedDict(ReplicatedContainer):
"""Replication class with dict-like methods"""

DEFAULT_VALUE = {}

async def update(self, kwargs):
Expand All @@ -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)
Expand All @@ -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):
Expand Down

0 comments on commit 79d0e00

Please sign in to comment.