gorealis-v2/docs/leveraging-the-library.md

63 lines
1.5 KiB
Markdown
Raw Permalink Normal View History

2016-08-11 12:45:32 -07:00
# How to leverage the library (based on the [sample client](../examples/client.go))
For a more complete look at the API, please visit https://godoc.org/github.com/paypal/gorealis
2016-08-11 12:45:32 -07:00
* Create a default configuration file (alternatively, manually create your own Config):
```
config, err := realis.NewDefaultConfig(*url)
```
2016-08-11 12:45:32 -07:00
* Create a new Realis client by passing the configuration struct in:
```
r := realis.NewClient(config)
defer r.Close()
```
2016-08-11 12:45:32 -07:00
* Construct a job using a Job struct:
```
2016-08-11 12:45:32 -07:00
job = realis.NewJob().
Environment("prod").
Role("vagrant").
2016-08-11 12:45:32 -07:00
Name("docker-compose").
ExecutorName("docker-compose-executor").
ExecutorData("{}").
2016-08-11 12:45:32 -07:00
CPU(1).
RAM(64).
Disk(100).
IsService(false).
Production(false).
Tier("preemptible").
Priority(0).
InstanceCount(1).
AddPorts(1).
2016-08-11 12:45:32 -07:00
AddLabel("fileName", "sample-app/docker-compose.yml").
AddURIs(true, true, "https://github.com/mesos/docker-compose-executor/releases/download/0.1.0/sample-app.tar.gz")
```
2016-08-11 12:45:32 -07:00
* Use client to send a job to Aurora:
```
r.CreateJob(job)
```
2016-08-11 12:45:32 -07:00
* Killing an Aurora Job:
```
r.KillJob(job.GetKey())
```
2016-08-11 12:45:32 -07:00
* Restarting all instances of an Aurora Job:
```
r.RestartJob(job.GetKey())
```
2016-08-11 12:45:32 -07:00
* Adding instances (based on config of instance 0) to Aurora:
```
r.AddInstances(&aurora.InstanceKey{job.GetKey(),0}, 5)
```
2016-08-11 12:45:32 -07:00
* Updating the job configuration of a service job:
```
updateJob := realis.NewUpdateJob(job)
updateJob.InstanceCount(1)
updateJob.Ram(128)
msg, err := r.UpdateJob(updateJob, "")
2016-08-11 12:45:32 -07:00
```