利用PlantUML可以非常方便的畫各種UML圖灿巧,下面是我畫的KafkaProducer的類圖赶袄。
最方便的是這個(gè)圖是用幾行代碼表達(dá)出來的揽涮。
@startuml
!includeurl https://raw.githubusercontent.com/ebbypeter/Archimate-PlantUML/master/Archimate.puml
title Kafka Producer
' KafkaProducer Elements
class KafkaProducer
class ProducerMetadata
class ProducerConfig
class DefaultPartitioner
class RecordAccumulator {
ConcurrentMap<TopicPartition, Deque<ProducerBatch>> batches
}
class Sender
' RecordAccumulator Elements
class ProducerBatch
class TopicPartition
' Sender Elements
class KafkaClient
' KafkaProducer Relationships
Rel_Serving_Up(KafkaProducer, ProducerMetadata, "")
Rel_Serving_Up(KafkaProducer, ProducerConfig, "")
Rel_Serving_Up(KafkaProducer, DefaultPartitioner, "")
Rel_Serving_Up(KafkaProducer, RecordAccumulator, "")
Rel_Serving_Up(KafkaProducer, Sender, "")
' RecordAccumulator Relationships
Rel_Serving_Up(RecordAccumulator, ProducerBatch, "")
Rel_Serving_Up(RecordAccumulator, TopicPartition, "")
' Sender Relationships
Rel_Serving_Up(Sender, RecordAccumulator, "")
Rel_Serving_Up(Sender, ProducerMetadata, "")
Rel_Serving_Up(Sender, KafkaClient, "")
@enduml
我是用的intellij idea的plantuml插件畫的。sublime和vscode都有插件支持饿肺。
下次我再畫一下KafkaProducer的方法調(diào)用序列圖sequence uml蒋困。