From d0ac74169f36d1c380f84b5477d7a03e8ef451a6 Mon Sep 17 00:00:00 2001 From: Aleksey Myasnikov Date: Sun, 1 Dec 2024 23:09:43 +0300 Subject: [PATCH 1/3] fixed linter issues --- .github/workflows/lint.yml | 2 +- .golangci.yml | 28 ++++++++++------------------ go.mod | 6 ++---- go.sum | 24 ++---------------------- internal/config/config.go | 3 ++- internal/storage/ydb.go | 18 ++++++++---------- internal/storage/ydb_test.go | 2 -- out_ydb.go | 2 +- 8 files changed, 26 insertions(+), 59 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c5ce18e..0d73543 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -18,4 +18,4 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: v1.55.2 + version: v1.60.3 diff --git a/.golangci.yml b/.golangci.yml index bc1400b..3279736 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -10,14 +10,6 @@ run: #build-tags: # - mytag - # which dirs to skip: they won't be analyzed; - # can use regexp here: generated.*, regexp is applied on full path; - # default value is empty list, but next dirs are always skipped independently - # from this option's value: - # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ - # skip-dirs: - skip-dirs-use-default: false - # which files to skip: they will be analyzed, but issues from them # won't be reported. Default value is empty list, but there is # no need to include all autogenerated files, we confidently recognize @@ -30,7 +22,7 @@ run: # output configuration options output: # colored-line-number|line-number|json|tab|checkstyle, default is "colored-line-number" - format: colored-line-number + formats: colored-line-number # print lines of code with issue, default is true print-issued-lines: true @@ -51,10 +43,7 @@ linters-settings: check-blank: false govet: # report about shadowed variables - check-shadowing: true - golint: - # minimal confidence for issues, default is 0.8 - min-confidence: 0.8 + shadow: true gofmt: # simplify code: gofmt with `-s` option, true by default simplify: true @@ -223,7 +212,6 @@ linters: - depguard - dupl - exhaustive - - exhaustivestruct - exhaustruct - forbidigo - forcetypeassert @@ -231,15 +219,14 @@ linters: - gochecknoglobals - gocognit - godot - - goerr113 - - golint - - ifshort + - gomnd + - err113 - interfacebloat - ireturn - maintidx + - mnd - nonamedreturns - paralleltest - - structcheck - testableexamples - testpackage - thelper @@ -270,6 +257,11 @@ issues: # Default value for this option is true. exclude-use-default: true + # Enables exclude of directories: + # - vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ + # Default: true + exclude-dirs-use-default: false + # Maximum count of issues with the same text. Set to 0 to disable. Default is 3. max-same-issues: 0 diff --git a/go.mod b/go.mod index d928ff4..7709d3f 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module github.com/ydb-platform/fluent-bit-ydb -go 1.22.7 - -toolchain go1.23.3 +go 1.22 require ( github.com/fluent/fluent-bit-go v0.0.0-20230731091245-a7a013e2473c @@ -11,6 +9,7 @@ require ( github.com/surge/cityhash v0.0.0-20131128155616-cdd6a94144ab github.com/ydb-platform/ydb-go-sdk/v3 v3.92.6 github.com/ydb-platform/ydb-go-yc v0.12.1 + golang.org/x/sync v0.9.0 ) require ( @@ -26,7 +25,6 @@ require ( github.com/ydb-platform/ydb-go-genproto v0.0.0-20241112172322-ea1f63298f77 // indirect github.com/ydb-platform/ydb-go-yc-metadata v0.6.1 // indirect golang.org/x/net v0.31.0 // indirect - golang.org/x/sync v0.9.0 // indirect golang.org/x/sys v0.27.0 // indirect golang.org/x/text v0.20.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect diff --git a/go.sum b/go.sum index 32c7e4b..4f80dca 100644 --- a/go.sum +++ b/go.sum @@ -591,8 +591,6 @@ github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MG github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/golang-jwt/jwt/v4 v4.4.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo= github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= @@ -629,6 +627,8 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= @@ -790,14 +790,10 @@ github.com/yandex-cloud/go-genproto v0.0.0-20240425114406-68c9b49389a1 h1:VDGcTx github.com/yandex-cloud/go-genproto v0.0.0-20240425114406-68c9b49389a1/go.mod h1:HEUYX/p8966tMUHHT+TsS0hF/Ca/NYwqprC5WXSDMfE= github.com/ydb-platform/ydb-go-genproto v0.0.0-20221215182650-986f9d10542f/go.mod h1:Er+FePu1dNUieD+XTMDduGpQuCPssK5Q4BjF+IIXJ3I= github.com/ydb-platform/ydb-go-genproto v0.0.0-20230528143953-42c825ace222/go.mod h1:Er+FePu1dNUieD+XTMDduGpQuCPssK5Q4BjF+IIXJ3I= -github.com/ydb-platform/ydb-go-genproto v0.0.0-20240316140903-4a47abca1cca h1:PliQWLwi2gTSOk7QyYQ9GfjvvikmibLWmaplKHy+kfo= -github.com/ydb-platform/ydb-go-genproto v0.0.0-20240316140903-4a47abca1cca/go.mod h1:Er+FePu1dNUieD+XTMDduGpQuCPssK5Q4BjF+IIXJ3I= github.com/ydb-platform/ydb-go-genproto v0.0.0-20241112172322-ea1f63298f77 h1:LY6cI8cP4B9rrpTleZk95+08kl2gF4rixG7+V/dwL6Q= github.com/ydb-platform/ydb-go-genproto v0.0.0-20241112172322-ea1f63298f77/go.mod h1:Er+FePu1dNUieD+XTMDduGpQuCPssK5Q4BjF+IIXJ3I= github.com/ydb-platform/ydb-go-sdk/v3 v3.44.0/go.mod h1:oSLwnuilwIpaF5bJJMAofnGgzPJusoI3zWMNb8I+GnM= github.com/ydb-platform/ydb-go-sdk/v3 v3.47.3/go.mod h1:bWnOIcUHd7+Sl7DN+yhyY1H/I61z53GczvwJgXMgvj0= -github.com/ydb-platform/ydb-go-sdk/v3 v3.66.3 h1:XeY8gUh18MNJW0+TmPx8rl+vpnWwwiqgII27JdPmgJA= -github.com/ydb-platform/ydb-go-sdk/v3 v3.66.3/go.mod h1:hGX4CijskNnUTRgLlqMvZdrBQc1ALZgAnKHytF5nmj4= github.com/ydb-platform/ydb-go-sdk/v3 v3.92.6 h1:4T6B1Mv1vZiq+08Jv/J5R5ZG4ManSEeaVRPHB2FrRH4= github.com/ydb-platform/ydb-go-sdk/v3 v3.92.6/go.mod h1:WiezFS4YCi2vHqbYGQkeu/2MDBYFLix6dIs/pd87Yck= github.com/ydb-platform/ydb-go-yc v0.12.1 h1:qw3Fa+T81+Kpu5Io2vYHJOwcrYrVjgJlT6t/0dOXJrA= @@ -948,8 +944,6 @@ golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= -golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo= golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -996,8 +990,6 @@ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1077,8 +1069,6 @@ golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= -golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -1103,8 +1093,6 @@ golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1376,12 +1364,8 @@ google.golang.org/genproto v0.0.0-20230209215440-0dfe4f8abfcc/go.mod h1:RGgjbofJ google.golang.org/genproto v0.0.0-20230216225411-c8e22ba71e44/go.mod h1:8B0gmkoRebU8ukX6HP+4wrVQUY1+6PkQ44BSyIlflHA= google.golang.org/genproto v0.0.0-20230222225845-10f96fb3dbec/go.mod h1:3Dl5ZL0q0isWJt+FVcfpQyirqemEuLAK/iFvg1UP1Hw= google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4/go.mod h1:NWraEVixdDnqcqQ30jipen1STv2r/n24Wb7twVTGR4s= -google.golang.org/genproto/googleapis/api v0.0.0-20240415180920-8c6c420018be h1:Zz7rLWqp0ApfsR/l7+zSHhY3PMiH2xqgxlfYfAfNpoU= -google.golang.org/genproto/googleapis/api v0.0.0-20240415180920-8c6c420018be/go.mod h1:dvdCTIoAGbkWbcIKBniID56/7XHTt6WfxXNMxuziJ+w= google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 h1:hjSy6tcFQZ171igDaN5QHOw2n6vx40juYbC/x67CEhc= google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:qpvKtACPCQhAdu3PyQgV4l3LMXZEtft7y8QcarRsp9I= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be h1:LG9vZxsWGOmUKieR8wPAUR3u3MpnYFQZROPIMaXh7/A= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697 h1:LWZqQOEjDyONlF1H6afSWpAL/znlREo2tHfLoe+8LMA= google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697/go.mod h1:5uTbfoYQed2U9p3KIj2/Zzm02PYhndfdmML0qC3q3FU= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -1424,8 +1408,6 @@ google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsA google.golang.org/grpc v1.52.0/go.mod h1:pu6fVzoFb+NBYNAvQL08ic+lvB2IojljRYuun5vorUY= google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8= -google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= -google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= google.golang.org/grpc v1.68.0 h1:aHQeeJbo8zAkAa3pRzrVjZlbz6uSfeOXlJNQM0RAbz0= google.golang.org/grpc v1.68.0/go.mod h1:fmSPC5AsjSBCK54MyHRx48kpOti1/jRfOlwEWywNjWA= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= @@ -1445,8 +1427,6 @@ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io= google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/internal/config/config.go b/internal/config/config.go index c38e1d5..54be6a0 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -2,6 +2,7 @@ package config import ( "encoding/json" + "errors" "fmt" "net/url" "os" @@ -248,7 +249,7 @@ func ReadConfigFromPlugin(plugin unsafe.Pointer) (cfg Config, _ error) { // credentials creds, err := ydbCredentials(plugin) if err != nil { - return cfg, fmt.Errorf("required valid credentials") + return cfg, errors.New("required valid credentials") } cfg.CredentialsOption = creds diff --git a/internal/storage/ydb.go b/internal/storage/ydb.go index 2d5a642..faa11a5 100644 --- a/internal/storage/ydb.go +++ b/internal/storage/ydb.go @@ -40,7 +40,7 @@ type YDB struct { } func New(cfg *config.Config) (*YDB, error) { - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) //nolint:gomnd + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() opts := []ydb.Option{cfg.CredentialsOption} @@ -159,7 +159,7 @@ func null2Type(t types.Type, optional bool, columnTypeYql string) (types.Value, return nil, -1, fmt.Errorf("not supported conversion from NULL to '%s' (%s)", columnTypeYql, t) } -func type2Type(t types.Type, v interface{}) (types.Value, int, error) { +func type2Type(t types.Type, v interface{}) (types.Value, int, error) { //nolint:funlen optional, columnType := convertTypeIfOptional(t) columnTypeYql := yqlType(columnType) @@ -265,7 +265,7 @@ func (s *YDB) AppendColumn(name string, in interface{}, rowbytes int, columns [] return s.AppendColumnPlain(cref, in, rowbytes, columns) } -func (s *YDB) ConvertRows(events []*model.Event) ([]types.Value, int, error) { +func (s *YDB) ConvertRows(events []*model.Event) ([]types.Value, int, error) { //nolint:funlen rows := make([]types.Value, 0, len(events)) maxrowbytes := 1 colCount := len(s.fieldMapping) @@ -348,7 +348,7 @@ func (s *YDB) ConvertRows(events []*model.Event) ([]types.Value, int, error) { if err != nil { return nil, -1, fmt.Errorf("failed to marshal json value: %w. Value: %#v", err, hashValue) } - hashval := cityhash.CityHash64(j, uint32(len(j))) + hashval := cityhash.CityHash64(j, uint32(len(j))) //nolint:gosec columns, rowbytes, err = s.AppendColumnPlain(hashColumn, hashval, rowbytes, columns) if err != nil { return nil, -1, err @@ -390,11 +390,9 @@ func (s *YDB) Write(events []*model.Event) error { } part := rows[position:finish] writes.Go(func() error { - return s.db.Table().Do(context.Background(), - func(ctx context.Context, sess table.Session) error { - return sess.BulkUpsert(ctx, path.Join(s.db.Name(), s.cfg.TablePath), types.ListValue(part...)) - }, - table.WithIdempotent(), + return s.db.Table().BulkUpsert(context.Background(), + path.Join(s.db.Name(), s.cfg.TablePath), + table.BulkUpsertDataRows(types.ListValue(part...)), ) }) position = finish @@ -430,7 +428,7 @@ func convertByteFieldsToString(in map[interface{}]interface{}) map[string]interf out := make(map[string]interface{}, len(in)) for key, value := range in { - key := key.(string) + key := key.(string) //nolint:forcetypeassert switch value := value.(type) { case map[interface{}]interface{}: diff --git a/internal/storage/ydb_test.go b/internal/storage/ydb_test.go index 209bbb0..290caa6 100644 --- a/internal/storage/ydb_test.go +++ b/internal/storage/ydb_test.go @@ -113,8 +113,6 @@ func TestType2TypeOk(t *testing.T) { } for _, tc := range cases { - tc := tc - t.Run(tc.name, func(t *testing.T) { actual, _, err := type2Type(tc.column, tc.value) diff --git a/out_ydb.go b/out_ydb.go index ed912f1..565d404 100644 --- a/out_ydb.go +++ b/out_ydb.go @@ -71,7 +71,7 @@ func FLBPluginFlushCtx(ctx, data unsafe.Pointer, length C.int, tag *C.char) int var timestamp time.Time switch t := ts.(type) { case output.FLBTime: - timestamp = ts.(output.FLBTime).Time + timestamp = ts.(output.FLBTime).Time //nolint:forcetypeassert case uint64: timestamp = time.Unix(int64(t), 0) default: From 0b1c1caa48a7e245d696e11f913fd006898b738f Mon Sep 17 00:00:00 2001 From: Aleksey Myasnikov Date: Sun, 1 Dec 2024 23:16:03 +0300 Subject: [PATCH 2/3] reverted version + added CHANGELOG --- CHANGELOG.md | 3 +++ version.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4df11c5..bc0f7c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +* Upgraded `ydb-go-sdk` dependency +* Set `info` as default log-level for fluent-bit ydb plugin + ## v1.2.0 * Switched the internal plugin logger from `fmt` to `zerolog` with default logging level `zerolog.Disabled` * Added optional parameter of ydb output plugin `LogLevel` (if not defined - plugin logging disabled) diff --git a/version.go b/version.go index 835167d..3938161 100644 --- a/version.go +++ b/version.go @@ -3,7 +3,7 @@ package main const ( versionMajor = "1" versionMinor = "2" - versionPatch = "1" + versionPatch = "0" ) const version = versionMajor + "." + versionMinor + "." + versionPatch From 9abf1696e62fc70e5d4f87c615d2c7ddc669c8f5 Mon Sep 17 00:00:00 2001 From: Aleksey Myasnikov Date: Sun, 1 Dec 2024 23:20:41 +0300 Subject: [PATCH 3/3] fix go mod tidy --- go.mod | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 7709d3f..b25c690 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,8 @@ module github.com/ydb-platform/fluent-bit-ydb -go 1.22 +go 1.22.7 + +toolchain go1.23.0 require ( github.com/fluent/fluent-bit-go v0.0.0-20230731091245-a7a013e2473c