本文整理汇总了C#中Akka.Configuration.Config.HasPath方法的典型用法代码示例。如果您正苦于以下问题:C# Config.HasPath方法的具体用法?C# Config.HasPath怎么用?C# Config.HasPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Akka.Configuration.Config
的用法示例。
在下文中一共展示了Config.HasPath方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SessionSettings
public SessionSettings(Config config)
{
if (config == null) throw new ArgumentNullException("config");
Builder = Cluster.Builder();
// Get IP and port configuration
int port = config.GetInt("port", 9042);
IPEndPoint[] contactPoints = ParseContactPoints(config.GetStringList("contact-points"), port);
Builder.AddContactPoints(contactPoints);
// Support user/pass authentication
if (config.HasPath("credentials"))
Builder.WithCredentials(config.GetString("credentials.username"), config.GetString("credentials.password"));
// Support SSL
if (config.GetBoolean("ssl"))
Builder.WithSSL();
// Support compression
string compressionTypeConfig = config.GetString("compression");
if (compressionTypeConfig != null)
{
var compressionType = (CompressionType) Enum.Parse(typeof (CompressionType), compressionTypeConfig, true);
Builder.WithCompression(compressionType);
}
}
示例2: BroadcastPool
/// <summary>
/// Initializes a new instance of the <see cref="BroadcastPool"/> class.
/// </summary>
/// <param name="config">The configuration used to configure the pool.</param>
public BroadcastPool(Config config)
: this(
nrOfInstances: config.GetInt("nr-of-instances"),
resizer: Resizer.FromConfig(config),
supervisorStrategy: Pool.DefaultSupervisorStrategy,
routerDispatcher: Dispatchers.DefaultDispatcherId,
usePoolDispatcher: config.HasPath("pool-dispatcher"))
{
}
示例3: ConfiguratorFrom
private MessageDispatcherConfigurator ConfiguratorFrom(Config cfg)
{
if (!cfg.HasPath("id")) throw new ConfigurationException($"Missing dispatcher `id` property in config: {cfg.Root}");
var id = cfg.GetString("id");
var type = cfg.GetString("type");
MessageDispatcherConfigurator dispatcher;
/*
* Fallbacks are added here in order to preserve backwards compatibility with versions of AKka.NET prior to 1.1,
* before the ExecutorService system was implemented
*/
switch (type)
{
case "Dispatcher":
dispatcher = new DispatcherConfigurator(cfg, Prerequisites);
break;
case "TaskDispatcher":
dispatcher = new DispatcherConfigurator(TaskExecutorConfig.WithFallback(cfg), Prerequisites);
break;
case "PinnedDispatcher":
dispatcher = new PinnedDispatcherConfigurator(cfg, Prerequisites);
break;
case "ForkJoinDispatcher":
dispatcher = new DispatcherConfigurator(ForkJoinExecutorConfig.WithFallback(cfg), Prerequisites);
break;
case "SynchronizedDispatcher":
dispatcher = new CurrentSynchronizationContextDispatcherConfigurator(cfg, Prerequisites);
break;
case null:
throw new ConfigurationException($"Could not resolve dispatcher for path {id}. type is null");
default:
Type dispatcherType = Type.GetType(type);
if (dispatcherType == null)
{
throw new ConfigurationException($"Could not resolve dispatcher type {type} for path {id}");
}
dispatcher = (MessageDispatcherConfigurator)Activator.CreateInstance(dispatcherType, cfg, Prerequisites);
break;
}
return dispatcher;
}
示例4: ConsistentHashingPool
/// <summary>
/// Initializes a new instance of the <see cref="ConsistentHashingPool"/> class.
///
/// <note>
/// 'virtual-nodes-factor' defaults to 0 (zero) if it is not defined in the provided configuration.
/// </note>
/// </summary>
/// <param name="config">The configuration used to configure the pool.</param>
public ConsistentHashingPool(Config config)
: this(
nrOfInstances: config.GetInt("nr-of-instances"),
resizer: Resizer.FromConfig(config),
supervisorStrategy: Pool.DefaultSupervisorStrategy,
routerDispatcher: Dispatchers.DefaultDispatcherId,
usePoolDispatcher: config.HasPath("pool-dispatcher"))
{
VirtualNodesFactor = config.GetInt("virtual-nodes-factor");
}
示例5: TailChoppingPool
/// <summary>
/// Initializes a new instance of the <see cref="TailChoppingPool"/> class.
/// <note>
/// 'nr-of-instances', 'within', and 'tail-chopping-router.interval'
/// must be defined in the provided configuration.
/// </note>
/// </summary>
/// <param name="config">The configuration used to configure the pool.</param>
public TailChoppingPool(Config config)
: this(
config.GetInt("nr-of-instances"),
Resizer.FromConfig(config),
Pool.DefaultSupervisorStrategy,
Dispatchers.DefaultDispatcherId,
config.GetTimeSpan("within"), config.GetTimeSpan("tail-chopping-router.interval"), config.HasPath("pool-dispatcher"))
{
}
示例6: TailChoppingPool
/// <summary>
/// Creates an instance of the TailChoppingPool.
/// </summary>
/// <param name="config">The configuration to use with this instance.</param>
public TailChoppingPool(Config config)
: this(config.GetInt("nr-of-instances"),
DefaultResizer.FromConfig(config),
null,
null, //TODO: what are our defaults? null?
config.GetTimeSpan("within"),
config.GetTimeSpan("tail-chopping-router.interval"),
config.HasPath("pool-dispatcher")
)
{
}
示例7: ScatterGatherFirstCompletedPool
/// <summary>
/// Initializes a new instance of the <see cref="ScatterGatherFirstCompletedPool"/> class.
/// </summary>
/// <param name="config">
/// The configuration to use to lookup paths used by the group router.
///
/// <note>
/// 'within' must be defined in the provided configuration.
/// </note>
/// </param>
public ScatterGatherFirstCompletedPool(Config config)
: this(
nrOfInstances: config.GetInt("nr-of-instances"),
resizer: Resizer.FromConfig(config),
within: config.GetTimeSpan("within"),
supervisorStrategy: Pool.DefaultSupervisorStrategy,
routerDispatcher: Dispatchers.DefaultDispatcherId,
usePoolDispatcher: config.HasPath("pool-dispatcher"))
{
}
示例8: TailChoppingPool
/// <summary>
/// Creates an instance of the TailChoppingPool.
/// </summary>
/// <param name="config">The configuration to use with this instance.</param>
public TailChoppingPool(Config config)
{
NrOfInstances = config.GetInt("nr-of-instances");
within = config.GetTimeSpan("within");
interval = config.GetTimeSpan("tail-chopping-router.interval");
Resizer = DefaultResizer.FromConfig(config);
UsePoolDispatcher = config.HasPath("pool-dispatcher");
}
示例9: GetMailboxType
public Type GetMailboxType(Props props, Config dispatcherConfig)
{
if (!string.IsNullOrEmpty(props.Mailbox))
{
return FromConfig(props.Mailbox);
}
if (dispatcherConfig == null)
dispatcherConfig = ConfigurationFactory.Empty;
var id = dispatcherConfig.GetString("id");
var deploy = props.Deploy;
var actorType = props.Type;
var actorRequirement = new Lazy<Type>(() => GetRequiredType(actorType));
var mailboxRequirement = GetMailboxRequirement(dispatcherConfig);
var hasMailboxRequirement = mailboxRequirement != typeof (IMessageQueue);
var hasMailboxType = dispatcherConfig.HasPath("mailbox-type") &&
dispatcherConfig.GetString("mailbox-type") != Deploy.NoMailboxGiven;
Func<Type, Type> verifyRequirements = mailboxType =>
{
// TODO Akka code after introducing IProducesMessageQueue
// if (hasMailboxRequirement && !mailboxRequirement.isAssignableFrom(mqType))
// throw new IllegalArgumentException(
// s"produced message queue type [$mqType] does not fulfill requirement for dispatcher [$id]. " +
// s"Must be a subclass of [$mailboxRequirement].")
// if (hasRequiredType(actorClass) && !actorRequirement.isAssignableFrom(mqType))
// throw new IllegalArgumentException(
// s"produced message queue type [$mqType] does not fulfill requirement for actor class [$actorClass]. " +
// s"Must be a subclass of [$actorRequirement].")
return mailboxType;
};
if (!deploy.Mailbox.Equals(Deploy.NoMailboxGiven))
return verifyRequirements(FromConfig(deploy.Mailbox));
if (!deploy.Dispatcher.Equals(Deploy.NoDispatcherGiven) && hasMailboxType)
return verifyRequirements(FromConfig(id));
if (actorRequirement.Value != null)
{
try
{
return verifyRequirements(LookupByQueueType(actorRequirement.Value));
}
catch (Exception e)
{
if (hasMailboxRequirement)
return verifyRequirements(LookupByQueueType(mailboxRequirement));
throw;
}
}
if (hasMailboxRequirement)
return verifyRequirements(LookupByQueueType(mailboxRequirement));
return verifyRequirements(_defaultMailboxType);
}
示例10: GetMailboxType
/// <summary></summary>
/// <exception cref="ArgumentException">
/// This exception is thrown if the 'mailbox-requirement' in the given <paramref name="dispatcherConfig"/> isn't met.
/// </exception>
public MailboxType GetMailboxType(Props props, Config dispatcherConfig)
{
if (dispatcherConfig == null)
dispatcherConfig = ConfigurationFactory.Empty;
var id = dispatcherConfig.GetString("id");
var deploy = props.Deploy;
var actorType = props.Type;
var actorRequirement = new Lazy<Type>(() => GetRequiredType(actorType));
var mailboxRequirement = GetMailboxRequirement(dispatcherConfig);
var hasMailboxRequirement = mailboxRequirement != typeof(IMessageQueue);
var hasMailboxType = dispatcherConfig.HasPath("mailbox-type") &&
dispatcherConfig.GetString("mailbox-type") != Deploy.NoMailboxGiven;
if (!hasMailboxType && !_mailboxSizeWarningIssued && dispatcherConfig.HasPath("mailbox-size"))
{
Warn($"Ignoring setting 'mailbox-size for disaptcher [{id}], you need to specify 'mailbox-type=bounded`");
_mailboxSizeWarningIssued = true;
}
Func<MailboxType, MailboxType> verifyRequirements = mailboxType =>
{
Lazy<Type> mqType = new Lazy<Type>(() => GetProducedMessageQueueType(mailboxType));
if (hasMailboxRequirement && !mailboxRequirement.IsAssignableFrom(mqType.Value))
throw new ArgumentException($"produced message queue type [{mqType.Value}] does not fulfill requirement for dispatcher [{id}]." +
$"Must be a subclass of [{mailboxRequirement}]");
if (HasRequiredType(actorType) && !actorRequirement.Value.IsAssignableFrom(mqType.Value))
throw new ArgumentException($"produced message queue type of [{mqType.Value}] does not fulfill requirement for actor class [{actorType}]." +
$"Must be a subclass of [{mailboxRequirement}]");
return mailboxType;
};
if (!deploy.Mailbox.Equals(Deploy.NoMailboxGiven))
return verifyRequirements(Lookup(deploy.Mailbox));
if (!deploy.Dispatcher.Equals(Deploy.NoDispatcherGiven) && hasMailboxType)
return verifyRequirements(Lookup(dispatcherConfig.GetString("id")));
if (actorRequirement.Value != null)
{
try
{
return verifyRequirements(LookupByQueueType(actorRequirement.Value));
}
catch (Exception e)
{
if (hasMailboxRequirement)
return verifyRequirements(LookupByQueueType(mailboxRequirement));
throw;
}
}
if (hasMailboxRequirement)
return verifyRequirements(LookupByQueueType(mailboxRequirement));
return verifyRequirements(Lookup(DefaultMailboxId));
}
示例11: ParseConfig
public override Deploy ParseConfig(string key, Config config)
{
Config config2 = config;
if (config.HasPath("cluster.enabled")
&& config.GetBoolean("cluster.enabled")
&& !config.HasPath("nr-of-instances"))
{
var maxTotalNrOfInstances = config
.WithFallback(Default)
.GetInt("cluster.max-total-nr-of-instances");
config2 = ConfigurationFactory.ParseString("nr-of-instances=" + maxTotalNrOfInstances)
.WithFallback(config);
}
var deploy = base.ParseConfig(key, config2);
if (deploy != null)
{
if (deploy.Config.GetBoolean("cluster.enabled"))
{
if (deploy.Scope != Deploy.NoScopeGiven)
throw new ConfigurationException(string.Format("Cluster deployment can't be combined with scope [{0}]", deploy.Scope));
if (deploy.RouterConfig is RemoteRouterConfig)
throw new ConfigurationException(string.Format("Cluster deployment can't be combined with [{0}]", deploy.Config));
if (deploy.RouterConfig is Pool)
{
return
deploy.WithScope(scope: ClusterScope.Instance)
.WithRouterConfig(new ClusterRouterPool(deploy.RouterConfig as Pool,
ClusterRouterPoolSettings.FromConfig(deploy.Config)));
}
else if (deploy.RouterConfig is Group)
{
return
deploy.WithScope(scope: ClusterScope.Instance)
.WithRouterConfig(new ClusterRouterGroup(deploy.RouterConfig as Group,
ClusterRouterGroupSettings.FromConfig(deploy.Config)));
}
else
{
throw new ArgumentException(string.Format("Cluster-aware router can only wrap Pool or Group, got [{0}]", deploy.RouterConfig.GetType()));
}
}
else
{
return deploy;
}
}
else
{
return null;
}
}