Skip to content

Commit

Permalink
ksql client. check response status code
Browse files Browse the repository at this point in the history
  • Loading branch information
serhiimakogon committed Dec 27, 2022
1 parent 023c023 commit 856de80
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 7 additions & 5 deletions examples/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ terraform {
}
}

provider "ksql" {
url = ""
username = ""
password = ""
}
provider "ksql" {}

resource "ksql_query" "products_hot_table_table" {
name = "products_hot_table"
type = "table"
query = "CREATE TABLE PRODUCTS_HOT_TABLE (ITEM_KEY STRING PRIMARY KEY) WITH (KAFKA_TOPIC = 'PRODUCTS_HOT',VALUE_FORMAT = 'AVRO');"

credentials {
url = ""
username = ""
password = ""
}
}
4 changes: 4 additions & 0 deletions ksql/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ func (c *Client) makePostKsqlRequest(ctx context.Context, query string) (Respons
return nil, err
}

if sc := resp.StatusCode; sc < 200 || sc > 300 {
return nil, fmt.Errorf("invalid response status code [%d], body [%s]", sc, string(body))
}

res := Response{}
err = json.Unmarshal(body, &res)
if err != nil {
Expand Down

0 comments on commit 856de80

Please sign in to comment.