Skip to content

Commit

Permalink
Flush events only when the buffer is full (close #827)
Browse files Browse the repository at this point in the history
# Conflicts:
#	Sources/Core/Emitter/Emitter.swift
  • Loading branch information
danigutierrezayuso authored and matus-tomlein committed Dec 7, 2023
1 parent 22e2079 commit cee0bbf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Sources/Core/Emitter/Emitter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,14 @@ class Emitter: EmitterEventProcessing {
}

/// Insert a Payload object into the buffer to be sent to collector.
/// This method will add the payload to the database and flush (send all events).
/// This method will add the payload to the database and flush (send all events) when the buffer is full.
/// - Parameter eventPayload: A Payload containing a completed event to be added into the buffer.
func addPayload(toBuffer eventPayload: Payload) {
self.eventStore.addEvent(eventPayload)
self.flush()

if self.eventStore.count() >= self.bufferOption.rawValue {
self.flush()
}
}

/// Empties the buffer of events using the respective HTTP request method.
Expand Down

0 comments on commit cee0bbf

Please sign in to comment.