package meerkat.bulletinboard.workers.multiserver;

import com.google.common.util.concurrent.FutureCallback;
import meerkat.bulletinboard.SingleServerBulletinBoardClient;
import meerkat.protobuf.BulletinBoardApi.BulletinBoardMessage;

import java.util.List;

/**
 * Created by Arbel Deutsch Peled on 27-Dec-15.
 */
public class MultiServerPostBatchWorker extends MultiServerGenericPostWorker<BulletinBoardMessage> {

    private final int chunkSize;

    public MultiServerPostBatchWorker(List<SingleServerBulletinBoardClient> clients,
                                      int minServers, BulletinBoardMessage payload, int chunkSize, int maxRetry,
                                      FutureCallback<Boolean> futureCallback) {

        super(clients, minServers, payload, maxRetry, futureCallback);

        this.chunkSize = chunkSize;

    }

    @Override
    protected void doPost(SingleServerBulletinBoardClient client, BulletinBoardMessage payload) {

        client.postAsBatch(payload, chunkSize, this);

    }


}
