From a1f0d73fc69dcdd61f93462bca42cba867a91f25 Mon Sep 17 00:00:00 2001 From: Andre Medeiros Date: Wed, 7 Jul 2021 21:01:54 -0400 Subject: [PATCH] import fastparser, increase connectino count to 128 --- go.mod | 1 + go.sum | 2 ++ internal/reddit/client.go | 8 +++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 980ed73..efefb5f 100644 --- a/go.mod +++ b/go.mod @@ -13,6 +13,7 @@ require ( github.com/lib/pq v1.10.1 github.com/sideshow/apns2 v0.20.0 github.com/stretchr/testify v1.5.1 // indirect + github.com/valyala/fastjson v1.6.3 // indirect golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb // indirect gopkg.in/yaml.v2 v2.3.0 // indirect ) diff --git a/go.sum b/go.sum index df224a0..45c3f44 100644 --- a/go.sum +++ b/go.sum @@ -23,6 +23,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/valyala/fastjson v1.6.3 h1:tAKFnnwmeMGPbwJ7IwxcTPCNr3uIzoIj3/Fh90ra4xc= +github.com/valyala/fastjson v1.6.3/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= diff --git a/internal/reddit/client.go b/internal/reddit/client.go index 1b6373a..e6c055d 100644 --- a/internal/reddit/client.go +++ b/internal/reddit/client.go @@ -6,6 +6,8 @@ import ( "net/http" "strings" "time" + + "github.com/valyala/fastjson" ) const ( @@ -16,19 +18,23 @@ type Client struct { id string secret string client *http.Client + parser *fastjson.Parser } func NewClient(id, secret string) *Client { tr := &http.Transport{ - MaxIdleConnsPerHost: 8, + MaxIdleConnsPerHost: 128, } client := &http.Client{Transport: tr} + parser := &fastjson.Parser{} + return &Client{ id, secret, client, + parser, } }