Group Chat Service--proxy mode or adapter mode

Source: Internet
Author: User

The palest ink is better than best memory--good memory than bad writing. 2014 . Business Scenario:

At that time, company product A (line a) is ready to add Group Chat (group) features. Also, product B, C ... This feature is also added (it is now true that several lines of business are connected to this service ~).

Group chat preliminary function like: Create a group, modify the group information, invite users into the group, users apply for the group, into the group audit, user retreat, kick people, group activities and other basic functions.

However, if more than one line of business access, may be each product line of business some "play" different, such as: users apply to the group. A product may require users to complete the profile information can be applied to the group, and B product business requirements of the user city, industry and other more specific restrictions, product C business requirements into the group also deduct user points-that is, the rules are not the same. Second, analysis & Solutions:

According to the basic principle of "static and dynamic separation", we decided to use basic function as service. Specific "Play" has a line of business services to complete the individual:

Both line-of-business systems and operational systems invoke public services through RPC. third, the realization of & issues:

1. Database design:
The number of groups is limited-not very large (even if 10 lines of business, the current company is unlikely to ~); The number of each group is quantitative. Therefore, do not press the business sub-Library, nor the need to split the table. So each table has an app field that identifies the business data source.

2. Question:
How the public service knows the calling source better. Writes or finds the specified business-related record data based on this source identity.

A. Public services exposed service each method has one more app enumeration parameter that lets callers pass in. Such as:

B. or inject a dependency into each serviceimpl:

A means that each method of the caller has to pass in the app parameters more than once, even if the entire line of business explicitly affirms that the business call only passes that value;
B is not convenient when operating system calls because the source is uncertain-the operating system manages all lines of business, such as incoming group audits.

Considering the "current" interface is not many, so adopt a scheme, and then add an agent layer in the service layer (static proxy), the agent layer relies on the app, the business system calls the configuration injected once the app, the operating system does not through the proxy, direct call. Iv. thinking:

Static agent, a layer more, and static agent has obvious shortcomings-interface changes, proxy class, the implementation of the class are to be changed; Foreign service, to achieve a lot of proxy class;

Dynamic agent is good to implement it. or adapter mode is better.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.