MCPcopy
hub / github.com/uber/aresdb / UpdateJob

Method UpdateJob

controller/mutators/etcd/job_mutator.go:114–145  ·  view source on GitHub ↗

UpdateJob updates job config

(namespace string, job models.JobConfig)

Source from the content-addressed store, hash-verified

112
113// UpdateJob updates job config
114func (j *jobMutatorImpl) UpdateJob(namespace string, job models.JobConfig) (err error) {
115 jobListProto, jobListVersion, err := readEntityList(j.etcdStore, utils.JobListKey(namespace))
116 if err != nil {
117 return err
118 }
119
120 jobListProto, found := updateEntity(jobListProto, job.Name)
121 if !found {
122 j.logger.With(
123 "job", job,
124 ).Info("job not found for update, creating new job")
125 return j.AddJob(namespace, job)
126 }
127
128 jobProto, jobVersion, err := j.readJob(namespace, job.Name)
129 if err != nil {
130 return err
131 }
132 if jobProto.Tomstoned {
133 return common.ErrJobConfigDoesNotExist
134 }
135 jobProto.Tomstoned = false
136 jobProto.Config, err = json.Marshal(job)
137 if err != nil {
138 return
139 }
140
141 return kvstore.NewTransaction().
142 AddKeyValue(utils.JobListKey(namespace), jobListVersion, &jobListProto).
143 AddKeyValue(utils.JobKey(namespace, job.Name), jobVersion, &jobProto).
144 WriteTo(j.etcdStore)
145}
146
147// AddJob adds a new job
148func (j *jobMutatorImpl) AddJob(namespace string, job models.JobConfig) error {

Callers

nothing calls this directly

Calls 11

AddJobMethod · 0.95
readJobMethod · 0.95
JobListKeyFunction · 0.92
NewTransactionFunction · 0.92
JobKeyFunction · 0.92
readEntityListFunction · 0.85
updateEntityFunction · 0.85
WriteToMethod · 0.80
AddKeyValueMethod · 0.80
InfoMethod · 0.65
WithMethod · 0.65

Tested by

no test coverage detected