Source Parsing 7 Layer Traffic Governance, Interface Limit
Author Profile: was a fester of an open source community committed to embracing open sources and hoping to interact with each other’s open-source enthusiasts for progress and growth.
Writing Time: 20 April 2022
Overview
The purpose of this document is to analyze the implementation of the interface flow
Prerequisite:
Document content refers to the following version of the code
Mosn d11b5a638a137045c2fb03d9d8ca36ecc0def11 (Division Develop)
Source analysis
Overall analysis
Reference to
https://mosn.io/docs/concept/extensions/
Mosn Stream Filter Extension
Code in: flowcontrol代码
stream_filter_factory.go analysis
This class is a factory class to create StreamFilter.
Some constant values are defined for default values
Defines the restricted stream config class to load yaml definition and parse production corresponding functions
init() Inner initialization is the storage of name and corresponding constructor to the filter blocking plant map
Highlight createRpcFlowControlFilterFactory Production rpc Current Factory
Before looking at streamfilter, we see how factory classes are producing restricted streamers
Limit the streaming to the restricted stream chain structure to take effect in sequential order.
CreateFilterChain method adds multiple filters to the link structure
We can see that this interface is achieved by a wide variety of plant types, including those that we are studying today.
Stream_filter.go Analysis
Overall process:
Finally, we look back at the overall process progress:
-
Starting from the initialization function of stream_filter_factory.go, the program inserted createRpcFlowControlFilterFactory.
-
Mosn created a filter chain (code positionfactory.go) by circulating CreateFilterChain to include all filters in the chain structure, including our master restricted streaming today.
-
Create Limiter NewStreamFilter().
-
OnReceive() and eventually by sentinel (whether the threshold has been reached, whether to release traffic or stop traffic, StreamFilterStop or StreamFilterContinue).