Golang Quick Start Code Combat

Source: Internet
Author: User
Tags learn golang
This is a creation in Article, where the information may have evolved or changed.

The work encountered in the previous period golang of the project, a little bit of interest in it, intends to seriously study, just in the building mysql of the main environment when found that if using an agent to test their own will be more convenient (mainly to build wheels), so the time to use golang Wrote a TCP agent (absolutely free time, very full of work)

Demand

    1. Because it is to learn golang, so in order to implement the basic functions of the agent as far as possible to use the basic knowledge of Golang, do not come up to take other people's things, not conducive to tamping the foundation
    2. Not really simple to play, learn a thing in addition to enrich the brain, but also in order to have practical use, so it is necessary to master the engineering process
    3. The program is not too complicated, after all, this is my first golang project, more days

Design

The structure diagram is as follows:

+----------+                                           +------------+|            Client |<--------+ |   |+----------+ +-------->+-----+<--------------->|                               Server |     |                 |            |     |+----------+                   |                 |  +------------+|     Client |<----------------->|     |+----------+                   |                               |     |                 |  +------------++----------+                   |                 L |            |  ||  Client |^----------------->|   B |<--------------->|  Server |+----------+ |                 S |            |                               |     |                 |     +------------++----------+                   |  ||     Client |<----------------->|     |+----------+                   |                 |     +------------+                               |                 | |            |+----------+ +--------->+-----+<--------------->|  Server | |            Client |<-------+ |           |+----------+                                           +------------+

The most common load-balancing mode, but there are several points that need to be supported:
1. Support different scheduling strategies, such as: rotation, random, Iphash
2. To have a heartbeat check mechanism, timely remove the problematic backend server, but also to recover at the time of server recovery
3. Simple monitoring, easy to see the backend Server Agent situation and the client connection situation
4. Configuration of parameters, easy to modify
5 ..... Follow up and add ...

Realize

Github:easyproxy
Welcome to Exchange ~

Summarize

At the end of the easyproxy first edition, more in-depth study,,,, and slice map channel struct interface Other structures, but also play the next Golang 协程 , 反射 , and 多态 other characteristics, incidentally mastered under its engineering should pay attention 包循环引入 to, debug, and 打包发布 other issues
Feel now reading also not empty, see Open source Code also more Mulligan ~

Related Article

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.