Skip to content

Commit 143e2de

Browse files
committed
Api documentation for cassandra, cassandra.cluster
1 parent 8884e3a commit 143e2de

10 files changed

Lines changed: 301 additions & 119 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ MANIFEST
66
dist
77
.coverage
88
cover/
9+
docs/_build/

cassandra/__init__.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,51 @@
33

44

55
class ConsistencyLevel(object):
6+
"""
7+
Spcifies how many replicas must respond for an operation to be considered
8+
a success. By default, ``ONE`` is used for all operations.
9+
"""
610

711
ANY = 0
12+
"""
13+
Only requires that one replica receives the write *or* the coordinator
14+
stores a hint to replay later. Valid only for writes.
15+
"""
16+
817
ONE = 1
18+
"""
19+
Only one replica needs to respond to consider the operation a success
20+
"""
21+
922
TWO = 2
23+
"""
24+
Two replicas must respond to consider the operation a success
25+
"""
26+
1027
THREE = 3
28+
"""
29+
Three replicas must respond to consider the operation a success
30+
"""
31+
1132
QUORUM = 4
33+
"""
34+
``ceil(RF/2)`` replicas must respond to consider the operation a success
35+
"""
36+
1237
ALL = 5
38+
"""
39+
All replicas must respond to consider the operation a success
40+
"""
41+
1342
LOCAL_QUORUM = 6
43+
"""
44+
Requires a quorum of replicas in the local datacenter
45+
"""
46+
1447
EACH_QUORUM = 7
48+
"""
49+
Requires a quorum of replicas in each datacenter
50+
"""
1551

1652
ConsistencyLevel.value_to_name = {
1753
ConsistencyLevel.ANY: 'ANY',
@@ -37,10 +73,20 @@ class ConsistencyLevel(object):
3773

3874

3975
class Unavailable(Exception):
76+
"""
77+
There were not enough live replicas to satisfy the requested consistency
78+
level, so the coordinator node immediately failed the request without
79+
forwarding it to any replicas.
80+
"""
4081

4182
consistency = None
83+
""" The requested :class:`ConsistencyLevel` """
84+
4285
required_replicas = None
86+
""" The number of replicas that needed to be live to complete the operation """
87+
4388
alive_replicas = None
89+
""" The number of replicas that were actually alive """
4490

4591
def __init__(self, message, consistency=None, required_replicas=None, alive_replicas=None):
4692
Exception.__init__(self, message)
@@ -50,10 +96,21 @@ def __init__(self, message, consistency=None, required_replicas=None, alive_repl
5096

5197

5298
class Timeout(Exception):
99+
"""
100+
Replicas failed to respond to the coordinator node before timing out.
101+
"""
53102

54103
consistency = None
104+
""" The requested :class:`ConsistencyLevel` """
105+
55106
required_responses = None
107+
""" The number of required replica responses """
108+
56109
received_responses = None
110+
"""
111+
The number of replicas that responded before the coordinator timed out
112+
the operation
113+
"""
57114

58115
def __init__(self, message, consistency=None, required_responses=None, received_responses=None):
59116
Exception.__init__(self, message)
@@ -63,17 +120,31 @@ def __init__(self, message, consistency=None, required_responses=None, received_
63120

64121

65122
class ReadTimeout(Timeout):
123+
"""
124+
A subclass of :exc:`Timeout` for read operations.
125+
"""
66126

67127
data_retrieved = None
128+
"""
129+
A boolean indicating whether the requested data was retrieved
130+
by the coordinator from any replicas before it timed out the
131+
operation
132+
"""
68133

69134
def __init__(self, message, data_retrieved=None, **kwargs):
70135
Timeout.__init__(self, message, **kwargs)
71136
self.data_retrieved = data_retrieved
72137

73138

74139
class WriteTimeout(Timeout):
140+
"""
141+
A subclass of :exc:`Timeout` for write operations.
142+
"""
75143

76144
write_type = None
145+
"""
146+
The type of write operation, enum on :class:`~cassandra.policies.WriteType`
147+
"""
77148

78149
def __init__(self, message, write_type=None, **kwargs):
79150
Timeout.__init__(self, message, **kwargs)

0 commit comments

Comments
 (0)