Skip to content

Commit 873fdb4

Browse files
authored
Merge pull request #38 from u2takey/develop
fix: add missing method RunWithResource
2 parents 56ea322 + 3cc1710 commit 873fdb4

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

examples/limitcpu_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func ComplexFilterExample(testInputFile, testOverlayFile, testOutputFile string)
2626
// 1386105 root 20 0 2114152 273780 31672 R 50.2 1.7 0:16.79 ffmpeg
2727
func TestLimitCpu(t *testing.T) {
2828
e := ComplexFilterExample("./sample_data/in1.mp4", "./sample_data/overlay.png", "./sample_data/out2.mp4")
29-
err := e.WithCpuCoreRequest(0.1).WithCpuCoreLimit(0.5).RunLinux()
29+
err := e.RunWithResource(0.1, 0.5)
3030
if err != nil {
3131
assert.Nil(t, err)
3232
}

run_linux.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ func writeCGroupFile(rootPath, file string, value string) error {
6868
return ioutil.WriteFile(filepath.Join(rootPath, file), []byte(value), 0755)
6969
}
7070

71+
func (s *Stream) RunWithResource(cpuRequest, cpuLimit float32) error {
72+
return s.WithCpuCoreRequest(cpuRequest).WithCpuCoreLimit(cpuLimit).RunLinux()
73+
}
74+
7175
func (s *Stream) RunLinux() error {
7276
a := s.Context.Value(cgroupConfigKey).(*cgroupConfig)
7377
if a.cpuRequest > a.cpuLimit {

0 commit comments

Comments
 (0)