001package com.avaje.ebeanservice.docstore.api;
002
003import com.avaje.ebean.plugin.BeanType;
004
005import java.io.IOException;
006
007/**
008 * Processes index updates.
009 * <p>
010 * This involves sending updates directly to ElasticSearch via it's Bulk API or
011 * queuing events for future processing.
012 * </p>
013 */
014public interface DocStoreUpdateProcessor {
015
016  /**
017   * Create a processor to handle updates per bean via a findEach query.
018   */
019  <T> DocStoreQueryUpdate<T> createQueryUpdate(BeanType<T> beanType, int bulkBatchSize) throws IOException;
020
021  /**
022   * Process all the updates for a transaction.
023   * <p>
024   * Typically this makes calls to the Bulk API of the document store or simply adds entries
025   * to a queue for future processing.
026   * </p>
027   *
028   * @param docStoreUpdates  The 'Bulk' and 'Queue' updates to the indexes for the transaction.
029   * @param bulkBatchSize The batch size to use for Bulk API calls specified on the transaction.
030   *                      If this is 0 then the default batch size is used.
031   */
032  void process(DocStoreUpdates docStoreUpdates, int bulkBatchSize);
033
034}