Esempio n. 1
0
 /// <summary>
 /// Partial application map
 /// </summary>
 /// <remarks>TODO: Better documentation of this function</remarks>
 public static Option <Func <T2, Func <T3, R> > > map <T1, T2, T3, R>(Option <T1> option, Func <T1, T2, T3, R> mapper) =>
 option.Map(mapper);
Esempio n. 2
0
 public static Option <R> map <T, R>(Option <T> option, Func <T, R> mapper) =>
 option.Map(mapper);
Esempio n. 3
0
 public static Option <R> map <T, R>(Option <T> option, Func <T, R> Some, Func <R> None) =>
 option.Map(Some, None);
Esempio n. 4
0
 public static Eff <RT, Option <B> > Sequence <RT, A, B>(this Option <A> ta, Func <A, Eff <RT, B> > f) where RT : struct =>
 ta.Map(f).Sequence();
Esempio n. 5
0
 public static HashSet <Option <B> > Sequence <A, B>(this Option <A> ta, Func <A, HashSet <B> > f) =>
 ta.Map(f).Sequence();
Esempio n. 6
0
 public static OptionAsync <Option <B> > Sequence <A, B>(this Option <A> ta, Func <A, OptionAsync <B> > f) =>
 ta.Map(f).Sequence();
Esempio n. 7
0
 public static ProcessName GetRootProcessName() =>
 cluster.Map(x => x.NodeName)
 .IfNone(ActorSystemConfig.Default.RootProcessName);
Esempio n. 8
0
        public ActorSystem(SystemName systemName, Option <ICluster> cluster, AppProfile appProfile, ProcessSystemConfig settings)
        {
            var name = GetRootProcessName(cluster);

            if (name.Value == "root" && cluster.IsSome)
            {
                throw new ArgumentException("Cluster node name cannot be 'root', it's reserved for local use only.");
            }
            if (name.Value == "disp" && cluster.IsSome)
            {
                throw new ArgumentException("Cluster node name cannot be 'disp', it's reserved for internal use.");
            }
            if (name.Value == "js")
            {
                throw new ArgumentException("Node name cannot be 'js', it's reserved for ProcessJS.");
            }

            SystemName       = systemName;
            this.appProfile  = appProfile;
            this.settings    = settings;
            this.cluster     = cluster;
            startupTimestamp = DateTime.UtcNow.Ticks;
            sessionManager   = new SessionManager(cluster, SystemName, appProfile.NodeName, VectorConflictStrategy.Branch);
            watchers         = Map.empty <ProcessId, Set <ProcessId> >();
            watchings        = Map.empty <ProcessId, Set <ProcessId> >();

            startupSubscription = NotifyCluster(cluster, startupTimestamp);

            Dispatch.init();
            Role.init(cluster.Map(r => r.Role).IfNone("local"));
            Reg.init();

            var root      = ProcessId.Top.Child(GetRootProcessName(cluster));
            var rootInbox = new ActorInboxLocal <ActorSystemBootstrap, Unit>();
            var parent    = new ActorItem(new NullProcess(SystemName), new NullInbox(), ProcessFlags.Default);

            var state = new ActorSystemBootstrap(
                this,
                cluster,
                root, null,
                rootInbox,
                cluster.Map(x => x.NodeName).IfNone(ActorSystemConfig.Default.RootProcessName),
                ActorSystemConfig.Default,
                Settings,
                sessionManager.Sync
                );

            var rootProcess = state.RootProcess;

            state.Startup();
            rootItem    = new ActorItem(rootProcess, rootInbox, ProcessFlags.Default);
            userContext = new ActorRequestContext(
                this,
                rootProcess.Children["user"],
                ProcessId.NoSender,
                rootItem,
                null,
                null,
                ProcessFlags.Default,
                null,
                null);
            rootInbox.Startup(rootProcess, parent, cluster, settings.GetProcessMailboxSize(rootProcess.Id));
        }
Esempio n. 9
0
 public static Validation <Fail, Option <B> > Sequence <Fail, A, B>(this Option <A> ta, Func <A, Validation <Fail, B> > f) =>
 ta.Map(f).Sequence();
Esempio n. 10
0
 public static Stck <Option <B> > Sequence <A, B>(this Option <A> ta, Func <A, Stck <B> > f) =>
 ta.Map(f).Traverse(Prelude.identity);
Esempio n. 11
0
        public static Unit Startup(Option <ICluster> cluster, int version = 0)
        {
            if (started)
            {
                return(unit);
            }

            ActorContext.cluster = cluster;
            var name = GetRootProcessName();

            if (name.Value == "root" && cluster.IsSome)
            {
                throw new ArgumentException("Cluster node name cannot be 'root', it's reserved for local use only.");
            }
            if (name.Value == "registered")
            {
                throw new ArgumentException("Node name cannot be 'registered', it's reserved for registered processes.");
            }
            if (name.Value == "js")
            {
                throw new ArgumentException("Node name cannot be 'js', it's reserved for ProcessJS.");
            }

            lock (sync)
            {
                if (started)
                {
                    return(unit);
                }
                var root      = ProcessId.Top.Child(name);
                var rootInbox = new ActorInboxLocal <ActorSystemState, Unit>();
                var parent    = new ActorItem(new NullProcess(), new NullInbox(), ProcessFlags.Default);

                var go          = new AutoResetEvent(false);
                var state       = new ActorSystemState(cluster, root, null, rootInbox, cluster.Map(x => x.NodeName).IfNone(ActorConfig.Default.RootProcessName), ActorConfig.Default);
                var rootProcess = state.RootProcess;
                state.Startup();
                userContext = new ActorRequestContext(rootProcess.Children["user"], ProcessId.NoSender, rootItem, null, null, ProcessFlags.Default);
                rootInbox.Startup(rootProcess, parent, cluster, version);
                rootProcess.Startup();
                rootItem = new ActorItem(rootProcess, rootInbox, ProcessFlags.Default);
                started  = true;
            }
            return(unit);
        }
