Skip to content

Commit 1decd0f

Browse files
committed
Fixing
1 parent cefa444 commit 1decd0f

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

examples/products/main.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"context"
5+
"crypto/tls"
56
"flag"
67
"fmt"
78
"github.com/erply/api-go-wrapper/pkg/api"
@@ -18,12 +19,20 @@ func main() {
1819
clientCode := flag.String("cc", "", "client code")
1920
flag.Parse()
2021

22+
connectionTimeout := 60 * time.Second
23+
transport := &http.Transport{
24+
DisableKeepAlives: true,
25+
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
26+
ResponseHeaderTimeout: connectionTimeout,
27+
}
28+
httpCl := &http.Client{Transport: transport}
29+
2130
sessionKey, err := auth.VerifyUser(*username, *password, *clientCode, http.DefaultClient)
2231
if err != nil {
2332
panic(err)
2433
}
2534

26-
apiClient, err := api.NewClient(sessionKey, *clientCode, nil)
35+
apiClient, err := api.NewClient(sessionKey, *clientCode, httpCl)
2736
if err != nil {
2837
panic(err)
2938
}
@@ -80,8 +89,8 @@ func GetProductsInParallel(cl *api.Client) ([]products.Product, error) {
8089
sharedCommon.ListingSettings{
8190
MaxRequestsCountPerSecond: 5,
8291
StreamBufferLength: 10,
83-
MaxItemsPerRequest: 10,
84-
MaxFetchersCount: 2,
92+
MaxItemsPerRequest: 300,
93+
MaxFetchersCount: 10,
8594
},
8695
productsDataProvider,
8796
func(sleepTime time.Duration) {
@@ -92,7 +101,9 @@ func GetProductsInParallel(cl *api.Client) ([]products.Product, error) {
92101
ctx, cancel := context.WithTimeout(context.Background(), time.Second * 5)
93102
defer cancel()
94103

95-
prodsChan := lister.Get(ctx, map[string]interface{}{})
104+
prodsChan := lister.Get(ctx, map[string]interface{}{
105+
"changedSince": time.Date(2020, 2, 15, 0, 0, 0, 0, time.UTC).Unix(),
106+
})
96107

97108
prods := make([]products.Product, 0)
98109
var err error

pkg/api/common/listing.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func (p *Lister) getCursors(ctx context.Context, totalCount int) chan []Cursor {
156156
},
157157
)
158158
curPage++
159-
leftCount -= limit //leftCount 900
159+
leftCount -= limit
160160
}
161161
select {
162162
case out <- cursorsForBulkRequest:

pkg/api/products/listing.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ func NewListingDataProvider(erplyClient Manager) *ListingDataProvider {
1515
}
1616

1717
func (l *ListingDataProvider) Count(ctx context.Context, filters map[string]interface{}) (int, error) {
18+
filters["recordsOnPage"] = 1
19+
filters["pageNo"] = 1
20+
1821
resp, err := l.erplyAPI.GetProductsBulk(ctx, []map[string]interface{}{filters}, map[string]string{})
1922

2023
if err != nil {

0 commit comments

Comments
 (0)