Skip to content

Commit faef661

Browse files
committed
add replicationFactor + writeConcern
1 parent 52d5c1b commit faef661

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

arango/collection.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,14 +301,33 @@ def response_handler(resp: Response) -> Json:
301301
return self._execute(request, response_handler)
302302

303303
def configure(
304-
self, sync: Optional[bool] = None, schema: Optional[Json] = None
304+
self,
305+
sync: Optional[bool] = None,
306+
schema: Optional[Json] = None,
307+
replication_factor: Optional[int] = None,
308+
write_concern: Optional[int] = None
305309
) -> Result[Json]:
306310
"""Configure collection properties.
307311
308312
:param sync: Block until operations are synchronized to disk.
309313
:type sync: bool | None
310314
:param schema: document schema for validation of objects.
311315
:type schema: dict
316+
:param replication_factor: Number of copies of each shard on different
317+
servers in a cluster. Allowed values are 1 (only one copy is kept
318+
and no synchronous replication), and n (n-1 replicas are kept and
319+
any two copies are replicated across servers synchronously, meaning
320+
every write to the master is copied to all slaves before operation
321+
is reported successful).
322+
:type replication_factor: int
323+
:param write_concern: Write concern for the collection. Determines how
324+
many copies of each shard are required to be in sync on different
325+
DBServers. If there are less than these many copies in the cluster
326+
a shard will refuse to write. Writes to shards with enough
327+
up-to-date copies will succeed at the same time. The value of this
328+
parameter cannot be larger than that of **replication_factor**.
329+
Default value is 1. Used for clusters only.
330+
:type write_concern: int
312331
:return: New collection properties.
313332
:rtype: dict
314333
:raise arango.exceptions.CollectionConfigureError: If operation fails.
@@ -318,6 +337,10 @@ def configure(
318337
data["waitForSync"] = sync
319338
if schema is not None:
320339
data["schema"] = schema
340+
if replication_factor is not None:
341+
data["replicationFactor"] = replication_factor
342+
if write_concern is not None:
343+
data["writeConcern"] = write_concern
321344

322345
request = Request(
323346
method="put",

0 commit comments

Comments
 (0)