Skip to content

Commit 229782c

Browse files
committed
fix: remove juju/ratelimit due to license concerns
1 parent e69cfbe commit 229782c

13 files changed

Lines changed: 268 additions & 724 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ require (
1515
github.com/docker/go-connections v0.4.0
1616
github.com/evanphx/json-patch v4.12.0+incompatible
1717
github.com/evanphx/json-patch/v5 v5.1.0
18+
github.com/fujiwara/shapeio v1.0.0
1819
github.com/gertd/go-pluralize v0.2.0
1920
github.com/ghodss/yaml v1.0.0
2021
github.com/gliderlabs/ssh v0.3.5
@@ -26,7 +27,6 @@ require (
2627
github.com/jessevdk/go-flags v1.4.0
2728
github.com/joho/godotenv v1.3.0
2829
github.com/json-iterator/go v1.1.12
29-
github.com/juju/ratelimit v1.0.1
3030
github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213
3131
github.com/loft-sh/loft-util v0.0.9-alpha
3232
github.com/loft-sh/notify v0.0.0-20210827094439-0720dcc7feee

go.sum

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3
397397
github.com/dprotaso/go-yit v0.0.0-20191028211022-135eb7262960 h1:aRd8M7HJVZOqn/vhOzrGcQH0lNAMkqMn+pXUYkatmcA=
398398
github.com/dprotaso/go-yit v0.0.0-20191028211022-135eb7262960/go.mod h1:9HQzr9D/0PGwMEbC3d5AB7oi67+h4TsQqItC1GVYG58=
399399
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
400+
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
400401
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
401402
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
402403
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
@@ -442,6 +443,8 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo
442443
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
443444
github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI=
444445
github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU=
446+
github.com/fujiwara/shapeio v1.0.0 h1:xG5D9oNqCSUUbryZ/jQV3cqe1v2suEjwPIcEg1gKM8M=
447+
github.com/fujiwara/shapeio v1.0.0/go.mod h1:LmEmu6L/8jetyj1oewewFb7bZCNRwE7wLCUNzDLaLVA=
445448
github.com/fullstorydev/grpcurl v1.6.0/go.mod h1:ZQ+ayqbKMJNhzLmbpCiurTVlaK2M/3nqZCxaQ2Ze/sM=
446449
github.com/fzipp/gocyclo v0.3.1/go.mod h1:DJHO6AUmbdqj2ET4Z9iArSuwWgYDRryYt2wASxc7x3E=
447450
github.com/garyburd/redigo v0.0.0-20150301180006-535138d7bcd7/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY=
@@ -833,7 +836,6 @@ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHm
833836
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
834837
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
835838
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
836-
github.com/juju/ratelimit v1.0.1 h1:+7AIFJVQ0EQgq/K9+0Krm7m530Du7tIz0METWzN0RgY=
837839
github.com/juju/ratelimit v1.0.1/go.mod h1:qapgC/Gy+xNh9UxzV13HGGl/6UXNN+ct+vwSgWNm/qk=
838840
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
839841
github.com/julz/importas v0.0.0-20210419104244-841f0c0fe66d/go.mod h1:oSFU2R4XK/P7kNBrnL/FEQlDGN1/6WoxXEjSSXO0DV0=
@@ -1737,6 +1739,7 @@ golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxb
17371739
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
17381740
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
17391741
golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
1742+
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
17401743
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 h1:vVKdlvoWBphwdxWKrFZEuM0kGgGLxUOYcY4U/2Vjg44=
17411744
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
17421745
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

pkg/devspace/sync/downstream.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ package sync
33
import (
44
"context"
55
"fmt"
6-
"github.com/loft-sh/devspace/helper/server/ignoreparser"
7-
"github.com/loft-sh/devspace/pkg/util/fsutil"
86
"io"
97
"os"
108
"path"
119
"path/filepath"
1210
"strings"
1311
"time"
1412

15-
"github.com/juju/ratelimit"
16-
"github.com/pkg/errors"
17-
1813
"github.com/loft-sh/devspace/helper/remote"
14+
"github.com/loft-sh/devspace/helper/server/ignoreparser"
1915
"github.com/loft-sh/devspace/helper/util"
16+
"github.com/loft-sh/devspace/pkg/util/fsutil"
17+
18+
"github.com/fujiwara/shapeio"
19+
"github.com/pkg/errors"
2020
)
2121

2222
type downstream struct {
@@ -42,10 +42,14 @@ func newDownstream(reader io.ReadCloser, writer io.WriteCloser, sync *Sync) (*do
4242

4343
// Apply limits if specified
4444
if sync.Options.DownstreamLimit > 0 {
45-
clientReader = ratelimit.Reader(reader, ratelimit.NewBucketWithRate(float64(sync.Options.DownstreamLimit), sync.Options.DownstreamLimit))
45+
limitedReader := shapeio.NewReader(reader)
46+
limitedReader.SetRateLimit(float64(sync.Options.DownstreamLimit))
47+
clientReader = limitedReader
4648
}
4749
if sync.Options.UpstreamLimit > 0 {
48-
clientWriter = ratelimit.Writer(writer, ratelimit.NewBucketWithRate(float64(sync.Options.UpstreamLimit), sync.Options.UpstreamLimit))
50+
limitedWriter := shapeio.NewWriter(writer)
51+
limitedWriter.SetRateLimit(float64(sync.Options.UpstreamLimit))
52+
clientWriter = limitedWriter
4953
}
5054

5155
// Create client connection

pkg/devspace/sync/upstream.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,29 @@ import (
77
"context"
88
"fmt"
99
"io"
10-
"mvdan.cc/sh/v3/expand"
1110
"os"
1211
"path"
1312
"path/filepath"
1413
"strings"
1514
"sync"
1615
"time"
1716

18-
"github.com/loft-sh/devspace/pkg/devspace/build/builder/restart"
19-
"github.com/loft-sh/devspace/pkg/devspace/pipeline/engine"
20-
"github.com/loft-sh/devspace/pkg/util/fsutil"
21-
22-
"github.com/bmatcuk/doublestar"
23-
"github.com/juju/ratelimit"
2417
"github.com/loft-sh/devspace/helper/remote"
2518
"github.com/loft-sh/devspace/helper/server/ignoreparser"
2619
"github.com/loft-sh/devspace/helper/util"
2720
"github.com/loft-sh/devspace/helper/util/crc32"
21+
"github.com/loft-sh/devspace/pkg/devspace/build/builder/restart"
2822
"github.com/loft-sh/devspace/pkg/devspace/config/versions/latest"
23+
"github.com/loft-sh/devspace/pkg/devspace/pipeline/engine"
24+
"github.com/loft-sh/devspace/pkg/util/fsutil"
25+
2926
"github.com/loft-sh/loft-util/pkg/command"
3027
"github.com/loft-sh/notify"
28+
29+
"github.com/bmatcuk/doublestar"
30+
"github.com/fujiwara/shapeio"
3131
"github.com/pkg/errors"
32+
"mvdan.cc/sh/v3/expand"
3233
)
3334

3435
var (
@@ -72,10 +73,14 @@ func newUpstream(reader io.ReadCloser, writer io.WriteCloser, sync *Sync) (*upst
7273

7374
// Apply limits if specified
7475
if sync.Options.DownstreamLimit > 0 {
75-
clientReader = ratelimit.Reader(reader, ratelimit.NewBucketWithRate(float64(sync.Options.DownstreamLimit), sync.Options.DownstreamLimit))
76+
limitedReader := shapeio.NewReader(reader)
77+
limitedReader.SetRateLimit(float64(sync.Options.DownstreamLimit))
78+
clientReader = limitedReader
7679
}
7780
if sync.Options.UpstreamLimit > 0 {
78-
clientWriter = ratelimit.Writer(writer, ratelimit.NewBucketWithRate(float64(sync.Options.UpstreamLimit), sync.Options.UpstreamLimit))
81+
limitedWriter := shapeio.NewWriter(writer)
82+
limitedWriter.SetRateLimit(float64(sync.Options.UpstreamLimit))
83+
clientWriter = limitedWriter
7984
}
8085

8186
// Create client

vendor/github.com/fujiwara/shapeio/.gitignore

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/fujiwara/shapeio/LICENSE

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/fujiwara/shapeio/README.md

Lines changed: 93 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/fujiwara/shapeio/shapeio.go

Lines changed: 97 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)