Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update fields structure in protobuf file for RetryOptions and ConfigSource #8027

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/WebJobs.Script.Grpc/Channel/GrpcWorkerChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,15 @@ internal void ProcessFunctionMetadataResponses(FunctionMetadataResponses functio
{
Metadata = functionMetadata,
Bindings = bindings,
RetryOptions = metadata.RetryOptions,
ConfigurationSource = metadata.ConfigSource
RetryOptions = new Description.RetryOptions()
{
Strategy = metadata.RetryOptions == null ? Description.RetryStrategy.ExponentialBackoff : (Description.RetryStrategy)Enum.Parse(typeof(Description.RetryStrategy), metadata.RetryOptions.Strategy.ToString(), true),
MaxRetryCount = metadata.RetryOptions?.MaxRetryCount,
DelayInterval = metadata.RetryOptions?.DelayInterval.ToTimeSpan(),
MaximumInterval = metadata.RetryOptions?.MaximumInterval.ToTimeSpan(),
MinimumInterval = metadata.RetryOptions?.MinimumInterval.ToTimeSpan()
},
ConfigurationSource = (Description.ConfigurationSource)Enum.Parse(typeof(Description.ConfigurationSource), metadata.ConfigSource.ToString(), true),
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,11 @@ message RpcFunctionMetadata {
// Raw binding info
repeated string raw_bindings = 10;

// Retry Options: string representation of JObject retry options (maxRetryCount, intervals, etc.)
string retry_options = 11;
// Retry Options
RetryOptions retry_options = 11;

// Configuration Source: string representation of JToken configuration source property in function metadata
string config_source = 12;
// Configuration Source
ConfigurationSource config_source = 12;
}

// Host tells worker it is ready to receive metadata
Expand Down Expand Up @@ -341,6 +341,42 @@ message RetryContext {
RpcException exception = 3;
}

// Host retry options
message RetryOptions {
// Retry strategy
RetryStrategy strategy = 1;

// Maximum retry count
int32 maxRetryCount = 2 ;

// Delay interval
google.protobuf.Duration delayInterval = 3;

// Minimum interval
google.protobuf.Duration minimumInterval = 4;

// Maximum interval
google.protobuf.Duration maximumInterval = 5;
}

// Host retry strategy
enum RetryStrategy {
// Exponential Backoff
ExponentialBackoff = 0;

// Fixed Delay
FixedDelay = 1;
}

// Host configuration source
enum ConfigurationSource {
// configuration source is Attributes
Attributes = 0;

// configuration source is config
Config = 1;
}

// Host requests worker to cancel invocation
message InvocationCancel {
// Unique id for invocation
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;

namespace Microsoft.Azure.WebJobs.Script.Description
{
public enum ConfigurationSource
{
Attributes = 0,
Config = 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License. See License.txt in the project root for license information.

using System.Collections.Generic;
using Azure.Core;
using Newtonsoft.Json.Linq;

namespace Microsoft.Azure.WebJobs.Script.Description
Expand All @@ -12,8 +13,8 @@ public class RawFunctionMetadata

public IEnumerable<string> Bindings { get; set; }

public string RetryOptions { get; set; }
public RetryOptions RetryOptions { get; set; }

public string ConfigurationSource { get; set; }
public ConfigurationSource ConfigurationSource { get; set; }
}
}
12 changes: 4 additions & 8 deletions src/WebJobs.Script/Host/WorkerFunctionMetadataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,9 @@ internal IEnumerable<FunctionMetadata> ValidateMetadata(IEnumerable<RawFunctionM
// skip function ScriptFile validation for now because this involves enumerating file directory

// configuration source validation
if (!string.IsNullOrEmpty(rawFunction.ConfigurationSource))
if (!string.IsNullOrEmpty(rawFunction.ConfigurationSource.ToString()))
{
JToken isDirect = JToken.Parse(rawFunction.ConfigurationSource);
var isDirectValue = isDirect?.ToString();
var isDirectValue = rawFunction.ConfigurationSource.ToString();
if (string.Equals(isDirectValue, "attributes", StringComparison.OrdinalIgnoreCase))
{
function.SetIsDirect(true);
Expand All @@ -96,11 +95,8 @@ internal IEnumerable<FunctionMetadata> ValidateMetadata(IEnumerable<RawFunctionM
}

// retry option validation
if (!string.IsNullOrEmpty(rawFunction.RetryOptions))
{
function.Retry = JObject.Parse(rawFunction.RetryOptions).ToObject<RetryOptions>();
Utility.ValidateRetryOptions(function.Retry);
}
function.Retry = rawFunction.RetryOptions;
Utility.ValidateRetryOptions(function.Retry);

// binding validation
function = ValidateBindings(rawFunction.Bindings, function);
Expand Down