分层调用图绘制指南

介绍如何绘制Biz-SIP业务中台各模块间调用的分层调用图。

Biz-SIP分层调用图是说明基于Biz-SIP中间件构建的分布式系统之间的调用关系,分层调用图是采用PlantUML(http://plantuml.com)来绘制的。
下例是HelloWorld项目的分层调用图示例:

@startuml
left to right direction

() openapi as "开放OpenAPI接口"


class sink.SampleSinkBeanSink {
	sample-sink-bean-sink
	--
	sink-bean类型的sink例子
}
interface sink.SampleBeanSink <<HelloInterface>> {
	sample-bean-sink
	--
	bean类型的sink例子
}

interface sink.SampleRabbitmqBeanSink <<HelloInterface>> {
	sample-rabbitmq-bean-sink
	--
	bean类型的rabbitmq异步sink例子
}

interface app.SampleBeanService {
	app/sample-bean-service
	--
	bean-service类型的app服务例子
}

class app.SampleAppBeanService {
	app/sample-app-bean-service
	--
	app-bean-service类型的app服务例子
}

abstract app.Sink1 {
	sink/sample-sink-bean-service
	--
	sample-sink-bean-sink
}

class source.SampleRestController {
	--
	RESTful接口的source例子
}

namespace sink {
}

namespace app {
}

namespace source{
}

openapi --> app.SampleBeanService
openapi --> app.SampleAppBeanService
openapi --> app.Sink1

source.SampleRestController --> app.SampleBeanService

app.SampleBeanService --> sink.SampleSinkBeanSink
app.SampleBeanService --> sink.SampleBeanSink
app.SampleBeanService ..> sink.SampleRabbitmqBeanSink
app.SampleAppBeanService --> sink.SampleBeanSink
app.Sink1 --> sink.SampleSinkBeanSink

@enduml

下例是xbank项目的分层调用图示例:

@startuml
left to right direction

interface sink.CustomerSinkService {
	customer-sink
	--
	客户域sink服务
}

interface sink.AccountSinkService {
	account-sink
	--
	账户域sink服务
}

class sink.Payment1SinkService {
	payment1-sink
	--
	支付域sink服务(简单处理)
}

class sink.Payment2SinkService {
	payment2-sink
	--
	支付域sink服务(复杂处理)
}

interface app.PersonalAppService {
	app/personal
	--
	个人业务app服务
}
abstract app.customer {
	sink/customer
	--
	customer-sink
}

abstract app.account {
	sink/account
	--
	account-sink
}

abstract app.payment1 {
	sink/payment1
	--
	patyment1-sink
}

class source.OpenapiController {
	--
	OpenAPI接口的source
}

class source.XmlController {
	xml-source
	--
	XML接口的source
}

namespace sink {
}

namespace app {

}

namespace source{

}

app.customer --> sink.CustomerSinkService
app.account --> sink.AccountSinkService
app.payment1 --> sink.Payment1SinkService
app.PersonalAppService --> sink.CustomerSinkService
app.PersonalAppService --> sink.AccountSinkService
app.PersonalAppService --> sink.Payment1SinkService
app.PersonalAppService --> sink.Payment2SinkService
app.PersonalAppService ..> app.PersonalAppService

source.OpenapiController --> app.PersonalAppService
source.OpenapiController --> app.payment1
source.XmlController --> app.PersonalAppService
source.XmlController --> app.payment1

@enduml

下面将具体给出绘制步骤和绘制说明。

1. 绘制层

Biz-SIP中间件分为source层、app层、sink层,这3层在PlantUML中用namespace来绘制:

@startuml
left to right direction

namespace sink {
}

namespace app {
}

namespace source{
}

@enduml

2. 绘制sink服务

sink层中的sink服务,绘制举例如下:

@startuml
left to right direction

class sink.SampleService1 {
	sample-service1-sink
	--
	sink服务描述...
}

interface sink.SampleService2 <<SampleInterface>> {
	sample-service2-sink
	--
	sink服务描述...
}

namespace sink {
}

namespace app {
}

namespace source{
}

@enduml

sink服务在绘制时,标签统一都用类名:

  • sink-bean类型sink服务用class元素,第1分组写sink-id,第2分组写sink描述;
  • bean类型sink服务用interface元素(在类名上要加上实现的接口名),第1分组写sink-id,第2分组写sink描述。


3. 绘制app服务

app层中的app服务,绘制举例如下:

@startuml
left to right direction

class app.SampleAppBeanService {
	app/sample-app-bean-service
	--
	app服务描述...
}

interface app.SampleBeanService <<SampleBeanInterface>> {
	app/sample-bean-service
	--
	app服务描述...
}

abstract app.Sink1 {
	sink/sample-service2-sink
	--
	sample-service2-sink
}

namespace sink {
}

namespace app {
}

namespace source{
}

@enduml

app服务在绘制时,app-bean-service和bean-service类型标签统一都用类名,sink-service类型用Sink1、Sink2…来作为标签:

  • app-bean-service类型app服务用class元素,第1分组写service-id,第2分组写app服务描述;
  • bean-service类型app服务用interface元素(在类名上要加上实现的接口名),第1分组写service-id,第2分组写app服务描述。
  • sink-service类型app服务用abstract元素,第1分组写service-id,第2分组写关联的sink-id。

4. 绘制source服务

source层中的source服务,绘制举例如下:

@startuml
left to right direction

class source.Sample1SourceController {
	source1
	--
	source1服务描述...
}


namespace sink {
}

namespace app {
}

namespace source{
}

@enduml

source服务在绘制时,标签统一都用类名,第1分组写source-id(如果有的话),第2分组写source服务描述。

5. 绘制source调用app的关系

通过查找source服务类中所有SourceClientFactory.getAppServiceClient()方法,找出source服务类调用app服务的关系,并绘制之间的调用关系:

@startuml
left to right direction

class source.Sample1SourceController {
	source1
	--
	source1服务描述...
}

class app.SampleAppBeanService {
	app/sample-app-bean-service
	--
	app服务描述...
}

interface app.SampleBeanService <<SampleBeanInterface>> {
	app/sample-bean-service
	--
	app服务描述...
}

abstract app.Sink1 {
	sink/sample-service2-sink
	--
	sample-service2-sink
}

namespace sink {
}

namespace app {
}

namespace source{
}

source.Sample1SourceController --> app.SampleAppBeanService
source.Sample1SourceController --> app.Sink1

@enduml

6. 绘制app调用sink的关系

通过查找app服务类中所有AppClientFactory.getSinkClient()方法,找出app服务类调用sink服务的关系,并绘制之间的调用关系,对于微服务(rest)调用采用实线,RabbitMQ异步调用采用虚线:

@startuml
left to right direction

class source.Sample1SourceController {
	source1
	--
	source1服务描述...
}

class app.SampleAppBeanService {
	app/sample-app-bean-service
	--
	app服务描述...
}

interface app.SampleBeanService <<SampleBeanInterface>> {
	app/sample-bean-service
	--
	app服务描述...
}

abstract app.Sink1 {
	sink/sample-service2-sink
	--
	sample-service2-sink
}

class sink.SampleService1 {
	sample-service1-sink
	--
	sink服务描述...
}

interface sink.SampleService2 <<SampleInterface>> {
	sample-service2-sink
	--
	sink服务描述...
}

namespace sink {
}

namespace app {
}

namespace source{
}

source.Sample1SourceController --> app.SampleAppBeanService
source.Sample1SourceController --> app.Sink1
app.SampleAppBeanService --> sink.SampleService1
app.SampleAppBeanService --> sink.SampleService2
app.Sink1 --> sink.SampleService2
@enduml

7. 绘制app延迟调用app服务的关系

通过查找app服务类中所有AppClientFactory.getDelayAppServiceClient()方法,找出app服务类延迟调用app服务的关系,并绘制之间的调用关系,调用关系用虚线表示:

@startuml
left to right direction

class source.Sample1SourceController {
	source1
	--
	source1服务描述...
}

class app.SampleAppBeanService {
	app/sample-app-bean-service
	--
	app服务描述...
}

interface app.SampleBeanService <<SampleBeanInterface>>{
	app/sample-bean-service
	--
	app服务描述...
}

abstract app.Sink1 {
	sink/sample-service2-sink
	--
	sample-service2-sink
}

class sink.SampleService1 {
	sample-service1-sink
	--
	sink服务描述...
}

interface sink.SampleService2 <<SampleInterface>> {
	sample-service2-sink
	--
	sink服务描述...
}

namespace sink {
}

namespace app {
}

namespace source{
}

source.Sample1SourceController --> app.SampleAppBeanService
source.Sample1SourceController --> app.Sink1
app.SampleAppBeanService --> sink.SampleService1
app.SampleAppBeanService --> sink.SampleService2
app.Sink1 --> sink.SampleService2
app.SampleAppBeanService ..> app.Sink1
app.SampleAppBeanService ..> app.SampleAppBeanService

@enduml

上一页
下一页