public static TypedActorRef InterfacedActorOf <TActor>(this IActorRefFactory factory, Expression <Func <TActor> > propFactory, SupervisorStrategy supervisorStrategy = null, string name = null)
     where TActor : InterfacedActor
 {
     return(new TypedActorRef {
         Actor = factory.ActorOf(Props.Create(propFactory, supervisorStrategy), name), Type = typeof(TActor)
     });
 }
示例#2
0
 public GetFileWebController(
     IActorRefFactory actorSystem,
     ITimeoutSettings timeoutSettings)
 {
     this.actorSystem     = actorSystem;
     this.timeoutSettings = timeoutSettings;
 }
示例#3
0
        public static IEventActor SubscribeToEvent <TEvent>(this IActorRefFactory actor, IActorRef target, Action <TEvent> handler, bool killOnFirstResponse = false)
        {
            var eventActor = EventActor.Create(actor, handler, killOnFirstResponse);

            eventActor.Send(target, new EventSubscribe(true, typeof(TEvent)));
            return(eventActor);
        }
 public static TypedActorRef InterfacedActorOf <TActor>(this IActorRefFactory factory, string name = null)
     where TActor : InterfacedActor, new()
 {
     return(new TypedActorRef {
         Actor = factory.ActorOf <TActor>(name), Type = typeof(TActor)
     });
 }
示例#5
0
 public static void TellEntityChildren <TMessageType>(this IActorRefFactory selector, IActorRef sender)
     where TMessageType : EntityActorMessage, new()
 {
     selector
     .ActorSelection(MEAKKASelectionConstants.ALL_DIRECT_CHILDREN_SELECTOR)
     .TellEntitySelection(new TMessageType(), sender);
 }
        public SoftwareRepository Create(IActorRefFactory factory, IDirectory path)
        {
            var temp = new SoftwareRepository(factory, path);

            temp.InitNew();
            return(temp);
        }
        public static IActorRef CategoryQueryAggregate(this IActorRefFactory system)
        {
            var nameOfQueryActor = SystemData.CategoryQueryActor.Name;
            var queryProps       = new ConsistentHashingPool(10).Props(Props.Create <CategoryQuery>());

            return(system.ActorOf(queryProps, $"{nameOfQueryActor}"));
        }
        public static IActorRef CategoryCommanderAggregate(this IActorRefFactory system, Guid id,
                                                           int snapshotThreshold = 2)
        {
            var nameOfCommanderActor  = SystemData.CategoryCommanderActor.Name;
            var nameofProjectionActor = SystemData.CategoryProjectionsActor.Name;
            // var nameOfProcessManagerActor = "category-process-manager";

            // build up the category actor
            var projectionsProps = new ConsistentHashingPool(10)
                                   .Props(Props.Create <ReadModelProjections>());
            var projections = system.ActorOf(projectionsProps, $"{nameofProjectionActor}-{nameOfCommanderActor}");

            /*var processManagerProps = new ConsistentHashingPool(1)
             *  .Props(Props.Create(() => new CategoryProcessManager(id)));*/
            // var processManager = system.ActorOf(Props.Create(() => new CategoryProcessManager(id)));
            // var categoryStatusSaga = system.ActorSelection($"/user/{SystemData.CategoryStatusSagaActor.Name}-group");

            var categoryStatusSagaActor = system.ActorOf(
                Props.Empty.WithRouter(FromConfig.Instance), "category-status-broadcaster-group");

            var creationParams = new AggregateRootCreationParameters(id, projections,
                                                                     new HashSet <IActorRef>(new List <IActorRef> {
                categoryStatusSagaActor
            }), snapshotThreshold);

            return(system.ActorOf(Props.Create <Category>(creationParams), nameOfCommanderActor));
        }
