(taskCtx plugin.TaskContext, connection *models.TapdConnection)
| 25 | ) |
| 26 | |
| 27 | func NewTapdApiClient(taskCtx plugin.TaskContext, connection *models.TapdConnection) (*api.ApiAsyncClient, errors.Error) { |
| 28 | // create synchronize api client so we can calculate api rate limit dynamically |
| 29 | apiClient, err := api.NewApiClientFromConnection(taskCtx.GetContext(), taskCtx, connection) |
| 30 | if err != nil { |
| 31 | return nil, err |
| 32 | } |
| 33 | |
| 34 | // create rate limit calculator |
| 35 | rateLimiter := &api.ApiRateLimitCalculator{ |
| 36 | UserRateLimitPerHour: connection.RateLimitPerHour, |
| 37 | } |
| 38 | asyncApiClient, err := api.CreateAsyncApiClient( |
| 39 | taskCtx, |
| 40 | apiClient, |
| 41 | rateLimiter, |
| 42 | ) |
| 43 | if err != nil { |
| 44 | return nil, err |
| 45 | } |
| 46 | |
| 47 | return asyncApiClient, nil |
| 48 | } |
no test coverage detected