Shortening API by removing redundant words
This commit is contained in:
parent
982bbe4e08
commit
ab057e793b
3 changed files with 44 additions and 44 deletions
|
@ -52,29 +52,29 @@ func main() {
|
|||
fmt.Print("Error reading json config file: ", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
job = realis.NewJob().SetEnvironment("prod").
|
||||
SetRole("vagrant").
|
||||
SetName("hello_world_from_gorealis").
|
||||
SetExecutorName(aurora.AURORA_EXECUTOR_NAME).
|
||||
SetExecutorData(string(payload)).
|
||||
SetNumCpus(1).
|
||||
SetRam(64).
|
||||
SetDisk(100).
|
||||
SetIsService(true).
|
||||
SetInstanceCount(1).
|
||||
job = realis.NewJob().Environment("prod").
|
||||
Role("vagrant").
|
||||
Name("hello_world_from_gorealis").
|
||||
ExecutorName(aurora.AURORA_EXECUTOR_NAME).
|
||||
ExecutorData(string(payload)).
|
||||
NumCpus(1).
|
||||
Ram(64).
|
||||
Disk(100).
|
||||
IsService(true).
|
||||
InstanceCount(1).
|
||||
AddPorts(1)
|
||||
break
|
||||
case "compose":
|
||||
job = realis.NewJob().SetEnvironment("prod").
|
||||
SetRole("vagrant").
|
||||
SetName("docker-compose").
|
||||
SetExecutorName("docker-compose-executor").
|
||||
SetExecutorData("{}").
|
||||
SetNumCpus(1).
|
||||
SetRam(64).
|
||||
SetDisk(100).
|
||||
SetIsService(false).
|
||||
SetInstanceCount(1).
|
||||
job = realis.NewJob().Environment("prod").
|
||||
Role("vagrant").
|
||||
Name("docker-compose").
|
||||
ExecutorName("docker-compose-executor").
|
||||
ExecutorData("{}").
|
||||
NumCpus(1).
|
||||
Ram(64).
|
||||
Disk(100).
|
||||
IsService(false).
|
||||
InstanceCount(1).
|
||||
AddPorts(1).
|
||||
AddLabel("fileName", "sample-app/sample-app.yml").
|
||||
AddURI("https://dl.bintray.com/rdelvalle/mesos-compose-executor/sample-app.tar.gz", true, true)
|
||||
|
@ -97,7 +97,7 @@ func main() {
|
|||
case "kill":
|
||||
fmt.Println("Killing job")
|
||||
|
||||
msg, err := r.KillJob(job.GetJobKey())
|
||||
msg, err := r.KillJob(job.JobKey())
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ func main() {
|
|||
break
|
||||
case "restart":
|
||||
fmt.Println("Restarting job")
|
||||
msg, err := r.RestartJob(job.GetJobKey())
|
||||
msg, err := r.RestartJob(job.JobKey())
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ func main() {
|
|||
break
|
||||
case "flexUp":
|
||||
fmt.Println("Flexing up job")
|
||||
msg, err := r.AddInstances(job.GetJobKey(), 5)
|
||||
msg, err := r.AddInstances(job.JobKey(), 5)
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ func main() {
|
|||
fmt.Println("Updating a job with a new name")
|
||||
updateJob := realis.NewUpdateJob(job)
|
||||
|
||||
updateJob.SetInstanceCount(3).SetRam(128)
|
||||
updateJob.InstanceCount(3).Ram(128)
|
||||
|
||||
msg, err := r.StartJobUpdate(updateJob, "")
|
||||
if err != nil {
|
||||
|
@ -135,7 +135,7 @@ func main() {
|
|||
break
|
||||
case "abortUpdate":
|
||||
fmt.Println("Abort update")
|
||||
msg, err := r.AbortJobUpdate(job.GetJobKey(), *updateId, "")
|
||||
msg, err := r.AbortJobUpdate(job.JobKey(), *updateId, "")
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
|
|
24
job.go
24
job.go
|
@ -66,12 +66,12 @@ func NewJob() *Job {
|
|||
return &Job{jobConfig, numCpus, ramMb, diskMb, 0}
|
||||
}
|
||||
|
||||
func (a *Job) SetEnvironment(env string) *Job {
|
||||
func (a *Job) Environment(env string) *Job {
|
||||
a.jobConfig.Key.Environment = env
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *Job) SetRole(role string) *Job {
|
||||
func (a *Job) Role(role string) *Job {
|
||||
a.jobConfig.Key.Role = role
|
||||
|
||||
//Will be deprecated
|
||||
|
@ -81,58 +81,58 @@ func (a *Job) SetRole(role string) *Job {
|
|||
return a
|
||||
}
|
||||
|
||||
func (a *Job) SetName(name string) *Job {
|
||||
func (a *Job) Name(name string) *Job {
|
||||
a.jobConfig.Key.Name = name
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *Job) SetExecutorName(name string) *Job {
|
||||
func (a *Job) ExecutorName(name string) *Job {
|
||||
a.jobConfig.TaskConfig.ExecutorConfig.Name = name
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *Job) SetExecutorData(data string) *Job {
|
||||
func (a *Job) ExecutorData(data string) *Job {
|
||||
a.jobConfig.TaskConfig.ExecutorConfig.Data = data
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *Job) SetNumCpus(cpus float64) *Job {
|
||||
func (a *Job) NumCpus(cpus float64) *Job {
|
||||
a.numCpus.NumCpus = &cpus
|
||||
a.jobConfig.TaskConfig.NumCpus = cpus //Will be deprecated soon
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *Job) SetRam(ram int64) *Job {
|
||||
func (a *Job) Ram(ram int64) *Job {
|
||||
a.ramMb.RamMb = &ram
|
||||
a.jobConfig.TaskConfig.RamMb = ram //Will be deprecated soon
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *Job) SetDisk(disk int64) *Job {
|
||||
func (a *Job) Disk(disk int64) *Job {
|
||||
a.diskMb.DiskMb = &disk
|
||||
a.jobConfig.TaskConfig.DiskMb = disk //Will be deprecated
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *Job) SetMaxFailure(maxFail int32) *Job {
|
||||
func (a *Job) MaxFailure(maxFail int32) *Job {
|
||||
a.jobConfig.TaskConfig.MaxTaskFailures = maxFail
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *Job) SetInstanceCount(instCount int32) *Job {
|
||||
func (a *Job) InstanceCount(instCount int32) *Job {
|
||||
a.jobConfig.InstanceCount = instCount
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *Job) SetIsService(isService bool) *Job {
|
||||
func (a *Job) IsService(isService bool) *Job {
|
||||
a.jobConfig.TaskConfig.IsService = isService
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *Job) GetJobKey() *aurora.JobKey {
|
||||
func (a *Job) JobKey() *aurora.JobKey {
|
||||
return a.jobConfig.Key
|
||||
}
|
||||
|
||||
|
|
14
updatejob.go
14
updatejob.go
|
@ -40,44 +40,44 @@ func NewUpdateJob(job *Job) *UpdateJob {
|
|||
return &UpdateJob{job, req}
|
||||
}
|
||||
|
||||
func (u *UpdateJob) SetInstanceCount(inst int32) *UpdateJob {
|
||||
func (u *UpdateJob) InstanceCount(inst int32) *UpdateJob {
|
||||
u.req.InstanceCount = inst
|
||||
return u
|
||||
}
|
||||
|
||||
// Max number of instances being updated at any given moment.
|
||||
func (u *UpdateJob) SetBatchSize(size int32) *UpdateJob {
|
||||
func (u *UpdateJob) BatchSize(size int32) *UpdateJob {
|
||||
u.req.Settings.UpdateGroupSize = size
|
||||
return u
|
||||
}
|
||||
|
||||
// Minimum number of seconds a shard must remain in RUNNING state before considered a success
|
||||
func (u *UpdateJob) SetWatchTime(milliseconds int32) *UpdateJob {
|
||||
func (u *UpdateJob) WatchTime(milliseconds int32) *UpdateJob {
|
||||
u.req.Settings.MaxPerInstanceFailures = milliseconds
|
||||
return u
|
||||
}
|
||||
|
||||
// Wait for all instances in a group to be done before moving on
|
||||
func (u *UpdateJob) SetWaitForBatchCompletion(batchWait bool) *UpdateJob {
|
||||
func (u *UpdateJob) WaitForBatchCompletion(batchWait bool) *UpdateJob {
|
||||
u.req.Settings.WaitForBatchCompletion = batchWait
|
||||
return u
|
||||
}
|
||||
|
||||
// Max number of instance failures to tolerate before marking instance as FAILED.
|
||||
func (u *UpdateJob) SetMaxPerInstanceFailures(inst int32) *UpdateJob {
|
||||
func (u *UpdateJob) MaxPerInstanceFailures(inst int32) *UpdateJob {
|
||||
u.req.Settings.MaxPerInstanceFailures = inst
|
||||
return u
|
||||
}
|
||||
|
||||
// Max number of FAILED instances to tolerate before terminating the update.
|
||||
func (u *UpdateJob) SetMaxFailedInstances(inst int32) *UpdateJob {
|
||||
func (u *UpdateJob) MaxFailedInstances(inst int32) *UpdateJob {
|
||||
|
||||
u.req.Settings.MaxFailedInstances = inst
|
||||
return u
|
||||
}
|
||||
|
||||
// When False, prevents auto rollback of a failed update
|
||||
func (u *UpdateJob) SetRollbackOnFail(rollback bool) *UpdateJob {
|
||||
func (u *UpdateJob) RollbackOnFail(rollback bool) *UpdateJob {
|
||||
|
||||
u.req.Settings.RollbackOnFailure = rollback
|
||||
return u
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue