From 461b86adc78d41355d78fd6b890f5bc9a115f147 Mon Sep 17 00:00:00 2001 From: okJiang <819421878@qq.com> Date: Fri, 20 Dec 2024 13:30:06 +0800 Subject: [PATCH] client: move `WithCallerComponent` from `RPCClient` to `Client` (#8943) ref tikv/pd#8593 Signed-off-by: okJiang <819421878@qq.com> Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com> --- client/client.go | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/client/client.go b/client/client.go index 272d6c597b5..2fc9bd3ef0d 100644 --- a/client/client.go +++ b/client/client.go @@ -102,16 +102,6 @@ type RPCClient interface { // SetExternalTimestamp sets external timestamp SetExternalTimestamp(ctx context.Context, timestamp uint64) error - // WithCallerComponent returns a new RPCClient with the specified caller - // component. Caller component refers to the specific part or module within - // the process. You can set the component in two ways: - // * Define it manually, like `caller.Component("DDL")`. - // * Use the provided helper function, `caller.GetComponent(upperLayer)`. - // The upperLayer parameter specifies the depth of the caller stack, - // where 0 means the current function. Adjust the upperLayer value based - // on your needs. - WithCallerComponent(callerComponent caller.Component) RPCClient - router.Client tso.Client metastorage.Client @@ -138,6 +128,15 @@ type Client interface { // UpdateOption updates the client option. UpdateOption(option opt.DynamicOption, value any) error + // WithCallerComponent returns a new Client with the specified caller + // component. Caller component refers to the specific part or module within + // the process. You can set the component in two ways: + // * Define it manually, like `caller.Component("DDL")`. + // * Use the provided helper function, `caller.GetComponent(upperLayer)`. + // The upperLayer parameter specifies the depth of the caller stack, + // where 0 means the current function. Adjust the upperLayer value based + // on your needs. + WithCallerComponent(callerComponent caller.Component) Client // Close closes the client. Close() @@ -1364,7 +1363,7 @@ func (c *client) respForErr(observer prometheus.Observer, start time.Time, err e } // WithCallerComponent implements the RPCClient interface. -func (c *client) WithCallerComponent(callerComponent caller.Component) RPCClient { +func (c *client) WithCallerComponent(callerComponent caller.Component) Client { newClient := *c newClient.callerComponent = callerComponent return &newClient