1. Functions completed by gen_container Action Mode
Gen_container features: Container startup and shutdown, the same asynchronous message distribution processing of messages, obtaining the number of container instances, obtaining the list of running instances in the container, enabling the instance hot plugging to dynamically add and delete instances, creating and monitoring instances, management and Maintenance after destruction and exit.
2. This behavior mode is divided into two queues: online and offline. An instance is running in the current container. The offline queue stores all the instances that can be managed by the current container and stores them in beanlist as a list and saved in state.
3. gen_container action mode process
4. Summary of development behavior patterns.
The development behavior mode must consider the behavior mode itself (Template) and the callback module that implements the behavior mode. You need to carefully consider how the callback module is called. In the behavior mode module, hold the module name of the callback module when it is started, and then enter the polling of the received message. After receiving the message, by matching the message and executing the callback function corresponding to the callback module, You can associate the common function with the callback function. To some extent, the behavior pattern is a manifestation of polymorphism. A common function can be mapped to the execution of different callback functions.
Erlang custom gen_container behavior mode development