-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
226 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Compiled Object files, Static and Dynamic libs (Shared Objects) | ||
*.o | ||
*.a | ||
*.so | ||
|
||
# Folders | ||
_obj | ||
_test | ||
|
||
# Architecture specific extensions/prefixes | ||
*.[568vq] | ||
[568vq].out | ||
|
||
*.cgo1.go | ||
*.cgo2.c | ||
_cgo_defun.c | ||
_cgo_gotypes.go | ||
_cgo_export.* | ||
|
||
_testmain.go | ||
|
||
*.exe | ||
*.test | ||
*.prof | ||
|
||
sabo | ||
vendor/ | ||
dist/ | ||
foo/ | ||
*~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
builds: | ||
- binary: sabo | ||
goos: | ||
- darwin | ||
- linux | ||
goarch: | ||
- amd64 | ||
ldflags: | ||
- -X main.Version={{.Version}} | ||
archive: | ||
format: zip | ||
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}" | ||
release: | ||
github: | ||
owner: kazeburo | ||
name: sabo |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Gopkg.toml example | ||
# | ||
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html | ||
# for detailed Gopkg.toml documentation. | ||
# | ||
# required = ["github.com/user/thing/cmd/thing"] | ||
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] | ||
# | ||
# [[constraint]] | ||
# name = "github.com/user/project" | ||
# version = "1.0.0" | ||
# | ||
# [[constraint]] | ||
# name = "github.com/user/project2" | ||
# branch = "dev" | ||
# source = "github.com/myfork/project2" | ||
# | ||
# [[override]] | ||
# name = "github.com/x/y" | ||
# version = "2.4.0" | ||
# | ||
# [prune] | ||
# non-go = false | ||
# go-tests = true | ||
# unused-packages = true | ||
|
||
|
||
[[constraint]] | ||
name = "github.com/dustin/go-humanize" | ||
version = "1.0.0" | ||
|
||
[[constraint]] | ||
name = "github.com/jessevdk/go-flags" | ||
version = "1.4.0" | ||
|
||
[[constraint]] | ||
branch = "master" | ||
name = "golang.org/x/time" | ||
|
||
[prune] | ||
go-tests = true | ||
unused-packages = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
VERSION=0.0.1 | ||
LDFLAGS=-ldflags "-X main.Version=${VERSION}" | ||
all: sabo | ||
|
||
.PHONY: sabo | ||
|
||
bundle: | ||
dep ensure | ||
|
||
update: | ||
dep ensure -update | ||
|
||
sabo: sabo.go | ||
go build $(LDFLAGS) -o sabo | ||
|
||
linux: sabo.go | ||
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o sabo | ||
|
||
fmt: | ||
go fmt ./... | ||
|
||
clean: | ||
rm -rf sabo | ||
|
||
tag: | ||
git tag v${VERSION} | ||
git push origin v${VERSION} | ||
git push origin master | ||
goreleaser --rm-dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,39 @@ | ||
# sabo | ||
# sabo - bandwidth limiting pipe with collaborative capability | ||
|
||
sabo is bandwidth limiting pipe like throttle command. And has collaborative capability like trickle | ||
|
||
throttle - bandwidth limiting pipe https://linux.die.net/man/1/throttle | ||
trickle - a lightweight userspace bandwidth shaper https://www.systutorials.com/docs/linux/man/1-trickle/ | ||
|
||
## Usage | ||
|
||
``` | ||
cat /dev/urandom| go run sabo.go --max-bandwidth 100 --work-dir foo > /dev/null | ||
% sabo -h | ||
Usage: | ||
sabo [OPTIONS] | ||
Application Options: | ||
--max-bandwidth= max bandwidth (Bytes/sec) | ||
--work-dir= directory for control bandwidth | ||
-v, --version Show version | ||
Help Options: | ||
-h, --help Show this help message | ||
``` | ||
|
||
sabo creates a lock file in work dir. sabo checks number of files in work dirr in 1 sec. | ||
Each process's bandwidth limitation become `max-bandwidth / number of file`. | ||
|
||
## example | ||
|
||
``` | ||
MAX_BW=100M | ||
WORK_DIR=/tmp/sabo_for_dump | ||
mkdir -p /tmp/sabo_for_dump | ||
mysqldump -h backup1 db table1 | sabo --max-bandwidth $MAX_BW --work-dir $WORK_DIR > /tmp/sabo_for_dump/table1.sql & | ||
mysqldump -h backup2 db table2 | sabo --max-bandwidth $MAX_BW --work-dir $WORK_DIR > /tmp/sabo_for_dump/table2.sql & | ||
wait | ||
``` | ||
|
||
Each mysqldump's bandwidth limitation is 50MB/sec. | ||
When either of mysqldump finishes, the bandwidth of the remaining process becomes 100 MB/s. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters