Package convex.net

Class ResultConsumer

java.lang.Object
convex.net.ResultConsumer
All Implemented Interfaces:
Consumer<Message>

public abstract class ResultConsumer extends Object implements Consumer<Message>
Consumer abstract base class for awaiting results. Provides basic buffering of: - Missing data until all data is available.
  • Constructor Details

    • ResultConsumer

      public ResultConsumer()
  • Method Details

    • accept

      public void accept(Message m)
      Specified by:
      accept in interface Consumer<Message>
    • unbuffer

      protected void unbuffer(Hash hash)
      Unbuffer and replay messages for a given hash
      Parameters:
      hash -
    • handleResult

      protected void handleResult(long id, Object value)
      Method called when a normal (non-error) result is received. If this method throws a MissingDataException, missing data is requested and the result handling may be retried later.
      Parameters:
      id - The ID of the original message to which this result corresponds
      value - The result value
    • handleResult

      protected void handleResult(Object value)
      Method called when a normal (non-error) result is received. If this method throws a MissingDataException, missing data is requested and the result handling may be retried later.
      Parameters:
      value - The result value
    • handleResultMessage

      protected void handleResultMessage(Message m)
      Method called when a result is received. By default, delegates to handleResult and handleError
    • handleError

      protected void handleError(long id, Object code, Object errorMessage)
      Method called when an error result is received. Default behaviour is simply to log the error. If this method throws a MissingDataException, missing data is requested and the result handling may be retried later.
      Parameters:
      id - The ID of the original message to which this result corresponds
      code - The error code received. May not be null, and is usually a Keyword
      errorMessage - The error message associated with the result (may be null)
    • handleError

      protected void handleError(Object code, Object errorMessage)
      Method called when an error result is received. Default behaviour is simply to log the error. If this method throws a MissingDataException, missing data is requested and the result handling may be retried later.
      Parameters:
      code - The error code received. May not be null, and is usually a Keyword
      errorMessage - The error message associated with the result (may be null)