What is the function of server.go and client.go in the pd source?

I study the TIKV and PD and their source code.

On the source code of PD, I got confused by server.go and client.go. I think the PD as a server that scheduling TiKV instances. How about the function of PD Client?

I am Looking forward to experts, thank you!

Thanks for starting this thread @wang !

I categorize this post with scheduling which PD project aims at.

May @nolouch @disksing @hundundm can answer your question.

From what I can say, PD is a server so when you talk to it, you need a client. PD client is used for retrieving anything you’d like PD provides such as timestamp (TSO), cluster ID, region by ID, etc.

The PD client is used by TiDB and other components (such as BR) to connect to PDs, wrapping raw grpc requests and internally supporting the logic of locating the PD leader and switching connections.

I’m glad you’re paying attention to the details of the PD implementation. We will soon launch a PD source code reading articles on pingcap’s official blog, so stay tuned :grinning:

Thank you @disksing and @tison! So I think the PD client should maybe an app which can connect to pd server and get some information from the pd server or make some operation for pd server.

Hi @wang,

I do the reformat work for your post, you may try to format message better the next time.

For your statements, it is true.