public void Test_ParallelSequence() { Workspace = new Workspace("Name", "Description"); Model = Workspace.Model; SoftwareSystem softwareSystem = Model.AddSoftwareSystem("Name", "Description"); Person user = Model.AddPerson("User", "Description"); Container microservice1 = softwareSystem.AddContainer("Microservice 1", "", ""); Container database1 = softwareSystem.AddContainer("Database 1", "", ""); Container microservice2 = softwareSystem.AddContainer("Microservice 2", "", ""); Container database2 = softwareSystem.AddContainer("Database 2", "", ""); Container microservice3 = softwareSystem.AddContainer("Microservice 3", "", ""); Container database3 = softwareSystem.AddContainer("Database 3", "", ""); Container messageBus = softwareSystem.AddContainer("Message Bus", "", ""); user.Uses(microservice1, "Updates using"); microservice1.Delivers(user, "Sends updates to"); microservice1.Uses(database1, "Stores data in"); microservice1.Uses(messageBus, "Sends messages to"); microservice1.Uses(messageBus, "Sends messages to"); messageBus.Uses(microservice2, "Sends messages to"); messageBus.Uses(microservice3, "Sends messages to"); microservice2.Uses(database2, "Stores data in"); microservice3.Uses(database3, "Stores data in"); DynamicView view = Workspace.Views.CreateDynamicView(softwareSystem, "key", "Description"); view.Add(user, "1", microservice1); view.Add(microservice1, "2", database1); view.Add(microservice1, "3", messageBus); view.StartParallelSequence(); view.Add(messageBus, "4", microservice2); view.Add(microservice2, "5", database2); view.EndParallelSequence(); view.StartParallelSequence(); view.Add(messageBus, "4", microservice3); view.Add(microservice3, "5", database3); view.EndParallelSequence(); view.Add(microservice1, "5", database1); Assert.Equal(1, view.Relationships.Count(r => r.Order.Equals("1"))); Assert.Equal(1, view.Relationships.Count(r => r.Order.Equals("2"))); Assert.Equal(1, view.Relationships.Count(r => r.Order.Equals("3"))); Assert.Equal(3, view.Relationships.Count(r => r.Order.Equals("4"))); Assert.Equal(2, view.Relationships.Count(r => r.Order.Equals("5"))); }
public void Test_ParallelSequence() { Workspace = new Workspace("Name", "Description"); Model = Workspace.Model; SoftwareSystem softwareSystemA = Model.AddSoftwareSystem("A", ""); SoftwareSystem softwareSystemB = Model.AddSoftwareSystem("B", ""); SoftwareSystem softwareSystemC1 = Model.AddSoftwareSystem("C1", ""); SoftwareSystem softwareSystemC2 = Model.AddSoftwareSystem("C2", ""); SoftwareSystem softwareSystemD = Model.AddSoftwareSystem("D", ""); SoftwareSystem softwareSystemE = Model.AddSoftwareSystem("E", ""); // A -> B -> C1 -> D -> E // A -> B -> C2 -> D -> E softwareSystemA.Uses(softwareSystemB, "uses"); softwareSystemB.Uses(softwareSystemC1, "uses"); softwareSystemC1.Uses(softwareSystemD, "uses"); softwareSystemB.Uses(softwareSystemC2, "uses"); softwareSystemC2.Uses(softwareSystemD, "uses"); softwareSystemD.Uses(softwareSystemE, "uses"); DynamicView view = Workspace.Views.CreateDynamicView("key", "Description"); view.Add(softwareSystemA, softwareSystemB); view.StartParallelSequence(); view.Add(softwareSystemB, softwareSystemC1); view.Add(softwareSystemC1, softwareSystemD); view.EndParallelSequence(); view.StartParallelSequence(); view.Add(softwareSystemB, softwareSystemC2); view.Add(softwareSystemC2, softwareSystemD); view.EndParallelSequence(true); view.Add(softwareSystemD, softwareSystemE); Assert.Equal(1, view.Relationships.Count(r => r.Order.Equals("1"))); Assert.Equal(2, view.Relationships.Count(r => r.Order.Equals("2"))); Assert.Equal(2, view.Relationships.Count(r => r.Order.Equals("3"))); Assert.Equal(1, view.Relationships.Count(r => r.Order.Equals("4"))); }
static void Main() { Workspace workspace = new Workspace("Microservices example", "An example of a microservices architecture, which includes asynchronous and parallel behaviour."); Model model = workspace.Model; SoftwareSystem mySoftwareSystem = model.AddSoftwareSystem("Customer Information System", "Stores information "); Person customer = model.AddPerson("Customer", "A customer"); Container customerApplication = mySoftwareSystem.AddContainer("Customer Application", "Allows customers to manage their profile.", "Angular"); Container customerService = mySoftwareSystem.AddContainer("Customer Service", "The point of access for customer information.", "Java and Spring Boot"); customerService.AddTags(MicroserviceTag); Container customerDatabase = mySoftwareSystem.AddContainer("Customer Database", "Stores customer information.", "Oracle 12c"); customerDatabase.AddTags(DataStoreTag); Container reportingService = mySoftwareSystem.AddContainer("Reporting Service", "Creates normalised data for reporting purposes.", "Ruby"); reportingService.AddTags(MicroserviceTag); Container reportingDatabase = mySoftwareSystem.AddContainer("Reporting Database", "Stores a normalised version of all business data for ad hoc reporting purposes.", "MySQL"); reportingDatabase.AddTags(DataStoreTag); Container auditService = mySoftwareSystem.AddContainer("Audit Service", "Provides organisation-wide auditing facilities.", "C# .NET"); auditService.AddTags(MicroserviceTag); Container auditStore = mySoftwareSystem.AddContainer("Audit Store", "Stores information about events that have happened.", "Event Store"); auditStore.AddTags(DataStoreTag); Container messageBus = mySoftwareSystem.AddContainer("Message Bus", "Transport for business events.", "RabbitMQ"); messageBus.AddTags(MessageBusTag); customer.Uses(customerApplication, "Uses"); customerApplication.Uses(customerService, "Updates customer information using", "JSON/HTTPS", InteractionStyle.Synchronous); customerService.Uses(messageBus, "Sends customer update events to", "", InteractionStyle.Asynchronous); customerService.Uses(customerDatabase, "Stores data in", "JDBC", InteractionStyle.Synchronous); customerService.Uses(customerApplication, "Sends events to", "WebSocket", InteractionStyle.Asynchronous); messageBus.Uses(reportingService, "Sends customer update events to", "", InteractionStyle.Asynchronous); messageBus.Uses(auditService, "Sends customer update events to", "", InteractionStyle.Asynchronous); reportingService.Uses(reportingDatabase, "Stores data in", "", InteractionStyle.Synchronous); auditService.Uses(auditStore, "Stores events in", "", InteractionStyle.Synchronous); ViewSet views = workspace.Views; ContainerView containerView = views.CreateContainerView(mySoftwareSystem, "Containers", null); containerView.AddAllElements(); DynamicView dynamicView = views.CreateDynamicView(mySoftwareSystem, "CustomerUpdateEvent", "This diagram shows what happens when a customer updates their details."); dynamicView.Add(customer, customerApplication); dynamicView.Add(customerApplication, customerService); dynamicView.Add(customerService, customerDatabase); dynamicView.Add(customerService, messageBus); dynamicView.StartParallelSequence(); dynamicView.Add(messageBus, reportingService); dynamicView.Add(reportingService, reportingDatabase); dynamicView.EndParallelSequence(); dynamicView.StartParallelSequence(); dynamicView.Add(messageBus, auditService); dynamicView.Add(auditService, auditStore); dynamicView.EndParallelSequence(); dynamicView.Add(customerService, "Confirms update to", customerApplication); Styles styles = views.Configuration.Styles; styles.Add(new ElementStyle(Tags.Element) { Color = "#000000" }); styles.Add(new ElementStyle(Tags.Person) { Background = "#ffbf00", Shape = Shape.Person }); styles.Add(new ElementStyle(Tags.Container) { Background = "#facc2E" }); styles.Add(new ElementStyle(MessageBusTag) { Width = 1600, Shape = Shape.Pipe }); styles.Add(new ElementStyle(MicroserviceTag) { Shape = Shape.Hexagon }); styles.Add(new ElementStyle(DataStoreTag) { Background = "#f5da81", Shape = Shape.Cylinder }); styles.Add(new RelationshipStyle(Tags.Relationship) { Routing = Routing.Orthogonal }); styles.Add(new RelationshipStyle(Tags.Asynchronous) { Dashed = true }); styles.Add(new RelationshipStyle(Tags.Synchronous) { Dashed = false }); StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret); structurizrClient.PutWorkspace(WorkspaceId, workspace); }