Callback to delete job
Issue-ID: NONRTRIC-587
Signed-off-by: elinuxhenrik <henrik.b.andersson@est.tech>
Change-Id: I2bdca3fc648ea3a909a0a60c43504d5f80ee05bc
diff --git a/dmaap-mediator-producer/internal/jobs/jobs.go b/dmaap-mediator-producer/internal/jobs/jobs.go
index 09d3891..e5a1070 100644
--- a/dmaap-mediator-producer/internal/jobs/jobs.go
+++ b/dmaap-mediator-producer/internal/jobs/jobs.go
@@ -55,6 +55,7 @@
type JobHandler interface {
AddJob(JobInfo) error
+ DeleteJob(jobId string)
}
var (
@@ -87,6 +88,15 @@
}
}
+func (jh *jobHandlerImpl) DeleteJob(jobId string) {
+ mu.Lock()
+ defer mu.Unlock()
+ for _, typeData := range allTypes {
+ delete(typeData.Jobs, jobId)
+ }
+ log.Debug("Deleted job: ", jobId)
+}
+
func validateJobInfo(ji JobInfo) error {
if _, ok := allTypes[ji.InfoTypeIdentity]; !ok {
return fmt.Errorf("type not supported: %v", ji.InfoTypeIdentity)
@@ -142,6 +152,10 @@
return Handler.AddJob(job)
}
+func DeleteJob(jobId string) {
+ Handler.DeleteJob(jobId)
+}
+
func RunJobs(mRAddress string) {
for {
pollAndDistributeMessages(mRAddress)