MCPcopy
hub / github.com/apache/devlake / GetApiClient

Method GetApiClient

backend/helpers/pluginhelper/api/remote_api_helper.go:131–150  ·  view source on GitHub ↗
(connection plugin.CacheableConnection)

Source from the content-addressed store, hash-verified

129)
130
131func (r *RemoteApiHelper[Conn, Scope, ApiScope, Group]) GetApiClient(connection plugin.CacheableConnection) (*ApiClient, errors.Error) {
132 key := connection.GetHash()
133 // empty key means no connection reuse
134 if key == "" {
135 r.logger.Info("No api client reuse")
136 return NewApiClientFromConnection(gocontext.TODO(), r.basicRes, connection)
137 }
138
139 if client, ok := r.httpClientCache[key]; ok {
140 r.logger.Info("Reused api client")
141 return client, nil
142 }
143 r.logger.Info("Creating new api client")
144 newClient, err := NewApiClientFromConnection(gocontext.TODO(), r.basicRes, connection)
145 if err != nil {
146 return nil, err
147 }
148 r.httpClientCache[key] = newClient
149 return newClient, nil
150}
151
152func (r *RemoteApiHelper[Conn, Scope, ApiScope, Group]) ProxyApiGet(conn plugin.CacheableConnection, path string, query url.Values) (*plugin.ApiResourceOutput, errors.Error) {
153 apiClient, err := r.GetApiClient(conn)

Callers 1

ProxyApiGetMethod · 0.95

Calls 3

GetHashMethod · 0.65
InfoMethod · 0.65

Tested by

no test coverage detected