diff --git a/go.mod b/go.mod index 7d5f0ff3e..0b66e86c8 100644 --- a/go.mod +++ b/go.mod @@ -4,33 +4,25 @@ go 1.14 require ( bou.ke/monkey v1.0.2 - github.com/fasthttp/router v1.0.2 // indirect - github.com/gogo/protobuf v1.3.1 github.com/golang/protobuf v1.4.2 github.com/google/uuid v1.1.1 - github.com/grpc-ecosystem/go-grpc-middleware v1.2.0 // indirect github.com/mr-tron/base58 v1.1.3 github.com/multiformats/go-multiaddr v0.2.0 github.com/multiformats/go-multiaddr-net v0.1.2 // v0.1.1 => v0.1.2 github.com/multiformats/go-multihash v0.0.13 // indirect - github.com/nspcc-dev/hrw v1.0.9 // indirect github.com/nspcc-dev/neo-go v0.91.1-pre.0.20200827184617-7560aa345a78 github.com/nspcc-dev/neofs-api-go v1.3.1-0.20200902121740-5a6dff8c83ba github.com/nspcc-dev/neofs-crypto v0.3.0 - github.com/nspcc-dev/netmap v1.7.0 // indirect - github.com/nspcc-dev/tzhash v1.4.0 // indirect github.com/panjf2000/ants/v2 v2.3.0 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.6.0 github.com/soheilhy/cmux v0.1.4 - github.com/spaolacci/murmur3 v1.1.0 github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/viper v1.7.0 github.com/stretchr/testify v1.6.1 github.com/valyala/fasthttp v1.9.0 go.etcd.io/bbolt v1.3.4 go.uber.org/atomic v1.5.1 - go.uber.org/dig v1.8.0 // indirect go.uber.org/multierr v1.4.0 // indirect go.uber.org/zap v1.13.0 golang.org/x/crypto v0.0.0-20200117160349-530e935923ad // indirect diff --git a/go.sum b/go.sum index 1bc614959..a99aeddd9 100644 --- a/go.sum +++ b/go.sum @@ -47,8 +47,6 @@ github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hC github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/awalterschulze/gographviz v0.0.0-20181013152038-b2885df04310 h1:t+qxRrRtwNiUYA+Xh2jSXhoG2grnMCMKX4Fg6lx9X1U= -github.com/awalterschulze/gographviz v0.0.0-20181013152038-b2885df04310/go.mod h1:GEV5wmg4YquNw7v1kkyoX9etIk8yVmXj+AkDHuuETHs= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0 h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= @@ -108,8 +106,6 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/etcd-io/bbolt v1.3.3 h1:gSJmxrs37LgTqR/oyJBWok6k6SvXEUerFTbltIhXkBM= github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw= -github.com/fasthttp/router v1.0.2 h1:rdYdcAmwOLqWuFgc4afa409SYmuw4t0A66K5Ib+GT3I= -github.com/fasthttp/router v1.0.2/go.mod h1:Myk/ofrwtfiLSCIfbE44+e+PyP3mR6JhZg3AYzqwJI0= github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/flynn-archive/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BMXYYRWTLOJKlh+lOBt6nUQgXAfB7oVIQt5cNreqSLI= @@ -131,10 +127,6 @@ github.com/go-yaml/yaml v2.1.0+incompatible/go.mod h1:w2MrLa16VYP0jy6N7M5kHaCkaL github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= -github.com/gogo/protobuf v1.3.0 h1:G8O7TerXerS4F6sx9OV7/nRfJdnXgHZu/S/7F2SN+UE= -github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= -github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= -github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -185,8 +177,6 @@ github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0U github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 h1:Iju5GlWwrvL6UBg4zJJt3btmonfrMlCDdsejg4CZE7c= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -github.com/grpc-ecosystem/go-grpc-middleware v1.2.0 h1:0IKlLyQ3Hs9nDaiK5cSHAGmcQEIC8l2Ts1u6x5Dfrqg= -github.com/grpc-ecosystem/go-grpc-middleware v1.2.0/go.mod h1:mJzapYve32yjrKlk9GbyCZHuPgZsrbyIbyKhSzOpg6s= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= @@ -227,7 +217,6 @@ github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7 github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= -github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/klauspost/compress v1.8.2 h1:Bx0qjetmNjdFXASH02NSAREKpiaDwkO1DRZ3dV2KCcs= @@ -253,7 +242,6 @@ github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVc github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.9 h1:d5US/mDsogSGW37IV293h//ZFaeajb69h+EHFsv2xGg= github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= @@ -305,38 +293,20 @@ github.com/nspcc-dev/dbft v0.0.0-20200219114139-199d286ed6c1 h1:yEx9WznS+rjE0jl0 github.com/nspcc-dev/dbft v0.0.0-20200219114139-199d286ed6c1/go.mod h1:O0qtn62prQSqizzoagHmuuKoz8QMkU3SzBoKdEvm3aQ= github.com/nspcc-dev/dbft v0.0.0-20200711144034-c526ccc6f570 h1:EHBwlOyd2m06C3dnxhpPokpYqlNg7u5ZX/uPBhjYuZ4= github.com/nspcc-dev/dbft v0.0.0-20200711144034-c526ccc6f570/go.mod h1:1FYQXSbb6/9HQIkoF8XO7W/S8N7AZRkBsgwbcXRvk0E= -github.com/nspcc-dev/hrw v1.0.8 h1:vwRuJXZXgkMvf473vFzeWGCfY1WBVeSHAEHvR4u3/Cg= -github.com/nspcc-dev/hrw v1.0.8/go.mod h1:l/W2vx83vMQo6aStyx2AuZrJ+07lGv2JQGlVkPG06MU= -github.com/nspcc-dev/hrw v1.0.9 h1:17VcAuTtrstmFppBjfRiia4K2wA/ukXZhLFS8Y8rz5Y= -github.com/nspcc-dev/hrw v1.0.9/go.mod h1:l/W2vx83vMQo6aStyx2AuZrJ+07lGv2JQGlVkPG06MU= github.com/nspcc-dev/neo-go v0.73.1-pre.0.20200303142215-f5a1b928ce09/go.mod h1:pPYwPZ2ks+uMnlRLUyXOpLieaDQSEaf4NM3zHVbRjmg= -github.com/nspcc-dev/neo-go v0.90.0 h1:ABNDrJuF9C1XuLQu0q9DKSVMlg9eQn/g6rX8Jbr31bo= -github.com/nspcc-dev/neo-go v0.90.0/go.mod h1:pPFdnApJwUSRAnpdiPBZl7I7jv0doDg5naecpSPK4+Q= github.com/nspcc-dev/neo-go v0.91.0 h1:KKOPMKs0fm8JIau1SuwxiLdrZ+1kDPBiVRlWwzfebWE= github.com/nspcc-dev/neo-go v0.91.0/go.mod h1:G6HdOWvzQ6tlvFdvFSN/PgCzLPN/X/X4d5hTjFRUDcc= github.com/nspcc-dev/neo-go v0.91.1-pre.0.20200827184617-7560aa345a78 h1:stIa+nBXK8uDY/JZaxIZzAUfkzfaotVw2FbnHxO4aZI= github.com/nspcc-dev/neo-go v0.91.1-pre.0.20200827184617-7560aa345a78/go.mod h1:G6HdOWvzQ6tlvFdvFSN/PgCzLPN/X/X4d5hTjFRUDcc= -github.com/nspcc-dev/neo-go v0.91.1 h1:ynmqfTE5uKgt3kIZD6aVV1IDDbWybSUz3uEluyeSA6k= -github.com/nspcc-dev/neo-go v0.91.1/go.mod h1:G6HdOWvzQ6tlvFdvFSN/PgCzLPN/X/X4d5hTjFRUDcc= -github.com/nspcc-dev/neofs-api-go v1.3.0 h1:w0wYIXzPJIElwhqahnQw/1NKiHxjRZKJhDUMSbEHmdk= -github.com/nspcc-dev/neofs-api-go v1.3.0/go.mod h1:NlCjqm//ZRXBNlxtrilLM1GgkRz0mv4V3pdX8OcGoLw= -github.com/nspcc-dev/neofs-api-go v1.3.1-0.20200820112910-89e79ebe72b0 h1:aaDAx0xezfCzpD7NrmaJTLDHs58t5JM4ZV3ttyMJicY= -github.com/nspcc-dev/neofs-api-go v1.3.1-0.20200820112910-89e79ebe72b0/go.mod h1:6euXsb8tS06O9z3iuM49FrKeOhHO66R2DW8T8E1Wfl8= -github.com/nspcc-dev/neofs-api-go v1.3.1-0.20200821125006-afd2ce0400ec h1:RiOp+9omHGk4y70GHaC4rhnCe/3TPoFR/YmdL/5Ke1c= -github.com/nspcc-dev/neofs-api-go v1.3.1-0.20200821125006-afd2ce0400ec/go.mod h1:6euXsb8tS06O9z3iuM49FrKeOhHO66R2DW8T8E1Wfl8= github.com/nspcc-dev/neofs-crypto v0.2.0/go.mod h1:F/96fUzPM3wR+UGsPi3faVNmFlA9KAEAUQR7dMxZmNA= github.com/nspcc-dev/neofs-crypto v0.2.3 h1:aca3X2aly92ENRbFK+kH6Hd+J9EQ4Eu6XMVoITSIKtc= github.com/nspcc-dev/neofs-crypto v0.2.3/go.mod h1:8w16GEJbH6791ktVqHN9YRNH3s9BEEKYxGhlFnp0cDw= github.com/nspcc-dev/neofs-crypto v0.3.0 h1:zlr3pgoxuzrmGCxc5W8dGVfA9Rro8diFvVnBg0L4ifM= github.com/nspcc-dev/neofs-crypto v0.3.0/go.mod h1:8w16GEJbH6791ktVqHN9YRNH3s9BEEKYxGhlFnp0cDw= -github.com/nspcc-dev/netmap v1.7.0 h1:ak64xn/gPdgYw4tsqSSF7kAGQGbEpeuJEF3XwBX4L9Y= -github.com/nspcc-dev/netmap v1.7.0/go.mod h1:mhV3UOg9ljQmu0teQShD6+JYX09XY5gu2I4hIByCH9M= github.com/nspcc-dev/rfc6979 v0.1.0 h1:Lwg7esRRoyK1Up/IN1vAef1EmvrBeMHeeEkek2fAJ6c= github.com/nspcc-dev/rfc6979 v0.1.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso= github.com/nspcc-dev/rfc6979 v0.2.0 h1:3e1WNxrN60/6N0DW7+UYisLeZJyfqZTNOjeV/toYvOE= github.com/nspcc-dev/rfc6979 v0.2.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso= -github.com/nspcc-dev/tzhash v1.4.0 h1:RVIR+mxOBHl58CE99+DXtE31ylD5PEkZSoWqoj4fVjg= -github.com/nspcc-dev/tzhash v1.4.0/go.mod h1:Z8gp/VZbyWgPhaMp/KTmeoW5UTynp/N60g0jTtSzBws= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -346,7 +316,6 @@ github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1 h1:K0jcRCwNQM3vFGh1ppMtDh/+7ApJrjldlX8fA0jDTLQ= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/panjf2000/ants/v2 v2.3.0 h1:+l+41IiyMmpcK+YhWs2dn3tgL6cg4cvJzup1mBGmU00= github.com/panjf2000/ants/v2 v2.3.0/go.mod h1:LtwNaBX6OeF5qRtQlaeGndalVwJlS2ueur7uwoAHbPA= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= @@ -406,8 +375,6 @@ github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6So github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/savsgio/gotils v0.0.0-20200319105752-a9cc718f6a3f h1:XfUnevLK4O22at3R77FlyQHKwlQs75LELdsH2wRX2KQ= -github.com/savsgio/gotils v0.0.0-20200319105752-a9cc718f6a3f/go.mod h1:lHhJedqxCoHN+zMtwGNTXWmF0u9Jt363FYRhV6g0CdY= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= @@ -446,8 +413,6 @@ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0 github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= @@ -481,8 +446,6 @@ go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.5.1 h1:rsqfU5vBkVknbhUGbAUwQKR2H4ItV8tjJ+6kJX4cxHM= go.uber.org/atomic v1.5.1/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/dig v1.8.0 h1:1rR6hnL/bu1EVcjnRDN5kx1vbIjEJDTGhSQ2B3ddpcI= -go.uber.org/dig v1.8.0/go.mod h1:X34SnWGr8Fyla9zQNO2GSO2D+TIuqB14OS8JhYocIyw= go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0 h1:sFPn2GLc3poCkfrpIXGhBD2X0CMIo4Q/zSULXrj/+uc= @@ -572,7 +535,6 @@ golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -593,7 +555,6 @@ golang.org/x/sys v0.0.0-20191010194322-b09406accb47 h1:/XfQ9z7ib8eEJX2hdgFTZJ/nt golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -609,7 +570,6 @@ golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180318012157-96caea41033d/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/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= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= @@ -627,8 +587,6 @@ golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191030062658-86caa796c7ab h1:tpc/nJ4vD66vAk/2KN0sw/DvQIz2sKmCpWvyKtPmfMQ= -golang.org/x/tools v0.0.0-20191030062658-86caa796c7ab/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200123022218-593de606220b h1:ztSlcncMErSAUzXwnVO1iTPxHwtvOHBB26SGiyYXIEE= diff --git a/pkg/local_object_storage/bucket/test/bucket.go b/pkg/local_object_storage/bucket/test/bucket.go deleted file mode 100644 index 78cdf240d..000000000 --- a/pkg/local_object_storage/bucket/test/bucket.go +++ /dev/null @@ -1,144 +0,0 @@ -package test - -import ( - "errors" - "sync" - - "github.com/mr-tron/base58" - "github.com/nspcc-dev/neofs-api-go/object" - "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/bucket" -) - -type ( - testBucket struct { - sync.RWMutex - items map[string][]byte - } -) - -var ( - errOverflow = errors.New("overflow") - errNotFound = errors.New("not found") -) - -// Bucket constructs test Bucket implementation. -func Bucket() bucket.Bucket { - return &testBucket{ - items: make(map[string][]byte), - } -} - -func (t *testBucket) Get(key []byte) ([]byte, error) { - t.Lock() - defer t.Unlock() - - val, ok := t.items[base58.Encode(key)] - if !ok { - return nil, bucket.ErrNotFound - } - - return val, nil -} - -func (t *testBucket) Set(key, value []byte) error { - t.Lock() - defer t.Unlock() - - t.items[base58.Encode(key)] = value - - return nil -} - -func (t *testBucket) Del(key []byte) error { - t.RLock() - defer t.RUnlock() - - delete(t.items, base58.Encode(key)) - - return nil -} - -func (t *testBucket) Has(key []byte) bool { - t.RLock() - defer t.RUnlock() - - _, ok := t.items[base58.Encode(key)] - - return ok -} - -func (t *testBucket) Size() (res int64) { - t.RLock() - defer t.RUnlock() - - for _, v := range t.items { - res += int64(len(v)) - } - - return -} - -func (t *testBucket) List() ([][]byte, error) { - t.Lock() - defer t.Unlock() - - res := make([][]byte, 0) - - for k := range t.items { - sk, err := base58.Decode(k) - if err != nil { - return nil, err - } - - res = append(res, sk) - } - - return res, nil -} - -func (t *testBucket) Iterate(f bucket.FilterHandler) error { - t.RLock() - defer t.RUnlock() - - for k, v := range t.items { - key, err := base58.Decode(k) - if err != nil { - continue - } - - if !f(key, v) { - return bucket.ErrIteratingAborted - } - } - - return nil -} - -func (t *testBucket) Close() error { - t.Lock() - defer t.Unlock() - - for k := range t.items { - delete(t.items, k) - } - - return nil -} - -func (t *testBucket) PRead(key []byte, rng object.Range) ([]byte, error) { - t.RLock() - defer t.RUnlock() - - k := base58.Encode(key) - - v, ok := t.items[k] - if !ok { - return nil, errNotFound - } - - if rng.Offset+rng.Length > uint64(len(v)) { - return nil, errOverflow - } - - return v[rng.Offset : rng.Offset+rng.Length], nil -} diff --git a/pkg/local_object_storage/meta/iterator.go b/pkg/local_object_storage/meta/iterator.go deleted file mode 100644 index f5d3642ff..000000000 --- a/pkg/local_object_storage/meta/iterator.go +++ /dev/null @@ -1,15 +0,0 @@ -package meta - -import ( - "github.com/nspcc-dev/neofs-api-go/object" -) - -type ( - // Iterator is an interface of the iterator over object storage. - Iterator interface { - Iterate(IterateFunc) error - } - - // IterateFunc is a function that checks whether an object matches a specific criterion. - IterateFunc func(*object.Object) error -) diff --git a/pkg/services/metrics/meta.go b/pkg/services/metrics/meta.go deleted file mode 100644 index 86f2a63d5..000000000 --- a/pkg/services/metrics/meta.go +++ /dev/null @@ -1,33 +0,0 @@ -package metrics - -import ( - "sync" - - meta2 "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/meta" -) - -type metaWrapper struct { - sync.Mutex - iter meta2.Iterator -} - -func newMetaWrapper() *metaWrapper { - return &metaWrapper{} -} - -func (m *metaWrapper) changeIter(iter meta2.Iterator) { - m.Lock() - m.iter = iter - m.Unlock() -} - -func (m *metaWrapper) Iterate(h meta2.IterateFunc) error { - m.Lock() - defer m.Unlock() - - if m.iter == nil { - return errEmptyMetaStore - } - - return m.iter.Iterate(h) -} diff --git a/pkg/services/metrics/metrics.go b/pkg/services/metrics/metrics.go deleted file mode 100644 index ed9ce8bf3..000000000 --- a/pkg/services/metrics/metrics.go +++ /dev/null @@ -1,175 +0,0 @@ -package metrics - -import ( - "context" - "errors" - "sync" - "time" - - "github.com/nspcc-dev/neofs-api-go/object" - "github.com/nspcc-dev/neofs-api-go/refs" - "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/bucket" - meta2 "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/meta" - "go.uber.org/zap" -) - -type ( - // Collector is an interface of the metrics collector. - Collector interface { - Start(ctx context.Context) - UpdateSpaceUsage() - - SetCounter(ObjectCounter) - SetIterator(iter meta2.Iterator) - UpdateContainer(cid refs.CID, size uint64, op SpaceOp) - } - - collector struct { - log *zap.Logger - interval time.Duration - counter *counterWrapper - - sizes *syncStore - metas *metaWrapper - - updateSpaceSize func() - updateObjectCount func() - } - - // Params groups the parameters of metrics collector's constructor. - Params struct { - Options []string - Logger *zap.Logger - Interval time.Duration - MetricsStore bucket.Bucket - } - - // ObjectCounter is an interface of object number storage. - ObjectCounter interface { - ObjectsCount() (uint64, error) - } - - // CounterSetter is an interface of ObjectCounter container. - CounterSetter interface { - SetCounter(ObjectCounter) - } - - counterWrapper struct { - sync.Mutex - counter ObjectCounter - } -) - -var ( - errEmptyCounter = errors.New("empty object counter") - errEmptyLogger = errors.New("empty logger") - errEmptyMetaStore = errors.New("empty meta store") - errEmptyMetricsStore = errors.New("empty metrics store") -) - -const defaultMetricsInterval = 5 * time.Second - -// New constructs metrics collector and returns Collector interface. -func New(p Params) (Collector, error) { - switch { - case p.Logger == nil: - return nil, errEmptyLogger - case p.MetricsStore == nil: - return nil, errEmptyMetricsStore - } - - if p.Interval <= 0 { - p.Interval = defaultMetricsInterval - } - - metas := newMetaWrapper() - sizes := newSyncStore(p.Logger, p.MetricsStore) - - sizes.Load() - - return &collector{ - log: p.Logger, - interval: p.Interval, - counter: new(counterWrapper), - - metas: metas, - sizes: sizes, - - updateSpaceSize: spaceUpdater(sizes), - updateObjectCount: metricsUpdater(p.Options), - }, nil -} - -func (c *counterWrapper) SetCounter(counter ObjectCounter) { - c.Lock() - defer c.Unlock() - - c.counter = counter -} - -func (c *counterWrapper) ObjectsCount() (uint64, error) { - c.Lock() - defer c.Unlock() - - if c.counter == nil { - return 0, errEmptyCounter - } - - return c.counter.ObjectsCount() -} - -func (c *collector) SetCounter(counter ObjectCounter) { - c.counter.SetCounter(counter) -} - -func (c *collector) SetIterator(iter meta2.Iterator) { - c.metas.changeIter(iter) -} - -func (c *collector) UpdateContainer(cid refs.CID, size uint64, op SpaceOp) { - c.sizes.Update(cid, size, op) - c.updateSpaceSize() -} - -func (c *collector) UpdateSpaceUsage() { - sizes := make(map[refs.CID]uint64) - - err := c.metas.Iterate(func(obj *object.Object) error { - if !obj.IsTombstone() { - cid := obj.SystemHeader.CID - sizes[cid] += obj.SystemHeader.PayloadLength - } - - return nil - }) - - if err != nil { - c.log.Error("could not update space metrics", zap.Error(err)) - } - - c.sizes.Reset(sizes) - c.updateSpaceSize() -} - -func (c *collector) Start(ctx context.Context) { - t := time.NewTicker(c.interval) - -loop: - for { - select { - case <-ctx.Done(): - c.log.Warn("stop collecting metrics", zap.Error(ctx.Err())) - break loop - case <-t.C: - count, err := c.counter.ObjectsCount() - if err != nil { - c.log.Warn("get object count failure", zap.Error(err)) - continue loop - } - counter.Store(float64(count)) - c.updateObjectCount() - } - } - - t.Stop() -} diff --git a/pkg/services/metrics/metrics_test.go b/pkg/services/metrics/metrics_test.go deleted file mode 100644 index 2b9d017e5..000000000 --- a/pkg/services/metrics/metrics_test.go +++ /dev/null @@ -1,275 +0,0 @@ -package metrics - -import ( - "context" - "encoding/binary" - "sync" - "testing" - "time" - - "github.com/nspcc-dev/neofs-api-go/object" - "github.com/nspcc-dev/neofs-api-go/refs" - meta2 "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/meta" - "github.com/pkg/errors" - "github.com/stretchr/testify/require" - "go.uber.org/zap" -) - -type ( - fakeCounter int - fakeIterator string - fakeMetaStore []*object.Object -) - -var ( - _ ObjectCounter = (*fakeCounter)(nil) - _ meta2.Iterator = (*fakeIterator)(nil) -) - -func (f fakeCounter) ObjectsCount() (uint64, error) { - return uint64(f), nil -} - -func (f fakeIterator) Iterate(_ meta2.IterateFunc) error { - if f == "" { - return nil - } - - return errors.New(string(f)) -} - -func (f fakeMetaStore) Iterate(cb meta2.IterateFunc) error { - if cb == nil { - return nil - } - - for i := range f { - if err := cb(f[i]); err != nil { - return err - } - } - - return nil -} - -func TestCollector(t *testing.T) { - buck := &fakeBucket{items: make(map[uint64]int)} - - t.Run("check errors", func(t *testing.T) { - t.Run("empty logger", func(t *testing.T) { - svc, err := New(Params{MetricsStore: buck}) - require.Nil(t, svc) - require.EqualError(t, err, errEmptyLogger.Error()) - }) - - t.Run("empty metrics store", func(t *testing.T) { - svc, err := New(Params{Logger: zap.L()}) - require.Nil(t, svc) - require.EqualError(t, err, errEmptyMetricsStore.Error()) - }) - }) - - svc, err := New(Params{ - Logger: zap.L(), - MetricsStore: buck, - Options: []string{ - "/Location:Europe/Country:Russia/City:Moscow", - "/Some:Another/Key:Value", - }, - }) - - require.NoError(t, err) - require.NotNil(t, svc) - - coll, ok := svc.(*collector) - require.True(t, ok) - require.NotNil(t, coll) - - t.Run("check start", func(t *testing.T) { - coll.interval = time.Second - - t.Run("stop by context", func(t *testing.T) { - ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) - wg := new(sync.WaitGroup) - wg.Add(1) - - counter.Store(-1) - - go func() { - svc.Start(ctx) - wg.Done() - }() - - cancel() - wg.Wait() - - require.Equal(t, float64(-1), counter.Load()) - }) - - t.Run("should fail on empty counter", func(t *testing.T) { - ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) - wg := new(sync.WaitGroup) - wg.Add(1) - - counter.Store(0) - - go func() { - svc.Start(ctx) - wg.Done() - }() - - time.Sleep(2 * time.Second) - cancel() - wg.Wait() - - require.Equal(t, float64(0), counter.Load()) - }) - - t.Run("should success on fakeCounter", func(t *testing.T) { - ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) - wg := new(sync.WaitGroup) - wg.Add(1) - - coll.SetCounter(fakeCounter(8)) - counter.Store(0) - - go func() { - svc.Start(ctx) - wg.Done() - }() - - time.Sleep(2 * time.Second) - cancel() - wg.Wait() - - require.Equal(t, float64(8), counter.Load()) - }) - }) - - t.Run("iterator", func(t *testing.T) { - { - coll.SetIterator(nil) - require.Nil(t, coll.metas.iter) - require.EqualError(t, coll.metas.Iterate(nil), errEmptyMetaStore.Error()) - } - - { - iter := fakeIterator("") - coll.SetIterator(iter) - require.Equal(t, iter, coll.metas.iter) - require.NoError(t, coll.metas.Iterate(nil)) - } - - { - iter := fakeIterator("test") - coll.SetIterator(iter) - require.Equal(t, iter, coll.metas.iter) - require.EqualError(t, coll.metas.Iterate(nil), string(iter)) - } - }) - - t.Run("add-rem space", func(t *testing.T) { - cid := refs.CID{1, 2, 3, 4, 5} - buf := make([]byte, 8) - key := keyFromBytes(cid.Bytes()) - - zero := make([]byte, 8) - size := uint64(100) - - binary.BigEndian.PutUint64(buf, size) - - { - coll.UpdateContainer(cid, size, AddSpace) - require.Len(t, coll.sizes.items, 1) - require.Len(t, buck.items, 1) - require.Contains(t, buck.items, key) - require.Contains(t, buck.kv, fakeKV{key: cid.Bytes(), val: buf}) - } - - { - coll.UpdateContainer(cid, size, RemSpace) - require.Len(t, coll.sizes.items, 1) - require.Len(t, buck.items, 1) - require.Contains(t, buck.items, key) - require.Contains(t, buck.kv, fakeKV{key: cid.Bytes(), val: zero}) - } - - { - coll.UpdateContainer(cid, size, RemSpace) - require.Len(t, coll.sizes.items, 1) - require.Len(t, buck.items, 1) - require.Contains(t, buck.kv, fakeKV{key: cid.Bytes(), val: zero}) - } - }) - - t.Run("add-rem multi thread", func(t *testing.T) { - wg := new(sync.WaitGroup) - wg.Add(10) - - size := uint64(100) - zero := make([]byte, 8) - - // reset - coll.UpdateSpaceUsage() - - for i := 0; i < 10; i++ { - cid := refs.CID{1, 2, 3, 4, byte(i)} - coll.UpdateContainer(cid, size, AddSpace) - - go func() { - coll.UpdateContainer(cid, size, RemSpace) - wg.Done() - }() - } - - wg.Wait() - - require.Len(t, coll.sizes.items, 10) - require.Len(t, buck.items, 10) - - for i := 0; i < 10; i++ { - cid := refs.CID{1, 2, 3, 4, byte(i)} - require.Contains(t, buck.kv, fakeKV{key: cid.Bytes(), val: zero}) - } - }) - - t.Run("reset buckets", func(t *testing.T) { - coll.UpdateSpaceUsage() - require.Len(t, coll.sizes.items, 0) - require.Len(t, buck.items, 0) - }) - - t.Run("reset from metaStore", func(t *testing.T) { - cid := refs.CID{1, 2, 3, 4, 5} - buf := make([]byte, 8) - key := keyFromBytes(cid.Bytes()) - size := uint64(100) - binary.BigEndian.PutUint64(buf, size) - - iter := fakeMetaStore{ - { - SystemHeader: object.SystemHeader{ - PayloadLength: size, - CID: cid, - }, - }, - - { - Headers: []object.Header{ - { - Value: &object.Header_Tombstone{Tombstone: &object.Tombstone{}}, - }, - }, - }, - } - - coll.SetIterator(iter) - - coll.UpdateSpaceUsage() - require.Len(t, coll.sizes.items, 1) - require.Len(t, buck.items, 1) - - require.Contains(t, buck.items, key) - require.Contains(t, buck.kv, fakeKV{key: cid.Bytes(), val: buf}) - }) -} diff --git a/pkg/services/metrics/prometeus.go b/pkg/services/metrics/prometeus.go deleted file mode 100644 index 438e85f56..000000000 --- a/pkg/services/metrics/prometeus.go +++ /dev/null @@ -1,83 +0,0 @@ -package metrics - -import ( - "strings" - - "github.com/prometheus/client_golang/prometheus" - "go.uber.org/atomic" -) - -const ( - locationLabel = "location" - countryLabel = "country" - cityLabel = "city" - - containerLabel = "cid" -) - -var ( - objectsCount = prometheus.NewGaugeVec(prometheus.GaugeOpts{ - Namespace: "neofs", - Name: "count_objects_on_node", - Help: "Number of objects stored on this node", - }, []string{locationLabel, countryLabel, cityLabel}) - - spaceCounter = prometheus.NewGaugeVec(prometheus.GaugeOpts{ - Namespace: "neofs", - Name: "container_space_sizes", - Help: "Space allocated by ContainerID", - }, []string{containerLabel}) - - counter = atomic.NewFloat64(0) -) - -func init() { - prometheus.MustRegister( - objectsCount, - spaceCounter, - ) -} - -func spaceUpdater(m *syncStore) func() { - return func() { - m.mutex.RLock() - for cid := range m.items { - spaceCounter. - With(prometheus.Labels{ - containerLabel: cid.String(), - }). - Set(float64(m.items[cid])) - } - m.mutex.RUnlock() - } -} - -func metricsUpdater(opts []string) func() { - var ( - locationCode string - countryCode string - cityCode string - ) - - for i := range opts { - ss := strings.Split(opts[i], "/") - for j := range ss { - switch s := strings.SplitN(ss[j], ":", 2); strings.ToLower(s[0]) { - case locationLabel: - locationCode = s[1] - case countryLabel: - countryCode = s[1] - case cityLabel: - cityCode = s[1] - } - } - } - - return func() { - objectsCount.With(prometheus.Labels{ - locationLabel: locationCode, - countryLabel: countryCode, - cityLabel: cityCode, - }).Set(counter.Load()) - } -} diff --git a/pkg/services/metrics/store.go b/pkg/services/metrics/store.go deleted file mode 100644 index ef17ec2c7..000000000 --- a/pkg/services/metrics/store.go +++ /dev/null @@ -1,122 +0,0 @@ -package metrics - -import ( - "encoding/binary" - "encoding/hex" - "sync" - - "github.com/nspcc-dev/neofs-api-go/refs" - "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/bucket" - "go.uber.org/zap" -) - -type ( - syncStore struct { - log *zap.Logger - store bucket.Bucket - mutex sync.RWMutex - items map[refs.CID]uint64 - } - - // SpaceOp is an enumeration of space size operations. - SpaceOp int -) - -const ( - _ SpaceOp = iota - - // AddSpace is a SpaceOp of space size increasing. - AddSpace - - // RemSpace is a SpaceOp of space size decreasing. - RemSpace -) - -func newSyncStore(log *zap.Logger, store bucket.Bucket) *syncStore { - return &syncStore{ - log: log, - store: store, - items: make(map[refs.CID]uint64), - } -} - -func (m *syncStore) Load() { - m.mutex.Lock() - defer m.mutex.Unlock() - - _ = m.store.Iterate(func(key, val []byte) bool { - cid, err := refs.CIDFromBytes(key) - if err != nil { - m.log.Error("could not load space value", zap.Error(err)) - return true - } - - m.items[cid] += binary.BigEndian.Uint64(val) - return true - }) -} - -func (m *syncStore) Reset(items map[refs.CID]uint64) { - m.mutex.Lock() - defer m.mutex.Unlock() - - m.items = items - if items == nil { - m.items = make(map[refs.CID]uint64) - } - - keys, err := m.store.List() - if err != nil { - m.log.Error("could not fetch keys space metrics", zap.Error(err)) - return - } - - // cleanup metrics store - for i := range keys { - if err := m.store.Del(keys[i]); err != nil { - cid := hex.EncodeToString(keys[i]) - m.log.Error("could not remove key", - zap.String("cid", cid), - zap.Error(err)) - } - } - - buf := make([]byte, 8) - - for cid := range items { - binary.BigEndian.PutUint64(buf, items[cid]) - - if err := m.store.Set(cid.Bytes(), buf); err != nil { - m.log.Error("could not store space value", - zap.Stringer("cid", cid), - zap.Error(err)) - } - } -} - -func (m *syncStore) Update(cid refs.CID, size uint64, op SpaceOp) { - m.mutex.Lock() - defer m.mutex.Unlock() - - switch op { - case RemSpace: - if m.items[cid] < size { - m.log.Error("space could not be negative") - return - } - - m.items[cid] -= size - case AddSpace: - m.items[cid] += size - default: - m.log.Error("unknown space operation", zap.Int("op", int(op))) - return - } - - buf := make([]byte, 8) - binary.BigEndian.PutUint64(buf, m.items[cid]) - - if err := m.store.Set(cid.Bytes(), buf); err != nil { - m.log.Error("could not update space size", zap.Int("op", int(op))) - } -} diff --git a/pkg/services/metrics/store_test.go b/pkg/services/metrics/store_test.go deleted file mode 100644 index dd4b760f5..000000000 --- a/pkg/services/metrics/store_test.go +++ /dev/null @@ -1,154 +0,0 @@ -package metrics - -import ( - "sync" - "testing" - - "github.com/nspcc-dev/neofs-api-go/refs" - "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/bucket" - "github.com/spaolacci/murmur3" - "github.com/stretchr/testify/require" - "go.uber.org/zap" -) - -type ( - fakeKV struct { - key []byte - val []byte - } - - fakeBucket struct { - sync.RWMutex - kv []fakeKV - items map[uint64]int - } -) - -func keyFromBytes(b []byte) uint64 { - return murmur3.Sum64(b) -} - -func (f *fakeBucket) Set(key, value []byte) error { - f.Lock() - defer f.Unlock() - - var ( - id int - ok bool - uid = keyFromBytes(key) - ) - - if id, ok = f.items[uid]; !ok || id >= len(f.kv) { - id = len(f.kv) - f.items[uid] = id - f.kv = append(f.kv, fakeKV{ - key: key, - val: value, - }) - - return nil - } - - f.kv[id] = fakeKV{ - key: key, - val: value, - } - - return nil -} - -func (f *fakeBucket) Del(key []byte) error { - f.Lock() - defer f.Unlock() - - delete(f.items, keyFromBytes(key)) - - return nil -} - -func (f *fakeBucket) List() ([][]byte, error) { - f.RLock() - defer f.RUnlock() - - items := make([][]byte, 0, len(f.items)) - for _, id := range f.items { - // ignore unknown KV - if id >= len(f.kv) { - continue - } - - items = append(items, f.kv[id].key) - } - - return items, nil -} - -func (f *fakeBucket) Iterate(handler bucket.FilterHandler) error { - f.Lock() - defer f.Unlock() - - for _, id := range f.items { - // ignore unknown KV - if id >= len(f.kv) { - continue - } - - kv := f.kv[id] - - if !handler(kv.key, kv.val) { - break - } - } - - return nil -} - -func (f *fakeBucket) Get(_ []byte) ([]byte, error) { panic("implement me") } -func (f *fakeBucket) Has(_ []byte) bool { panic("implement me") } -func (f *fakeBucket) Size() int64 { panic("implement me") } -func (f *fakeBucket) Close() error { panic("implement me") } - -func TestSyncStore(t *testing.T) { - buck := &fakeBucket{items: make(map[uint64]int)} - sizes := newSyncStore(zap.L(), buck) - - for i := 0; i < 10; i++ { - cid := refs.CID{0, 0, 0, byte(i)} - require.NoError(t, buck.Set(cid.Bytes(), []byte{1, 2, 3, 4, 5, 6, 7, byte(i)})) - } - - t.Run("load", func(t *testing.T) { - sizes.Load() - require.Len(t, sizes.items, len(buck.items)) - }) - - t.Run("reset", func(t *testing.T) { - sizes.Reset(nil) - require.Len(t, sizes.items, 0) - }) - - t.Run("update", func(t *testing.T) { - cid := refs.CID{1, 2, 3, 4, 5} - - { // add space - sizes.Update(cid, 8, AddSpace) - val, ok := sizes.items[cid] - require.True(t, ok) - require.Equal(t, uint64(8), val) - } - - { // rem space - sizes.Update(cid, 8, RemSpace) - val, ok := sizes.items[cid] - require.True(t, ok) - require.Zero(t, val) - } - - { // rem space (zero - val) - sizes.Update(cid, 8, RemSpace) - val, ok := sizes.items[cid] - require.True(t, ok) - require.Zero(t, val) - } - }) -} diff --git a/pkg/services/object_manager/verifier/verifier.go b/pkg/services/object_manager/verifier/verifier.go deleted file mode 100644 index 46c83ce7b..000000000 --- a/pkg/services/object_manager/verifier/verifier.go +++ /dev/null @@ -1,35 +0,0 @@ -package verifier - -import ( - "bytes" - "context" - - "github.com/nspcc-dev/neofs-api-go/object" -) - -// Verifier is an interface for checking whether an object conforms to a certain criterion. -// Nil error is equivalent to matching the criterion. -type Verifier interface { - Verify(context.Context, *object.Object) error -} - -// MarshalHeaders marshals all object headers which are "higher" than to-th extended header. -func MarshalHeaders(obj *object.Object, to int) ([]byte, error) { - buf := new(bytes.Buffer) - - if sysHdr, err := obj.SystemHeader.Marshal(); err != nil { - return nil, err - } else if _, err := buf.Write(sysHdr); err != nil { - return nil, err - } - - for i := range obj.Headers[:to] { - if header, err := obj.Headers[i].Marshal(); err != nil { - return nil, err - } else if _, err := buf.Write(header); err != nil { - return nil, err - } - } - - return buf.Bytes(), nil -}