@@ -31,7 +31,7 @@ class ArcticTransaction(object):
31
31
call the `write` method of the context manager to output changes. The changes will only be written when the block
32
32
exits.
33
33
34
- NB changes are audited.
34
+ NB changes may be audited.
35
35
36
36
Example:
37
37
-------
@@ -44,7 +44,8 @@ class ArcticTransaction(object):
44
44
retry the whole block should that happens, as the assumption is that you need to base your changes on a different
45
45
starting timeseries.
46
46
'''
47
- def __init__ (self , version_store , symbol , user , log , modify_timeseries = None , * args , ** kwargs ):
47
+ def __init__ (self , version_store , symbol , user , log , modify_timeseries = None , audit = True ,
48
+ * args , ** kwargs ):
48
49
'''
49
50
Parameters
50
51
----------
@@ -67,13 +68,20 @@ def __init__(self, version_store, symbol, user, log, modify_timeseries=None, *ar
67
68
interacting with code that read in the data already and for some reason you cannot refactor the read-write
68
69
operation to be contained within this context manager
69
70
71
+ audit: `bool`
72
+ should we 'audit' the transaction. An audited write transaction is equivalent to a snapshot
73
+ before and after the data change - i.e. we won't prune versions of the data involved in an
74
+ audited transaction. This can be used to ensure that the history of certain data changes is
75
+ preserved indefinitely.
76
+
70
77
all other args:
71
78
Will be passed into the initial read
72
79
'''
73
80
self ._version_store = version_store
74
81
self ._symbol = symbol
75
82
self ._user = user
76
83
self ._log = log
84
+ self ._audit = audit
77
85
logger .info ("MT: {}@{}: [{}] {}: {}" .format (_get_host (version_store ).get ('l' ),
78
86
_get_host (version_store ).get ('mhost' ),
79
87
user , log , symbol )
@@ -136,4 +144,5 @@ def __exit__(self, *args, **kwargs):
136
144
self ._symbol , self .base_ts .version , written_ver .version ))
137
145
138
146
changed = ChangedItem (self ._symbol , self .base_ts , written_ver , None )
139
- self ._version_store ._write_audit (self ._user , self ._log , changed )
147
+ if self ._audit :
148
+ self ._version_store ._write_audit (self ._user , self ._log , changed )
0 commit comments