Skip to content

Commit c321231

Browse files
author
Alexander Furer
committed
interceptors diagram [skip ci]
1 parent f7eb469 commit c321231

File tree

5 files changed

+117
-25
lines changed

5 files changed

+117
-25
lines changed

README.adoc

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -281,32 +281,22 @@ Error handling interceptor has the highest precedence.
281281

282282
The way grpc interceptor works is that it intercepts the call and returns the server call listener, which in turn can intercept the request message as well, before forwarding it to the actual service call handler :
283283

284-
****
285-
`interceptor_1(interceptCall)` -> `interceptor_2(interceptCall)` -> `interceptor_3(interceptCall)` -> +
286-
`interceptor_1(On_Message)`-> `interceptor_2(On_Message)`-> `interceptor_3(On_Message)`-> +
287-
`actual service call`
288-
****
284+
image:./images/interceptors_001.png[]
285+
289286

290287
By setting `grpc.security.auth.fail-fast` property to `false` all downstream interceptors as well as all upstream interceptors (On_Message) will still be executed in case of authentication/authorization failure +
291288

292289
Assuming `interceptor_2` is `securityInterceptor` :
293290

294291
* For failed authentication/authorization with `grpc.security.auth.fail-fast=true`(default): +
295292
+
293+
image:./images/interceptors_002.png[]
296294

297-
****
298-
`interceptor_1(interceptCall)` -> `securityInterceptor(interceptCall)` - *Call is Closed* -> +++<del>+++ `interceptor_3(interceptCall)` -> +
299-
`interceptor_1(On_Message)`-> `securityInterceptor(On_Message)`->`interceptor_3(On_Message)`-> +
300-
`actual service call`+++</del>+++
301-
****
302295

303296
* For failed authentication/authorization with `grpc.security.auth.fail-fast=false`: +
304297
+
305-
****
306-
`interceptor_1(interceptCall)` -> `securityInterceptor(interceptCall)` -> `interceptor_3(interceptCall)` ->
307-
`interceptor_1(On_Message)`-> `securityInterceptor(On_Message)` - *Call is Closed* +++<del>+++-> `interceptor_3(On_Message)`-> +
308-
`actual service call`+++</del>+++
309-
****
298+
image:./images/interceptors_003.png[]
299+
310300

311301
=== Distributed tracing support (Spring Cloud Sleuth integration)
312302

images/interceptors.txt

