Skip to content

Commit 7617fed

Browse files
committed
feat: update code using functions new names and response body's
1 parent 2e08a8f commit 7617fed

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

request/api_async_request.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ import (
88

99
const API = "/_search"
1010

11-
// AsyncAPIRequest makes API requests asynchronously
12-
func AsyncAPIRequest(users []models.ReadCsv, numberOfWorkers int, url string, method string, auth string) ([]models.ResponseBody, error) {
11+
// AsyncAPIRequestLawsuit makes API requests asynchronously
12+
func AsyncAPIRequestLawsuit(users []models.ReadCsvLaawsuit, numberOfWorkers int, url string, method string, auth string) ([]models.ResponseBodyLawsuit, error) {
1313
// Create a channel to signal when the goroutines are done processing inputs
1414
done := make(chan struct{})
1515
defer close(done)
1616
// Create a channel to receive inputs from
17-
inputCh := StreamInputs(done, users)
17+
inputCh := StreamInputsLawsuits(done, users)
1818

1919
// Create a wait group to wait for the worker goroutines to finish
2020
var wg sync.WaitGroup
2121
wg.Add(numberOfWorkers)
2222

2323
// Create a channel to receive results from
24-
resultCh := make(chan models.ResponseBody)
24+
resultCh := make(chan models.ResponseBodyLawsuit)
2525

2626
// Spawn worker goroutines to process inputs
2727
var errorOnApiRequests error
@@ -30,8 +30,8 @@ func AsyncAPIRequest(users []models.ReadCsv, numberOfWorkers int, url string, me
3030
// Each worker goroutine consumes inputs from the shared input channel
3131
for input := range inputCh {
3232
// Make the API request and send the response to the result channel
33-
tj, err := defineTJ(input.CNJNumber)
34-
bodyStr, err := APIRequest(url+tj+API, method, auth, input)
33+
tj, err := defineTJLawsuit(input.CNJNumber)
34+
bodyStr, err := APIRequestLawsuit(url+tj+API, method, auth, input)
3535
resultCh <- bodyStr
3636
if err != nil {
3737
// If there is an error making the API request, print the error
@@ -58,18 +58,18 @@ func AsyncAPIRequest(users []models.ReadCsv, numberOfWorkers int, url string, me
5858
}
5959

6060
// Collect results from the result channel and return them as a slice
61-
var results []models.ResponseBody
61+
var results []models.ResponseBodyLawsuit
6262
for result := range resultCh {
6363
results = append(results, result)
6464
}
6565

6666
return results, nil
6767
}
6868

69-
// StreamInputs sends inputs from a slice to a channel
70-
func StreamInputs(done <-chan struct{}, inputs []models.ReadCsv) <-chan models.ReadCsv {
69+
// StreamInputsLawsuits sends inputs from a slice to a channel
70+
func StreamInputsLawsuits(done <-chan struct{}, inputs []models.ReadCsvLaawsuit) <-chan models.ReadCsvLaawsuit {
7171
// Create a channel to send inputs to
72-
inputCh := make(chan models.ReadCsv)
72+
inputCh := make(chan models.ReadCsvLaawsuit)
7373
go func() {
7474
defer close(inputCh)
7575
for _, input := range inputs {

0 commit comments

Comments
 (0)