public AuthStatusCoordinatorActor( Action <string> updateStatus, Action <string> updateStatusColor, Action <bool> setIsBusy) { ActorPathPrinter.Print(Self); authStatusActor = Context.ActorOf( Props.Create <AuthStatusActor>(updateStatus, updateStatusColor), ActorNames.AuthStatus); busyStatusActor = Context.ActorOf( Props.Create <BusyStatusUpdatorActor>(setIsBusy), ActorNames.AuthBusy); Receive <Authenticate>(msg => { authStatusActor.Tell(msg); busyStatusActor.Tell(SystemBusy.Instance); }); Receive <AuthenticationFailed>(msg => { authStatusActor.Tell(msg); busyStatusActor.Tell(SystemIdle.Instance); }); Receive <AuthenticationCancelled>(msg => { authStatusActor.Tell(msg); busyStatusActor.Tell(SystemIdle.Instance); }); Receive <AuthenticationSuccess>(msg => { authStatusActor.Tell(msg); busyStatusActor.Tell(SystemIdle.Instance); }); }
public GithubCommanderActor(Func <IGitHubClient> gitHubClientFactory) { ActorPathPrinter.Print(Self); this.gitHubClientFactory = gitHubClientFactory ?? throw new ArgumentNullException(nameof(gitHubClientFactory)); Receive <CanAcceptJob>(job => { canAcceptJobSender = Sender; githubCoordinator.Tell(job); }); Receive <UnableToAcceptJob>(job => { canAcceptJobSender.Tell(job); }); Receive <AbleToAcceptJob>(job => { canAcceptJobSender.Tell(job); //start processing messages githubCoordinator.Tell(new BeginJob(job)); }); }
public DispatcherCoordinatorActor() { System.Console.WriteLine("DispatcherCoordinatorActor created"); ActorPathPrinter.Print(Self); Receive <NotifyDispatcherCommandCanExecuteChanged>(msg => { Context.ActorSelection(ActorPaths.DispatcherCommandNotifier).Tell(msg); }); Receive <PageNavigate>(msg => { System.Console.WriteLine("Navigating . . ."); Context.ActorSelection(ActorPaths.PageNavigator).Tell(msg); }); System.Console.WriteLine("Receiving PageNavigate . . ."); Receive <PageNavigateBack>(msg => { Context.ActorSelection(ActorPaths.PageNavigator).Tell(msg); }); Receive <CreateDispatcherActor>(msg => { Context.ActorOf( Props.Create(msg.ActorType, msg.ConstructorParams) .WithDispatcher("akka.actor.synchronized-dispatcher"), msg.ActorName); }); Self.Tell(CreateDispatcherActor.Build <DispatcherCommandNotifierActor>( ActorNames.DispatcherCommandNotifier)); }
public PageNavigatorActor(Action <Page> navigateTo) { ActorPathPrinter.Print(Self); this.navigateTo = navigateTo ?? throw new ArgumentNullException(nameof(navigateTo)); Receive <PageNavigate>(navigation => { this.navigateTo(navigation.Page); App.UIActors .ActorSelection(ActorPaths.PageTitle) .Tell(new PageTitle(navigation.Title)); if (navigation.Stash) { pages.Push(navigation); } }); Receive <PageNavigateBack>(_ => { if (pages.Count > 0) { Self.Tell(pages.Pop()); } }); }
public RepoResultsActor(Action <Repo> addRepoResult) { ActorPathPrinter.Print(Self); this.addRepoResult = addRepoResult ?? throw new ArgumentNullException(nameof(addRepoResult)); //user update Receive <IEnumerable <SimilarRepo> >(repos => { var addRepo = this.addRepoResult; foreach (var similarRepo in repos) { var repo = similarRepo.Repo; addRepo(new Repo(repo.Name, repo.Owner.Login, repo.HtmlUrl) { SharedStarsCount = similarRepo.SharedStarrers, OpenIssuesCount = repo.OpenIssuesCount, StarsCount = repo.StargazersCount, ForksCount = repo.ForksCount }); } }); }
public RepoResultsCoordinatorActor( Action <Repo> addRepoResult, Func <RepoRequestProgress, RepoRequestProgress> updateProgress, Action <string> updateStatus) { ActorPathPrinter.Print(Self); resultsActor = Context.ActorOf( Props.Create <RepoResultsActor>(addRepoResult), ActorNames.RepoResults); statusActor = Context.ActorOf( Props.Create <RepoResultsStatusActor>(updateProgress, updateStatus), ActorNames.RepoProgress); Receive <GithubProgressStats>(stats => { statusActor.Tell(stats); }); Receive <IEnumerable <SimilarRepo> >(repos => { resultsActor.Tell(repos); }); Receive <JobFailed>(failed => { statusActor.Tell(failed); }); }
public GithubWorkerActor(Func <IGitHubClient> gitHubClientFactory) { ActorPathPrinter.Print(Self); _gitHubClientFactory = gitHubClientFactory; InitialReceives(); }
public PageTitleActor(Action <string> setTitle) { ActorPathPrinter.Print(Self); this.setTitle = setTitle; Receive <PageTitle>(title => this.setTitle(title.Value)); }
public BusyStatusUpdatorActor(Action <bool> setIsBusy) { ActorPathPrinter.Print(Self); this.setIsBusy = setIsBusy ?? throw new ArgumentNullException(nameof(setIsBusy)); Receive <SystemBusy>(_ => this.setIsBusy(true)); Receive <SystemIdle>(_ => this.setIsBusy(false)); }
public GithubCoordinatorActor(Func <IGitHubClient> gitHubClientFactory) { ActorPathPrinter.Print(Self); this.gitHubClientFactory = gitHubClientFactory ?? throw new ArgumentNullException(nameof(gitHubClientFactory)); Waiting(); }
public DispatcherCommandNotifierActor() { ActorPathPrinter.Print(Self); Receive <NotifyDispatcherCommandCanExecuteChanged>(msg => { msg.Command.NotifyCanExecuteChanged(); }); }
public RepoResultsStatusActor(Func <RepoRequestProgress, RepoRequestProgress> updateProgress, Action <string> updateStatus) { ActorPathPrinter.Print(Self); this.updateProgress = updateProgress; this.updateStatus = updateStatus; Receive <GithubProgressStats>( stats => stats.ExpectedUsers == 0 && stats.IsFinished, stats => { if (!progressInitialized) { this.updateProgress(new RepoRequestProgress(0)); progressInitialized = true; } this.updateStatus("no user found."); }); //progress update Receive <GithubProgressStats>( stats => stats.ExpectedUsers > 0, stats => { if (!progressInitialized) { this.updateProgress(new RepoRequestProgress(stats.ExpectedUsers, stats.UsersThusFar)); progressInitialized = true; } else { this.updateProgress(null).Current = stats.UsersThusFar + stats.QueryFailures; } this.updateStatus($"{stats.UsersThusFar} out of {stats.ExpectedUsers} users " + $"({stats.QueryFailures} failures) [{stats.Elapsed} elapsed]"); }); //critical failure, like not being able to connect to Github Receive <JobFailed>(failed => { if (!progressInitialized) { var progress = new RepoRequestProgress(1, 1); progress.Fail(); this.updateProgress(progress); progressInitialized = true; } else { this.updateProgress(null).Fail(); } this.updateStatus($"Failed to gather data for Github repository {failed}"); }); }
public MainFormActor() { ActorPathPrinter.Print(Self); repoResultsPresenterActor = Context.ActorOf( Props.Create <RepoResultsPresenterActor>(), ActorNames.RepoResultsPresenter); Ready(); }
public TextStatusUpdatorActor(Action <string> updateStatus, Action <string> updateStatusColor) { ActorPathPrinter.Print(Self); this.updateStatus = updateStatus ?? throw new ArgumentNullException(nameof(updateStatus)); this.updateStatusColor = updateStatusColor ?? throw new ArgumentNullException(nameof(updateStatusColor)); UpdateColor(StatusColors.Idle); }
public RepoStatusCoordinatorActor( Action <string> updateStatus, Action <string> updateStatusColor, Action <bool> setIsBusy) { ActorPathPrinter.Print(Self); repoStatusActor = Context.ActorOf( Props.Create <RepoStatusActor>(updateStatus, updateStatusColor), ActorNames.RepoStatus); busyStatusActor = Context.ActorOf( Props.Create <BusyStatusUpdatorActor>(setIsBusy), ActorNames.RepoBusy); Receive <ValidateRepo>(repo => { repoStatusActor.Tell(repo); busyStatusActor.Tell(SystemBusy.Instance); }); Receive <ValidRepo>(valid => { repoStatusActor.Tell(valid); busyStatusActor.Tell(SystemIdle.Instance); }); Receive <InvalidRepo>(invalid => { repoStatusActor.Tell(invalid); busyStatusActor.Tell(SystemIdle.Instance); }); Receive <CanAcceptJob>(ask => { repoStatusActor.Tell(ask); busyStatusActor.Tell(SystemBusy.Instance); }); Receive <UnableToAcceptJob>(job => { repoStatusActor.Tell(job); busyStatusActor.Tell(SystemIdle.Instance); }); Receive <AbleToAcceptJob>(job => { repoStatusActor.Tell(job); busyStatusActor.Tell(SystemIdle.Instance); }); }
public InitializerActor() { ActorPathPrinter.Print(Self); Receive <Initialize>(_ => { System.Console.WriteLine("Initialize"); App.UIActors .ActorSelection(ActorPaths.DispatcherCoordinator) .Tell(PageNavigate.Create <Views.GithubAuth, ViewModels.GithubAuth>("Sign in to GitHub")); Become(Initialized); }); }
public GetHubRepoValidatorActor(Func <IGitHubClient> gitHubClientFactory) { ActorPathPrinter.Print(Self); this.gitHubClientFactory = gitHubClientFactory ?? throw new ArgumentNullException(nameof(gitHubClientFactory)); //Outright invalid URLs Receive <ValidateRepo>( repo => string.IsNullOrEmpty(repo.URL) || !Uri.IsWellFormedUriString(repo.URL, UriKind.Absolute), repo => Sender.Tell(new InvalidRepo(repo.URL, "Not a valid absolute URI"))); //Repos that at least have a valid absolute URL Receive <ValidateRepo>(repoAddress => { var repo = RepoKey.FromAddress(repoAddress); //close over the sender in an instance variable var sender = Sender; githubClient.Repository.Get(repo.Owner, repo.Repo) .ContinueWith <object>(t => { //Rule #1 of async in Akka.NET - turn exceptions into messages your actor understands if (t.IsCanceled) { return(new InvalidRepo(repoAddress.URL, "Repo lookup timed out")); } if (t.IsFaulted) { return(new InvalidRepo( repoAddress.URL, t.Exception != null ? t.Exception.GetBaseException().Message : "Unknown Octokit error")); } return(t.Result); }) .PipeTo(sender); }); }
public RepoLauncherActor() { ActorPathPrinter.Print(Self); Initializing(); }
public GithubAuthenticationActor() { ActorPathPrinter.Print(Self); Unauthenticated(); }
public RepoResultsPresenterActor() { ActorPathPrinter.Print(Self); Initializing(); }