static Task SendBatch(GetAllRequest request, GetAllResponse batchToSend, IServerStreamWriter <GetAllResponse> responseStream, ILogger logger) { if (batchToSend.States.Count == 1 && batchToSend.CalculateSize() > MaxBatchMessageSize) { var stateThatIsTooLarge = batchToSend.States[0]; Log.ProjectionStateTooLargeButSendingAnyways( logger, stateThatIsTooLarge.Key, request.ProjectionId, request.ScopeId, stateThatIsTooLarge.CalculateSize(), MaxBatchMessageSize); } Log.SendingGetAllInBatchesResult(logger, request.ProjectionId, request.ScopeId, batchToSend.States.Count); return(responseStream.WriteAsync(batchToSend)); }
static bool BatchWouldBeTooLarge(GetAllResponse batch, ProjectionCurrentState nextState) => batch.CalculateSize() + nextState.CalculateSize() > MaxBatchMessageSize;