This is the 10th day of my participation in the November Gwen Challenge. Check out the event details: The last Gwen Challenge 2021
I was thinking about Monday to find a good consultation with Longfei, but fortunately, these two days are very busy longfei. Because a new project has been started, iteration 0 of the project is being prepared. Finally, on Wednesday, Longxi had time and could not wait to ask:
I follow the buildctl build command to c.c.invoke in control.pb.go, and the editor can’t help me locate the function below.I don’t know where to start.
Long Fei listened to, think about it, quickly said, should be the last step of the front-end request, issued GRPC request. And then there’sbuildkitd
Request received, processing started. Say open source, quickly findbuildkit/cmd/buildkitd/main.go
themain
Function GRPC service related code:
As mentioned in the code, first create a Controller, then register the Controller with the service, and finally start the service, in this case the GRPC service. This allows you to receive and process requests from the front end. Learned from the front, and the request of the link is moby buildkit. V1. Control/Solve, we can guess the service address that is registered in advance, right? So let’s look at controller.register (…) This operation.
As we jump step by step, the method “Solve” appears:
And the processing method shown is_Control_Solve_Handler
:What the code shows here is that it finds the server and callsSolve
Methods.
Then let’s go back to the object created by the newController. Since this object is registered with the server, let’s verify that this object has the Solve method. If we want to ensure, we can verify other methods, such as DiskUsage and ListWorkers.
After a simple search, sure enough:
The controller method does contain the object we want, and we’re finally connected, so it looks like we can continue exploring from here.
Yuan Xiaobai thanked Longfei while, while the heart can not help respect.
It’s the end of the tunnel.
This is the experience of looking at source code, encountering problems, solving problems, encountering problems again, solving problems again, and so on. This is also why people don’t like to read other people’s source code, a lot of times, rather than look at someone else’s code, you want to write from scratch.
Where will Yuan Xiaobai be stuck next time? Don’t worry, we’ll see soon enough.