|
|
@ -30,6 +30,7 @@ |
|
|
|
#endregion |
|
|
|
#endregion |
|
|
|
using System; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Collections.Generic; |
|
|
|
|
|
|
|
using System.Collections.Immutable; |
|
|
|
using System.Runtime.InteropServices; |
|
|
|
using System.Runtime.InteropServices; |
|
|
|
using System.Threading; |
|
|
|
using System.Threading; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using System.Threading.Tasks; |
|
|
@ -37,33 +38,18 @@ using Grpc.Core.Internal; |
|
|
|
|
|
|
|
|
|
|
|
namespace Grpc.Core |
|
|
|
namespace Grpc.Core |
|
|
|
{ |
|
|
|
{ |
|
|
|
// TODO: should we be using the builder pattern? |
|
|
|
/// <summary> |
|
|
|
|
|
|
|
/// gRPC channel options. |
|
|
|
|
|
|
|
/// </summary> |
|
|
|
public class ChannelArgs |
|
|
|
public class ChannelArgs |
|
|
|
{ |
|
|
|
{ |
|
|
|
public const string SslTargetNameOverrideKey = "grpc.ssl_target_name_override"; |
|
|
|
public const string SslTargetNameOverrideKey = "grpc.ssl_target_name_override"; |
|
|
|
|
|
|
|
|
|
|
|
public class Builder |
|
|
|
readonly ImmutableDictionary<string, string> stringArgs; |
|
|
|
{ |
|
|
|
|
|
|
|
Dictionary<string, string> stringArgs = new Dictionary<string, string>(); |
|
|
|
|
|
|
|
// TODO: AddInteger not supported yet. |
|
|
|
|
|
|
|
public Builder AddString(string key, string value) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
stringArgs.Add(key, value); |
|
|
|
|
|
|
|
return this; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ChannelArgs Build() |
|
|
|
private ChannelArgs(ImmutableDictionary<string, string> stringArgs) |
|
|
|
{ |
|
|
|
|
|
|
|
return new ChannelArgs(stringArgs); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dictionary<string, string> stringArgs; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ChannelArgs(Dictionary<string, string> stringArgs) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
// TODO: use immutable dict? |
|
|
|
this.stringArgs = stringArgs; |
|
|
|
this.stringArgs = new Dictionary<string, string>(stringArgs); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public string GetSslTargetNameOverride() |
|
|
|
public string GetSslTargetNameOverride() |
|
|
@ -76,11 +62,28 @@ namespace Grpc.Core |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static Builder NewBuilder() |
|
|
|
public static Builder CreateBuilder() |
|
|
|
{ |
|
|
|
{ |
|
|
|
return new Builder(); |
|
|
|
return new Builder(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class Builder |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
readonly Dictionary<string, string> stringArgs = new Dictionary<string, string>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: AddInteger not supported yet. |
|
|
|
|
|
|
|
public Builder AddString(string key, string value) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
stringArgs.Add(key, value); |
|
|
|
|
|
|
|
return this; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ChannelArgs Build() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return new ChannelArgs(stringArgs.ToImmutableDictionary()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// Creates native object for the channel arguments. |
|
|
|
/// Creates native object for the channel arguments. |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
|