Class PersistentQueue

  • All Implemented Interfaces:
    com.jetbrains.fus.reporting.defaults.dispatcher.EventQueue

    
    public final class PersistentQueue<E extends Object>
     implements EventQueue<E>
                        
    • Constructor Detail

      • PersistentQueue

        PersistentQueue(MessageBus messageBus, FileStorage fileStorage, FusJsonSerializer jsonSerializer, FusLoggerFactory loggerFactory, Duration defaultDelay, KClass<E> eventClass, EventLogBuildType buildType, Long maxFileBytes, Duration maxFileAge)
    • Method Detail

      • enqueue

         Unit enqueue(E item)

        Adds an item to the event queue.

      • dequeue

         SendResult dequeue(SuspendFunction1<List<E>, Boolean> action)

        Dequeues a batch of events from the queue and processes them using the specified action.

        This method must be thread-safe. Use Mutex to ensure exclusive access to the queue if necessary.

        Also, action is expected not to throw exceptions. If an exception is thrown, it will be interpreted as a catastrophic problem with the event log data and the respective data should be discarded.

        Returns:

        A pair containing a boolean indicating if the operation was successful, and the duration to delay before the next dequeue attempt. Duration may be zero if dequeue can be executed immediately

      • close

         Unit close()

        Closes the event queue, releasing any allocated resources or file handles.

        This method ensures that the underlying resources, such as files or connections, associated with the event queue are properly closed and cleaned up. It should be called when the event queue is no longer needed to prevent resource leaks.