void SetupRemoteSubscriptions(Option <ICluster> cluster, ProcessFlags flags) { if (remoteSubsAcquired) { return; } cluster.IfSome(c => { // Watches for local state-changes and persists them if ((flags & ProcessFlags.PersistState) == ProcessFlags.PersistState) { try { stateSubject.Subscribe(state => c.SetValue(StateKey, state)); } catch (Exception e) { logSysErr(e); } } // Watches for local state-changes and publishes them remotely if ((flags & ProcessFlags.RemoteStatePublish) == ProcessFlags.RemoteStatePublish) { try { stateSubject.Subscribe(state => c.PublishToChannel(ActorInboxCommon.ClusterStatePubSubKey(Id), state)); } catch (Exception e) { logSysErr(e); } } // Watches for publish events and remotely publishes them if ((flags & ProcessFlags.RemotePublish) == ProcessFlags.RemotePublish) { try { publishSubject.Subscribe(msg => c.PublishToChannel(ActorInboxCommon.ClusterPubSubKey(Id), msg)); } catch (Exception e) { logSysErr(e); } } }); remoteSubsAcquired = true; }
public IObservable <T> Observe <T>() => Cluster.SubscribeToChannel <T>(ActorInboxCommon.ClusterPubSubKey(ProcessId));
public Unit Publish(object message) => transactionalIO ? ignore(Cluster.PublishToChannel(ActorInboxCommon.ClusterPubSubKey(ProcessId), message)) : ProcessOp.IO(() => Cluster.PublishToChannel(ActorInboxCommon.ClusterPubSubKey(ProcessId), message));