@@ -71,18 +71,21 @@ def post_status_update(self, status_msg, severity="info"):
71
71
def _prefix_file (self , file_path ):
72
72
return file_path if not self .file_prefix else self .file_prefix + file_path
73
73
74
+ def _create_json (self , file_info ):
75
+ return {
76
+ "timestamp" : datetime .now ().isoformat (),
77
+ "paths" : [self ._prefix_file (fp ) for fp in file_info ['paths' ]],
78
+ 'adler32' : file_info ['adler32' ],
79
+ 'file_size' : file_info ['file_size' ],
80
+ 'file_events' : file_info ['file_events' ]
81
+ }
82
+
74
83
def put_file_add (self , file_info ):
75
84
success = False
76
85
attempts = 0
77
86
while not success and attempts < MAX_RETRIES :
78
87
try :
79
- mesg = {
80
- "timestamp" : datetime .now ().isoformat (),
81
- "paths" : [self ._prefix_file (fp ) for fp in file_info ['paths' ]],
82
- 'adler32' : file_info ['adler32' ],
83
- 'file_size' : file_info ['file_size' ],
84
- 'file_events' : file_info ['file_events' ]
85
- }
88
+ mesg = self ._create_json (file_info )
86
89
requests .put (self .endpoint + "/files" , json = mesg )
87
90
self .logger .info (f"Metric: { json .dumps (mesg )} " )
88
91
success = True
@@ -95,18 +98,12 @@ def put_file_add(self, file_info):
95
98
f'message: { str (file_info )} - Ignoring error.' )
96
99
97
100
def put_file_add_bulk (self , file_list ):
98
- for chunk in chunks (file_list , 20 ):
101
+ for chunk in chunks (file_list , 30 ):
99
102
success = False
100
103
attempts = 0
101
104
mesg = []
102
105
for fi in chunk :
103
- mesg .append ({
104
- "timestamp" : datetime .now ().isoformat (),
105
- "paths" : [self ._prefix_file (fp ) for fp in fi ['paths' ]],
106
- 'adler32' : fi ['adler32' ],
107
- 'file_size' : fi ['file_size' ],
108
- 'file_events' : fi ['file_events' ]
109
- })
106
+ mesg .append (self ._create_json (fi ))
110
107
while not success and attempts < MAX_RETRIES :
111
108
try :
112
109
requests .put (self .endpoint + "/files" , json = mesg )
0 commit comments