Lines changed: 112 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,124 @@
1+
' to generate png files : download the latest jar from https://github.com/plantuml/plantuml/releases and run java -jar plantuml-1.2021.13.jar intercepts.txt
2+
13
@startdef(id=main)
2-
participant interceptor_1 $color
4+
participant $interceptorName1 as interceptor_1
5+
participant $interceptorName2 as interceptor_2
6+
participant $interceptorName3 as interceptor_3
7+
8+
[-> interceptor_1 : start call
9+
activate interceptor_1
10+
11+
interceptor_1 $arrow1_2 interceptor_2: $intStyle1_2 intercept $intStyle1_2
12+
activate interceptor_2
13+
14+
interceptor_2 $arrow2_3 interceptor_3: $intStyle2_3 intercept $intStyle2_3
15+
activate interceptor_3
16+
17+
interceptor_3 $arrow3_3 interceptor_3: $intStyle3_3 intercept $intStyle3_3
18+
return $intReturn2
19+
return $intReturn1
20+
21+
deactivate interceptor_3
22+
deactivate interceptor_2
23+
[<- interceptor_1 : $intResponseStyle return listener $intResponseStyle
24+
deactivate interceptor_1
25+
26+
327

4-
interceptor_1 -> interceptor_2 :intercept
5-
interceptor_2 -> interceptor_3 :intercept
6-
interceptor_3 -> interceptor_3 :intercept
28+
[-> interceptor_1 : $reqStyle request $reqStyle
29+
activate interceptor_1
30+
31+
interceptor_1 $msgArrow1_2 interceptor_2 :$msgStyle1_2 onMessage $msgStyle1_2
32+
activate interceptor_2
33+
34+
interceptor_2 $msgArrow2_3 interceptor_3 : $msgStyle2_3 onMessage $msgStyle2_3
35+
activate interceptor_3
36+
37+
interceptor_3 $msgArrow3 service : $msgStyle3 actual call $msgStyle3
38+
return $msgReturn2
39+
return $msgReturn1
40+
[<- interceptor_1 : $responseStyle response $responseStyle
41+
42+
deactivate interceptor_3
43+
deactivate interceptor_2
44+
deactivate interceptor_1
745

8-
interceptor_1 -> interceptor_2 :onMessage
9-
interceptor_2 -> interceptor_3 :onMessage
10-
interceptor_3 -> interceptor_3 :onMessage
11-
interceptor_3 -> service : actual call
1246
@enddef
1347

1448
@startuml
15-
!$color = "#red"
49+
!$arrow1_2 = "->"
50+
!$arrow2_3 = "->"
51+
!$arrow3_3 = "->"
52+
!$intStyle1_2 = ""
53+
!$intStyle2_3 = ""
54+
!$intStyle3_3 = ""
55+
!$msgArrow1_2 = "->"
56+
!$msgArrow2_3 = "->"
57+
!$msgArrow3 = "->"
58+
!$msgStyle1_2 = ""
59+
!$msgStyle2_3 = ""
60+
!$msgStyle3 = ""
61+
!$reqStyle = ""
62+
!$responseStyle = ""
63+
!$intResponseStyle = ""
64+
!$intReturn1 = ""
65+
!$intReturn2 = ""
66+
!$msgReturn1 = ""
67+
!$msgReturn2 = ""
68+
!$interceptorName1 = "interceptor_1"
69+
!$interceptorName2 = "interceptor_2"
70+
!$interceptorName3 = "interceptor_3"
71+
!includedef main
72+
@enduml
73+
74+
@startuml
75+
!$arrow1_2 = "->"
76+
!$arrow2_3 = "x->"
77+
!$arrow3_3 = "x->"
78+
!$intStyle1_2 = ""
79+
!$intStyle2_3 = "---"
80+
!$intStyle3_3 = "---"
81+
!$msgArrow1_2 = "x->"
82+
!$msgArrow2_3 = "x->"
83+
!$msgArrow3 = "x->"
84+
!$msgStyle1_2 = "---"
85+
!$msgStyle2_3 = "---"
86+
!$msgStyle3 = "---"
87+
!$reqStyle = "---"
88+
!$responseStyle = "---"
89+
!$intResponseStyle = "---"
90+
!$intReturn1 = "close call"
91+
!$intReturn2 = ""
92+
!$msgReturn1 = ""
93+
!$msgReturn2 = ""
94+
!$interceptorName1 = "interceptor_1"
95+
!$interceptorName2 = "securityInterceptor"
96+
!$interceptorName3 = "interceptor_3"
1697
!includedef main
1798
@enduml
1899

19100
@startuml
20-
!$color = "#Blue"
101+
!$arrow1_2 = "->"
102+
!$arrow2_3 = "->"
103+
!$arrow3_3 = "->"
104+
!$intStyle1_2= ""
105+
!$intStyle2_3= ""
106+
!$intStyle3_3= ""
107+
!$msgArrow1_2 = "->"
108+
!$msgArrow2_3 = "x->"
109+
!$msgArrow3 = "x->"
110+
!$msgStyle1_2 = ""
111+
!$msgStyle2_3 = "---"
112+
!$msgStyle3 = "---"
113+
!$reqStyle = ""
114+
!$responseStyle = "---"
115+
!$intResponseStyle= ""
116+
!$intReturn1 = ""
117+
!$intReturn2 = ""
118+
!$msgReturn1 = "close call"
119+
!$msgReturn2 = ""
120+
!$interceptorName1 = "interceptor_1"
121+
!$interceptorName2 = "securityInterceptor"
122+
!$interceptorName3 = "interceptor_3"
21123
!includedef main
22124
@enduml

images/interceptors_001.png

18.2 KB
Loading

images/interceptors_002.png

21.6 KB
Loading

images/interceptors_003.png

20.9 KB
Loading

0 commit comments

Comments
 (0)