From 2f5ae91ee1b325a6464678f89093cea06d740b88 Mon Sep 17 00:00:00 2001 From: Martin Englund Date: Wed, 13 Sep 2023 10:42:22 -0700 Subject: [PATCH] improved multi-vi support (#138) --- example_query_test.go | 2 +- example_s3_test.go | 14 ++-- go.mod | 38 +++++----- go.sum | 58 +++++++++------ openapi/README.md | 2 +- openapi/configuration.go | 2 +- option/query.go | 19 ++++- option/virtual_instance.go | 24 +++++-- queries.go | 23 +++++- rockset_test.go | 11 ++- version.go | 2 +- virtual_instances.go | 82 ++++++++++++--------- virtual_instances_test.go | 141 ++++++++++++++++++++++++++++--------- wait.go | 13 +++- 14 files changed, 298 insertions(+), 133 deletions(-) diff --git a/example_query_test.go b/example_query_test.go index fb03b4b6..53c30818 100644 --- a/example_query_test.go +++ b/example_query_test.go @@ -56,7 +56,7 @@ func ExampleRockClient_query() { } r, err := rc.Query(ctx, "SELECT * FROM commons._events where label = :label", - option.WithRowLimit(10), + option.WithDefaultRowLimit(10), option.WithParameter("label", "string", "QUERY_SUCCESS")) if err != nil { log.Fatal(err) diff --git a/example_s3_test.go b/example_s3_test.go index bcdab2d8..424d32b3 100644 --- a/example_s3_test.go +++ b/example_s3_test.go @@ -97,11 +97,11 @@ func Example_s3() { fmt.Printf("integration deleted: %s\n", r.GetName()) // Output: - // integration created: example_s3_go - // collection created: example_s3_go - // collection ready: example_s3_go - // collection name: example_s3_go - // collection deleted: example_s3_go - // collection gone: example_s3_go - // integration deleted: example_s3_go + // integration created: go_example_s3 + // collection created: go_example_s3 + // collection ready: go_example_s3 + // collection name: go_example_s3 + // collection deleted: go_example_s3 + // collection gone: go_example_s3 + // integration deleted: go_example_s3 } diff --git a/go.mod b/go.mod index 0f630f68..7dc45df4 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,8 @@ module github.com/rockset/rockset-go-client go 1.20 require ( - github.com/aws/aws-sdk-go-v2/config v1.18.30 - github.com/aws/aws-sdk-go-v2/service/s3 v1.37.1 + github.com/aws/aws-sdk-go-v2/config v1.18.39 + github.com/aws/aws-sdk-go-v2/service/s3 v1.38.5 github.com/confluentinc/confluent-kafka-go v1.9.2 github.com/fatih/structs v1.1.0 github.com/go-zookeeper/zk v1.0.3 @@ -18,23 +18,23 @@ require ( github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect github.com/Microsoft/go-winio v0.6.0 // indirect github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect - github.com/aws/aws-sdk-go-v2 v1.19.1 // indirect - github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 // indirect - github.com/aws/aws-sdk-go-v2/credentials v1.13.29 // indirect - github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.6 // indirect + github.com/aws/aws-sdk-go-v2 v1.21.0 // indirect + github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.13 // indirect + github.com/aws/aws-sdk-go-v2/credentials v1.13.37 // indirect + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11 // indirect github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.74 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.36 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.30 // indirect - github.com/aws/aws-sdk-go-v2/internal/ini v1.3.37 // indirect - github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.28 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.31 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.30 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.14.5 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.12.14 // indirect - github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.14 // indirect - github.com/aws/aws-sdk-go-v2/service/sts v1.20.1 // indirect - github.com/aws/smithy-go v1.13.5 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35 // indirect + github.com/aws/aws-sdk-go-v2/internal/ini v1.3.42 // indirect + github.com/aws/aws-sdk-go-v2/internal/v4a v1.1.4 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.14 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.36 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.15.4 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.13.6 // indirect + github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.6 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.21.5 // indirect + github.com/aws/smithy-go v1.14.2 // indirect github.com/cenkalti/backoff/v4 v4.1.3 // indirect github.com/containerd/continuity v0.3.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect @@ -65,7 +65,7 @@ require ( github.com/xeipuuv/gojsonschema v1.2.0 // indirect golang.org/x/crypto v0.12.0 // indirect golang.org/x/mod v0.9.0 // indirect - golang.org/x/sys v0.11.0 // indirect + golang.org/x/sys v0.12.0 // indirect golang.org/x/tools v0.7.0 // indirect gopkg.in/yaml.v2 v2.3.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 0555a17b..4d232ee4 100644 --- a/go.sum +++ b/go.sum @@ -11,44 +11,62 @@ github.com/actgardner/gogen-avro/v10 v10.1.0/go.mod h1:o+ybmVjEa27AAr35FRqU98DJu github.com/actgardner/gogen-avro/v10 v10.2.1/go.mod h1:QUhjeHPchheYmMDni/Nx7VB0RsT/ee8YIgGY/xpEQgQ= github.com/actgardner/gogen-avro/v9 v9.1.0/go.mod h1:nyTj6wPqDJoxM3qdnjcLv+EnMDSDFqE0qDpva2QRmKc= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/aws/aws-sdk-go-v2 v1.19.1 h1:STs0lbbpXu3byTPcnRLghs2DH0yk9qKDo27TyyJSKsM= github.com/aws/aws-sdk-go-v2 v1.19.1/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= -github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 h1:dK82zF6kkPeCo8J1e+tGx4JdvDIQzj7ygIoLg8WMuGs= +github.com/aws/aws-sdk-go-v2 v1.21.0 h1:gMT0IW+03wtYJhRqTVYn0wLzwdnK9sRMcxmtfGzRdJc= +github.com/aws/aws-sdk-go-v2 v1.21.0/go.mod h1:/RfNgGmRxI+iFOB1OeJUyxiU+9s88k3pfHvDagGEp0M= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10/go.mod h1:VeTZetY5KRJLuD/7fkQXMU6Mw7H5m/KP2J5Iy9osMno= -github.com/aws/aws-sdk-go-v2/config v1.18.30 h1:TTAXQIn31qYFUQjkW6siVrRTX1ux+sADZDOe3jsZcMg= +github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.13 h1:OPLEkmhXf6xFPiz0bLeDArZIDx1NNS4oJyG4nv3Gct0= +github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.13/go.mod h1:gpAbvyDGQFozTEmlTFO8XcQKHzubdq0LzRyJpG6MiXM= github.com/aws/aws-sdk-go-v2/config v1.18.30/go.mod h1:+YogjT7e/t9JVu/sOnZZgxTge1G+bPNk8zOaI0QIQvE= -github.com/aws/aws-sdk-go-v2/credentials v1.13.29 h1:KNgCpThGuZyCjq9EuuqoLDenKKMwO/x1Xx01ckDa7VI= +github.com/aws/aws-sdk-go-v2/config v1.18.39 h1:oPVyh6fuu/u4OiW4qcuQyEtk7U7uuNBmHmJSLg1AJsQ= +github.com/aws/aws-sdk-go-v2/config v1.18.39/go.mod h1:+NH/ZigdPckFpgB1TRcRuWCB/Kbbvkxc/iNAKTq5RhE= github.com/aws/aws-sdk-go-v2/credentials v1.13.29/go.mod h1:VMq1LcmSEa9qxBlOCYTjVuGJWEEzhGmgL552jQsmhss= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.6 h1:kortK122LvTU34CGX/F9oJpelXKkEA2j/MW48II+8+8= +github.com/aws/aws-sdk-go-v2/credentials v1.13.37 h1:BvEdm09+ZEh2XtN+PVHPcYwKY3wIeB6pw7vPRM4M9/U= +github.com/aws/aws-sdk-go-v2/credentials v1.13.37/go.mod h1:ACLrdkd4CLZyXOghZ8IYumQbcooAcp2jo/s2xsFH8IM= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.6/go.mod h1:k7IPHyHNIASI0m0RwOmCjWOTtgG+J0raqwuHH8WhWJE= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11 h1:uDZJF1hu0EVT/4bogChk8DyjSF6fof6uL/0Y26Ma7Fg= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11/go.mod h1:TEPP4tENqBGO99KwVpV9MlOX4NSrSLP8u3KRy2CDwA8= github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.74 h1:5iIuHdeN3/x3kFBENHgYQl1ZtD+ZhLBXy6IgXflUtSI= github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.74/go.mod h1:kBEg7nSM1Dg9tsHX5eoFeJMmO+njnFOwxP0dPuQCEGc= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.36 h1:kbk81RlPoC6e4co7cQx2FAvH9TgbzxIqCqiosAFiB+w= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.36/go.mod h1:T8Jsn/uNL/AFOXrVYQ1YQaN1r9gN34JU1855/Lyjv+o= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.30 h1:lMl8S5SB8jNCB+Sty2Em4lnu3IJytceHQd7qbmfqKL0= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 h1:22dGT7PneFMx4+b3pz7lMTRyN8ZKH7M2cW4GP9yUS2g= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41/go.mod h1:CrObHAuPneJBlfEJ5T3szXOUkLEThaGfvnhTf33buas= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.30/go.mod h1:v3GSCnFxbHzt9dlWBqvA1K1f9lmWuf4ztupZBCAIVs4= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.37 h1:BXiqvN7WuV/pMhz8CivhO8cG8icJcjnjHumif4ukQ0c= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35 h1:SijA0mgjV8E+8G45ltVHs0fvKpTj8xmZJ3VwhGKtUSI= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35/go.mod h1:SJC1nEVVva1g3pHAIdCp7QsRIkMmLAgoDquQ9Rr8kYw= github.com/aws/aws-sdk-go-v2/internal/ini v1.3.37/go.mod h1:d4GZ62cjnz/hjKFdAu11gAwK73bdhqaFv2O4J1gaqIs= -github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.28 h1:mGA+qm0tiLaZ04PfQtxthU3XTZ1sN44YlqVjd+1E+Pk= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.42 h1:GPUcE/Yq7Ur8YSUk6lVkoIMWnJNO0HT18GUzCWCgCI0= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.42/go.mod h1:rzfdUlfA+jdgLDmPKjd3Chq9V7LVLYo1Nz++Wb91aRo= github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.28/go.mod h1:KkWH+0gAmvloVXaVjdY6/LLwQV6TjYOZ1j5JdVm+XBc= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11 h1:y2+VQzC6Zh2ojtV2LoC0MNwHWc6qXv/j2vrQtlftkdA= +github.com/aws/aws-sdk-go-v2/internal/v4a v1.1.4 h1:6lJvvkQ9HmbHZ4h/IEwclwv2mrTW8Uq1SOB/kXy0mfw= +github.com/aws/aws-sdk-go-v2/internal/v4a v1.1.4/go.mod h1:1PrKYwxTM+zjpw9Y41KFtoJCQrJ34Z47Y4VgVbfndjo= github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11/go.mod h1:iV4q2hsqtNECrfmlXyord9u4zyuFEJX9eLgLpSPzWA8= -github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.31 h1:TGjmYwqqE6dMDSUSyQNct4MyTAgz95bPnDAjBOEgwOI= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.14 h1:m0QTSI6pZYJTk5WSKx3fm5cNW/DCicVzULBgU/6IyD0= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.14/go.mod h1:dDilntgHy9WnHXsh7dDtUPgHKEfTJIBUTHM8OWm0f/0= github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.31/go.mod h1:HvfQ61vGBanxBijrBIpyG32mS9w6fsPZa+BwtV1uQUY= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.30 h1:UcVZxLVNY4yayCmiG94Ge3l2qbc5WEB/oa4RmjoQEi0= +github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.36 h1:eev2yZX7esGRjqRbnVk1UxMLw4CyVZDpZXRCcy75oQk= +github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.36/go.mod h1:lGnOkH9NJATw0XEPcAknFBj3zzNTEGRHtSw+CwC1YTg= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.30/go.mod h1:wPffyJiWWtHwvpFyn23WjAjVjMnlQOQrl02+vutBh3Y= -github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.14.5 h1:B90htdoSv7OMH6QzzZ9cuZUoXVwFml0fTCDOpcGakCw= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35 h1:CdzPW9kKitgIiLV1+MHobfR5Xg25iYnyzWZhyQuSlDI= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35/go.mod h1:QGF2Rs33W5MaN9gYdEQOBBFPLwTZkEhRwI33f7KIG0o= github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.14.5/go.mod h1:fdxqVm1S6xQa6obwHysh1GPowmyqO2pQuaRPWdyG2iQ= -github.com/aws/aws-sdk-go-v2/service/s3 v1.37.1 h1:OoFnDN7ZixctMX/Do4DgQXFvjtzQynz0p0ErQrOCeAs= +github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.15.4 h1:v0jkRigbSD6uOdwcaUQmgEwG1BkPfAPDqaeNt/29ghg= +github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.15.4/go.mod h1:LhTyt8J04LL+9cIt7pYJ5lbS/U98ZmXovLOR/4LUsk8= github.com/aws/aws-sdk-go-v2/service/s3 v1.37.1/go.mod h1:fBgi8xY80Fv2EveXOoTM008OhKdjrxxtVH0w0h0ozYU= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.14 h1:gUjz7trfz9qBm0AlkKTvJHBXELi1wvw+2LA9GfD2AsM= +github.com/aws/aws-sdk-go-v2/service/s3 v1.38.5 h1:A42xdtStObqy7NGvzZKpnyNXvoOmm+FENobZ0/ssHWk= +github.com/aws/aws-sdk-go-v2/service/s3 v1.38.5/go.mod h1:rDGMZA7f4pbmTtPOk5v5UM2lmX6UAbRnMDJeDvnH7AM= github.com/aws/aws-sdk-go-v2/service/sso v1.12.14/go.mod h1:9kfRdJgLCbnyeqZ/DpaSwcgj9ZDYLfRpe8Sze+NrYfQ= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.14 h1:8bEtxV5UT9ucdWGXfZ7CM3caQhSHGjWnTHt0OeF7m7s= +github.com/aws/aws-sdk-go-v2/service/sso v1.13.6 h1:2PylFCfKCEDv6PeSN09pC/VUiRd10wi1VfHG5FrW0/g= +github.com/aws/aws-sdk-go-v2/service/sso v1.13.6/go.mod h1:fIAwKQKBFu90pBxx07BFOMJLpRUGu8VOzLJakeY+0K4= github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.14/go.mod h1:nd9BG2UnexN2sDx/mk2Jd6pf3d2E61AiA8m8Fdvdx8Y= -github.com/aws/aws-sdk-go-v2/service/sts v1.20.1 h1:U7h9CPoyMfVoN5jUglB0LglCMP10AK4vMBsbsCKM8Yw= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.6 h1:pSB560BbVj9ZlJZF4WYj5zsytWHWKxg+NgyGV4B2L58= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.6/go.mod h1:yygr8ACQRY2PrEcy3xsUI357stq2AxnFM6DIsR9lij4= github.com/aws/aws-sdk-go-v2/service/sts v1.20.1/go.mod h1:BUHusg4cOA1TFGegj7x8/eoWrbdHzJfoMrXcbMQAG0k= -github.com/aws/smithy-go v1.13.5 h1:hgz0X/DX0dGqTYpGALqXJoRKRj5oQ7150i5FdTePzO8= +github.com/aws/aws-sdk-go-v2/service/sts v1.21.5 h1:CQBFElb0LS8RojMJlxRSo/HXipvTZW2S44Lt9Mk2aYQ= +github.com/aws/aws-sdk-go-v2/service/sts v1.21.5/go.mod h1:VC7JDqsqiwXukYEDjoHh9U0fOJtNWh04FPQz4ct4GGU= github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= +github.com/aws/smithy-go v1.14.2 h1:MJU9hqBGbvWZdApzpvoF2WAIJDbtjK2NDJSiJP7HblQ= +github.com/aws/smithy-go v1.14.2/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4= github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= @@ -323,8 +341,8 @@ golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211116061358-0a5406a5449c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= diff --git a/openapi/README.md b/openapi/README.md index a11e35aa..3908754e 100644 --- a/openapi/README.md +++ b/openapi/README.md @@ -15,7 +15,7 @@ Build something awesome! This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client. - API version: v1 -- Package version: 0.21.1 +- Package version: 0.21.2 - Build package: org.openapitools.codegen.languages.GoClientCodegen ## Installation diff --git a/openapi/configuration.go b/openapi/configuration.go index a6bbf77d..2a6d1769 100644 --- a/openapi/configuration.go +++ b/openapi/configuration.go @@ -86,7 +86,7 @@ type Configuration struct { func NewConfiguration() *Configuration { cfg := &Configuration{ DefaultHeader: make(map[string]string), - UserAgent: "OpenAPI-Generator/0.21.1/go", + UserAgent: "OpenAPI-Generator/0.21.2/go", Debug: false, Servers: ServerConfigurations{ { diff --git a/option/query.go b/option/query.go index b38172d9..014f4126 100644 --- a/option/query.go +++ b/option/query.go @@ -4,6 +4,15 @@ import "github.com/rockset/rockset-go-client/openapi" type QueryOption func(request *openapi.QueryRequest) +// WithDefaultRowLimit sets the row limit to use. Limits specified in the query text will override this default. +func WithDefaultRowLimit(limit int32) QueryOption { + return func(o *openapi.QueryRequest) { + o.Sql.DefaultRowLimit = &limit + } +} + +// WithRowLimit sets the row limit to use. Limits specified in the query text will override this default. +// Deprecated, use WithDefaultRowLimit instead. func WithRowLimit(limit int32) QueryOption { return func(o *openapi.QueryRequest) { o.Sql.DefaultRowLimit = &limit @@ -22,7 +31,11 @@ func WithParameter(name, valueType, value string) QueryOption { } } -// WithAsync means that the query will run asynchronously so that queries can run with an extended timeout of 30 minutes. When set, the query request will return immediately with a query id that can be used to retrieve the status and results. +// WithAsync means that the query will run asynchronously for up to 30 minutes. +// The query request will immediately return with a query id that can be used to retrieve the query status and results. +// If not specified, the query will return with results once completed or timeout after 2 minutes. +// (To return results directly for shorter queries while still allowing a timeout of up to 30 minutes, +// use WithAsyncClientTimeout()) func WithAsync() QueryOption { return func(o *openapi.QueryRequest) { o.Async = openapi.PtrBool(true) @@ -30,7 +43,7 @@ func WithAsync() QueryOption { } // WithTimeout is the maximum amount of time that Rockset will attempt to complete query execution before -// aborting the query and returning an error. The query timeout defaults to a maximum of 2 minutes. +// aborting the query and returning an error. The query timeout defaults to a maximum of 2 minutes. // If WithAsync is set, the query timeout defaults to a maximum of 30 minutes. func WithTimeout(timeout int64) QueryOption { return func(o *openapi.QueryRequest) { @@ -39,7 +52,7 @@ func WithTimeout(timeout int64) QueryOption { } // WithMaxInitialResults is the maximum number of results you will receive as a client. If the query exceeds this limit, -// the remaining results can be requested using a returned pagination cursor. +// the remaining results can be requested using a returned pagination cursor. func WithMaxInitialResults(maxInitialResults int64) QueryOption { return func(o *openapi.QueryRequest) { o.MaxInitialResults = &maxInitialResults diff --git a/option/virtual_instance.go b/option/virtual_instance.go index bf579a57..bdabd79c 100644 --- a/option/virtual_instance.go +++ b/option/virtual_instance.go @@ -4,10 +4,12 @@ import "time" // VirtualInstanceOptions contains the optional settings for a virtual instance. type VirtualInstanceOptions struct { - Description *string - Size *string - MountRefreshInterval *time.Duration - AutoSuspend *time.Duration + Description *string + Size *string + MountRefreshInterval *time.Duration + AutoSuspend *time.Duration + EnableRemountOnResume *bool + Name *string } type VirtualInstanceOption func(*VirtualInstanceOptions) @@ -51,6 +53,20 @@ func WithVirtualInstanceSize(size VirtualInstanceSize) VirtualInstanceOption { } } +// WithVirtualInstanceName is used to set a new name for the virtual instance. +func WithVirtualInstanceName(name string) VirtualInstanceOption { + return func(o *VirtualInstanceOptions) { + o.Name = &name + } +} + +// WithVirtualInstanceDescription is used to set a description for the virtual instance. +func WithVirtualInstanceDescription(desc string) VirtualInstanceOption { + return func(o *VirtualInstanceOptions) { + o.Description = &desc + } +} + // TODO: once the openapi-generator generates a custom type for each enum the below two types can be replaced // https://github.com/OpenAPITools/openapi-generator/issues/9567 diff --git a/queries.go b/queries.go index 15e75648..9f2cff94 100644 --- a/queries.go +++ b/queries.go @@ -2,9 +2,10 @@ package rockset import ( "context" + "net/http" + "github.com/rockset/rockset-go-client/openapi" "github.com/rockset/rockset-go-client/option" - "net/http" ) type QueryState string @@ -19,12 +20,24 @@ const ( // Query executes a sql query with optional option.QueryOption func (rc *RockClient) Query(ctx context.Context, sql string, + options ...option.QueryOption) (openapi.QueryResponse, error) { + return queryWrapper(ctx, rc, "", sql, options...) +} + +func queryWrapper(ctx context.Context, rc *RockClient, vID, sql string, options ...option.QueryOption) (openapi.QueryResponse, error) { var err error var httpResp *http.Response var response *openapi.QueryResponse + var plainQuery openapi.ApiQueryRequest + var viQuery openapi.ApiQueryVirtualInstanceRequest + + if vID == "" { + plainQuery = rc.QueriesApi.Query(ctx) + } else { + viQuery = rc.VirtualInstancesApi.QueryVirtualInstance(ctx, vID) + } - q := rc.QueriesApi.Query(ctx) queryRequest := openapi.NewQueryRequestWithDefaults() queryRequest.Sql = openapi.QueryRequestSql{Query: sql} queryRequest.Sql.Parameters = []openapi.QueryParameter{} @@ -34,7 +47,11 @@ func (rc *RockClient) Query(ctx context.Context, sql string, } err = rc.Retry(ctx, func() error { - response, httpResp, err = q.Body(*queryRequest).Execute() + if vID == "" { + response, httpResp, err = plainQuery.Body(*queryRequest).Execute() + } else { + response, httpResp, err = viQuery.Body(*queryRequest).Execute() + } return NewErrorWithStatusCode(err, httpResp) }) diff --git a/rockset_test.go b/rockset_test.go index 8a4b886b..6b4793c6 100644 --- a/rockset_test.go +++ b/rockset_test.go @@ -119,7 +119,10 @@ func vcrClient(name string) (*rockset.RockClient, func(string) string, error) { func vcrClientWrapper(mode, name string) (*rockset.RockClient, func(string) string, error) { randFn := randomName - options := []rockset.RockOption{rockset.WithUserAgent("rockset-go-integration-tests")} + options := []rockset.RockOption{ + rockset.WithUserAgent("rockset-go-integration-tests"), + rockset.WithCustomHeader("x-rockset-test", "go-client"), + } var settings []govcr.Setting path := vcrBucketPath(name) @@ -149,8 +152,10 @@ func vcrClientWrapper(mode, name string) (*rockset.RockClient, func(string) stri options = append(options, rockset.WithAPIKey("fake"), rockset.WithAPIServer("fake"), rockset.WithRetry(&testRetrier{})) case "online": // for running everything live - settings = vcrSettings(false) - settings = append(settings, govcr.WithLiveOnlyMode(), govcr.WithReadOnlyMode()) + settings = append(vcrSettings(false), govcr.WithLiveOnlyMode(), govcr.WithReadOnlyMode()) + case "disabled": + rc, err := rockset.NewClient(options...) + return rc, randFn, err default: return nil, nil, fmt.Errorf("unknown VCR_MODE: %s", mode) } diff --git a/version.go b/version.go index 3103f436..c0fc1491 100644 --- a/version.go +++ b/version.go @@ -1,4 +1,4 @@ package rockset // Version is the Rockset client version -const Version = "0.21.1" +const Version = "0.21.2" diff --git a/virtual_instances.go b/virtual_instances.go index 197d3493..24ac20f3 100644 --- a/virtual_instances.go +++ b/virtual_instances.go @@ -20,6 +20,15 @@ const ( VirtualInstanceSuspended = "SUSPENDED" VirtualInstanceResuming = "RESUMING" VirtualInstanceDeleted = "DELETED" + + MountCreating = "CREATING" + MountActive = "ACTIVE" + MountRefreshing = "REFRESHING" + MountExpired = "EXPIRED" + MountDeleting = "DELETING" + MountSwitchingRefreshType = "SWITCHING_REFRESH_TYPE" + MountSuspended = "SUSPENDED" + MountSuspending = "SUSPENDING" ) // CreateVirtualInstance creates a new virtual instance. @@ -27,7 +36,8 @@ const ( // create a virtual instance that will never refresh the mounts. // // REST API documentation https://rockset.com/docs/rest-api/#createvirtualinstance -func (rc *RockClient) CreateVirtualInstance(ctx context.Context, name string, options ...option.VirtualInstanceOption) (openapi.VirtualInstance, error) { +func (rc *RockClient) CreateVirtualInstance(ctx context.Context, name string, + options ...option.VirtualInstanceOption) (openapi.VirtualInstance, error) { var err error var httpResp *http.Response var resp *openapi.CreateVirtualInstanceResponse @@ -54,6 +64,9 @@ func (rc *RockClient) CreateVirtualInstance(ctx context.Context, name string, op s := int32(opts.MountRefreshInterval.Seconds()) req.MountRefreshIntervalSeconds = &s } + if opts.EnableRemountOnResume != nil { + req.EnableRemountOnResume = opts.EnableRemountOnResume + } q := rc.VirtualInstancesApi.CreateVirtualInstance(ctx) @@ -156,12 +169,29 @@ func (rc *RockClient) UpdateVirtualInstance(ctx context.Context, vID string, q := rc.VirtualInstancesApi.SetVirtualInstance(ctx, vID) req := openapi.NewUpdateVirtualInstanceRequest() + if opts.Name != nil { + req.Name = opts.Name + } + if opts.Description != nil { + req.Description = opts.Description + } if opts.Size != nil { req.NewSize = opts.Size } + if opts.AutoSuspend != nil { + s := int32(opts.AutoSuspend.Seconds()) + req.AutoSuspendSeconds = &s + } + if opts.MountRefreshInterval != nil { + s := int32(opts.MountRefreshInterval.Seconds()) + req.MountRefreshIntervalSeconds = &s + } + if opts.EnableRemountOnResume != nil { + req.EnableRemountOnResume = opts.EnableRemountOnResume + } err = rc.Retry(ctx, func() error { - resp, httpResp, err = q.Execute() + resp, httpResp, err = q.Body(*req).Execute() return NewErrorWithStatusCode(err, httpResp) }) @@ -219,41 +249,19 @@ func (rc *RockClient) ResumeVirtualInstance(ctx context.Context, vID string) (op return resp.GetData(), nil } -// ExecuteQueryOnVirtualInstance executes the SQL query on a specific virtual instance instead of the main virtual instance. +// ExecuteQueryOnVirtualInstance executes the SQL query on a specific virtual instance instead of the main +// virtual instance. // // REST API documentation https://rockset.com/docs/rest-api/#queryvirtualinstance -func (rc *RockClient) ExecuteQueryOnVirtualInstance(ctx context.Context, vID string, sql string, options ...option.QueryOption) (openapi.QueryResponse, error) { - var err error - var httpResp *http.Response - var resp *openapi.QueryResponse - - queryRequest := openapi.NewQueryRequestWithDefaults() - queryRequest.Sql = openapi.QueryRequestSql{Query: sql} - queryRequest.Sql.Parameters = []openapi.QueryParameter{} - - for _, o := range options { - o(queryRequest) - } - - q := rc.VirtualInstancesApi.QueryVirtualInstance(ctx, vID) - - err = rc.Retry(ctx, func() error { - resp, httpResp, err = q.Body(*queryRequest).Execute() - - return NewErrorWithStatusCode(err, httpResp) - }) - - if err != nil { - return openapi.QueryResponse{}, err - } - - return *resp, nil +func (rc *RockClient) ExecuteQueryOnVirtualInstance(ctx context.Context, vID string, sql string, + options ...option.QueryOption) (openapi.QueryResponse, error) { + return queryWrapper(ctx, rc, vID, sql, options...) } -// GetVirtualInstanceQueries lists actively queued and running queries for a particular Virtual Instance. +// ListVirtualInstanceQueries lists actively queued and running queries for a particular Virtual Instance. // // REST API documentation -func (rc *RockClient) GetVirtualInstanceQueries(ctx context.Context, vID string) ([]openapi.QueryInfo, error) { +func (rc *RockClient) ListVirtualInstanceQueries(ctx context.Context, vID string) ([]openapi.QueryInfo, error) { var err error var httpResp *http.Response var resp *openapi.ListQueriesResponse @@ -299,7 +307,8 @@ func (rc *RockClient) ListCollectionMounts(ctx context.Context, vID string) ([]o // GetCollectionMount gets a mount on this virtual instance. // // REST API documentation https://rockset.com/docs/rest-api/#getcollectionmount -func (rc *RockClient) GetCollectionMount(ctx context.Context, vID, collectionPath string) (openapi.CollectionMount, error) { +func (rc *RockClient) GetCollectionMount(ctx context.Context, vID, + collectionPath string) (openapi.CollectionMount, error) { var err error var httpResp *http.Response var resp *openapi.CollectionMountResponse @@ -319,10 +328,12 @@ func (rc *RockClient) GetCollectionMount(ctx context.Context, vID, collectionPat return *resp.Data, nil } -// MountCollection mounts collections on a virtual instance. +// MountCollections mounts collections on a virtual instance, where the collections are listed as +// workspace.collection. // // REST API documentation https://rockset.com/docs/rest-api/#mountcollection -func (rc *RockClient) MountCollection(ctx context.Context, vID string, collectionPaths []string) ([]openapi.CollectionMount, error) { +func (rc *RockClient) MountCollections(ctx context.Context, vID string, + collectionPaths []string) ([]openapi.CollectionMount, error) { var err error var httpResp *http.Response var resp *openapi.CreateCollectionMountsResponse @@ -348,7 +359,8 @@ func (rc *RockClient) MountCollection(ctx context.Context, vID string, collectio // UnmountCollection unmount a collection from a virtual instance. // // REST API documentation https://rockset.com/docs/rest-api/#unmountcollection -func (rc *RockClient) UnmountCollection(ctx context.Context, vID string, collectionPath string) (openapi.CollectionMount, error) { +func (rc *RockClient) UnmountCollection(ctx context.Context, vID string, + collectionPath string) (openapi.CollectionMount, error) { var err error var httpResp *http.Response var resp *openapi.CollectionMountResponse diff --git a/virtual_instances_test.go b/virtual_instances_test.go index 8ef5f126..7c9eb7fc 100644 --- a/virtual_instances_test.go +++ b/virtual_instances_test.go @@ -37,7 +37,7 @@ func TestVirtualInstance(t *testing.T) { func (s *VirtualInstanceSuite) TestListQueries() { ctx := testCtx() - queries, err := s.rc.GetVirtualInstanceQueries(ctx, s.vID) + queries, err := s.rc.ListVirtualInstanceQueries(ctx, s.vID) s.Require().NoError(err) for _, q := range queries { s.NotEmpty(q.GetQueryId()) @@ -102,86 +102,159 @@ type VirtualInstanceIntegrationSuite struct { name string workspace string collection string + path string } // This test suite requires a Rockset org with "premium" support, as it needs to create a virtual instance. func TestVirtualInstanceIntegration(t *testing.T) { rc, randomName := vcrTestClient(t, t.Name()) + name := randomName("vi") s := VirtualInstanceIntegrationSuite{ rc: rc, - name: randomName("vi"), + name: name, + path: name + "." + name, } suite.Run(t, &s) } -func (s *VirtualInstanceIntegrationSuite) TestVirtualInstance() { +func (s *VirtualInstanceIntegrationSuite) TestVirtualInstance_0_Create() { ctx := testCtx() + t0 := time.Now() + rc, _ := vcrTestClient(s.T(), s.T().Name()) - vi, err := s.rc.CreateVirtualInstance(ctx, s.name, + vi, err := rc.CreateVirtualInstance(ctx, s.name, option.WithVirtualInstanceSize(option.SizeSmall), option.WithNoMountRefresh(), - option.WithAutoSuspend(time.Hour), + option.WithAutoSuspend(15*time.Minute), ) s.Require().NoError(err) s.vID = vi.GetId() - s.T().Logf("vi %s (%s) is created", vi.GetName(), vi.GetId()) + s.T().Logf("vi %s / %s is created (%s)", vi.GetId(), vi.GetName(), time.Since(t0)) + t0 = time.Now() - err = s.rc.WaitUntilVirtualInstanceActive(ctx, s.vID) + err = rc.WaitUntilVirtualInstanceActive(ctx, s.vID) s.Require().NoError(err) - s.T().Logf("vi %s is active", s.vID) + s.T().Logf("vi %s is active (%s)", s.vID, time.Since(t0)) + t0 = time.Now() +} + +func (s *VirtualInstanceIntegrationSuite) TestVirtualInstance_1_Collection() { + ctx := testCtx() + t0 := time.Now() + rc, _ := vcrTestClient(s.T(), s.T().Name()) - ws, err := s.rc.CreateWorkspace(ctx, s.name) + ws, err := rc.CreateWorkspace(ctx, s.name) s.Require().NoError(err) s.workspace = ws.GetName() - s.T().Logf("workspace %s is created", s.workspace) + s.T().Logf("workspace %s is created (%s)", s.workspace, time.Since(t0)) + t0 = time.Now() - err = s.rc.WaitUntilWorkspaceAvailable(ctx, s.workspace) + err = rc.WaitUntilWorkspaceAvailable(ctx, s.workspace) s.Require().NoError(err) - s.T().Logf("workspace %s is available", s.workspace) + s.T().Logf("workspace %s is available (%s)", s.workspace, time.Since(t0)) + t0 = time.Now() - c, err := s.rc.CreateCollection(ctx, s.workspace, s.name, option.WithSampleDataset(dataset.Movies)) + c, err := rc.CreateCollection(ctx, s.workspace, s.name, option.WithSampleDataset(dataset.Movies)) s.Require().NoError(err) s.collection = c.GetName() - s.T().Logf("collection %s.%s is created", s.workspace, s.collection) + s.T().Logf("collection %s.%s is created (%s)", s.workspace, s.collection, time.Since(t0)) + t0 = time.Now() - err = s.rc.WaitUntilCollectionHasDocuments(ctx, s.workspace, s.collection, 2_830) + err = rc.WaitUntilCollectionHasDocuments(ctx, s.workspace, s.collection, 2_830) s.Require().NoError(err) - s.T().Log("collection has documents") + s.T().Log("collection has documents", time.Since(t0)) + t0 = time.Now() + +} + +func (s *VirtualInstanceIntegrationSuite) TestVirtualInstance_2_Mount() { + ctx := testCtx() + t0 := time.Now() + rc, _ := vcrTestClient(s.T(), s.T().Name()) - path := s.workspace + "." + s.collection - _, err = s.rc.MountCollection(ctx, s.vID, []string{path}) + _, err := rc.MountCollections(ctx, s.vID, []string{s.path}) s.Require().NoError(err) - s.T().Logf("collection %s.%s is mounted on %s", s.workspace, s.collection, s.vID) + s.T().Logf("collection %s.%s is mounted on %s (%s)", s.workspace, s.collection, s.vID, time.Since(t0)) + t0 = time.Now() - err = s.rc.WaitUntilCollectionReady(ctx, s.workspace, s.collection) + err = rc.WaitUntilCollectionReady(ctx, s.workspace, s.collection) s.Require().NoError(err) - s.T().Logf("collection %s.%s is ready", s.workspace, s.collection) + s.T().Logf("collection %s.%s is ready (%s)", s.workspace, s.collection, time.Since(t0)) + t0 = time.Now() - query := fmt.Sprintf("SELECT * FROM %s", path) - _, err = s.rc.Query(ctx, query) + err = rc.WaitUntilMountActive(ctx, s.vID, s.workspace, s.collection) s.Require().NoError(err) - s.T().Log("query ran") + s.T().Logf("mount is active: %s", time.Since(t0)) + t0 = time.Now() +} + +func (s *VirtualInstanceIntegrationSuite) TestVirtualInstance_3_Query() { + ctx := testCtx() + t0 := time.Now() + rc, _ := vcrTestClient(s.T(), s.T().Name()) - _, err = s.rc.SuspendVirtualInstance(ctx, s.vID) + query := fmt.Sprintf("SELECT * FROM %s.%s", s.workspace, s.collection) + _, err := rc.ExecuteQueryOnVirtualInstance(ctx, s.vID, query) s.Require().NoError(err) - s.T().Log("vi is suspending") + s.T().Logf("query ran (%s)", time.Since(t0)) + t0 = time.Now() - err = s.rc.WaitUntilVirtualInstanceSuspended(ctx, s.vID) + queries, err := rc.ListVirtualInstanceQueries(ctx, s.vID) s.Require().NoError(err) - s.T().Log("vi is suspended") + s.T().Logf("listed queries (%s)", time.Since(t0)) + s.NotEmpty(queries) + t0 = time.Now() +} + +func (s *VirtualInstanceIntegrationSuite) TestVirtualInstance_4_Unmount() { + ctx := testCtx() + t0 := time.Now() + rc, _ := vcrTestClient(s.T(), s.T().Name()) - _, err = s.rc.ResumeVirtualInstance(ctx, s.vID) + mounts, err := rc.ListCollectionMounts(ctx, s.vID) s.Require().NoError(err) - s.T().Log("vi is resuming") + s.T().Logf("listed mounts (%s)", time.Since(t0)) + s.NotEmpty(mounts) + t0 = time.Now() - err = s.rc.WaitUntilVirtualInstanceActive(ctx, s.vID) + _, err = rc.UnmountCollection(ctx, s.vID, s.path) s.Require().NoError(err) - s.T().Log("vi is active") + s.T().Logf("unmounted (%s)", time.Since(t0)) + t0 = time.Now() +} + +func (s *VirtualInstanceIntegrationSuite) TestVirtualInstance_5_Suspend() { + ctx := testCtx() + t0 := time.Now() + rc, _ := vcrTestClient(s.T(), s.T().Name()) + + _, err := rc.SuspendVirtualInstance(ctx, s.vID) + s.Require().NoError(err) + s.T().Logf("vi is suspending (%s)", time.Since(t0)) + t0 = time.Now() + + err = rc.WaitUntilVirtualInstanceSuspended(ctx, s.vID) + s.Require().NoError(err) + s.T().Logf("vi is suspended (%s)", time.Since(t0)) + t0 = time.Now() + + _, err = rc.ResumeVirtualInstance(ctx, s.vID) + s.Require().NoError(err) + s.T().Logf("vi is resuming (%s)", time.Since(t0)) + t0 = time.Now() - _, err = s.rc.Query(ctx, query) + err = rc.WaitUntilVirtualInstanceActive(ctx, s.vID) + s.Require().NoError(err) + s.T().Logf("vi is active (%s)", time.Since(t0)) + t0 = time.Now() + + _, err = rc.UpdateVirtualInstance(ctx, s.vID, + option.WithVirtualInstanceName("new_"+s.name), + option.WithVirtualInstanceDescription("new"), + ) s.Require().NoError(err) - s.T().Log("query after resume ran") + s.T().Logf("vi updated (%s)", time.Since(t0)) } func (s *VirtualInstanceIntegrationSuite) TearDownSuite() { diff --git a/wait.go b/wait.go index b64a664b..c8c6abfb 100644 --- a/wait.go +++ b/wait.go @@ -4,8 +4,9 @@ import ( "context" "errors" "fmt" - "github.com/rockset/rockset-go-client/option" "github.com/rs/zerolog" + + "github.com/rockset/rockset-go-client/option" ) const ( @@ -95,6 +96,16 @@ func (rc *RockClient) WaitUntilVirtualInstanceSuspended(ctx context.Context, id })) } +// WaitUntilMountActive waits until the collection mount is active, and queries can be issued to it on the +// virtual instance. +func (rc *RockClient) WaitUntilMountActive(ctx context.Context, vID, workspace, collection string) error { + return rc.RetryWithCheck(ctx, resourceHasState(ctx, []string{MountActive}, + func(ctx context.Context) (string, error) { + cm, err := rc.GetCollectionMount(ctx, vID, workspace+"."+collection) + return cm.GetState(), err + })) +} + // WaitUntilCollectionGone waits until a collection marked for deletion is gone, i.e. GetCollection() // returns "not found". func (rc *RockClient) WaitUntilCollectionGone(ctx context.Context, workspace, name string) error {