Skip to content

Commit

Permalink
added scale restreamer (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
Allan-Nava authored Nov 17, 2023
1 parent 6e90f44 commit 8ab922e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
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 @@ func (o *compress) GetSingleRestreamer(instanceName string) (*Restreamer, error)
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.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.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 findRestreamersRequest struct {
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.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.21.x)

string not terminated
}

0 comments on commit 8ab922e

Please sign in to comment.