public static async Task <int> put__messages_durable(HttpRequest request, ILocalWorkerSender workers, IMessageLogger logger, IMessagingRoot root) { if (root.ListeningStatus == ListeningStatus.TooBusy) { return(503); } try { // TODO -- optimize the reading here to reduce allocations var bytes = await request.Body.ReadBytesAsync(request.ContentLength); var envelopes = Envelope.ReadMany(bytes); await workers.EnqueueDurably(envelopes); return(200); } catch (Exception e) { var message = $"Error receiving envelopes from {request.Headers["x-jasper-envelope-sender"]}"; logger.LogException(e, message: message); return(500); } }
public async Task <int> put__messages(HttpRequest request, ILocalWorkerSender workers, CompositeMessageLogger logger) { try { // TODO -- optimize the reading here to reduce allocations var bytes = await request.Body.ReadBytesAsync(request.ContentLength); var envelopes = Envelope.ReadMany(bytes); await workers.EnqueueLightweight(envelopes); return(200); } catch (Exception e) { var message = $"Error receiving envelopes from {request.Headers["x-jasper-envelope-sender"]}"; logger.LogException(e, message: message); return(500); } }