Skip to content

Commit

Permalink
#5 - Added javadoc comments for the LastPriceServiceClient
Browse files Browse the repository at this point in the history
  • Loading branch information
stankevichevg authored and Evgenii Stankevich committed Oct 27, 2020
1 parent 006aba9 commit 8c6dac7
Showing 1 changed file with 36 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ public LastPriceServiceClient(
wrapResponseBufferForRead();
}

/**
* Requests last price for the given instrument.
*
* @param instrument instrument to receive price for
* @return last price record
* @throws ConnectionTimeoutException if response was not received in time
*/
public PriceRecord requestLastPrice(CharSequence instrument) throws ConnectionTimeoutException {
lastPriceRequest.instrument(instrument);
makeCall(lastPriceRequest);
Expand All @@ -67,29 +74,52 @@ public PriceRecord requestLastPrice(CharSequence instrument) throws ConnectionTi
/**
* Send command to start a batch run.
*
* @return
* @throws ConnectionTimeoutException
* @return started batch id
* @throws ConnectionTimeoutException if response was not received in time
*/
public long startBatchRun() throws ConnectionTimeoutException {
makeCall(startBatchRequest);
return batchStartedResponse.batchId();
}

/**
* Uploads given price records chunk to the service.
*
* @param batchRunId batch run id to upload the chunk to
* @param priceRecordsChunk chunk to upload
* @return {@code true} if chunk was uploaded, else {@code false}
* @throws ConnectionTimeoutException if response was not received in time
*/
public boolean uploadChunk(long batchRunId, PriceRecordsChunk priceRecordsChunk) throws ConnectionTimeoutException {
uploadChunkRequest.batchId(batchRunId);
uploadChunkRequest.putChunk(priceRecordsChunk);
makeCall(uploadChunkRequest);
return uploadChunkResponse.status() == UploadChunkResponse.SUCCESS_STATUS;
}

public boolean cancelBatchRun(long batchRun) throws ConnectionTimeoutException {
cancelBatchRunRequest.batchId(batchRun);
/**
* Cancels butch with the given id.
*
* @param batchRunId batch run id to cancel
* @return {@code true} if batch was canceled, else {@code false}
* @throws ConnectionTimeoutException if response was not received in time
*/
public boolean cancelBatchRun(long batchRunId) throws ConnectionTimeoutException {
cancelBatchRunRequest.batchId(batchRunId);
makeCall(cancelBatchRunRequest);
return cancelBatchRunResponse.status() == CancelBatchRunResponse.SUCCESS_STATUS;
}

public boolean completeBatchRun(long batchRun) throws ConnectionTimeoutException {
completeBatchRunRequest.batchId(batchRun);
/**
* Completes batch run with the given id.
* After this operation was applied price changes in batch should be visible for all consequent read requests.
*
* @param batchRunId batch run id to complete
* @return {@code true} if batch was completed, else {@code false}
* @throws ConnectionTimeoutException if response was not received in time
*/
public boolean completeBatchRun(long batchRunId) throws ConnectionTimeoutException {
completeBatchRunRequest.batchId(batchRunId);
makeCall(completeBatchRunRequest);
return completeBatchRunResponse.status() == CompleteBatchRunResponse.SUCCESS_STATUS;
}
Expand Down

0 comments on commit 8c6dac7

Please sign in to comment.