本文整理汇总了C#中LanguageExt.ProcessId类的典型用法代码示例。如果您正苦于以下问题:C# ProcessId类的具体用法?C# ProcessId怎么用?C# ProcessId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProcessId类属于LanguageExt命名空间,在下文中一共展示了ProcessId类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: DeserialiseMsg
public static Message DeserialiseMsg(RemoteMessageDTO msg, ProcessId actorId)
{
var sender = String.IsNullOrEmpty(msg.Sender) ? ProcessId.NoSender : new ProcessId(msg.Sender);
var replyTo = String.IsNullOrEmpty(msg.ReplyTo) ? ProcessId.NoSender : new ProcessId(msg.ReplyTo);
switch ((Message.TagSpec)msg.Tag)
{
case Message.TagSpec.UserReply:
var content = DeserialiseMsgContent(msg);
return new ActorResponse(content, content.GetType().AssemblyQualifiedName, actorId, sender, msg.RequestId, msg.Exception == "RESPERR");
case Message.TagSpec.UserAsk: return new ActorRequest(DeserialiseMsgContent(msg), actorId, replyTo, msg.RequestId);
case Message.TagSpec.User: return new UserMessage(DeserialiseMsgContent(msg), sender, replyTo);
case Message.TagSpec.UserTerminated: return (TerminatedMessage)DeserialiseMsgContent(msg);
case Message.TagSpec.GetChildren: return UserControlMessage.GetChildren;
case Message.TagSpec.StartupProcess: return SystemMessage.StartupProcess;
case Message.TagSpec.ShutdownProcess: return (ShutdownProcessMessage)DeserialiseMsgContent(msg);
case Message.TagSpec.Restart: return SystemMessage.Restart;
case Message.TagSpec.Pause: return SystemMessage.Pause;
case Message.TagSpec.Unpause: return SystemMessage.Unpause;
case Message.TagSpec.DispatchWatch: return (SystemDispatchWatchMessage)DeserialiseMsgContent(msg);
case Message.TagSpec.DispatchUnWatch: return (SystemDispatchUnWatchMessage)DeserialiseMsgContent(msg);
case Message.TagSpec.Watch: return (SystemAddWatcherMessage)DeserialiseMsgContent(msg);
case Message.TagSpec.UnWatch: return (SystemRemoveWatcherMessage)DeserialiseMsgContent(msg);
}
throw new Exception($"Unknown Message Tag: {msg.Tag}");
}
开发者ID:plouh,项目名称:language-ext,代码行数:31,代码来源:MessageSerialiser.cs
示例2: Inbox
public static ProcessId Inbox(ProcessId hub, RelayMsg msg)
{
try
{
switch (msg.Tag)
{
case RelayMsg.MsgTag.Connected:
SpawnConnection(msg, hub);
break;
case RelayMsg.MsgTag.Disconnected:
kill(Self[msg.ConnectionId]);
break;
case RelayMsg.MsgTag.Inbound:
case RelayMsg.MsgTag.Subscribe:
case RelayMsg.MsgTag.Unsubscribe:
fwd(SpawnConnection(msg, hub), msg);
break;
}
}
catch (Exception e)
{
tell(Errors, e);
}
return hub;
}
开发者ID:plouh,项目名称:language-ext,代码行数:27,代码来源:RelayActor.cs
示例3: StrategyContext
StrategyContext(
StrategyState global,
Exception exception,
object message,
ProcessId sender,
ProcessId failedProcess,
ProcessId parentProcess,
IEnumerable<ProcessId> siblings,
IEnumerable<ProcessId> affects,
Time pause,
Option<Directive> directive,
Option<MessageDirective> messageDirective
)
{
bool isStop = directive == LanguageExt.Directive.Stop;
Global = isStop ? StrategyState.Empty : global;
Exception = exception;
Message = message;
Sender = sender;
Self = failedProcess;
ParentProcess = parentProcess;
Siblings = siblings ?? Siblings;
Affects = affects ?? Affects;
Pause = isStop ? 0 * s : pause;
Directive = directive;
MessageDirective = messageDirective;
}
开发者ID:OlduwanSteve,项目名称:language-ext,代码行数:28,代码来源:StrategyContext.cs
示例4: ActorRequest
public ActorRequest(object message, ProcessId to, ProcessId replyTo, long requestId)
{
Message = message;
To = to;
ReplyTo = replyTo;
RequestId = requestId;
}
开发者ID:plouh,项目名称:language-ext,代码行数:7,代码来源:ActorRequestResponse.cs
示例5: Failure
/// <summary>
/// Creates a new State computation that is primed with the data of a particular
/// failure event.
/// </summary>
/// <param name="strategy">Strategy as a State computation</param>
/// <param name="pid">Process ID that failed</param>
/// <param name="sender">Process that sent the message that cause the failure</param>
/// <param name="parent">Supervisor of the failed Process</param>
/// <param name="siblings">The siblings of the failed Process</param>
/// <param name="ex">Exception</param>
/// <param name="msg">Message that caused the failure</param>
/// <returns>State computation that can be invoked by passing it
/// an object of StrategyState. This will result in a StateResult that contains
/// the mutated StrategyState and a StrategyDecision. The StrategyDecision
/// contains all the information needed to decide the fate of a Process (and
/// related processes)</returns>
public static State<StrategyState, StrategyDecision> Failure(
this State<StrategyContext, Unit> strategy,
ProcessId pid,
ProcessId sender,
ProcessId parent,
IEnumerable<ProcessId> siblings,
Exception ex,
object msg
)
{
return stateInst =>
{
var now = DateTime.UtcNow;
var state = strategy(StrategyContext.Empty.With(
Global: stateInst.With(Failures: stateInst.Failures + 1),
FailedProcess: pid,
ParentProcess: parent,
Sender: sender,
Siblings: siblings,
Exception: ex,
Message: msg)).State;
var decision = new StrategyDecision(
state.Directive.IfNone(Directive.Restart),
state.MessageDirective.IfNone(MessageDirective.ForwardToDeadLetters),
state.Affects,
state.Pause
);
return StateResult.Return(state.Global.With(LastFailure: now), decision);
};
}
开发者ID:cartermp,项目名称:language-ext,代码行数:49,代码来源:StrategyEvent.cs
示例6: AskActorReq
public AskActorReq(object msg, Subject<object> subject, ProcessId to, ProcessId replyTo)
{
Message = msg;
Subject = subject;
To = to;
ReplyTo = replyTo;
}
开发者ID:ricardopieper,项目名称:language-ext,代码行数:7,代码来源:AskActor.cs
示例7: SystemChildFaultedMessage
public SystemChildFaultedMessage(ProcessId child, ProcessId sender, Exception exception, object message)
{
Child = child;
Sender = sender;
Exception = exception;
Message = message;
}
开发者ID:jy2k00mk1,项目名称:language-ext,代码行数:7,代码来源:SystemMessage.cs
示例8: ActorResponse
public ActorResponse(ProcessId replyTo, object message, ProcessId replyFrom, long requestId)
{
Message = message;
ReplyTo = replyTo;
ReplyFrom = replyFrom;
RequestId = requestId;
}
开发者ID:ricardopieper,项目名称:language-ext,代码行数:7,代码来源:ActorRequestResponse.cs
示例9: SpawnResolver
void SpawnResolver()
{
resolver = spawn<Map<ProcessId, BallState>, Tuple<ProcessId, BallState>>(
"resolver",
() => Map<ProcessId, BallState>(),
Resolver.Inbox
);
}
开发者ID:OlduwanSteve,项目名称:language-ext,代码行数:8,代码来源:MainWindow.xaml.cs
示例10: DeadLetter
private DeadLetter(ProcessId sender, ProcessId recipient, Exception ex, string reason, object message)
{
Sender = sender;
Recipient = recipient;
Exception = Optional(ex);
Reason = Optional(reason);
Message = Optional(message);
}
开发者ID:JamesTryand,项目名称:language-ext,代码行数:8,代码来源:DeadLetter.cs
示例11: Create
internal static RemoteMessageDTO Create(object message, ProcessId to, ProcessId sender, Message.Type type, Message.TagSpec tag, Option<SessionId> sessionId) =>
map(message as ActorRequest, req =>
req == null
? map(message as ActorResponse, res =>
res == null
? CreateMessage(message, to, sender, type, tag, sessionId)
: CreateResponse(res, to, sender, sessionId))
: CreateRequest(req, to, sender, sessionId));
开发者ID:OlduwanSteve,项目名称:language-ext,代码行数:8,代码来源:UserControlMessage.cs
示例12: shutdown
/// <summary>
/// Shutdown the process log
/// </summary>
public static Unit shutdown()
{
if (processId.IsValid)
{
kill(processId);
processId = ProcessId.None;
}
return unit;
}
开发者ID:jzabroski,项目名称:language-ext,代码行数:12,代码来源:ProcessLog.cs
示例13: ActorResponse
public ActorResponse(object message, string responseMessageType, ProcessId replyTo, ProcessId replyFrom, long requestId, bool isFaulted = false)
{
Message = message;
ResponseMessageType = responseMessageType;
ReplyTo = replyTo;
ReplyFrom = replyFrom;
RequestId = requestId;
IsFaulted = isFaulted;
}
开发者ID:plouh,项目名称:language-ext,代码行数:9,代码来源:ActorRequestResponse.cs
示例14: ConnectionInbox
public static ProcessId ConnectionInbox(ProcessId hub, RelayMsg rmsg)
{
switch (rmsg.Tag)
{
case RelayMsg.MsgTag.Inbound:
var inmsg = rmsg as InboundRelayMsg;
if (rmsg.IsAsk)
{
// Ask not supported
tell(Errors, "'ask' not supported from JS to server.");
}
else
{
tell(rmsg.To, inmsg.Message, rmsg.Sender.IsValid ? Self.Append(rmsg.Sender) : ProcessId.NoSender);
}
break;
case RelayMsg.MsgTag.Outbound:
fwd(hub, rmsg);
break;
case RelayMsg.MsgTag.Subscribe:
var pid = rmsg.To;
var subscriber = rmsg.Sender;
var connectionId = rmsg.ConnectionId;
ActorContext.SelfProcess.Actor.AddSubscription(
rmsg.To,
ActorContext.Observe<object>(pid).Subscribe(x =>
tell(hub,
new OutboundRelayMsg(
connectionId,
new RemoteMessageDTO {
MessageId = Guid.NewGuid(),
Content = JsonConvert.SerializeObject(x),
Sender = pid.Path,
To = subscriber.Path,
ContentType = x.GetType().AssemblyQualifiedName,
ReplyTo = pid.Path,
Tag = (int)Message.TagSpec.User,
Type = (int)Message.Type.User
},
subscriber,
pid,
false),
pid)));
break;
case RelayMsg.MsgTag.Unsubscribe:
ActorContext.SelfProcess.Actor.RemoveSubscription(rmsg.To);
break;
}
return hub;
}
开发者ID:plouh,项目名称:language-ext,代码行数:54,代码来源:RelayActor.cs
示例15: RemoveFromStore
public static Unit RemoveFromStore(ProcessId id)
{
lock (storeLock)
{
var path = id.Value;
if (Store.ContainsKey(path))
{
Store = Store.Remove(path);
}
}
return unit;
}
开发者ID:antonioj-mattos,项目名称:language-ext,代码行数:12,代码来源:ActorContext.cs
示例16: WatchWorkers
internal static ProcessId WatchWorkers(ProcessId router, IEnumerable<ProcessId> workers, RouterOption option)
{
if ((option & RouterOption.RemoveLocalWorkerWhenTerminated) == RouterOption.RemoveLocalWorkerWhenTerminated)
{
workers.Where(w => ActorContext.IsLocal(w)).Iter(w => watch(router, w));
}
if ((option & RouterOption.RemoveRemoteWorkerWhenTerminated) == RouterOption.RemoveRemoteWorkerWhenTerminated)
{
workers.Where(w => !ActorContext.IsLocal(w)).Iter(w => watch(router, w));
}
return router;
}
开发者ID:jy2k00mk1,项目名称:language-ext,代码行数:12,代码来源:Router.cs
示例17: AddToStore
public static Unit AddToStore(ProcessId id, IProcess process)
{
lock (storeLock)
{
var path = id.Value;
if (Store.ContainsKey(path))
{
Store[path].Dispose();
Store = Store.Remove(path);
}
Store = Store.Add(path, process);
}
return unit;
}
开发者ID:antonioj-mattos,项目名称:language-ext,代码行数:14,代码来源:ActorContext.cs
示例18: CreateRequest
internal static RemoteMessageDTO CreateRequest(ActorRequest req, ProcessId to, ProcessId sender) =>
new RemoteMessageDTO()
{
Type = (int)Message.Type.User,
Tag = (int)Message.TagSpec.UserAsk,
Child = null,
Exception = null,
To = to.Path,
RequestId = req.RequestId,
MessageId = Guid.NewGuid(),
Sender = sender.ToString(),
ReplyTo = req.ReplyTo.ToString(),
ContentType = req.Message.GetType().AssemblyQualifiedName,
Content = JsonConvert.SerializeObject(req.Message, ActorConfig.Default.JsonSerializerSettings)
};
开发者ID:JamesTryand,项目名称:language-ext,代码行数:15,代码来源:UserControlMessage.cs
示例19: ActorRequestContext
public ActorRequestContext(
ActorItem self,
ProcessId sender,
ActorItem parent,
object currentMsg,
ActorRequest currentRequest,
ProcessFlags processFlags
)
{
Self = self;
Sender = sender;
Parent = parent;
CurrentMsg = currentMsg;
CurrentRequest = currentRequest;
ProcessFlags = processFlags;
}
开发者ID:cihanozhan,项目名称:language-ext,代码行数:16,代码来源:ActorRequestContext.cs
示例20: CreateMessage
internal static RemoteMessageDTO CreateMessage(object message, ProcessId to, ProcessId sender, Message.Type type, Message.TagSpec tag) =>
new RemoteMessageDTO
{
Type = (int)type,
Tag = (int)tag,
To = to.Path,
RequestId = -1,
MessageId = Guid.NewGuid(),
Sender = sender.ToString(),
ReplyTo = sender.ToString(),
ContentType = message == null
? null
: message.GetType().AssemblyQualifiedName,
Content = message == null
? null
: JsonConvert.SerializeObject(message, ActorSystemConfig.Default.JsonSerializerSettings)
};
开发者ID:plouh,项目名称:language-ext,代码行数:17,代码来源:UserControlMessage.cs
注:本文中的LanguageExt.ProcessId类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论