Esempio n. 12
0
 public static Option <Option <R> > lift <T, R>(Option <Option <T> > m, Func <T, R> f) =>
 m.Map(x => x.Map(f));
Esempio n. 13
0
 public static Aff <RT, Option <B> > Sequence <RT, A, B>(this Option <A> ta, Func <A, Aff <RT, B> > f)
     where RT : struct, HasCancel <RT> =>
 ta.Map(f).Sequence();
 static string GetNodeName(Option <ICluster> cluster) =>
 cluster.Map(c => c.NodeName.Value).IfNone("root");
Esempio n. 15
0
 public static IEnumerable <Option <B> > Sequence <A, B>(this Option <A> ma, Func <A, IEnumerable <B> > f) =>
 ma.Map(f).Sequence();
Esempio n. 16
0
 public static Option <B> map <A, B>(Option <A> option, Func <A, B> f) =>
 option.Map(f);
Esempio n. 17
0
 public static EitherUnsafe <L, Option <B> > Sequence <L, A, B>(this Option <A> ta, Func <A, EitherUnsafe <L, B> > f) =>
 ta.Map(f).Sequence();
Esempio n. 18
0
 public static Validation <MonoidFail, Fail, Option <B> > Sequence <MonoidFail, Fail, A, B>(this Option <A> ta, Func <A, Validation <MonoidFail, Fail, B> > f)
     where MonoidFail : struct, Monoid <Fail>, Eq <Fail> =>
 ta.Map(f).Traverse(Prelude.identity);
Esempio n. 19
0
        public static Unit Startup(Option <ICluster> cluster)
        {
            if (started)
            {
                return(unit);
            }

            ActorContext.cluster = cluster;
            var name = GetRootProcessName();

            if (name.Value == "root" && cluster.IsSome)
            {
                throw new ArgumentException("Cluster node name cannot be 'root', it's reserved for local use only.");
            }
            if (name.Value == "disp" && cluster.IsSome)
            {
                throw new ArgumentException("Cluster node name cannot be 'disp', it's reserved for internal use.");
            }
            if (name.Value == "js")
            {
                throw new ArgumentException("Node name cannot be 'js', it's reserved for ProcessJS.");
            }

            lock (sync)
            {
                if (started)
                {
                    return(unit);
                }

                startupTimestamp = DateTime.UtcNow.Ticks;
                startupSubscription?.Dispose();
                startupSubscription = NotifyCluster(cluster, startupTimestamp);

                Dispatch.init();
                Role.init(cluster.Map(r => r.Role).IfNone("local"));
                Reg.init();

                watchers  = Map.empty <ProcessId, Set <ProcessId> >();
                watchings = Map.empty <ProcessId, Set <ProcessId> >();
                var root      = ProcessId.Top.Child(name);
                var rootInbox = new ActorInboxLocal <ActorSystemState, Unit>();
                var parent    = new ActorItem(new NullProcess(), new NullInbox(), ProcessFlags.Default);

                var go    = new AutoResetEvent(false);
                var state = new ActorSystemState(
                    cluster,
                    root, null,
                    rootInbox,
                    cluster.Map(x => x.NodeName).IfNone(ActorSystemConfig.Default.RootProcessName),
                    ActorSystemConfig.Default
                    );
                var rootProcess = state.RootProcess;
                state.Startup();
                userContext = new ActorRequestContext(
                    rootProcess.Children["user"],
                    ProcessId.NoSender,
                    rootItem,
                    null,
                    null,
                    ProcessFlags.Default,
                    ProcessOpTransaction.Start(rootProcess.Children["user"].Actor.Id)
                    );
                rootInbox.Startup(rootProcess, parent, cluster, ProcessConfig.Settings.GetProcessMailboxSize(rootProcess.Id));
                rootItem = new ActorItem(rootProcess, rootInbox, ProcessFlags.Default);
                started  = true;

                SessionManager.Init(cluster);
                ClusterWatch(cluster);
            }
            return(unit);
        }
Esempio n. 20
0
 public static ValueTask <Option <B> > Sequence <A, B>(this Option <A> ta, Func <A, ValueTask <B> > f) =>
 ta.Map(f).Sequence();
Esempio n. 21
0
 public static TryOption <Option <B> > Sequence <A, B>(this Option <A> ta, Func <A, TryOption <B> > f) =>
 ta.Map(f).Sequence();
Esempio n. 22
0
 /// <summary>
 /// Convert a LanguageExt Option into an F# Option
 /// </summary>
 public static FSharpOption <T> fs <T>(Option <T> option) =>
 option.Map(FSharpOption <T> .Some)
 .IfNoneUnsafe(FSharpOption <T> .None);