(connection plugin.CacheableConnection)
| 129 | ) |
| 130 | |
| 131 | func (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 | |
| 152 | func (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) |
no test coverage detected