refactor: rename iot client to stateless gateway
This commit is contained in:
@@ -94,7 +94,7 @@ func dispatchIoTOutbox(ctx context.Context) {
|
||||
}
|
||||
payload["identity"] = outbox.CommandIdentity
|
||||
body, _ := json.Marshal(payload)
|
||||
dispatch, err := http.NewRequestWithContext(ctx, http.MethodPost, config.Spec.IoTAPI.ClientBaseURL+"/v1/device-commands", bytes.NewReader(body))
|
||||
dispatch, err := http.NewRequestWithContext(ctx, http.MethodPost, config.Spec.IoTAPI.GatewayBaseURL+"/v1/device-commands", bytes.NewReader(body))
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
@@ -102,7 +102,7 @@ func dispatchIoTOutbox(ctx context.Context) {
|
||||
dispatch.Header.Set("X-Heqi-Iot-Token", config.Spec.IoTAPI.Token)
|
||||
dispatchResponse, err := client.Do(dispatch)
|
||||
if err != nil {
|
||||
completeIoTOutbox(ctx, client, outbox.Identity, false, 0, "IOT_CLIENT_UNAVAILABLE")
|
||||
completeIoTOutbox(ctx, client, outbox.Identity, false, 0, "IOT_GATEWAY_UNAVAILABLE")
|
||||
continue
|
||||
}
|
||||
var result struct {
|
||||
@@ -114,7 +114,7 @@ func dispatchIoTOutbox(ctx context.Context) {
|
||||
success := (status == http.StatusAccepted || status == http.StatusOK) && decodeErr == nil
|
||||
errorCode := ""
|
||||
if !success {
|
||||
errorCode = "IOT_CLIENT_REJECTED"
|
||||
errorCode = "IOT_GATEWAY_REJECTED"
|
||||
}
|
||||
completeIoTOutbox(ctx, client, outbox.Identity, success, result.PacketNumber, errorCode)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user