From 11b32622914ca5417afcf88f3d7468bcfdd9ee08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?France=CC=81=20Wilke?= <francewilke@gmail.com> Date: Thu, 23 Mar 2023 14:07:57 +0200 Subject: [PATCH] Update OpenSearch go library to V2.2.0 --- go.mod | 14 ++-- go.sum | 54 ++++++++++---- {search => opensearch}/README.md | 0 {search => opensearch}/config.go | 2 +- {search => opensearch}/dev/docker-compose.yml | 44 +++++------- {search => opensearch}/document_store.go | 43 +++++++----- {search => opensearch}/opensearch_types.go | 70 ++++++++++--------- {search => opensearch}/time_series.go | 39 ++++++----- {search => opensearch}/writer.go | 19 ++--- 9 files changed, 160 insertions(+), 125 deletions(-) rename {search => opensearch}/README.md (100%) rename {search => opensearch}/config.go (98%) rename {search => opensearch}/dev/docker-compose.yml (59%) rename {search => opensearch}/document_store.go (90%) rename {search => opensearch}/opensearch_types.go (86%) rename {search => opensearch}/time_series.go (94%) rename {search => opensearch}/writer.go (93%) diff --git a/go.mod b/go.mod index b2619ee..aca98a3 100644 --- a/go.mod +++ b/go.mod @@ -6,20 +6,22 @@ require ( github.com/MindscapeHQ/raygun4go v1.1.1 github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de github.com/aws/aws-lambda-go v1.26.0 - github.com/aws/aws-sdk-go v1.43.2 + github.com/aws/aws-sdk-go v1.44.180 github.com/aws/aws-secretsmanager-caching-go v1.1.0 github.com/go-pg/pg/v10 v10.10.6 github.com/go-redis/redis/v8 v8.11.4 github.com/go-redis/redis_rate/v9 v9.1.2 github.com/go-resty/resty/v2 v2.7.0 + github.com/golang-jwt/jwt/v4 v4.4.3 github.com/google/uuid v1.3.0 github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 - github.com/opensearch-project/opensearch-go v1.1.0 + github.com/opensearch-project/opensearch-go/v2 v2.2.0 github.com/pkg/errors v0.9.1 github.com/r3labs/diff/v2 v2.14.2 github.com/sirupsen/logrus v1.8.1 github.com/thoas/go-funk v0.9.1 - golang.org/x/text v0.3.7 + golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 + golang.org/x/text v0.4.0 ) require ( @@ -27,7 +29,6 @@ require ( github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/go-errors/errors v1.4.1 // indirect github.com/go-pg/zerochecker v0.2.0 // indirect - github.com/golang-jwt/jwt/v4 v4.4.3 // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect @@ -39,9 +40,8 @@ require ( github.com/vmihailenco/msgpack/v5 v5.3.4 // indirect github.com/vmihailenco/tagparser v0.1.2 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect - golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect - golang.org/x/net v0.0.0-20211216030914-fe4d6282115f // indirect - golang.org/x/sys v0.0.0-20210923061019-b8560ed6a9b7 // indirect + golang.org/x/net v0.1.0 // indirect + golang.org/x/sys v0.1.0 // indirect google.golang.org/appengine v1.6.6 // indirect google.golang.org/protobuf v1.26.0 // indirect mellium.im/sasl v0.2.1 // indirect diff --git a/go.sum b/go.sum index 2d3ed86..f9f519c 100644 --- a/go.sum +++ b/go.sum @@ -7,11 +7,22 @@ github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de/go.mod h1:DCaWoU github.com/aws/aws-lambda-go v1.26.0 h1:6ujqBpYF7tdZcBvPIccs98SpeGfrt/UOVEiexfNIdHA= github.com/aws/aws-lambda-go v1.26.0/go.mod h1:jJmlefzPfGnckuHdXX7/80O3BvUUi12XOkbv4w9SGLU= github.com/aws/aws-sdk-go v1.19.23/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go v1.42.27/go.mod h1:OGr6lGMAKGlG9CVrYnWYDKIyb829c6EVBRjxqjmPepc= -github.com/aws/aws-sdk-go v1.43.2 h1:T6LuKCNu8CYXXDn3xJoldh8FbdvuVH7C9aSuLNrlht0= -github.com/aws/aws-sdk-go v1.43.2/go.mod h1:OGr6lGMAKGlG9CVrYnWYDKIyb829c6EVBRjxqjmPepc= +github.com/aws/aws-sdk-go v1.44.180 h1:VLZuAHI9fa/3WME5JjpVjcPCNfpGHVMiHx8sLHWhMgI= +github.com/aws/aws-sdk-go v1.44.180/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go-v2 v1.17.3/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= +github.com/aws/aws-sdk-go-v2/config v1.18.8/go.mod h1:5XCmmyutmzzgkpk/6NYTjeWb6lgo9N170m1j6pQkIBs= +github.com/aws/aws-sdk-go-v2/credentials v1.13.8/go.mod h1:lVa4OHbvgjVot4gmh1uouF1ubgexSCN92P6CJQpT0t8= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.21/go.mod h1:ugwW57Z5Z48bpvUyZuaPy4Kv+vEfJWnIrky7RmkBvJg= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.27/go.mod h1:a1/UpzeyBBerajpnP5nGZa9mGzsBn5cOKxm6NWQsvoI= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.21/go.mod h1:+Gxn8jYn5k9ebfHEqlhrMirFjSW0v0C9fI+KN5vk2kE= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.28/go.mod h1:yRZVr/iT0AqyHeep00SZ4YfBAKojXz08w3XMBscdi0c= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.21/go.mod h1:lRToEJsn+DRA9lW4O9L9+/3hjTkUzlzyzHqn8MTds5k= +github.com/aws/aws-sdk-go-v2/service/sso v1.12.0/go.mod h1:wo/B7uUm/7zw/dWhBJ4FXuw1sySU5lyIhVg1Bu2yL9A= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.0/go.mod h1:TZSH7xLO7+phDtViY/KUp9WGCJMQkLJ/VpgkTFd5gh8= +github.com/aws/aws-sdk-go-v2/service/sts v1.18.0/go.mod h1:+lGbb3+1ugwKrNTWcf2RT05Xmp543B06zDFTwiTLp7I= github.com/aws/aws-secretsmanager-caching-go v1.1.0 h1:vcV94XGJ9KouXKYBTMqgrBw96Tae8JKLmoUZ5SbaXNo= github.com/aws/aws-secretsmanager-caching-go v1.1.0/go.mod h1:wahQpJP1dZKMqjGFAjGCqilHkTlN0zReGWocPLbXmxg= +github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= @@ -65,8 +76,9 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -104,8 +116,8 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc= github.com/onsi/gomega v1.16.0 h1:6gjqkI8iiRHMvdccRJM8rVKjCWk6ZIm6FTm3ddIe4/c= github.com/onsi/gomega v1.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= -github.com/opensearch-project/opensearch-go v1.1.0 h1:eG5sh3843bbU1itPRjA9QXbxcg8LaZ+DjEzQH9aLN3M= -github.com/opensearch-project/opensearch-go v1.1.0/go.mod h1:+6/XHCuTH+fwsMJikZEWsucZ4eZMma3zNSeLrTtVGbo= +github.com/opensearch-project/opensearch-go/v2 v2.2.0 h1:6RicCBiqboSVtLMjSiKgVQIsND4I3sxELg9uwWe/TKM= +github.com/opensearch-project/opensearch-go/v2 v2.2.0/go.mod h1:R8NTTQMmfSRsmZdfEn2o9ZSuSXn0WTHPYhzgl7LCFLY= github.com/pborman/uuid v1.2.1 h1:+ZZIw58t/ozdjRaXh/3awHfmWRbzYxJoAdNJxe/3pvw= github.com/pborman/uuid v1.2.1/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -126,12 +138,17 @@ github.com/smartystreets/assertions v1.2.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYl github.com/smartystreets/goconvey v1.7.2 h1:9RBaZCeXEQ3UselpuwUQHltGVXvdwm6cv1hgR6gDIPg= github.com/smartystreets/goconvey v1.7.2/go.mod h1:Vw0tHAZW6lzCRk3xgdin6fKYcG+G3Pg9vgXWeJpQFMM= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/thoas/go-funk v0.9.1 h1:O549iLZqPpTUQ10ykd26sZhzD+rmR5pWhuElrhbC20M= github.com/thoas/go-funk v0.9.1/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q= github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc h1:9lRDQMhESg+zvGYmW5DyG0UqvY96Bu5QYsTLvCHdrgo= @@ -148,6 +165,7 @@ github.com/vmihailenco/tagparser v0.1.2/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgq github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -159,6 +177,7 @@ golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTk golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -173,13 +192,15 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211216030914-fe4d6282115f h1:hEYJvxw1lSnWIl8X9ofsYMklzaDs90JI2az5YMd4fPM= -golang.org/x/net v0.0.0-20211216030914-fe4d6282115f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.1.0 h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0= +golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -195,15 +216,21 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210923061019-b8560ed6a9b7 h1:c20P3CcPbopVp2f7099WLOqSNKURf30Z0uq66HpijZY= golang.org/x/sys v0.0.0-20210923061019-b8560ed6a9b7/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= 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= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -212,10 +239,10 @@ golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -253,8 +280,9 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= mellium.im/sasl v0.2.1 h1:nspKSRg7/SyO0cRGY71OkfHab8tf9kCts6a6oTDut0w= diff --git a/search/README.md b/opensearch/README.md similarity index 100% rename from search/README.md rename to opensearch/README.md diff --git a/search/config.go b/opensearch/config.go similarity index 98% rename from search/config.go rename to opensearch/config.go index 4f1a112..622649e 100644 --- a/search/config.go +++ b/opensearch/config.go @@ -1,4 +1,4 @@ -package search +package opensearch import ( "regexp" diff --git a/search/dev/docker-compose.yml b/opensearch/dev/docker-compose.yml similarity index 59% rename from search/dev/docker-compose.yml rename to opensearch/dev/docker-compose.yml index ba1b3fd..0dc8e6d 100644 --- a/search/dev/docker-compose.yml +++ b/opensearch/dev/docker-compose.yml @@ -1,13 +1,13 @@ version: '3' services: - opensearch-node1: + opensearch-node1A: image: opensearchproject/opensearch:latest - container_name: opensearch-node1 + container_name: opensearch-node1A environment: - cluster.name=opensearch-cluster - - node.name=opensearch-node1 - - discovery.seed_hosts=opensearch-node1,opensearch-node2 - - cluster.initial_master_nodes=opensearch-node1,opensearch-node2 + - node.name=opensearch-node1A + - discovery.seed_hosts=opensearch-node1A,opensearch-node2A + - cluster.initial_master_nodes=opensearch-node1A,opensearch-node2A - bootstrap.memory_lock=true # along with the memlock settings below, disables swapping - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # minimum and maximum Java heap size, recommend setting both to 50% of system RAM ulimits: @@ -24,14 +24,14 @@ services: - 9600:9600 # required for Performance Analyzer networks: - opensearch-net - opensearch-node2: + opensearch-node2A: image: opensearchproject/opensearch:latest - container_name: opensearch-node2 + container_name: opensearch-node2A environment: - cluster.name=opensearch-cluster - - node.name=opensearch-node2 - - discovery.seed_hosts=opensearch-node1,opensearch-node2 - - cluster.initial_master_nodes=opensearch-node1,opensearch-node2 + - node.name=opensearch-node2A + - discovery.seed_hosts=opensearch-node1A,opensearch-node2A + - cluster.initial_master_nodes=opensearch-node1A,opensearch-node2A - bootstrap.memory_lock=true - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" ulimits: @@ -45,30 +45,20 @@ services: - opensearch-data2:/usr/share/opensearch/data networks: - opensearch-net - opensearch-dashboards: + opensearch-dashboardsA: image: opensearchproject/opensearch-dashboards:latest - container_name: opensearch-dashboards + container_name: opensearch-dashboardsA ports: - 5601:5601 expose: - "5601" environment: - OPENSEARCH_HOSTS: '["https://opensearch-node1:9200","https://opensearch-node2:9200"]' + OPENSEARCH_HOSTS: '["https://opensearch-node1A:9200","https://opensearch-node2A:9200"]' networks: - opensearch-net - - kibana: - container_name: opensearch-kibana - image: docker.elastic.co/kibana/kibana:7.11.0 - depends_on: - - opensearch-node1 - - opensearch-node2 - ports: - - 5602:5601 - expose: - - "5602" - environment: - ELASTICSEARCH_HOSTS: '["https://opensearch-node1:9200","https://opensearch-node2:9200"]' + logstash-with-plugin: + image: opensearchproject/logstash-oss-with-opensearch-output-plugin:latest + container_name: logstash-with-plugin networks: - opensearch-net @@ -77,4 +67,4 @@ volumes: opensearch-data2: networks: - opensearch-net: + opensearch-net: \ No newline at end of file diff --git a/search/document_store.go b/opensearch/document_store.go similarity index 90% rename from search/document_store.go rename to opensearch/document_store.go index d0437a4..542a4af 100644 --- a/search/document_store.go +++ b/opensearch/document_store.go @@ -1,15 +1,15 @@ -package search +package opensearch import ( "bytes" "context" "encoding/json" + "github.com/opensearch-project/opensearch-go/v2/opensearchapi" "io/ioutil" "net/http" "reflect" "strings" - opensearchapi "github.com/opensearch-project/opensearch-go/opensearchapi" "gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/errors" "gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/logs" ) @@ -27,7 +27,7 @@ type DocumentStore struct { // NewDocumentStore purpose: // -// create a document store index to write e.g. orders then allow one to search them +// create a document store index to write e.g. orders then allow one to opensearch them // // parameters: // @@ -100,19 +100,17 @@ func (ds *DocumentStore) Write(id string, data interface{}) error { return errors.Errorf("cannot write %T into DocumentStore(%s), expecting %s", data, ds.name, ds.dataType) } - // get daily search index to write to, from start time + // get daily opensearch index to write to, from start time indexName := ds.name // + "-" + startTime.Format("20060102") if !ds.created { res, err := ds.w.api.Create( indexName, // index name indexName, // document id strings.NewReader(string(ds.jsonSettings))) - defer func() { + if err != nil { if res != nil { res.Body.Close() } - }() - if err != nil { return errors.Wrapf(err, "failed to create index(%s)", indexName) } switch res.StatusCode { @@ -120,6 +118,9 @@ func (ds *DocumentStore) Write(id string, data interface{}) error { case http.StatusCreated: case http.StatusConflict: // 409 = already exists default: + if res != nil { + res.Body.Close() + } return errors.Errorf("failed to create index(%s): %v %s %s", indexName, res.StatusCode, res.Status(), res.String()) } @@ -128,6 +129,9 @@ func (ds *DocumentStore) Write(id string, data interface{}) error { Body: strings.NewReader(string(ds.jsonMappings)), }.Do(context.Background(), ds.w.client) if err != nil { + if res != nil { + res.Body.Close() + } return errors.Wrapf(err, "failed to create index(%s)", indexName) } switch res.StatusCode { @@ -135,14 +139,17 @@ func (ds *DocumentStore) Write(id string, data interface{}) error { case http.StatusCreated: case http.StatusConflict: // 409 = already exists default: + if res != nil { + res.Body.Close() + } return errors.Errorf("failed to create index(%s): %v %s %s", indexName, res.StatusCode, res.Status(), res.String()) } ds.created = true } - if res, err := ds.w.Write(indexName, id, data); err != nil { + if indexResponse, err := ds.w.Write(indexName, id, data); err != nil { return err } else { - logs.Info("IndexResponse: %+v", res) + logs.Info("IndexResponse: %+v", indexResponse) } return nil } @@ -160,7 +167,7 @@ func (ds *DocumentStore) Search(query Query, limit int64) (res *SearchResponseHi return } - // example search request body for free text + // example opensearch request body for free text // { // "size": 5, // "query": { @@ -184,7 +191,7 @@ func (ds *DocumentStore) Search(query Query, limit int64) (res *SearchResponseHi searchResponse, err := search.Do(context.Background(), ds.w.client) if err != nil { - err = errors.Wrapf(err, "failed to search documents") + err = errors.Wrapf(err, "failed to opensearch documents") return } @@ -202,8 +209,8 @@ func (ds *DocumentStore) Search(query Query, limit int64) (res *SearchResponseHi var response SearchResponseBody err = json.Unmarshal(bodyData, &response) if err != nil { - logs.Info("search response body: %s", string(bodyData)) - err = errors.Wrapf(err, "cannot decode search response body") + logs.Info("opensearch response body: %s", string(bodyData)) + err = errors.Wrapf(err, "cannot decode opensearch response body") return } @@ -215,9 +222,8 @@ func (ds *DocumentStore) Get(id string) (res *GetResponseBody, err error) { return nil, errors.Errorf("document store == nil") } get := opensearchapi.GetRequest{ - Index: ds.name, - DocumentType: "_doc", - DocumentID: id, + Index: ds.name, + DocumentID: id, } getResponse, err := get.Do(context.Background(), ds.w.client) if err != nil { @@ -261,9 +267,8 @@ func (ds *DocumentStore) Delete(id string) (err error) { }() del := opensearchapi.DeleteRequest{ - Index: ds.name, - DocumentType: "_doc", - DocumentID: id, + Index: ds.name, + DocumentID: id, } delResponse, err = del.Do(context.Background(), ds.w.client) if err != nil { diff --git a/search/opensearch_types.go b/opensearch/opensearch_types.go similarity index 86% rename from search/opensearch_types.go rename to opensearch/opensearch_types.go index 8e52f07..bfc31f4 100644 --- a/search/opensearch_types.go +++ b/opensearch/opensearch_types.go @@ -1,4 +1,4 @@ -package search +package opensearch // Settings // Mapping configures an index in OpenSearch @@ -36,7 +36,7 @@ type SearchRequestBody struct { Size int64 `json:"size,omitempty"` // limit From int64 `json:"from,omitempty"` // offset Query Query `json:"query"` - Timeout string `json:"timeout,omitempty"` // timeout for search + Timeout string `json:"timeout,omitempty"` // timeout for opensearch } // https://opensearch.org/docs/latest/opensearch/query-dsl/bool/ @@ -84,7 +84,7 @@ type QueryTerm map[string]string type QueryWildcard map[string]string type QueryMultiMatch struct { - Query string `json:"query"` // Full value match search in selected fields + Query string `json:"query"` // Full value match opensearch in selected fields Fields []string `json:"fields,omitempty" doc:"List of fields"` Type QueryMultiMatchType `json:"type,omitempty"` Operator string `json:"operator,omitempty"` @@ -98,7 +98,7 @@ const ( ) type QueryString struct { - Query string `json:"query"` // Text search with partial matches, using asterisk for optional or question mark for required wildcards before and/or after text + Query string `json:"query"` // Text opensearch with partial matches, using asterisk for optional or question mark for required wildcards before and/or after text Fields []string `json:"fields,omitempty" doc:"List of fields"` DefaultOperator string `json:"default_operator,omitempty"` } @@ -108,6 +108,7 @@ type QueryRange map[string]QueryExpr type QueryExpr map[string]string // SearchResponseBody example: +// // { // "took":872, // "timed_out":false, @@ -124,26 +125,26 @@ type QueryExpr map[string]string // }, // "max_score":null, // "hits":[ -// { -// "_index": "go-utils-audit-test-20211030", -// "_type": "_doc", -// "_id": "Tj9l5XwBWRiAneoYazic", -// "_score": 1.2039728, -// "_source": { -// "@timestamp": "2021-10-30T15:03:20.679481+02:00", -// "@end_time": "2021-10-30T15:03:20.469481+02:00", -// "@duration_ms": -210, -// "test1": "6", -// "test2": "ACC_00098", -// "test3": 10, -// "http": { -// "method": "GET", -// "path": "/accounts" -// }, -// "http_method": "GET", -// "http_path": "/accounts" -// } -// }, +// { +// "_index": "go-utils-audit-test-20211030", +// "_type": "_doc", +// "_id": "Tj9l5XwBWRiAneoYazic", +// "_score": 1.2039728, +// "_source": { +// "@timestamp": "2021-10-30T15:03:20.679481+02:00", +// "@end_time": "2021-10-30T15:03:20.469481+02:00", +// "@duration_ms": -210, +// "test1": "6", +// "test2": "ACC_00098", +// "test3": 10, +// "http": { +// "method": "GET", +// "path": "/accounts" +// }, +// "http_method": "GET", +// "http_path": "/accounts" +// } +// }, // ] // } // } @@ -181,16 +182,17 @@ type HitDoc struct { } // GetResponseBody Example: -// { -// "_index": "go-utils-search-docs-test", -// "_type": "_doc", -// "_id": "836c6443-5b0e-489b-aa0f-712ebed96841", -// "_version": 1, -// "_seq_no": 6, -// "_primary_term": 1, -// "found": true, -// "_source": { ... } -// } +// +// { +// "_index": "go-utils-opensearch-docs-test", +// "_type": "_doc", +// "_id": "836c6443-5b0e-489b-aa0f-712ebed96841", +// "_version": 1, +// "_seq_no": 6, +// "_primary_term": 1, +// "found": true, +// "_source": { ... } +// } type GetResponseBody struct { Index string `json:"_index"` // name of index Type string `json:"_type"` // _doc diff --git a/search/time_series.go b/opensearch/time_series.go similarity index 94% rename from search/time_series.go rename to opensearch/time_series.go index bf2022f..ffcd3f0 100644 --- a/search/time_series.go +++ b/opensearch/time_series.go @@ -1,4 +1,4 @@ -package search +package opensearch import ( "bytes" @@ -10,7 +10,7 @@ import ( "strings" "time" - "github.com/opensearch-project/opensearch-go/opensearchapi" + "github.com/opensearch-project/opensearch-go/v2/opensearchapi" "gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/errors" "gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/logs" ) @@ -133,7 +133,7 @@ func structMappingProperties(structType reflect.Type) (map[string]MappingPropert continue } - // get default type of search value from field type + // get default type of opensearch value from field type fieldMapping := MappingProperty{Type: "text"} switch structField.Type.Kind() { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: @@ -219,7 +219,8 @@ func (ts *TimeSeries) Write(startTime, endTime time.Time, data interface{}) erro return errors.Errorf("cannot write %T into TimeSeries(%s), expecting %s", data, ts.name, ts.dataType) } - // get daily search index to write to, from start time + // get daily opensearch index to write to, from start time + // indexName := ts.name + "-" + startTime.Format("20060102") indexName := ts.name + "-" + startTime.Format("20060102") if _, ok := ts.createdDates[indexName]; !ok { // create new index for this date - if not exists @@ -228,12 +229,10 @@ func (ts *TimeSeries) Write(startTime, endTime time.Time, data interface{}) erro indexName, // index name also used for document id strings.NewReader(string(ts.jsonSettings)), ) - defer func() { + if err != nil { if res != nil { res.Body.Close() } - }() - if err != nil { return errors.Wrapf(err, "failed to create index(%s)", indexName) } switch res.StatusCode { @@ -241,6 +240,9 @@ func (ts *TimeSeries) Write(startTime, endTime time.Time, data interface{}) erro case http.StatusCreated: case http.StatusConflict: // 409 = already exists default: + if res != nil { + res.Body.Close() + } return errors.Errorf("failed to create index(%s): %v %s %s", indexName, res.StatusCode, res.Status(), res.String()) } @@ -249,6 +251,9 @@ func (ts *TimeSeries) Write(startTime, endTime time.Time, data interface{}) erro Body: strings.NewReader(string(ts.jsonMappings)), }.Do(context.Background(), ts.w.client) if err != nil { + if res != nil { + res.Body.Close() + } return errors.Wrapf(err, "failed to create index(%s)", indexName) } switch res.StatusCode { @@ -256,6 +261,9 @@ func (ts *TimeSeries) Write(startTime, endTime time.Time, data interface{}) erro case http.StatusCreated: case http.StatusConflict: // 409 = already exists default: + if res != nil { + res.Body.Close() + } return errors.Errorf("failed to create index(%s): %v %s %s", indexName, res.StatusCode, res.Status(), res.String()) } ts.createdDates[indexName] = true @@ -269,10 +277,10 @@ func (ts *TimeSeries) Write(startTime, endTime time.Time, data interface{}) erro EndTime: endTime, DurationMs: endTime.Sub(startTime).Milliseconds(), })) - if res, err := ts.w.Write(indexName, "", x.Elem().Interface()); err != nil { + if indexResponse, err := ts.w.Write(indexName, "", x.Elem().Interface()); err != nil { return err } else { - logs.Info("IndexResponse: %+v", res) + logs.Info("IndexResponse: %+v", indexResponse) } return nil @@ -362,7 +370,7 @@ type IndexSettings struct { // So you can safely type assert e.g. // // type myType struct {...} -// ts := search.TimeSeries(..., myType{}) +// ts := opensearch.TimeSeries(..., myType{}) // docs,totalCount,err := ts.Search(...) // if err == nil { // for id,docValue := range docs { @@ -380,7 +388,7 @@ func (ts *TimeSeries) Search(query Query, sort []map[string]string, limit int64, return } - // example search request body for free text + // example opensearch request body for free text // { // "size": 5, // "query": { @@ -429,8 +437,8 @@ func (ts *TimeSeries) Search(query Query, sort []map[string]string, limit int64, var response SearchResponseBody err = json.Unmarshal(bodyData, &response) if err != nil { - logs.Info("search response body: %s", string(bodyData)) - err = errors.Wrapf(err, "cannot decode search response body") + logs.Info("opensearch response body: %s", string(bodyData)) + err = errors.Wrapf(err, "cannot decode opensearch response body") return } @@ -446,9 +454,8 @@ func (ts *TimeSeries) Get(id string) (res *GetResponseBody, err error) { } parts := strings.SplitN(id, "/", 2) get := opensearchapi.GetRequest{ - Index: parts[0], - DocumentType: "_doc", - DocumentID: parts[1], + Index: parts[0], + DocumentID: parts[1], } getResponse, err := get.Do(context.Background(), ts.w.client) if err != nil { diff --git a/search/writer.go b/opensearch/writer.go similarity index 93% rename from search/writer.go rename to opensearch/writer.go index 7c2a798..3091ebd 100644 --- a/search/writer.go +++ b/opensearch/writer.go @@ -1,10 +1,10 @@ -package search +package opensearch import ( "crypto/tls" "encoding/json" - opensearch "github.com/opensearch-project/opensearch-go" - opensearchapi "github.com/opensearch-project/opensearch-go/opensearchapi" + opensearch "github.com/opensearch-project/opensearch-go/v2" + opensearchapi "github.com/opensearch-project/opensearch-go/v2/opensearchapi" "gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/errors" "gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/logs" "net/http" @@ -71,16 +71,19 @@ func (writer Writer) Write(indexName string, id string, doc interface{}) (*Index if id != "" { options = append(options, writer.api.Index.WithDocumentID(id)) } - indexResponse, err := writer.api.Index( - indexName, - strings.NewReader(jsonDocStr), - options..., - ) + + var indexResponse *opensearchapi.Response + var err error defer func() { if indexResponse != nil { indexResponse.Body.Close() } }() + indexResponse, err = writer.api.Index( + indexName, + strings.NewReader(jsonDocStr), + options..., + ) if err != nil { return nil, errors.Wrapf(err, "failed to index document") } -- GitLab