Skip to content

Commit b750684

Browse files
authored
Remove duplicate code for event processing (#201)
1 parent 4d703ae commit b750684

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

server/src/event.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ impl Event {
230230
// schema is then enforced on rest of the events sent to this log stream.
231231
fn process_first_event<S: ObjectStorage, R: std::io::Read>(
232232
&self,
233-
mut event: json::Reader<R>,
233+
event: json::Reader<R>,
234234
schema: Schema,
235235
) -> Result<(), EventError> {
236236
// note for functions _schema_with_map and _set_schema_with_map,
@@ -256,8 +256,7 @@ impl Event {
256256

257257
// Store record batch on local cache
258258
log::info!("creating local writer for this first event");
259-
let rb = event.next()?.ok_or(EventError::MissingRecord)?;
260-
STREAM_WRITERS::append_to_local(stream_name, &rb)?;
259+
self.process_event(event)?;
261260

262261
log::info!("schema is set in memory map for logstream {}", stream_name);
263262
_set_schema_with_map(stream_name, schema.clone(), &mut stream_metadata);
@@ -298,10 +297,7 @@ impl Event {
298297
mut event: json::Reader<R>,
299298
) -> Result<(), EventError> {
300299
let rb = event.next()?.ok_or(EventError::MissingRecord)?;
301-
let stream_name = &self.stream_name;
302-
303-
STREAM_WRITERS::append_to_local(stream_name, &rb)?;
304-
300+
STREAM_WRITERS::append_to_local(&self.stream_name, &rb)?;
305301
Ok(())
306302
}
307303

0 commit comments

Comments
 (0)