@@ -61,28 +61,29 @@ func (h *handler) streamHandler(_ interface{}, serverStream grpc.ServerStream) e
61
61
if ! ok {
62
62
return status .Errorf (codes .Internal , "ServerTransportStream not exists in context" )
63
63
}
64
+
64
65
// full method name has the form /service/method, we want the service
65
66
serviceName := strings .Split (fullMethodName , "/" )[1 ]
66
- excluded := contains (h .disruption .Excluded , serviceName )
67
- if ! excluded {
68
- if h .disruption .ErrorRate > 0 && rand .Float32 () <= h .disruption .ErrorRate {
69
- h .metrics .Inc (protocol .MetricRequestsFaulted )
70
- return h .injectError (serverStream )
71
- }
67
+ if contains (h .disruption .Excluded , serviceName ) {
68
+ h .metrics .Inc (protocol .MetricRequestsExcluded )
69
+ return h .transparentForward (serverStream )
70
+ }
72
71
73
- // add delay
74
- if h .disruption .AverageDelay > 0 {
75
- h .metrics .Inc (protocol .MetricRequestsFaulted )
72
+ if rand .Float32 () < h .disruption .ErrorRate {
73
+ h .metrics .Inc (protocol .MetricRequestsFaulted )
74
+ return h .injectError (serverStream )
75
+ }
76
76
77
- delay := int64 (h .disruption .AverageDelay )
78
- if h .disruption .DelayVariation > 0 {
79
- variation := int64 (h .disruption .DelayVariation )
80
- delay = delay + variation - 2 * rand .Int63n (variation )
81
- }
82
- time .Sleep (time .Duration (delay ))
77
+ // add delay
78
+ if h .disruption .AverageDelay > 0 {
79
+ h .metrics .Inc (protocol .MetricRequestsFaulted )
80
+
81
+ delay := int64 (h .disruption .AverageDelay )
82
+ if h .disruption .DelayVariation > 0 {
83
+ variation := int64 (h .disruption .DelayVariation )
84
+ delay = delay + variation - 2 * rand .Int63n (variation )
83
85
}
84
- } else {
85
- h .metrics .Inc (protocol .MetricRequestsExcluded )
86
+ time .Sleep (time .Duration (delay ))
86
87
}
87
88
88
89
return h .transparentForward (serverStream )
0 commit comments