public FilteredPoliciesRM(IConfiguredConnection conn, List <string> policyFilter = null) : base(nameof(FilteredPoliciesRM), () => conn.GetListener(nameof(FilteredPoliciesRM))) { if (policyFilter != null) { AllowedApplications = new HashSet <string>(policyFilter); } //set handlers EventStream.Subscribe <ApplicationMsgs.ApplicationCreated>(this); EventStream.Subscribe <ApplicationMsgs.PolicyCreated>(this); EventStream.Subscribe <ApplicationMsgs.RoleCreated>(this); EventStream.Subscribe <PolicyUserMsgs.PolicyUserAdded>(this); EventStream.Subscribe <PolicyUserMsgs.RoleAdded>(this); EventStream.Subscribe <PolicyUserMsgs.RoleRemoved>(this); EventStream.Subscribe <PolicyUserMsgs.UserDeactivated>(this); EventStream.Subscribe <PolicyUserMsgs.UserReactivated>(this); //read long?appCheckpoint; long?userCheckpoint; using (var reader = conn.GetReader(nameof(FilteredPoliciesRM), Handle)) { reader.Read <Domain.SecuredApplication>(() => Idle); appCheckpoint = reader.Position; reader.Read <Domain.PolicyUser>(() => Idle); userCheckpoint = reader.Position; } //subscribe Start <Domain.SecuredApplication>(appCheckpoint); Start <Domain.PolicyUser>(userCheckpoint); }
public UserStore(IConfiguredConnection conn) { _conn = conn; _userSvc = new UserSvc(_conn.GetRepository(), new Dispatcher("bus-to-nowhere")); _usersRm = new UsersRm(_conn); _subjectsRm = new SubjectsRm(_conn); _repo = _conn.GetCorrelatedRepository(); }
/// <summary> /// Creates a read model using the provided stream store connection. Reads existing events using a /// reader, then transitions to a listener for live events. /// </summary> /// <param name="name">The name of the read model. Also used as the name of the listener and reader.</param> /// <param name="connection">A connection to a stream store.</param> protected ReadModelBase(string name, IConfiguredConnection connection) { Ensure.NotNull(connection, nameof(connection)); _getListener = () => connection.GetListener(name); _getReader = () => connection.GetReader(name, Handle); _listeners = new List <IListener>(); _bus = new InMemoryBus($"{nameof(ReadModelBase)}:{name} bus", false); _queue = new QueuedHandler(_bus, $"{nameof(ReadModelBase)}:{name} queue"); _queue.Start(); }
public ApplicationSvc( IConfiguredConnection conn, ICommandSubscriber subscriber) : base(subscriber) { _conn = conn; _repo = conn.GetCorrelatedRepository(); _rm = new FilteredPoliciesRM(conn); Subscribe <ApplicationMsgs.CreateApplication>(this); }
private static void ConnectToEs() { AppConfig = new ConfigurationBuilder() .SetBasePath(AppDomain.CurrentDomain.BaseDirectory) .AddJsonFile("es_settings.json") .Build(); Console.WriteLine($"{AppConfig["EventStoreUserName"]}"); EsConnection = BuildConnection(); Console.WriteLine("Connected"); }
public UsersRm(IConfiguredConnection conn) : base(nameof(UsersRm), () => conn.GetListener(nameof(UsersRm))) { long?position; EventStream.Subscribe <UserMsgs.UserEvent>(this); using (var reader = conn.GetReader(nameof(UsersRm), Handle)) { reader.Read <User>(() => Idle); position = reader.Position; } Start <User>(checkpoint: position, blockUntilLive: true); }
public PolicySvc( IConfiguredConnection conn, ICommandSubscriber cmdSource) : base(cmdSource) { _repo = conn.GetCorrelatedRepository(caching: true); Subscribe <ApplicationMsgs.CreateRole>(this); Subscribe <PolicyUserMsgs.AddPolicyUser>(this); Subscribe <PolicyUserMsgs.AddRole>(this); Subscribe <PolicyUserMsgs.RemoveRole>(this); Subscribe <PolicyUserMsgs.DeactivateUser>(this); Subscribe <PolicyUserMsgs.ReactivateUser>(this); }
public ClientStore(IConfiguredConnection conn) : base(nameof(ClientStore), () => conn.GetListener(nameof(ClientStore))) { long checkpoint; EventStream.Subscribe <ClientMsgs.ClientCreated>(this); EventStream.Subscribe <ClientMsgs.ClientSecretAdded>(this); EventStream.Subscribe <ClientMsgs.ClientSecretRemoved>(this); using (var reader = conn.GetReader(nameof(ClientStore), Handle)) { reader.Read <IdentityStorage.Domain.Client>(() => Idle); checkpoint = reader.Position ?? StreamPosition.Start; } Start <IdentityStorage.Domain.Client>(checkpoint); }
public SubjectsRm(IConfiguredConnection conn) : base(nameof(SubjectsRm), () => conn.GetListener(nameof(SubjectsRm))) { //set handlers EventStream.Subscribe <SubjectMsgs.SubjectCreated>(this); //read long?checkpoint; using (var reader = conn.GetReader(nameof(SubjectsRm), Handle)) { reader.Read <Subject>(() => Idle); checkpoint = reader.Position; } //subscribe Start <Subject>(checkpoint, true); }
/// <summary> /// Create a read model for getting information about Policy Users. /// </summary> public PolicyUserRm(IConfiguredConnection conn) : base(nameof(PolicyUserRm), () => conn.GetListener(nameof(PolicyUserRm))) { //set handlers EventStream.Subscribe <PolicyUserMsgs.PolicyUserAdded>(this); EventStream.Subscribe <PolicyUserMsgs.RoleAdded>(this); EventStream.Subscribe <PolicyUserMsgs.RoleRemoved>(this); EventStream.Subscribe <PolicyUserMsgs.UserDeactivated>(this); EventStream.Subscribe <PolicyUserMsgs.UserReactivated>(this); //read long?checkpoint; using (var reader = conn.GetReader(nameof(PolicyUserRm), Handle)) { reader.Read <Domain.PolicyUser>(() => Idle); checkpoint = reader.Position; } //subscribe Start <Domain.PolicyUser>(checkpoint); }
public static string GetSecuredApplicationStreamName(IConfiguredConnection conn, Guid id) { Ensure.NotEmptyGuid(id, nameof(id)); return(conn.StreamNamer.GenerateForAggregate(typeof(Domain.SecuredApplication), id)); }
public static string GetPolicyUserCategoryStreamName(IConfiguredConnection conn) { return(conn.StreamNamer.GenerateForCategory(typeof(Domain.PolicyUser))); }
public static string GetSecuredApplicationCategoryStreamName(IConfiguredConnection conn) { return(conn.StreamNamer.GenerateForCategory(typeof(Domain.SecuredApplication))); }