mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
refactor(http): implement shared transport and clients (#1288)
* fix(http): flip to a shared transport and clients * nice threads * that is terrible * fake uri for magnet * lazy locking * why bother with r's * flip magic params to struct * refactor(http-clients): use separate clients with shared transport * refactor(http-clients): add missing license header * refactor(http-clients): defer and fix errors --------- Co-authored-by: ze0s <ze0s@riseup.net>
This commit is contained in:
parent
2a4fb7750b
commit
3234f0d919
48 changed files with 537 additions and 391 deletions
|
@ -92,7 +92,7 @@ func (s *apiService) AddClient(indexer string, settings map[string]string) error
|
|||
if !ok || key == "" {
|
||||
return errors.New("api.Service.AddClient: could not initialize btn client: missing var 'api_key'")
|
||||
}
|
||||
s.apiClients[indexer] = btn.NewClient("", key)
|
||||
s.apiClients[indexer] = btn.NewClient(key)
|
||||
|
||||
case "ptp":
|
||||
user, ok := settings["api_user"]
|
||||
|
@ -128,7 +128,7 @@ func (s *apiService) AddClient(indexer string, settings map[string]string) error
|
|||
s.apiClients[indexer] = ops.NewClient(key)
|
||||
|
||||
case "mock":
|
||||
s.apiClients[indexer] = mock.NewMockClient("", "mock")
|
||||
s.apiClients[indexer] = mock.NewMockClient("mock")
|
||||
|
||||
default:
|
||||
return errors.New("api.Service.AddClient: could not initialize client: unsupported indexer: %s", indexer)
|
||||
|
@ -154,7 +154,7 @@ func (s *apiService) getClientForTest(req domain.IndexerTestApiRequest) (apiClie
|
|||
if req.ApiKey == "" {
|
||||
return nil, errors.New("api.Service.AddClient: could not initialize btn client: missing var 'api_key'")
|
||||
}
|
||||
return btn.NewClient("", req.ApiKey), nil
|
||||
return btn.NewClient(req.ApiKey), nil
|
||||
|
||||
case "ptp":
|
||||
if req.ApiUser == "" {
|
||||
|
@ -185,7 +185,7 @@ func (s *apiService) getClientForTest(req domain.IndexerTestApiRequest) (apiClie
|
|||
return ops.NewClient(req.ApiKey), nil
|
||||
|
||||
case "mock":
|
||||
return mock.NewMockClient("", "mock"), nil
|
||||
return mock.NewMockClient("mock"), nil
|
||||
|
||||
default:
|
||||
return nil, errors.New("api.Service.AddClient: could not initialize client: unsupported indexer: %s", req.Identifier)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue