public static async Task <InvocationMessage> SendAsync(this InvocationMessage invocationMessage) { var byteContent = invocationMessage.invocationRef.id.ToByteArray(); return(await EastFive.Web.Configuration.Settings.GetString( AppSettings.FunctionProcessorServiceBusTriggerName, async (serviceBusTriggerName) => { await AzureApplication.SendServiceBusMessageStaticAsync(serviceBusTriggerName, byteContent.AsEnumerable()); return invocationMessage; }, (why) => throw new Exception(why))); }
public static async Task <InvocationMessage> SendToFunctionsAsync(this InvocationMessage invocationMessage, string serviceBusTriggerNameOverride = default) { var invocationMessageRef = invocationMessage.invocationRef; var byteContent = invocationMessageRef.id.ToByteArray(); var serviceBusTriggerName = serviceBusTriggerNameOverride.HasBlackSpace() ? serviceBusTriggerNameOverride : AppSettings.FunctionProcessorServiceBusTriggerName.ConfigurationString(value => value, (why) => throw new Exception(why)); await AzureApplication.SendServiceBusMessageStaticAsync(serviceBusTriggerName, byteContent.AsEnumerable()); return(invocationMessage); }
public static async Task <InvocationMessage> InvocationMessageAsync(this IHttpRequest request, int executionLimit = 1) { var invocationMessageRef = Ref <InvocationMessage> .SecureRef(); var referrer = request.TryGetReferer(out Uri refererTmp) ? refererTmp : new Uri(System.Web.HttpUtility.UrlDecode(refererTmp.OriginalString)); var content = await request.ReadContentAsync(); var invocationMessage = new InvocationMessage { invocationRef = invocationMessageRef, headers = request.Headers .Select(hdr => hdr.Key.PairWithValue(hdr.Value.First())) .ToDictionary(), requestUri = new Uri(System.Web.HttpUtility.UrlDecode(request.RequestUri.OriginalString)), referrer = referrer, content = content, invocationMessageSource = GetInvocationMessageSource(), method = request.Method.Method, executionHistory = new KeyValuePair <DateTime, int>[] { }, executionLimit = executionLimit, }; return(invocationMessage); IRefOptional <InvocationMessage> GetInvocationMessageSource() { if (!request.TryGetHeader(InvocationMessage.InvocationMessageSourceHeaderKey, out string invocationMessageSourceStr)) { return(RefOptional <InvocationMessage> .Empty()); } if (!Guid.TryParse(invocationMessageSourceStr, out Guid invocationMessageSource)) { return(RefOptional <InvocationMessage> .Empty()); } return(invocationMessageSource.AsRefOptional <InvocationMessage>()); } }
public static async Task <InvocationMessage> InvocationMessageAsync(this HttpRequestMessage request) { var invocationMessageRef = Ref <InvocationMessage> .SecureRef(); var invocationMessage = new InvocationMessage { invocationRef = invocationMessageRef, headers = request.Headers .Select(hdr => hdr.Key.PairWithValue(hdr.Value.First())) .ToDictionary(), requestUri = request.RequestUri, content = request.Content.IsDefaultOrNull() ? default(byte[]) : await request.Content.ReadAsByteArrayAsync(), method = request.Method.Method, }; return(invocationMessage); }
public override Task <IHttpResponse> SendAsync(IHttpRequest httpRequest) { return(InvocationMessage.CreateAsync(httpRequest, executionLimit: executionLimit)); }
public Task <CloudQueueMessage> SendToQueueAsync(AzureApplication application) { return(InvocationMessage.SendToQueueAsync(this.invocationRef, application)); }
public override Task <HttpResponseMessage> SendAsync(HttpRequestMessage httpRequest) { return(InvocationMessage.CreateAsync(httpRequest)); }