Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added scale restreamer #6

Merged
merged 3 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions compress/api_restreamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,34 @@
o.debugPrint(obj)
return &obj, nil
}

/*

*/
func (o *compress) ScaleRestreamer(instanceName string, scale int) (*ResponseServer, error){
//
requestBody := &scaleRestreamerRequest{
BaseModel: BaseModel{ClientId: o.GetCliendId(), ApiKey: o.apiKey},
InstanceName: instanceName,
Scale: scale

Check failure on line 77 in compress/api_restreamer.go

View workflow job for this annotation

GitHub Actions / build (1.19.x)

syntax error: unexpected newline in composite literal; possibly missing comma or }

Check failure on line 77 in compress/api_restreamer.go

View workflow job for this annotation

GitHub Actions / build (1.20.x)

syntax error: unexpected newline in composite literal; possibly missing comma or }

Check failure on line 77 in compress/api_restreamer.go

View workflow job for this annotation

GitHub Actions / build (1.21.x)

syntax error: unexpected newline in composite literal; possibly missing comma or }

Check failure on line 77 in compress/api_restreamer.go

View workflow job for this annotation

GitHub Actions / build (1.19.x)

syntax error: unexpected newline in composite literal; possibly missing comma or }

Check failure on line 77 in compress/api_restreamer.go

View workflow job for this annotation

GitHub Actions / build (1.20.x)

syntax error: unexpected newline in composite literal; possibly missing comma or }

Check failure on line 77 in compress/api_restreamer.go

View workflow job for this annotation

GitHub Actions / build (1.21.x)

syntax error: unexpected newline in composite literal; possibly missing comma or }

}
if errs := validator.Validate(requestBody); errs != nil {
// values not valid, deal with errors here
return nil, errs
}
resp, err := o.restyPost(GET_RUNNING_SINGLE_INSTANCE(), requestBody)
if err != nil {
return nil, err
}
var obj ResponseServer
if err := json.Unmarshal(resp.Body(), &obj); err != nil {
return nil, err
}
if obj.Data == "KO" {
return nil, fmt.Errorf("Error %s", obj.Message)
}
o.debugPrint(obj)
return &obj, nil
//
}
1 change: 1 addition & 0 deletions compress/compress.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type ICompress interface {
CreateCategory(name string) (*Category, error)
GetRestreamers() ([]Restreamer, error) // startFrom int, amount int
GetSingleRestreamer(instanceName string) (*Restreamer, error)
ScaleRestreamer(instanceName string, scale int) (*ResponseServer, error)
//
}

Expand Down
3 changes: 3 additions & 0 deletions compress/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ var (
GET_RUNNING_SINGLE_INSTANCE = func() string {
return TNGRM_BASE_URL + RESTREAMERS + "/single_instance"
}
SCALE_INSTANCE = func() string {
return TNGRM_BASE_URL + RESTREAMERS + "/scale_instance"
}
GET_UPLOADS = func() string {
return TNGRM_BASE_URL + UPLOADS
}
Expand Down
6 changes: 6 additions & 0 deletions compress/model_restreamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,10 @@
type restreamerRequest struct {
BaseModel
InstanceName string `json:"instance_name" validate:"nonzero,min=1" required:"true"`
}

type scaleRestreamerRequest struct {
BaseModel
InstanceName string `json:"instance_name" validate:"nonzero,min=1" required:"true"`
Scale int `json:"instance_name validate:"nonnil,min=0" required:"true""

Check failure on line 91 in compress/model_restreamer.go

View workflow job for this annotation

GitHub Actions / build (1.19.x)

string not terminated

Check failure on line 91 in compress/model_restreamer.go

View workflow job for this annotation

GitHub Actions / build (1.20.x)

string not terminated

Check failure on line 91 in compress/model_restreamer.go

View workflow job for this annotation

GitHub Actions / build (1.21.x)

string not terminated

Check failure on line 91 in compress/model_restreamer.go

View workflow job for this annotation

GitHub Actions / build (1.19.x)

string not terminated

Check failure on line 91 in compress/model_restreamer.go

View workflow job for this annotation

GitHub Actions / build (1.20.x)

string not terminated

Check failure on line 91 in compress/model_restreamer.go

View workflow job for this annotation

GitHub Actions / build (1.21.x)

string not terminated
}
Loading