All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.hyperfoil.api.connection.Processor Maven / Gradle / Ivy

There is a newer version: 0.27
Show newest version
package io.hyperfoil.api.connection;

import java.io.Serializable;

import io.hyperfoil.api.config.BuilderBase;
import io.hyperfoil.api.session.ResourceUtilizer;
import io.hyperfoil.api.session.Session;
import io.netty.buffer.ByteBuf;

public interface Processor extends Serializable {
   /**
    * Invoked before we record first value from given response.
    * @param request Request.
    */
   default void before(R request) {
   }

   void process(R request, ByteBuf data, int offset, int length, boolean isLastPart);

   /**
    * Invoked after we record the last value from given response.
    * @param request Request.
    */
   default void after(R request) {
   }

   interface Builder extends BuilderBase> {
      Processor build();
   }

   abstract class BaseDelegating implements Processor, ResourceUtilizer {
      protected final Processor delegate;

      protected BaseDelegating(Processor delegate) {
         this.delegate = delegate;
      }

      @Override
      public void before(R request) {
         delegate.before(request);
      }

      @Override
      public void after(R request) {
         delegate.after(request);
      }

      @Override
      public void reserve(Session session) {
         if (delegate instanceof ResourceUtilizer) {
            ((ResourceUtilizer) delegate).reserve(session);
         }
      }
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy