コード例 #1
0
        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)));
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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>());
            }
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 public override Task <IHttpResponse> SendAsync(IHttpRequest httpRequest)
 {
     return(InvocationMessage.CreateAsync(httpRequest, executionLimit: executionLimit));
 }
コード例 #6
0
 public Task <CloudQueueMessage> SendToQueueAsync(AzureApplication application)
 {
     return(InvocationMessage.SendToQueueAsync(this.invocationRef, application));
 }
コード例 #7
0
 public override Task <HttpResponseMessage> SendAsync(HttpRequestMessage httpRequest)
 {
     return(InvocationMessage.CreateAsync(httpRequest));
 }