示例#9
0
        public static Task <TResult> Send <TResult, TCommand>(ISender sender, TCommand command, Action <string> messages, TimeSpan timeout, bool isEmpty)
            where TCommand : class, IReporterMessage
        {
            Log.LogInformation("Sending Command {CommandType} -- {SenderType}", command.GetType(), sender.GetType());
            command.ValidateApi(sender.GetType());

            var task = new TaskCompletionSource <TResult>();
            IActorRefFactory factory = ActorApplication.ActorSystem;

            //try
            //{
            //    factory = ObservableActor.ExposedContext;
            //}
            //catch (NotSupportedException)
            //{
            //    factory = ActorApplication.Application.ActorSystem;
            //}

            var listner = Reporter.CreateListner(factory, messages, result =>
            {
                if (result.Ok)
                {
                    if (isEmpty)
                    {
                        task.SetResult(default !);
示例#10
0
        public static IWorkDistributor <TInput> Create(IActorRefFactory factory, Props worker, string workerName, TimeSpan timeout, string?name = null)
        {
            var actor = factory.ActorOf(name,
                                        Feature.Create(() => new WorkDistributorFeature <TInput, TFinishMessage>(),
                                                       _ => new WorkDistributorFeatureState(new DistributorConfig(worker, workerName, timeout, 5))));

            return(new WorkSender(actor));
        }
示例#11
0
        public static IActorRef RunAsSupervisedActor <T>(this Action <T> action, IActorRefFactory actorRefFactory,
                                                         string childName, Func <SupervisorStrategy> getSupervisorStrategy = null)
        {
            var childProps      = Props.Create(() => new FunctorActor <T>(action));
            var supervisorProps = Props.Create(() => new SupervisorActor(childName, childProps, getSupervisorStrategy));

            return(actorRefFactory.ActorOf(supervisorProps));
        }
        public static IActorRef CreateListner(IActorRefFactory factory, Action <string> listner, TimeSpan timeout, string?name, out Task <IOperationResult> onCompled)
        {
            var source = new TaskCompletionSource <IOperationResult>();
            var actor  = CreateListner(factory, listner, source, timeout, null);

            onCompled = source.Task;
            return(actor);
        }
示例#13
0
 public SoftwareRepository(IActorRefFactory factory, IDirectory path)
     : base(new WorkspaceSuperviser(factory, "Software-Repository"))
 {
     Path    = path;
     Changed = Engine.EventSource(mc => mc.GetChange <CommonChange>().ApplicationList,
                                  context => context.Change is CommonChange);
     Changed.RespondOn(null, Save);
 }
        /// <summary>
        /// Creates an actor, creating props based on the provided
        /// actor factory method.
        /// </summary>
        /// <typeparam name="T">The actor type.</typeparam>
        /// <param name="actorRefFactory">ActorSystem or actor Context.</param>
        /// <param name="actorFactory">Actor factory method.</param>
        public static IActorRef CreateActor <T>(this IActorRefFactory actorRefFactory,
                                                Expression <Func <T> > actorFactory) where T : ActorBase
        {
            var props = Props.Create(actorFactory);
            var actor = actorRefFactory.ActorOf(props);

            return(actor);
        }
示例#15
0
 /// <summary>
 /// Using the given context, create an actor of the given _props, and optionally naming it with _name
 /// </summary>
 public IActorRef Apply(IActorRefFactory context)
 {
     if (_name.HasValue)
     {
         return(context.ActorOf(_props, _name.Value));
     }
     return(context.ActorOf(_props));
 }
 public DepartmentFeaturesService(
     IActorRefFactory actorsFactory,
     ActorPathsBuilder actorPathsBuilder,
     ITimeoutSettings timeoutSettings)
 {
     this.organizationActor = actorsFactory.ActorSelection(
         actorPathsBuilder.Get(WellKnownActorPaths.Organization));
     this.timeoutSettings = timeoutSettings;
 }
示例#17
0
 public PermissionsLoader(
     IActorRefFactory actorSystem,
     ActorPathsBuilder pathsBuilder,
     ITimeoutSettings timeoutSettings)
 {
     this.actorSystem     = actorSystem;
     this.pathsBuilder    = pathsBuilder;
     this.timeoutSettings = timeoutSettings;
 }
 public UserPreferencesService(
     IActorRefFactory actorsFactory,
     ActorPathsBuilder actorPathsBuilder,
     ITimeoutSettings timeoutSettings)
 {
     this.userPreferencesActor = actorsFactory.ActorSelection(
         actorPathsBuilder.Get(WellKnownActorPaths.UserPreferences));
     this.timeoutSettings = timeoutSettings;
 }
        public static Sink <SequencedFunctionTotalUsage, NotUsed> Create(IActorRefFactory system, string eventName)
        {
            var actorRef = system.ActorOf(Props.Create <FunctionsTotalUsageProjector>(eventName), nameof(FunctionsTotalUsageProjector));

            return(Sink.ActorRefWithAck <SequencedFunctionTotalUsage>(
                       actorRef,
                       ProjectorActorProtocol.Start.Instance,
                       ProjectorActorProtocol.Next.Instance,
                       ProjectorActorProtocol.ProjectionDone.Instance));
        }
        public static Sink <FunctionAdded, NotUsed> Create(IActorRefFactory system, string eventName)
        {
            var actorRef = system.ActorOf(Props.Create <KnownFunctionsProjector>(eventName), nameof(KnownFunctionsProjector));

            return(Sink.ActorRefWithAck <FunctionAdded>(
                       actorRef,
                       ProjectorActorProtocol.Start.Instance,
                       ProjectorActorProtocol.Next.Instance,
                       ProjectorActorProtocol.ProjectionDone.Instance));
        }
示例#21
0
 public FeedsController(
     ActorPathsBuilder pathsBuilder,
     IActorRefFactory actorFactory,
     ITimeoutSettings timeoutSettings,
     IUserEmployeeSearch userEmployeeSearch)
 {
     this.pathsBuilder       = pathsBuilder;
     this.actorFactory       = actorFactory;
     this.timeoutSettings    = timeoutSettings;
     this.userEmployeeSearch = userEmployeeSearch;
 }
示例#22
0
        public EventLog(IActorRefFactory factory, IActorRef journalRef, string persistenceId)
        {
            this.factory       = factory;
            this.journalRef    = journalRef;
            this.persistenceId = persistenceId;

            this.writer   = new EventWriter(factory, journalRef, persistenceId);
            this.replayer = new EventReplayer(factory, journalRef, persistenceId);

            Shape = new FlowShape <ImmutableList <IPersistentRepresentation>, Delivery <IPersistentRepresentation> >(Inlet, Outlet);
        }
        public static IActorRef CategoryCommanderAggregate(this IActorRefFactory system, Guid id,
                                                           int snapshotThreshold = 10)
        {
            var nameOfCommanderActor  = SystemData.CategoryCommanderActor.Name;
            var nameofProjectionActor = SystemData.CategoryProjectionsActor.Name;
            // build up the category actor
            var projectionsProps = new ConsistentHashingPool(5).Props(Props.Create <ReadModelProjections>());
            var projections      = system.ActorOf(projectionsProps, nameofProjectionActor + $"-{nameOfCommanderActor}");
            var creationParams   = new AggregateRootCreationParameters(id, projections, snapshotThreshold);

            return(system.ActorOf(Props.Create <Category>(creationParams), nameOfCommanderActor));
        }
示例#24
0
        public ProjectFileWorkspace(IActorRefFactory factory)
            : base(new WorkspaceSuperviser(factory, "Project_File_Workspace"))
        {
            _projectFile = new ProjectFile();

            Projects = new ProjectMutator(Engine, this);
            Source   = new SourceMutator(Engine, this);
            Entrys   = new EntryMutator(Engine);
            Build    = new BuildMutator(Engine);

            Analyzer.RegisterRule(new SourceRule());
        }
示例#25
0
        public ActorManager(IActorRefFactory actorSystem)
        {
            DeviceCoordinator =
                actorSystem.ActorOf(
                    Props.Create <DeviceCoordinator>(),
                    nameof(DeviceCoordinator));

            GroupCoordinator =
                actorSystem.ActorOf(
                    Props.Create <GroupCoordinator>(),
                    nameof(GroupCoordinator));
        }
示例#26
0
        public ShellViewModel(HomeViewModel home, SettingsViewModel settings, ConversationsViewModel convos, IActorRefFactory system)
        {
            _screens.Add(Screens.Home, home);
            _screens.Add(Screens.Settings, settings);
            _screens.Add(Screens.Conversations, convos);

            system.ActorSelection(ClientActorPaths.ErrorDialogActor.Path)
                .Tell(new ErrorDialogActor.RegisterShell(this));

            _shellViewModelActor = system.ActorOf(Props.Create(() => new ShellViewModelActor(this)),
                ClientActorPaths.ShellViewModelActor.Name);
        }
 public PendingRequestsController(
     IUserEmployeeSearch userEmployeeSearch,
     ActorPathsBuilder pathBuilder,
     ITimeoutSettings timeoutSettings,
     IActorRefFactory actorsFactory,
     IUserPreferencesService userPreferencesService)
 {
     this.userEmployeeSearch     = userEmployeeSearch;
     this.pathBuilder            = pathBuilder;
     this.timeoutSettings        = timeoutSettings;
     this.actorsFactory          = actorsFactory;
     this.userPreferencesService = userPreferencesService;
 }
示例#28
0
        public OgnConvertActor(
            IActorRefFactory actorSystem,
            AircraftProvider aircraftProvider,
            GatewayConfiguration gatewayConfiguration
            )
        {
            // When receiving the raw string from the listener, convert it to FlightData and pass it to the next Actor
            Receive <string>(message =>
            {
                var convertedMessage = StreamConversionService.ConvertData(message);
                if (convertedMessage == null)
                {
                    // Ignore non-parseable messages
                    return;
                }

                // The next step also happens on this Actor so tell another "Self" to handle the FlightData
                actorSystem.ActorSelection(Self.Path).Tell(convertedMessage, Self);
            });

            // When receiving FlightData, convert it into FlightDataDto and pass it to the next actor
            Receive <FlightData>(message =>
            {
                var aircraft = aircraftProvider.Load(message.AircraftId);
                if (!aircraft.Visible)
                {
                    // The aircraft should not be visible, therefore drop the message.
                    return;
                }

                var flying = message.Altitude >= gatewayConfiguration.MinimalAltitude &&
                             message.Speed >= gatewayConfiguration.MinimalSpeed;

                var convertedMessage = new FlightDataDto(
                    message.Speed,
                    message.Altitude,
                    message.VerticalSpeed,
                    message.TurnRate,
                    message.Course,
                    message.Position,
                    message.DateTime,
                    new AircraftDto(aircraft),
                    flying
                    );

                // Pass the convertedMessage to the IMessageProcessActor so it can be further processed.
                actorSystem
                .ActorSelection($"user/{ActorControlService.MessageProcessActorName}")
                .Tell(convertedMessage, Self);
            });
        }
示例#29
0
        public IActorRef CreateActor(IActorRefFactory actorRefFactory, object id, object[] args)
        {
            var param = (CreateGameParam)args[0];

            var gameActor = actorRefFactory.ActorOf(Props.Create(
                                                        () => new GameActor(_clusterContext, (long)id, param)));

            if (param.WithBot)
            {
                actorRefFactory.ActorOf(Props.Create(
                                            () => new GameBotActor(_clusterContext, gameActor.Cast <GameRef>(), 0, "bot")));
            }

            return(gameActor);
        }
示例#30
0
        /// <summary>
        /// <para>
        /// Creates a ActorMaterializer which will execute every step of a transformation
        /// pipeline within its own <see cref="ActorBase"/>. The required <see cref="IActorRefFactory"/>
        /// (which can be either an <see cref="ActorSystem"/> or an <see cref="IActorContext"/>)
        /// will be used to create one actor that in turn creates actors for the transformation steps.
        /// </para>
        /// <para>
        /// The materializer's <see cref="ActorMaterializerSettings"/> will be obtained from the
        /// configuration of the <paramref name="context"/>'s underlying <see cref="ActorSystem"/>.
        /// </para>
        /// <para>
        /// The <paramref name="namePrefix"/> is used as the first part of the names of the actors running
        /// the processing steps. The default <paramref name="namePrefix"/> is "flow". The actor names are built up of
        /// `namePrefix-flowNumber-flowStepNumber-stepName`.
        /// </para>
        /// </summary>
        /// <param name="context">TBD</param>
        /// <param name="settings">TBD</param>
        /// <param name="namePrefix">TBD</param>
        /// <exception cref="ArgumentException">
        /// This exception is thrown when the specified <paramref name="context"/> is not of type <see cref="ActorSystem"/> or <see cref="IActorContext"/>.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// This exception is thrown when the specified <paramref name="context"/> is undefined.
        /// </exception>
        /// <returns>TBD</returns>
        public static ActorMaterializer Create(IActorRefFactory context, ActorMaterializerSettings settings = null, string namePrefix = null)
        {
            var haveShutDown = new AtomicBoolean();
            var system       = ActorSystemOf(context);

            system.Settings.InjectTopLevelFallback(DefaultConfig());
            settings = settings ?? ActorMaterializerSettings.Create(system);

            return(new ActorMaterializerImpl(
                       system: system,
                       settings: settings,
                       dispatchers: system.Dispatchers,
                       supervisor: context.ActorOf(StreamSupervisor.Props(settings, haveShutDown).WithDispatcher(settings.Dispatcher), StreamSupervisor.NextName()),
                       haveShutDown: haveShutDown,
                       flowNames: EnumerableActorName.Create(namePrefix ?? "Flow")));
        }
示例#31
0
        private static ActorSystem ActorSystemOf(IActorRefFactory context)
        {
            if (context is ExtendedActorSystem)
            {
                return((ActorSystem)context);
            }
            if (context is IActorContext)
            {
                return(((IActorContext)context).System);
            }
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context), "IActorRefFactory must be defined");
            }

            throw new ArgumentException($"ActorRefFactory context must be a ActorSystem or ActorContext, got [{context.GetType()}]");
        }
示例#32
0
        public HomeViewModel(IActorRefFactory system)
        {
            DisplayName = "Home screen";

            _homeViewModelActor = system.ActorOf(Props.Create(() => new HomeViewModelActor(this)), ClientActorPaths.HomeViewModelActor.Name);
        }
示例#33
0
        public IActorRef CreateActor(IActorRefFactory actorRefFactory, object id, object[] args)
        {
            var param = (CreateGameParam)args[0];

            var gameActor = actorRefFactory.ActorOf(Props.Create(
                () => new GameActor(_clusterContext, (long)id, param)));

            if (param.WithBot)
            {
                actorRefFactory.ActorOf(Props.Create(
                    () => new GameBotActor(_clusterContext, gameActor.Cast<GameRef>(), 0, "bot")));
            }

            return gameActor;
        }
示例#34
0
 private RootBuilderContext(IActorRefFactory factory)
 {
     this.factory = factory;
 }
示例#35
0
        public SettingsViewModel(IActorRefFactory system)
        {
            DisplayName = "Settings";

            _vmActor = system.ActorOf(Props.Create(() => new SettingsViewModelActor(this)), ClientActorPaths.SettingsViewModelActor.Name);
        }
示例#36
0
 public static RootBuilderContext From(IActorRefFactory factory)
 {
     return new RootBuilderContext(factory);
 }
示例#37
0
 public IActorRef CreateActor(IActorRefFactory actorRefFactory, object id, object[] args)
 {
     return actorRefFactory.ActorOf(Props.Create(() => new UserActor(_clusterContext, (long)id)));
 }