docs: improve example about custom node usage

pull/25/head
Daniel Ferrari 6 years ago
parent 76021c66ea
commit b3e5dad821
No known key found for this signature in database
GPG Key ID: 608F584627030FF0

@ -170,18 +170,33 @@ with Diagram("Stateful Architecture", show=False):
![stateful architecture diagram](/img/stateful_architecture_diagram.png) ![stateful architecture diagram](/img/stateful_architecture_diagram.png)
## Using Custom Images ## RabbitMQ Consumers with custom nodes
```python ```python
from diagrams import Diagram from urllib.request import urlretrieve
from diagrams import Cluster, Diagram
from diagrams.custom import Custom from diagrams.custom import Custom
from diagrams.aws.database import Aurora
from diagrams.k8s.compute import Pod from diagrams.k8s.compute import Pod
with Diagram("Custom Node Example", show=False): # Download an image to be used into a Custom Node class
pod = Pod("pod") rabbitMQ_url = "https://jpadilla.github.io/rabbitmqapp/assets/img/icon.png"
node = Custom("service", "/img/diagrams.png") rabbitMQ_icon = "rabbitmq.png"
urlretrieve(rabbitMQ_url, rabbitMQ_icon)
with Diagram("Broker Consumers", show=False):
with Cluster("Consumers"):
consumers = [
Pod("worker"),
Pod("worker"),
Pod("worker")
]
queue = Custom("Message queue", rabbitMQ_icon)
node >> pod queue >> consumers >> Aurora("Database")
```` ````
![custom node diagram](/img/custom_node_example_diagram.png) ![rabbitmq consumers diagram](/img/rabbitmq_consumers_diagram.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Loading…
Cancel
Save