Interface AutoConsumer<T>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static AutoConsumer<?> NULL  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default void accept​(T item)  
      default void close()  
      static <T> AutoConsumer<T> managed​(java.lang.String name, java.util.function.Consumer<T> consumer)
      Will create a JMX bean, with the given name, that keeps track of the consumer's throughput.
      static <T> AutoConsumer<T> managed​(Throughput manager, java.util.function.Consumer<T> consumer)
      If you want that throughput manager to be registered as a JMX bean, that's up to you.
      static <S,​T>
      AutoConsumer<S>
      mapped​(java.util.function.Function<S,​T> mapper, java.util.function.Consumer<T> consumer)
      Map/transform and then consume
      static <T> AutoConsumer<T> queued​(java.util.concurrent.ExecutorService executor, java.util.concurrent.BlockingQueue<T> queue, java.util.function.Consumer<T>... consumers)
      Put on the queue, and then the consumers work off that queue.
      static <T> AutoConsumer<T> sharded​(java.util.function.ToIntFunction<T> distributor, java.util.function.Consumer<T>... consumers)
      Distribute to 1 of the consumers
      void write​(T item)
      Write the item to the consumer.
      default void writeBatch​(java.lang.Iterable<? extends T> batch)
      Write the batch (collection of items) to the consumer.
      • Methods inherited from interface java.util.function.Consumer

        andThen
    • Method Detail

      • managed

        static <T> AutoConsumer<T> managed​(java.lang.String name,
                                           java.util.function.Consumer<T> consumer)
        Will create a JMX bean, with the given name, that keeps track of the consumer's throughput.
      • managed

        static <T> AutoConsumer<T> managed​(Throughput manager,
                                           java.util.function.Consumer<T> consumer)
        If you want that throughput manager to be registered as a JMX bean, that's up to you.
      • mapped

        static <S,​T> AutoConsumer<S> mapped​(java.util.function.Function<S,​T> mapper,
                                                  java.util.function.Consumer<T> consumer)
        Map/transform and then consume
      • queued

        static <T> AutoConsumer<T> queued​(java.util.concurrent.ExecutorService executor,
                                          java.util.concurrent.BlockingQueue<T> queue,
                                          java.util.function.Consumer<T>... consumers)
        Put on the queue, and then the consumers work off that queue. There will be 1 thread (executor task) per consumer.
      • sharded

        static <T> AutoConsumer<T> sharded​(java.util.function.ToIntFunction<T> distributor,
                                           java.util.function.Consumer<T>... consumers)
        Distribute to 1 of the consumers
      • accept

        default void accept​(T item)
        Specified by:
        accept in interface java.util.function.Consumer<T>
        See Also:
        write(Object)
      • close

        default void close()
                    throws java.lang.Exception
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.lang.Exception
      • write

        void write​(T item)
        Write the item to the consumer.
        Parameters:
        item - The item to be written
      • writeBatch

        default void writeBatch​(java.lang.Iterable<? extends T> batch)
        Write the batch (collection of items) to the consumer.
        Parameters:
        batch - The batch to be written