Refactor Go code

Issue-ID: NONRTRIC-606
Signed-off-by: elinuxhenrik <henrik.b.andersson@est.tech>
Change-Id: Icbd97b8dbf0c3b015e2c864d4d4dd3581d5ade9b
diff --git a/dmaap-mediator-producer/simulator/consumersimulator.go b/dmaap-mediator-producer/simulator/consumersimulator.go
index 144f56f..03da6f4 100644
--- a/dmaap-mediator-producer/simulator/consumersimulator.go
+++ b/dmaap-mediator-producer/simulator/consumersimulator.go
@@ -26,18 +26,25 @@
 	"fmt"
 	"io"
 	http "net/http"
+	"time"
 
 	"oransc.org/nonrtric/dmaapmediatorproducer/internal/restclient"
 )
 
+var httpClient http.Client
+
 func main() {
+	httpClient = http.Client{
+		Timeout: time.Second * 5,
+	}
 	port := flag.Int("port", 40935, "The port this consumer will listen on")
 	flag.Parse()
 	http.HandleFunc("/jobs", handleData)
 
+	registerJob(*port)
+
 	fmt.Print("Starting consumer on port: ", *port)
 	http.ListenAndServe(fmt.Sprintf(":%v", *port), nil)
-	registerJob(*port)
 }
 
 func registerJob(port int) {
@@ -49,7 +56,7 @@
 	}{fmt.Sprintf("test%v", port), fmt.Sprintf("http://localhost:%v/jobs", port), "STD_Fault_Messages", "{}"}
 	fmt.Print("Registering consumer: ", jobInfo)
 	body, _ := json.Marshal(jobInfo)
-	putErr := restclient.Put(fmt.Sprintf("http://localhost:8083/data-consumer/v1/info-jobs/job%v", port), body)
+	putErr := restclient.Put(fmt.Sprintf("http://localhost:8083/data-consumer/v1/info-jobs/job%v", port), body, &httpClient)
 	if putErr != nil {
 		fmt.Printf("Unable to register consumer: %v", putErr)
 	}