Skip to content

Commit

Permalink
refactor: public ScaleParams & StartParams (#47)
Browse files Browse the repository at this point in the history
* refactor: public ScaleParams & StartParams

* chore: update config.go
  • Loading branch information
ishanarya0 authored Jul 25, 2023
1 parent f3642c1 commit cadc134
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
8 changes: 8 additions & 0 deletions modules/firehose/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ var (
validateConfig = validator.FromJSONSchema(configSchemaRaw)
)

type ScaleParams struct {
Replicas int `json:"replicas"`
}

type StartParams struct {
StopTime *time.Time `json:"stop_time"`
}

type Config struct {
// Stopped flag when set forces the firehose to be stopped on next sync.
Stopped bool `json:"stopped"`
Expand Down
9 changes: 2 additions & 7 deletions modules/firehose/driver_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package firehose
import (
"context"
"encoding/json"
"time"

"github.com/goto/entropy/core/module"
"github.com/goto/entropy/core/resource"
Expand Down Expand Up @@ -51,9 +50,7 @@ func (fd *firehoseDriver) planChange(exr module.ExpandedResource, act module.Act
curConf = newConf

case ScaleAction:
var scaleParams struct {
Replicas int `json:"replicas"`
}
var scaleParams ScaleParams
if err := json.Unmarshal(act.Params, &scaleParams); err != nil {
return nil, errors.ErrInvalid.WithMsgf("invalid params for scale action").WithCausef(err.Error())
} else if scaleParams.Replicas < 1 {
Expand All @@ -63,9 +60,7 @@ func (fd *firehoseDriver) planChange(exr module.ExpandedResource, act module.Act
curConf.Replicas = scaleParams.Replicas

case StartAction:
var startParams struct {
StopTime *time.Time `json:"stop_time"`
}
var startParams StartParams
if err := json.Unmarshal(act.Params, &startParams); err != nil {
return nil, errors.ErrInvalid.WithMsgf("invalid params for start action").WithCausef(err.Error())
}
Expand Down

0 comments on commit cadc134

Please sign in to comment.