[API advanced road] unimaginable! There are so many treasures in the hard disk of elder code farmer

Time:2020-11-26

Abstract:By making the required tool library as a cloud container application, the CCE engine is used to call the container application in the cloud container engine through the API gateway. It not only conforms to the original development trend of cloud, but also can flexibly expand the capacity at any time to meet the needs of large-scale development of the company.

After the company held the mid year meeting, everyone’s work began to return to normal. We also continued to code (write bugs) step by step. Occasionally, I saw the boss and the boss drinking tea through the office glass. I felt that since last time I affected the strategic direction of the company, the boss has been chatting with the boss more and more times, which seems to be “plotting” something.

Just thinking about it, the boss suddenly turned to look at me, four eyes relative or some embarrassment, more embarrassing is the boss motioned me to go.

The boss said: “the company wants to set up a technical committee. I’ll be the chairman. You will be the vice chairman and be responsible for management. The core responsibility is to deposit the company’s technical assets and improve the ability of all R & D personnel. You can think about how to act.”

“What? I am the vice chairman of the technical committee? What should be done to settle the company’s technical assets? What is technical assets? ” After returning to my seat, I seem to have changed back to the boy who used to be so excited. I opened the hard disk and saw the resources I had accumulated over the years.

In my hard disk, I have stored all kinds of programs, applications and tools that I have written over the years. This is called technical assets. If you take out the company’s data and the treasures in your hard disk to make a reusable and callable tool library, how much less code can be written.

But how can this be achieved?

Yes! Before inHuawei cloud official websiteI saw one on theCCE cloud container engine

We can make the tool library as a cloud container application,Use CCE engine to call container application in cloud container engine through API gateway. In this way, it not only conforms to the development trend of cloud, but also can flexibly expand the capacity at any time to meet the needs of large-scale development of the company.

Do what you say. Write a plan for the boss first. After I finished writing the idea, I focused on the method of using API gateway to access the container application in CCE cloud container engine. After all, it is still to use these technical assets in my work.

[API advanced road] unimaginable! There are so many treasures in the hard disk of elder code farmer

Method of accessing workload in CCE through API gateway

[API advanced road] unimaginable! There are so many treasures in the hard disk of elder code farmer

1、 Prepare CCE workload information

Before opening the workload of the container to the public through the API gateway, it is necessary to obtain the information as shown in the figure below in the CCE service console to create the cluster and workload. Pay attention to the access mode of the workload, which needs to be configured as “node access”.

1. Query access port

[API advanced road] unimaginable! There are so many treasures in the hard disk of elder code farmer

2. Query the name of the elastic server to which the instance belongs in the workload

[API advanced road] unimaginable! There are so many treasures in the hard disk of elder code farmer

[API advanced road] unimaginable! There are so many treasures in the hard disk of elder code farmer

2、 Create VPC channel

1. Log in to the console and enter the API gateway service.

2. In the “basic information” interface of “create VPC channel”, click “create fast channel”, enter the information as shown in the figure, and other parameters remain the default values.

[API advanced road] unimaginable! There are so many treasures in the hard disk of elder code farmer

3. Add instance nodes of CCE workload that need to be accessed through API gateway. Multiple instances can be added, and the API gateway supports the load balancing function.

[API advanced road] unimaginable! There are so many treasures in the hard disk of elder code farmer

Click Finish to add the VPC channel.

[API advanced road] unimaginable! There are so many treasures in the hard disk of elder code farmer

3、 Open API

1. Create group

[API advanced road] unimaginable! There are so many treasures in the hard disk of elder code farmer

2. Create the API. In the “basic information” interface of “new API”, enter the information as shown in the figure below.

[API advanced road] unimaginable! There are so many treasures in the hard disk of elder code farmer

[API advanced road] unimaginable! There are so many treasures in the hard disk of elder code farmer

In the “define API request” interface, enter the information as shown in the figure below.

[API advanced road] unimaginable! There are so many treasures in the hard disk of elder code farmer

In the “define back end service” interface, enter the information as shown in the figure below.

[API advanced road] unimaginable! There are so many treasures in the hard disk of elder code farmer

In the “return result basic definition” interface, enter “successful response example”. In this example, the input content is for reference only and has no practical effect. Click Finish to complete the API creation.

[API advanced road] unimaginable! There are so many treasures in the hard disk of elder code farmer

3. Debug API. Returns 200, indicating that the call was successful.

[API advanced road] unimaginable! There are so many treasures in the hard disk of elder code farmer

[API advanced road] unimaginable! There are so many treasures in the hard disk of elder code farmer

4. Publish API

[API advanced road] unimaginable! There are so many treasures in the hard disk of elder code farmer

[API advanced road] unimaginable! There are so many treasures in the hard disk of elder code farmer

4、 Call API

1. In the API details interface, copy the “API URL”.

[API advanced road] unimaginable! There are so many treasures in the hard disk of elder code farmer

[API advanced road] unimaginable! There are so many treasures in the hard disk of elder code farmer

2. Open your browser and paste the address of “API URL” in the address bar. When the API request is successful, the following interface is displayed. If you want to set the number of API calls over a period of time, set the flow control policy.

[API advanced road] unimaginable! There are so many treasures in the hard disk of elder code farmer

The boss was very satisfied after reading the plan, and he wanted to take this as the first key project after the establishment of the technical committee, apply for a special project fund, and set up a project team for me to complete with the team. Now I: look far away, firm eyes, well, it’s time to show real technology~

It is understood thatApig gatewayThe sharing version and exclusive version are opened. Developers can apply for experience demo and enter the shared version for experience operation.

Recommended Today

The course of using Chinese software of poedit Pro

Poedit pro (formerly known as poedit) is a free (professional version charge), open source and cross platform gettext class (. Po format, gettext is used in the application program for program internationalization) International Translation editor. It is also one of the most widely used software of the same type. At present, it is available in […]