private Response Put(ITransferQueue <JObject> selectedQ, Request req, CancellationToken ct = default) { if (selectedQ == null) { return(FormatResponse(req.Payload, status: (int)HttpStatusCode.BadRequest)); } bool success = selectedQ.Put(req.Payload, cToken: ct); return(FormatResponse(req.Payload, status: success ? (int)HttpStatusCode.OK : (int)HttpStatusCode.InternalServerError)); }
private async Task <Response> TransferAsync(ITransferQueue <JObject> selectedQ, Request request, CancellationToken cToken) { if (selectedQ == null) { return(FormatResponse(request.Payload, status: (int)HttpStatusCode.BadRequest)); } bool success = await selectedQ.TransferAsync(request.Payload, timeout : Convert.ToInt32(request.Headers["timeout"]), cToken : cToken); return(FormatResponse(request.Payload, success ? (int)HttpStatusCode.OK : (int)HttpStatusCode.RequestTimeout)); }
public Logger(CancellationToken cToken = default) { this.cToken = cToken; writes = new List <Task>(); queue = new TransferQueueV2 <string>(); thread = new Thread(CheckLogs) { Priority = ThreadPriority.Lowest, IsBackground = true }; thread.Start(); }
private async Task <Response> TakeAsync(ITransferQueue <JObject> selectedQ, Request request, CancellationToken ct = default) { if (selectedQ == null) { return(FormatResponse(request.Payload, status: (int)HttpStatusCode.BadRequest)); } JObject payload = await selectedQ.TakeAsync(timeout : Convert.ToInt32(request.Headers["timeout"]), cToken : ct); bool failure = payload == null; if (failure) { payload = request.Payload; } return(FormatResponse(payload, failure ? (int)HttpStatusCode.RequestTimeout : (int)HttpStatusCode.OK)); }