merge upstream

pull/43/head
S M 6 years ago
commit 5163b236e6

@ -42,9 +42,9 @@ You can start with [quick start](https://diagrams.mingrammer.com/docs/getting-st
## Examples
| Event Processing on AWS | Stateful Architecture on k8s | On-Premise System Architecture |
| Event Processing | Stateful Architecture | Advanced Web Service |
| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| ![event processing](https://diagrams.mingrammer.com/img/event_processing_diagram.png) | ![stateful architecture](https://diagrams.mingrammer.com/img/stateful_architecture_diagram.png) | ![on-premise system architecture diagram](https://diagrams.mingrammer.com/img/on-premise_system_architecture.png) |
| ![event processing](https://diagrams.mingrammer.com/img/event_processing_diagram.png) | ![stateful architecture](https://diagrams.mingrammer.com/img/stateful_architecture_diagram.png) | ![advanced web service with on-premise](https://diagrams.mingrammer.com/img/advanced_web_service_with_on-premise.png) |
You can find all the examples on the [examples](https://diagrams.mingrammer.com/docs/getting-started/examples) page.

@ -98,6 +98,8 @@ ALIASES = {
"Haproxy": "HAProxy",
},
"queue": {
"Activemq": "ActiveMQ",
"Rabbitmq": "RabbitMQ",
"Zeromq": "ZeroMQ",
},
"workflow": {

@ -139,6 +139,9 @@ class Diagram:
os.remove(self.filename)
setdiagram(None)
def _repr_png_(self):
return self.dot.pipe(format='png')
def _validate_direction(self, direction: str) -> bool:
direction = direction.upper()
for v in self.__directions:
@ -260,6 +263,8 @@ class Node:
_icon_dir = None
_icon = None
_height = 1.9
def __init__(self, label: str = ""):
"""Node represents a system component.
@ -272,9 +277,11 @@ class Node:
# fmt: off
# If a node has an icon, increase the height slightly to avoid
# that label being spanned between icon image and white space.
# Increase the height by the number of new lines included in the label.
padding = 0.4 * (label.count('\n'))
self.attrs = {
"shape": "none",
"height": "1.9",
"height": str(self._height + padding),
"image": self._load_icon(),
} if self._icon else {}
# fmt: on

@ -26,4 +26,6 @@ class Zeromq(_Queue):
# Aliases
ActiveMQ = Activemq
RabbitMQ = Rabbitmq
ZeroMQ = Zeromq

@ -5,7 +5,7 @@ title: Examples
Here are some more examples.
## Grouped Workers
## Grouped Workers on AWS
```python
from diagrams import Diagram
@ -54,7 +54,7 @@ with Diagram("Clustered Web Services", show=False):
![clustered web services diagram](/img/clustered_web_services_diagram.png)
## Event Processing
## Event Processing on AWS
```python
from diagrams import Cluster, Diagram
@ -89,7 +89,7 @@ with Diagram("Event Processing", show=False):
![event processing diagram](/img/event_processing_diagram.png)
## Message Collecting System
## Message Collecting System on GCP
```python
from diagrams import Cluster, Diagram
@ -127,7 +127,7 @@ with Diagram("Message Collecting", show=False):
![message collecting diagram](/img/message_collecting_diagram.png)
## Exposed Pod with 3 Replicas on k8s
## Exposed Pod with 3 Replicas on Kubernetes
```python
from diagrams import Diagram
@ -145,7 +145,7 @@ with Diagram("Exposed Pod with 3 Replicas", show=False):
![exposed pod with 3 replicas diagram](/img/exposed_pod_with_3_replicas_diagram.png)
## Stateful Architecture on k8s
## Stateful Architecture on Kubernetes
```python
from diagrams import Cluster, Diagram
@ -170,7 +170,50 @@ with Diagram("Stateful Architecture", show=False):
![stateful architecture diagram](/img/stateful_architecture_diagram.png)
## RabbitMQ Consumers with custom nodes
## Advanced Web Service with On-Premise
```python
from diagrams import Cluster, Diagram
from diagrams.onprem.analytics import Spark
from diagrams.onprem.compute import Server
from diagrams.onprem.database import PostgreSQL
from diagrams.onprem.inmemory import Redis
from diagrams.onprem.logging import Fluentd
from diagrams.onprem.monitoring import Grafana, Prometheus
from diagrams.onprem.network import Nginx
from diagrams.onprem.queue import Kafka
with Diagram("Advanced Web Service with On-Premise", show=False):
ingress = Nginx("ingress")
metrics = Prometheus("metric")
metrics << Grafana("monitoring")
with Cluster("Service Cluster"):
grpcsvc = [
Server("grpc1"),
Server("grpc2"),
Server("grpc3")]
with Cluster("Sessions HA"):
master = Redis("session")
master - Redis("replica") << metrics
grpcsvc >> master
with Cluster("Database HA"):
master = PostgreSQL("users")
master - PostgreSQL("slave") << metrics
grpcsvc >> master
aggregator = Fluentd("logging")
aggregator >> Kafka("stream") >> Spark("analytics")
ingress >> grpcsvc >> aggregator
```
![advanced web service with on-premise diagram](/img/advanced_web_service_with_on-premise.png)
## RabbitMQ Consumers with Custom Nodes
```python
from urllib.request import urlretrieve
@ -199,54 +242,4 @@ with Diagram("Broker Consumers", show=False):
queue >> consumers >> Aurora("Database")
````
![rabbitmq consumers diagram](/img/rabbitmq_consumers_diagram.png)
## On-Premise System Architecture
```python
from diagrams import Cluster, Diagram
from diagrams.onprem.analytics import Spark
from diagrams.onprem.compute import Server
from diagrams.onprem.database import PostgreSQL
from diagrams.onprem.inmemory import Redis
from diagrams.onprem.logging import Fluentd
from diagrams.onprem.monitoring import Grafana, Prometheus
from diagrams.onprem.network import Linkerd, Nginx
from diagrams.onprem.queue import Kafka
from diagrams.onprem.workflow import Airflow
with Diagram("On-Premise System Architecture", show=False):
ingress = Nginx("ingress")
with Cluster("Service Cluster"):
svcmesh = Linkerd("svcmesh")
grpcsvc = [Server("grpc1"), Server("grpc2"), Server("grpc3")]
svcmesh >> grpcsvc
with Cluster("Database HA"):
maindb_master = PostgreSQL("maindb")
maindb_replica = PostgreSQL("replica")
maindb_master - maindb_replica
grpcsvc >> maindb_master
maindb_replica >> Airflow("scheduler")
with Cluster("Sessions HA"):
session_master = Redis("session")
session_master - Redis("replica")
grpcsvc >> session_master
logaggr = Fluentd("aggregator")
logaggr >> Kafka("stream") >> Spark("log analytics")
grpcsvc >> logaggr
metricq = Kafka("buffer")
metricq >> Prometheus("metric") >> Grafana("monitoring")
logaggr >> metricq
svcmesh >> metricq
ingress >> svcmesh
```
![on-premise system architecture diagram](/img/on-premise_system_architecture.png)
![rabbitmq consumers diagram](/img/rabbitmq_consumers_diagram.png)

@ -5,7 +5,7 @@ title: Installation
It uses [Graphviz](https://www.graphviz.org/) to render the diagram, so you need to [install Graphviz](https://graphviz.gitlab.io/download/) to use **diagrams**. After installing graphviz (or already have it), install the **diagrams**.
> macOS users can download the Graphviz via `brew install graphviz` if you're using [Homebrew](https://brew.sh).
> macOS users can download the Graphviz via `brew install graphviz` if you're using [Homebrew](https://brew.sh). Similarly, Windows users with [Chocolatey](https://chocolatey.org) installed can run `choco install graphviz`.
```shell
# using pip (pip3)

@ -27,6 +27,19 @@ $ python diagram.py
It will generate an image file with single `EC2` node drawn as `simple_diagram.png` on your working directory, and open that created image file immediately.
## Jupyter Notebooks
Diagrams can be also rendered directly inside the notebook as like this:
```python
from diagrams import Diagram
from diagrams.aws.compute import EC2
with Diagram("Simple Diagram") as diag:
EC2("web")
diag
```
## Options
You can specify the output file format with `outformat` parameter. Default is **png**.

@ -71,9 +71,9 @@ Node classes list of onprem provider.
## onprem.queue
- **diagrams.onprem.queue.Activemq**
- **diagrams.onprem.queue.Activemq**, **ActiveMQ** (alias)
- **diagrams.onprem.queue.Kafka**
- **diagrams.onprem.queue.Rabbitmq**
- **diagrams.onprem.queue.Rabbitmq**, **RabbitMQ** (alias)
- **diagrams.onprem.queue.Zeromq**, **ZeroMQ** (alias)
## onprem.gitops

@ -1,6 +1,6 @@
[tool.poetry]
name = "diagrams"
version = "0.6.0"
version = "0.6.3"
description = "Diagram as Code"
license = "MIT"
authors = ["mingrammer <mingrammer@gmail.com>"]

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

Loading…
Cancel
Save