本文整理汇总了C#中LanguageExt.ProcessId类的典型用法代码示例。如果您正苦于以下问题:C# ProcessId类的具体用法?C# ProcessId怎么用?C# ProcessId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProcessId类属于LanguageExt命名空间,在下文中一共展示了ProcessId类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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}");
}
示例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;
}
示例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;
}
示例4: ActorRequest
public ActorRequest(object message, ProcessId to, ProcessId replyTo, long requestId)
{
Message = message;
To = to;
ReplyTo = replyTo;
RequestId = requestId;
}
示例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);
};
}
示例6: AskActorReq
public AskActorReq(object msg, Subject<object> subject, ProcessId to, ProcessId replyTo)
{
Message = msg;
Subject = subject;
To = to;
ReplyTo = replyTo;
}
示例7: SystemChildFaultedMessage
public SystemChildFaultedMessage(ProcessId child, ProcessId sender, Exception exception, object message)
{
Child = child;
Sender = sender;
Exception = exception;
Message = message;
}
示例8: ActorResponse
public ActorResponse(ProcessId replyTo, object message, ProcessId replyFrom, long requestId)
{
Message = message;
ReplyTo = replyTo;
ReplyFrom = replyFrom;
RequestId = requestId;
}
示例9: SpawnResolver
void SpawnResolver()
{
resolver = spawn<Map<ProcessId, BallState>, Tuple<ProcessId, BallState>>(
"resolver",
() => Map<ProcessId, BallState>(),
Resolver.Inbox
);
}
示例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);
}
示例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));
示例12: shutdown
/// <summary>
/// Shutdown the process log
/// </summary>
public static Unit shutdown()
{
if (processId.IsValid)
{
kill(processId);
processId = ProcessId.None;
}
return unit;
}
示例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;
}
示例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;
}
示例15: RemoveFromStore
public static Unit RemoveFromStore(ProcessId id)
{
lock (storeLock)
{
var path = id.Value;
if (Store.ContainsKey(path))
{
Store = Store.Remove(path);
}
}
return unit;
}