Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simapp keep trying for webui/config4g pod until it comeup #20

Merged
merged 1 commit into from
Oct 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions simapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ func sendMessage(msgChan chan configMessage, subProvisionEndpt SubProvisionEndpt
fmt.Println("Port ", subProvisionEndpt.Port)

ip := strings.TrimSpace(subProvisionEndpt.Addr)

fmt.Println("webui running at ", ip)
devGroupHttpend = "http://" + ip + ":" + subProvisionEndpt.Port + "/config/v1/device-group/"
fmt.Println("device trigger http endpoint ", devGroupHttpend)
Expand All @@ -231,7 +232,7 @@ func sendMessage(msgChan chan configMessage, subProvisionEndpt SubProvisionEndpt

for msg := range msgChan {
var httpend string
fmt.Println("Received Message from Channel")
fmt.Println("Received Message from Channel", msgChan, msg)
switch msg.msgType {
case device_group:
httpend = devGroupHttpend + msg.name
Expand All @@ -244,7 +245,12 @@ func sendMessage(msgChan chan configMessage, subProvisionEndpt SubProvisionEndpt
for {
if msg.msgOp == add_op {
fmt.Println("Post Message to ", httpend)
resp, err := http.Post(httpend, "application/json", msg.msgPtr)
client := &http.Client{Timeout: 5 * time.Second}
req, err := http.NewRequest(http.MethodPost, httpend, msg.msgPtr)
//resp, err := http.Post(httpend, "application/json", msg.msgPtr)
req.Header.Set("Content-Type", "application/json; charset=utf-8")
resp, err := client.Do(req)
fmt.Println("Post Message returned ", httpend)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be we dont need this in code.

//Handle Error
if err != nil {
fmt.Printf("An Error Occured %v", err)
Expand All @@ -263,7 +269,7 @@ func sendMessage(msgChan chan configMessage, subProvisionEndpt SubProvisionEndpt
} else if msg.msgOp == modify_op {
fmt.Println("PUT Message to ", httpend)
// initialize http client
client := &http.Client{}
client := &http.Client{Timeout: 5 * time.Second}
req, err := http.NewRequest(http.MethodPut, httpend, msg.msgPtr)
//Handle Error
if err != nil {
Expand All @@ -281,7 +287,7 @@ func sendMessage(msgChan chan configMessage, subProvisionEndpt SubProvisionEndpt
} else if msg.msgOp == delete_op {
fmt.Println("DELETE Message to ", httpend)
// initialize http client
client := &http.Client{}
client := &http.Client{Timeout: 5 * time.Second}
req, err := http.NewRequest(http.MethodDelete, httpend, msg.msgPtr)
//Handle Error
if err != nil {
Expand Down