forked from TrueCloudLab/frostfs-sdk-go
Merge pull request #2 from masterSplinter01/feature/116-move-policy-from-neofs-node
Move policy from neofs node
This commit is contained in:
commit
9dee13f0d5
14 changed files with 1475 additions and 0 deletions
8
.gitignore
vendored
8
.gitignore
vendored
|
@ -13,3 +13,11 @@
|
|||
|
||||
# Dependency directories (remove the comment below to include it)
|
||||
# vendor/
|
||||
|
||||
# IDE
|
||||
.idea
|
||||
.vscode
|
||||
|
||||
# coverage
|
||||
coverage.txt
|
||||
coverage.html
|
59
.golangci.yml
Normal file
59
.golangci.yml
Normal file
|
@ -0,0 +1,59 @@
|
|||
# This file contains all available configuration options
|
||||
# with their default values.
|
||||
|
||||
# options for analysis running
|
||||
run:
|
||||
# timeout for analysis, e.g. 30s, 5m, default is 1m
|
||||
timeout: 5m
|
||||
|
||||
# include test files or not, default is true
|
||||
tests: true
|
||||
|
||||
# output configuration options
|
||||
output:
|
||||
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
|
||||
format: tab
|
||||
|
||||
# all available settings of specific linters
|
||||
linters-settings:
|
||||
exhaustive:
|
||||
# indicates that switch statements are to be considered exhaustive if a
|
||||
# 'default' case is present, even if all enum members aren't listed in the
|
||||
# switch
|
||||
default-signifies-exhaustive: true
|
||||
govet:
|
||||
# report about shadowed variables
|
||||
check-shadowing: false
|
||||
|
||||
linters:
|
||||
enable:
|
||||
# mandatory linters
|
||||
- govet
|
||||
- golint
|
||||
|
||||
# some default golangci-lint linters
|
||||
- deadcode
|
||||
- errcheck
|
||||
- gosimple
|
||||
- ineffassign
|
||||
- staticcheck
|
||||
- structcheck
|
||||
- typecheck
|
||||
- unused
|
||||
- varcheck
|
||||
|
||||
# extra linters
|
||||
- exhaustive
|
||||
- godot
|
||||
- gofmt
|
||||
- whitespace
|
||||
- goimports
|
||||
disable-all: true
|
||||
fast: false
|
||||
|
||||
issues:
|
||||
include:
|
||||
- EXC0002 # should have a comment
|
||||
- EXC0003 # test/Test ... consider calling this
|
||||
- EXC0004 # govet
|
||||
- EXC0005 # C-style breaks
|
40
Makefile
Normal file
40
Makefile
Normal file
|
@ -0,0 +1,40 @@
|
|||
#!/usr/bin/make -f
|
||||
|
||||
# Run tests
|
||||
test:
|
||||
@go test ./... -cover
|
||||
|
||||
# Pull go dependencies
|
||||
dep:
|
||||
@printf "⇒ Download requirements: "
|
||||
@CGO_ENABLED=0 \
|
||||
go mod download && echo OK
|
||||
@printf "⇒ Tidy requirements: "
|
||||
@CGO_ENABLED=0 \
|
||||
go mod tidy -v && echo OK
|
||||
|
||||
# Run linters
|
||||
lint:
|
||||
@golangci-lint --timeout=5m run
|
||||
|
||||
# Run tests with race detection and produce coverage output
|
||||
cover:
|
||||
@go test -v -race ./... -coverprofile=coverage.txt -covermode=atomic
|
||||
@go tool cover -html=coverage.txt -o coverage.html
|
||||
|
||||
# Reformat code
|
||||
format:
|
||||
@echo "⇒ Processing gofmt check"
|
||||
@gofmt -s -w ./
|
||||
@echo "⇒ Processing goimports check"
|
||||
@goimports -w ./
|
||||
|
||||
# Show this help prompt
|
||||
help:
|
||||
@echo ' Usage:'
|
||||
@echo ''
|
||||
@echo ' make <target>'
|
||||
@echo ''
|
||||
@echo ' Targets:'
|
||||
@echo ''
|
||||
@awk '/^#/{ comment = substr($$0,3) } comment && /^[a-zA-Z][a-zA-Z0-9_-]+ ?:/{ print " ", $$1, comment }' $(MAKEFILE_LIST) | column -t -s ':' | grep -v 'IGNORE' | sort -u
|
9
go.mod
Normal file
9
go.mod
Normal file
|
@ -0,0 +1,9 @@
|
|||
module github.com/nspcc-dev/neofs-sdk-go
|
||||
|
||||
go 1.16
|
||||
|
||||
require (
|
||||
github.com/alecthomas/participle v0.7.1
|
||||
github.com/nspcc-dev/neofs-api-go v1.26.1
|
||||
github.com/stretchr/testify v1.6.1
|
||||
)
|
278
go.sum
Normal file
278
go.sum
Normal file
|
@ -0,0 +1,278 @@
|
|||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/CityOfZion/neo-go v0.62.1-pre.0.20191114145240-e740fbe708f8/go.mod h1:MJCkWUBhi9pn/CrYO1Q3P687y2KeahrOPS9BD9LDGb0=
|
||||
github.com/CityOfZion/neo-go v0.70.1-pre.0.20191209120015-fccb0085941e/go.mod h1:0enZl0az8xA6PVkwzEOwPWVJGqlt/GO4hA4kmQ5Xzig=
|
||||
github.com/CityOfZion/neo-go v0.70.1-pre.0.20191212173117-32ac01130d4c/go.mod h1:JtlHfeqLywZLswKIKFnAp+yzezY4Dji9qlfQKB2OD/I=
|
||||
github.com/CityOfZion/neo-go v0.71.1-pre.0.20200129171427-f773ec69fb84/go.mod h1:FLI526IrRWHmcsO+mHsCbj64pJZhwQFTLJZu+A4PGOA=
|
||||
github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
|
||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||
github.com/Workiva/go-datastructures v1.0.50/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA=
|
||||
github.com/abiosoft/ishell v2.0.0+incompatible/go.mod h1:HQR9AqF2R3P4XXpMpI0NAzgHf/aS6+zVXRj14cVk9qg=
|
||||
github.com/abiosoft/readline v0.0.0-20180607040430-155bce2042db/go.mod h1:rB3B4rKii8V21ydCbIzH5hZiCQE7f5E9SzUb/ZZx530=
|
||||
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
|
||||
github.com/alecthomas/participle v0.7.1 h1:2bN7reTw//5f0cugJcTOnY/NYZcWQOaajW+BwZB5xWs=
|
||||
github.com/alecthomas/participle v0.7.1/go.mod h1:HfdmEuwvr12HXQN44HPWXR0lHmVolVYe4dyL6lQ3duY=
|
||||
github.com/alecthomas/repr v0.0.0-20181024024818-d37bc2a10ba1/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
|
||||
github.com/alicebob/miniredis v2.5.0+incompatible/go.mod h1:8HZjEj4yU0dwhYHky+DxYx+6BMjkBbe5ONFIF1MXffk=
|
||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
|
||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
|
||||
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
|
||||
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg=
|
||||
github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY=
|
||||
github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc=
|
||||
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY=
|
||||
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
github.com/cespare/xxhash/v2 v2.1.0/go.mod h1:dgIUBU3pDso/gPgZ1osOZ0iQf77oPR28Tjxl5dIMyVM=
|
||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
|
||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
|
||||
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgraph-io/badger/v2 v2.0.3/go.mod h1:3KY8+bsP8wI0OEnQJAKpd4wIJW/Mm32yw2j/9FUVnIM=
|
||||
github.com/dgraph-io/ristretto v0.0.2-0.20200115201040-8f368f2f2ab3/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E=
|
||||
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
|
||||
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/flynn-archive/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:rZfgFAXFS/z/lEd6LJmf9HVZ1LkgYiHx5pHhV5DR16M=
|
||||
github.com/frankban/quicktest v1.10.0/go.mod h1:ui7WezCLWMWxVWr1GETZY3smRy0G4KWq9vcPtJmFl7Y=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-redis/redis v6.10.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/go-yaml/yaml v2.1.0+incompatible/go.mod h1:w2MrLa16VYP0jy6N7M5kHaCkaLENm+P+Tv+MfurjSw0=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM=
|
||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||
github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
|
||||
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/mr-tron/base58 v1.1.2/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/nspcc-dev/dbft v0.0.0-20191205084618-dacb1a30c254/go.mod h1:w1Ln2aT+dBlPhLnuZhBV+DfPEdS2CHWWLp5JTScY3bw=
|
||||
github.com/nspcc-dev/dbft v0.0.0-20191209120240-0d6b7568d9ae/go.mod h1:3FjXOoHmA51EGfb5GS/HOv7VdmngNRTssSeQ729dvGY=
|
||||
github.com/nspcc-dev/dbft v0.0.0-20200117124306-478e5cfbf03a/go.mod h1:/YFK+XOxxg0Bfm6P92lY5eDSLYfp06XOdL8KAVgXjVk=
|
||||
github.com/nspcc-dev/dbft v0.0.0-20200219114139-199d286ed6c1/go.mod h1:O0qtn62prQSqizzoagHmuuKoz8QMkU3SzBoKdEvm3aQ=
|
||||
github.com/nspcc-dev/dbft v0.0.0-20200711144034-c526ccc6f570/go.mod h1:1FYQXSbb6/9HQIkoF8XO7W/S8N7AZRkBsgwbcXRvk0E=
|
||||
github.com/nspcc-dev/dbft v0.0.0-20210302103605-cc75991b7cfb/go.mod h1:U8MSnEShH+o5hexfWJdze6uMFJteP0ko7J2frO7Yu1Y=
|
||||
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.91.0/go.mod h1:G6HdOWvzQ6tlvFdvFSN/PgCzLPN/X/X4d5hTjFRUDcc=
|
||||
github.com/nspcc-dev/neo-go v0.95.0/go.mod h1:bW07ge1WFXsBgqrcPpLUr6OcyQxHqM26MZNesWMdH0c=
|
||||
github.com/nspcc-dev/neofs-api-go v1.24.0/go.mod h1:G7dqincfdjBrAbL5nxVp82emF05fSVEqe59ICsoRDI8=
|
||||
github.com/nspcc-dev/neofs-api-go v1.26.1 h1:GMIuEB6Hv9IXP9SJd/1f8Df6gRriPkSplpmpJXgQ/1I=
|
||||
github.com/nspcc-dev/neofs-api-go v1.26.1/go.mod h1:SHuH1Ba3U/h3j+8HHbb3Cns1LfMlEb88guWog9Qi68Y=
|
||||
github.com/nspcc-dev/neofs-crypto v0.2.0/go.mod h1:F/96fUzPM3wR+UGsPi3faVNmFlA9KAEAUQR7dMxZmNA=
|
||||
github.com/nspcc-dev/neofs-crypto v0.2.3/go.mod h1:8w16GEJbH6791ktVqHN9YRNH3s9BEEKYxGhlFnp0cDw=
|
||||
github.com/nspcc-dev/neofs-crypto v0.3.0/go.mod h1:8w16GEJbH6791ktVqHN9YRNH3s9BEEKYxGhlFnp0cDw=
|
||||
github.com/nspcc-dev/rfc6979 v0.1.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso=
|
||||
github.com/nspcc-dev/rfc6979 v0.2.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso=
|
||||
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=
|
||||
github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pierrec/lz4 v2.5.2+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||
github.com/prometheus/client_golang v1.2.1/go.mod h1:XMU6Z2MjaRKVu/dC1qupJI9SiNkDYzz3xecMgSW/F+U=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/prometheus/procfs v0.0.5/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ=
|
||||
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
|
||||
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
|
||||
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
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/syndtr/goleveldb v0.0.0-20180307113352-169b1b37be73/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
|
||||
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
||||
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
||||
github.com/virtuald/go-ordered-json v0.0.0-20170621173500-b18e6e673d74/go.mod h1:RmMWU37GKR2s6pgrIEB4ixgpVCt/cf7dnJv3fuH1J1c=
|
||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
||||
github.com/yuin/gopher-lua v0.0.0-20190514113301-1cd887cd7036/go.mod h1:gqRgreBUhTSL0GeU64rtZ3Uq3wtjOa/TB2YfrtkCbVQ=
|
||||
github.com/yuin/gopher-lua v0.0.0-20191128022950-c6266f4fe8d7/go.mod h1:gqRgreBUhTSL0GeU64rtZ3Uq3wtjOa/TB2YfrtkCbVQ=
|
||||
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||
go.etcd.io/bbolt v1.3.4/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
|
||||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/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-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
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/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=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
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-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/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-20180905080454-ebe1bf3edb33/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-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-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=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191010194322-b09406accb47/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/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/tools v0.0.0-20180318012157-96caea41033d/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=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/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=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2ElGhA4+qG2zF97qiUzTM+rQ0klBOcE=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||
google.golang.org/grpc v1.29.1 h1:EC2SB8S04d2r73uptxphDSUG+kTKVgjRPF+N3xpxRB4=
|
||||
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
gopkg.in/abiosoft/ishell.v2 v2.0.0/go.mod h1:sFp+cGtH6o4s1FtpVPTMcHq2yue+c4DGOVohJCPUzwY=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/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=
|
20
pkg/policy/doc.go
Normal file
20
pkg/policy/doc.go
Normal file
|
@ -0,0 +1,20 @@
|
|||
// Package policy provides facilities for creating policy from SQL-like language.
|
||||
// eBNF grammar is provided in `grammar.ebnf` for illustration.
|
||||
//
|
||||
// Current limitations:
|
||||
// 1. Grouping filter expressions in parenthesis is not supported right now.
|
||||
// Requiring this will make query too verbose, making it optional makes
|
||||
// our grammar not LL(1). This can be supported in future.
|
||||
// 2. Filters must be defined before they are used.
|
||||
// This requirement may be relaxed in future.
|
||||
//
|
||||
// Example query:
|
||||
// REP 1 in SPB
|
||||
// REP 2 in Americas
|
||||
// CBF 4
|
||||
// SELECT 1 Node IN City FROM SPBSSD AS SPB
|
||||
// SELECT 2 Node IN SAME City FROM Americas AS Americas
|
||||
// FILTER SSD EQ true AS IsSSD
|
||||
// FILTER @IsSSD AND Country eq "RU" AND City eq "St.Petersburg" AS SPBSSD
|
||||
// FILTER 'Continent' == 'North America' OR Continent == 'South America' AS Americas
|
||||
package policy
|
141
pkg/policy/encode.go
Normal file
141
pkg/policy/encode.go
Normal file
|
@ -0,0 +1,141 @@
|
|||
package policy
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/netmap"
|
||||
)
|
||||
|
||||
// Encode parses data of PlacementPolicy to a string.
|
||||
func Encode(p *netmap.PlacementPolicy) []string {
|
||||
if p == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
replicas = p.Replicas()
|
||||
selectors = p.Selectors()
|
||||
filters = p.Filters()
|
||||
)
|
||||
|
||||
// 1 for container backup factor
|
||||
result := make([]string, 0, len(replicas)+len(selectors)+len(filters)+1)
|
||||
|
||||
// first print replicas
|
||||
encodeReplicas(replicas, &result)
|
||||
|
||||
// then backup factor
|
||||
if backupFactor := p.ContainerBackupFactor(); backupFactor != 0 {
|
||||
result = append(result, fmt.Sprintf("CBF %d", backupFactor))
|
||||
}
|
||||
|
||||
// then selectors
|
||||
encodeSelectors(selectors, &result)
|
||||
|
||||
// then filters
|
||||
encodeFilters(filters, &result)
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func encodeReplicas(replicas []*netmap.Replica, dst *[]string) {
|
||||
builder := new(strings.Builder)
|
||||
|
||||
for _, replica := range replicas {
|
||||
builder.WriteString("REP ")
|
||||
builder.WriteString(strconv.FormatUint(uint64(replica.Count()), 10))
|
||||
|
||||
if s := replica.Selector(); s != "" {
|
||||
builder.WriteString(" IN ")
|
||||
builder.WriteString(s)
|
||||
}
|
||||
|
||||
*dst = append(*dst, builder.String())
|
||||
builder.Reset()
|
||||
}
|
||||
}
|
||||
|
||||
func encodeSelectors(selectors []*netmap.Selector, dst *[]string) {
|
||||
builder := new(strings.Builder)
|
||||
|
||||
for _, selector := range selectors {
|
||||
builder.WriteString("SELECT ")
|
||||
builder.WriteString(strconv.FormatUint(uint64(selector.Count()), 10))
|
||||
|
||||
if a := selector.Attribute(); a != "" {
|
||||
builder.WriteString(" IN")
|
||||
|
||||
switch selector.Clause() {
|
||||
case netmap.ClauseSame:
|
||||
builder.WriteString(" SAME ")
|
||||
case netmap.ClauseDistinct:
|
||||
builder.WriteString(" DISTINCT ")
|
||||
default:
|
||||
builder.WriteString(" ")
|
||||
}
|
||||
|
||||
builder.WriteString(a)
|
||||
}
|
||||
|
||||
if f := selector.Filter(); f != "" {
|
||||
builder.WriteString(" FROM ")
|
||||
builder.WriteString(f)
|
||||
}
|
||||
|
||||
if n := selector.Name(); n != "" {
|
||||
builder.WriteString(" AS ")
|
||||
builder.WriteString(n)
|
||||
}
|
||||
|
||||
*dst = append(*dst, builder.String())
|
||||
builder.Reset()
|
||||
}
|
||||
}
|
||||
|
||||
func encodeFilters(filters []*netmap.Filter, dst *[]string) {
|
||||
builder := new(strings.Builder)
|
||||
|
||||
for _, filter := range filters {
|
||||
builder.WriteString("FILTER ")
|
||||
|
||||
builder.WriteString(encodeFilter(filter))
|
||||
|
||||
*dst = append(*dst, builder.String())
|
||||
builder.Reset()
|
||||
}
|
||||
}
|
||||
|
||||
func encodeFilter(filter *netmap.Filter) string {
|
||||
builder := new(strings.Builder)
|
||||
unspecified := filter.Operation() == 0
|
||||
|
||||
if k := filter.Key(); k != "" {
|
||||
builder.WriteString(k)
|
||||
builder.WriteString(" ")
|
||||
builder.WriteString(filter.Operation().String())
|
||||
builder.WriteString(" ")
|
||||
builder.WriteString(filter.Value())
|
||||
} else if n := filter.Name(); unspecified && n != "" {
|
||||
builder.WriteString("@")
|
||||
builder.WriteString(n)
|
||||
}
|
||||
|
||||
for i, subfilter := range filter.InnerFilters() {
|
||||
if i != 0 {
|
||||
builder.WriteString(" ")
|
||||
builder.WriteString(filter.Operation().String())
|
||||
builder.WriteString(" ")
|
||||
}
|
||||
|
||||
builder.WriteString(encodeFilter(subfilter))
|
||||
}
|
||||
|
||||
if n := filter.Name(); n != "" && !unspecified {
|
||||
builder.WriteString(" AS ")
|
||||
builder.WriteString(n)
|
||||
}
|
||||
|
||||
return builder.String()
|
||||
}
|
36
pkg/policy/encode_test.go
Normal file
36
pkg/policy/encode_test.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
package policy_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neofs-sdk-go/pkg/policy"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestEncode(t *testing.T) {
|
||||
testCases := []string{
|
||||
`REP 1 IN X
|
||||
CBF 1
|
||||
SELECT 2 IN SAME Location FROM * AS X`,
|
||||
|
||||
`REP 1
|
||||
SELECT 2 IN City FROM Good
|
||||
FILTER Country EQ RU AS FromRU
|
||||
FILTER @FromRU AND Rating GT 7 AS Good`,
|
||||
|
||||
`REP 7 IN SPB
|
||||
SELECT 1 IN City FROM SPBSSD AS SPB
|
||||
FILTER City EQ SPB AND SSD EQ true OR City EQ SPB AND Rating GE 5 AS SPBSSD`,
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
q, err := policy.Parse(testCase)
|
||||
require.NoError(t, err)
|
||||
|
||||
got := policy.Encode(q)
|
||||
fmt.Println(strings.Join(got, "\n"))
|
||||
require.Equal(t, testCase, strings.Join(got, "\n"))
|
||||
}
|
||||
}
|
55
pkg/policy/grammar.ebnf
Normal file
55
pkg/policy/grammar.ebnf
Normal file
|
@ -0,0 +1,55 @@
|
|||
Policy ::=
|
||||
RepStmt, [RepStmt],
|
||||
CbtStmt?,
|
||||
[SelectStmt],
|
||||
[FilterStmt],
|
||||
;
|
||||
|
||||
RepStmt ::=
|
||||
'REP', Number1, (* number of object replicas *)
|
||||
('AS', Ident)? (* optional selector name *)
|
||||
;
|
||||
|
||||
CbtStmt ::= 'CBF', Number1 (* container backup factor *)
|
||||
;
|
||||
|
||||
SelectStmt ::=
|
||||
'SELECT', Number1, (* number of nodes to select without container backup factor *)
|
||||
('IN', Clause?, Ident)?, (* bucket name *)
|
||||
FROM, (Ident | '*'), (* filter reference or whole netmap *)
|
||||
('AS', Ident)? (* optional selector name *)
|
||||
;
|
||||
|
||||
Clause ::=
|
||||
'SAME' (* nodes from the same bucket *)
|
||||
| 'DISTINCT' (* nodes from distinct buckets *)
|
||||
;
|
||||
|
||||
FilterStmt ::=
|
||||
'FILTER', AndChain, ['OR', AndChain],
|
||||
'AS', Ident (* obligatory filter name *)
|
||||
;
|
||||
|
||||
AndChain ::=
|
||||
Expr, ['AND', Expr]
|
||||
;
|
||||
|
||||
Expr ::=
|
||||
'@' Ident (* filter reference *)
|
||||
| Key, Op, Value (* attribute filter *)
|
||||
;
|
||||
|
||||
Op ::= 'EQ' | 'NE' | 'GE' | 'GT' | 'LT' | 'LE'
|
||||
;
|
||||
|
||||
Key ::= Ident | String
|
||||
;
|
||||
|
||||
Value ::= Ident | Number | String
|
||||
;
|
||||
|
||||
Number1 ::= Digit1 [Digit];
|
||||
Number ::= Digit [Digit];
|
||||
|
||||
Digit1 ::= '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' ;
|
||||
Digit ::= '0' | Digit1;
|
60
pkg/policy/grammar.go
Normal file
60
pkg/policy/grammar.go
Normal file
|
@ -0,0 +1,60 @@
|
|||
//nolint:govet,golint // fails on struct tags here, but participle needs this syntax
|
||||
package policy
|
||||
|
||||
import (
|
||||
"github.com/alecthomas/participle"
|
||||
)
|
||||
|
||||
var parser *participle.Parser
|
||||
|
||||
func init() {
|
||||
p, err := participle.Build(&query{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
parser = p
|
||||
}
|
||||
|
||||
type query struct {
|
||||
Replicas []*replicaStmt `@@+`
|
||||
CBF uint32 `("CBF" @Int)?`
|
||||
Selectors []*selectorStmt `@@*`
|
||||
Filters []*filterStmt `@@*`
|
||||
}
|
||||
|
||||
type replicaStmt struct {
|
||||
Count int `"REP" @Int`
|
||||
Selector string `("IN" @Ident)?`
|
||||
}
|
||||
|
||||
type selectorStmt struct {
|
||||
Count uint32 `"SELECT" @Int`
|
||||
Bucket []string `("IN" @(("SAME" | "DISTINCT")? Ident))?`
|
||||
Filter string `"FROM" @(Ident | "*")`
|
||||
Name string `("AS" @Ident)?`
|
||||
}
|
||||
|
||||
type filterStmt struct {
|
||||
Value *orChain `"FILTER" @@`
|
||||
Name string `"AS" @Ident`
|
||||
}
|
||||
|
||||
type filterOrExpr struct {
|
||||
Reference string `"@"@Ident`
|
||||
Expr *simpleExpr `| @@`
|
||||
}
|
||||
|
||||
type orChain struct {
|
||||
Clauses []*andChain `@@ ("OR" @@)*`
|
||||
}
|
||||
|
||||
type andChain struct {
|
||||
Clauses []*filterOrExpr `@@ ("AND" @@)*`
|
||||
}
|
||||
|
||||
type simpleExpr struct {
|
||||
Key string `@(Ident | String)`
|
||||
// We don't use literals here to improve error messages.
|
||||
Op string `@Ident`
|
||||
Value string `@(Ident | String | Int)`
|
||||
}
|
225
pkg/policy/json.go
Normal file
225
pkg/policy/json.go
Normal file
|
@ -0,0 +1,225 @@
|
|||
package policy
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/v2/netmap"
|
||||
)
|
||||
|
||||
type (
|
||||
filter struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Key string `json:"key,omitempty"`
|
||||
Op string `json:"op,omitempty"`
|
||||
Value string `json:"value,omitempty"`
|
||||
Filters []filter `json:"filters,omitempty"`
|
||||
}
|
||||
replica struct {
|
||||
Count uint32 `json:"count"`
|
||||
Selector string `json:"selector,omitempty"`
|
||||
}
|
||||
selector struct {
|
||||
Count uint32 `json:"count"`
|
||||
Attribute string `json:"attribute"`
|
||||
Filter string `json:"filter,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Clause string `json:"clause,omitempty"`
|
||||
}
|
||||
placement struct {
|
||||
Replicas []replica `json:"replicas"`
|
||||
CBF uint32 `json:"container_backup_factor,omitempty"`
|
||||
Selectors []selector `json:"selectors,omitempty"`
|
||||
Filters []filter `json:"filters,omitempty"`
|
||||
}
|
||||
)
|
||||
|
||||
// ToJSON converts placement policy to JSON.
|
||||
func ToJSON(np *netmap.PlacementPolicy) ([]byte, error) {
|
||||
p := new(placement)
|
||||
p.CBF = np.GetContainerBackupFactor()
|
||||
p.Filters = make([]filter, len(np.GetFilters()))
|
||||
for i, f := range np.GetFilters() {
|
||||
p.Filters[i].fromNetmap(f)
|
||||
}
|
||||
p.Selectors = make([]selector, len(np.GetSelectors()))
|
||||
for i, s := range np.GetSelectors() {
|
||||
p.Selectors[i].fromNetmap(s)
|
||||
}
|
||||
p.Replicas = make([]replica, len(np.GetReplicas()))
|
||||
for i, r := range np.GetReplicas() {
|
||||
p.Replicas[i].fromNetmap(r)
|
||||
}
|
||||
return json.Marshal(p)
|
||||
}
|
||||
|
||||
// FromJSON creates placement policy from JSON.
|
||||
func FromJSON(data []byte) (*netmap.PlacementPolicy, error) {
|
||||
p := new(placement)
|
||||
if err := json.Unmarshal(data, p); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rs := make([]*netmap.Replica, len(p.Replicas))
|
||||
for i := range p.Replicas {
|
||||
rs[i] = p.Replicas[i].toNetmap()
|
||||
}
|
||||
|
||||
var fs []*netmap.Filter
|
||||
if len(p.Filters) != 0 {
|
||||
fs = make([]*netmap.Filter, len(p.Filters))
|
||||
for i := range p.Filters {
|
||||
f, err := p.Filters[i].toNetmap()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fs[i] = f
|
||||
}
|
||||
}
|
||||
|
||||
var ss []*netmap.Selector
|
||||
if len(p.Selectors) != 0 {
|
||||
ss = make([]*netmap.Selector, len(p.Selectors))
|
||||
for i := range p.Selectors {
|
||||
s, err := p.Selectors[i].toNetmap()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ss[i] = s
|
||||
}
|
||||
}
|
||||
|
||||
pp := new(netmap.PlacementPolicy)
|
||||
pp.SetReplicas(rs)
|
||||
pp.SetContainerBackupFactor(p.CBF)
|
||||
pp.SetFilters(fs)
|
||||
pp.SetSelectors(ss)
|
||||
return pp, nil
|
||||
}
|
||||
|
||||
func (r *replica) toNetmap() *netmap.Replica {
|
||||
nr := new(netmap.Replica)
|
||||
nr.SetCount(r.Count)
|
||||
nr.SetSelector(r.Selector)
|
||||
return nr
|
||||
}
|
||||
|
||||
func (r *replica) fromNetmap(nr *netmap.Replica) {
|
||||
r.Count = nr.GetCount()
|
||||
r.Selector = nr.GetSelector()
|
||||
}
|
||||
|
||||
func (f *filter) toNetmap() (*netmap.Filter, error) {
|
||||
var op netmap.Operation
|
||||
switch strings.ToUpper(f.Op) {
|
||||
case "EQ":
|
||||
op = netmap.EQ
|
||||
case "NE":
|
||||
op = netmap.NE
|
||||
case "GT":
|
||||
op = netmap.GT
|
||||
case "GE":
|
||||
op = netmap.GE
|
||||
case "LT":
|
||||
op = netmap.LT
|
||||
case "LE":
|
||||
op = netmap.LE
|
||||
case "AND":
|
||||
op = netmap.AND
|
||||
case "OR":
|
||||
op = netmap.OR
|
||||
case "":
|
||||
op = netmap.UnspecifiedOperation
|
||||
default:
|
||||
return nil, fmt.Errorf("%w: '%s'", ErrUnknownOp, f.Op)
|
||||
}
|
||||
|
||||
var fs []*netmap.Filter
|
||||
if len(f.Filters) != 0 {
|
||||
fs = make([]*netmap.Filter, len(f.Filters))
|
||||
for i := range f.Filters {
|
||||
var err error
|
||||
fs[i], err = f.Filters[i].toNetmap()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nf := new(netmap.Filter)
|
||||
nf.SetFilters(fs)
|
||||
nf.SetOp(op)
|
||||
nf.SetName(f.Name)
|
||||
nf.SetValue(f.Value)
|
||||
nf.SetKey(f.Key)
|
||||
return nf, nil
|
||||
}
|
||||
|
||||
func (f *filter) fromNetmap(nf *netmap.Filter) {
|
||||
f.Name = nf.GetName()
|
||||
f.Key = nf.GetKey()
|
||||
f.Value = nf.GetValue()
|
||||
switch nf.GetOp() {
|
||||
case netmap.EQ:
|
||||
f.Op = "EQ"
|
||||
case netmap.NE:
|
||||
f.Op = "NE"
|
||||
case netmap.GT:
|
||||
f.Op = "GT"
|
||||
case netmap.GE:
|
||||
f.Op = "GE"
|
||||
case netmap.LT:
|
||||
f.Op = "LT"
|
||||
case netmap.LE:
|
||||
f.Op = "LE"
|
||||
case netmap.AND:
|
||||
f.Op = "AND"
|
||||
case netmap.OR:
|
||||
f.Op = "OR"
|
||||
default:
|
||||
// do nothing
|
||||
}
|
||||
if nf.GetFilters() != nil {
|
||||
f.Filters = make([]filter, len(nf.GetFilters()))
|
||||
for i, sf := range nf.GetFilters() {
|
||||
f.Filters[i].fromNetmap(sf)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *selector) toNetmap() (*netmap.Selector, error) {
|
||||
var c netmap.Clause
|
||||
switch strings.ToUpper(s.Clause) {
|
||||
case "SAME":
|
||||
c = netmap.Same
|
||||
case "DISTINCT":
|
||||
c = netmap.Distinct
|
||||
case "":
|
||||
default:
|
||||
return nil, fmt.Errorf("%w: '%s'", ErrUnknownClause, s.Clause)
|
||||
}
|
||||
ns := new(netmap.Selector)
|
||||
ns.SetName(s.Name)
|
||||
ns.SetAttribute(s.Attribute)
|
||||
ns.SetCount(s.Count)
|
||||
ns.SetClause(c)
|
||||
ns.SetFilter(s.Filter)
|
||||
return ns, nil
|
||||
}
|
||||
|
||||
func (s *selector) fromNetmap(ns *netmap.Selector) {
|
||||
s.Name = ns.GetName()
|
||||
s.Filter = ns.GetFilter()
|
||||
s.Count = ns.GetCount()
|
||||
s.Attribute = ns.GetAttribute()
|
||||
switch ns.GetClause() {
|
||||
case netmap.Same:
|
||||
s.Clause = "same"
|
||||
case netmap.Distinct:
|
||||
s.Clause = "distinct"
|
||||
default:
|
||||
// do nothing
|
||||
}
|
||||
s.Name = ns.GetName()
|
||||
}
|
84
pkg/policy/json_test.go
Normal file
84
pkg/policy/json_test.go
Normal file
|
@ -0,0 +1,84 @@
|
|||
package policy
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/v2/netmap"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestToJSON(t *testing.T) {
|
||||
check := func(t *testing.T, p *netmap.PlacementPolicy, json string) {
|
||||
data, err := ToJSON(p)
|
||||
require.NoError(t, err)
|
||||
require.JSONEq(t, json, string(data))
|
||||
|
||||
np, err := FromJSON(data)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, p, np)
|
||||
}
|
||||
t.Run("SimpleREP", func(t *testing.T) {
|
||||
p := new(netmap.PlacementPolicy)
|
||||
p.SetReplicas([]*netmap.Replica{newReplica("", 3)})
|
||||
check(t, p, `{"replicas":[{"count":3}]}`)
|
||||
})
|
||||
t.Run("REPWithCBF", func(t *testing.T) {
|
||||
p := new(netmap.PlacementPolicy)
|
||||
p.SetReplicas([]*netmap.Replica{newReplica("", 3)})
|
||||
p.SetContainerBackupFactor(3)
|
||||
check(t, p, `{"replicas":[{"count":3}],"container_backup_factor":3}`)
|
||||
})
|
||||
t.Run("REPFromSelector", func(t *testing.T) {
|
||||
p := new(netmap.PlacementPolicy)
|
||||
p.SetReplicas([]*netmap.Replica{newReplica("Nodes", 3)})
|
||||
p.SetContainerBackupFactor(3)
|
||||
p.SetSelectors([]*netmap.Selector{
|
||||
newSelector(1, netmap.Distinct, "City", "", "Nodes"),
|
||||
})
|
||||
check(t, p, `{
|
||||
"replicas":[{"count":3,"selector":"Nodes"}],
|
||||
"container_backup_factor":3,
|
||||
"selectors": [{
|
||||
"name":"Nodes",
|
||||
"attribute":"City",
|
||||
"clause":"distinct",
|
||||
"count":1
|
||||
}]}`)
|
||||
})
|
||||
t.Run("FilterOps", func(t *testing.T) {
|
||||
p := new(netmap.PlacementPolicy)
|
||||
p.SetReplicas([]*netmap.Replica{newReplica("Nodes", 3)})
|
||||
p.SetContainerBackupFactor(3)
|
||||
p.SetSelectors([]*netmap.Selector{
|
||||
newSelector(1, netmap.Same, "City", "Good", "Nodes"),
|
||||
})
|
||||
p.SetFilters([]*netmap.Filter{
|
||||
newFilter("GoodRating", "Rating", "5", netmap.GE),
|
||||
newFilter("Good", "", "", netmap.OR,
|
||||
newFilter("GoodRating", "", "", netmap.UnspecifiedOperation),
|
||||
newFilter("", "Attr1", "Val1", netmap.EQ),
|
||||
newFilter("", "Attr2", "Val2", netmap.NE),
|
||||
newFilter("", "", "", netmap.AND,
|
||||
newFilter("", "Attr4", "2", netmap.LT),
|
||||
newFilter("", "Attr5", "3", netmap.LE)),
|
||||
newFilter("", "Attr3", "1", netmap.GT)),
|
||||
})
|
||||
check(t, p, `{
|
||||
"replicas":[{"count":3,"selector":"Nodes"}],
|
||||
"container_backup_factor":3,
|
||||
"selectors": [{"name":"Nodes","attribute":"City","clause":"same","count":1,"filter":"Good"}],
|
||||
"filters": [
|
||||
{"name":"GoodRating","key":"Rating","op":"GE","value":"5"},
|
||||
{"name":"Good","op":"OR","filters":[
|
||||
{"name":"GoodRating"},
|
||||
{"key":"Attr1","op":"EQ","value":"Val1"},
|
||||
{"key":"Attr2","op":"NE","value":"Val2"},
|
||||
{"op":"AND","filters":[
|
||||
{"key":"Attr4","op":"LT","value":"2"},
|
||||
{"key":"Attr5","op":"LE","value":"3"}
|
||||
]},
|
||||
{"key":"Attr3","op":"GT","value":"1"}
|
||||
]}
|
||||
]}`)
|
||||
})
|
||||
}
|
178
pkg/policy/query.go
Normal file
178
pkg/policy/query.go
Normal file
|
@ -0,0 +1,178 @@
|
|||
package policy
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/netmap"
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrInvalidNumber is returned when a value of SELECT is 0.
|
||||
ErrInvalidNumber = errors.New("policy: expected positive integer")
|
||||
// ErrUnknownClause is returned when a statement(clause) in a query is unknown.
|
||||
ErrUnknownClause = errors.New("policy: unknown clause")
|
||||
// ErrUnknownOp is returned when an operation in a query is unknown.
|
||||
ErrUnknownOp = errors.New("policy: unknown operation")
|
||||
// ErrUnknownFilter is returned when a value of FROM in a query is unknown.
|
||||
ErrUnknownFilter = errors.New("policy: filter not found")
|
||||
// ErrUnknownSelector is returned when a value of IN is unknown.
|
||||
ErrUnknownSelector = errors.New("policy: selector not found")
|
||||
)
|
||||
|
||||
func parse(s string) (*query, error) {
|
||||
q := new(query)
|
||||
err := parser.Parse(strings.NewReader(s), q)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return q, nil
|
||||
}
|
||||
|
||||
// Parse parses s into a placement policy.
|
||||
func Parse(s string) (*netmap.PlacementPolicy, error) {
|
||||
q, err := parse(s)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
seenFilters := map[string]bool{}
|
||||
fs := make([]*netmap.Filter, 0, len(q.Filters))
|
||||
for _, qf := range q.Filters {
|
||||
f, err := filterFromOrChain(qf.Value, seenFilters)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
f.SetName(qf.Name)
|
||||
fs = append(fs, f)
|
||||
seenFilters[qf.Name] = true
|
||||
}
|
||||
|
||||
seenSelectors := map[string]bool{}
|
||||
ss := make([]*netmap.Selector, 0, len(q.Selectors))
|
||||
for _, qs := range q.Selectors {
|
||||
if qs.Filter != netmap.MainFilterName && !seenFilters[qs.Filter] {
|
||||
return nil, fmt.Errorf("%w: '%s'", ErrUnknownFilter, qs.Filter)
|
||||
}
|
||||
s := netmap.NewSelector()
|
||||
switch len(qs.Bucket) {
|
||||
case 1: // only bucket
|
||||
s.SetAttribute(qs.Bucket[0])
|
||||
case 2: // clause + bucket
|
||||
s.SetClause(clauseFromString(qs.Bucket[0]))
|
||||
s.SetAttribute(qs.Bucket[1])
|
||||
}
|
||||
s.SetName(qs.Name)
|
||||
seenSelectors[qs.Name] = true
|
||||
s.SetFilter(qs.Filter)
|
||||
if qs.Count == 0 {
|
||||
return nil, fmt.Errorf("%w: SELECT", ErrInvalidNumber)
|
||||
}
|
||||
s.SetCount(qs.Count)
|
||||
ss = append(ss, s)
|
||||
}
|
||||
|
||||
rs := make([]*netmap.Replica, 0, len(q.Replicas))
|
||||
for _, qr := range q.Replicas {
|
||||
r := netmap.NewReplica()
|
||||
if qr.Selector != "" {
|
||||
if !seenSelectors[qr.Selector] {
|
||||
return nil, fmt.Errorf("%w: '%s'", ErrUnknownSelector, qr.Selector)
|
||||
}
|
||||
r.SetSelector(qr.Selector)
|
||||
}
|
||||
if qr.Count == 0 {
|
||||
return nil, fmt.Errorf("%w: REP", ErrInvalidNumber)
|
||||
}
|
||||
r.SetCount(uint32(qr.Count))
|
||||
rs = append(rs, r)
|
||||
}
|
||||
|
||||
p := new(netmap.PlacementPolicy)
|
||||
p.SetFilters(fs...)
|
||||
p.SetSelectors(ss...)
|
||||
p.SetReplicas(rs...)
|
||||
p.SetContainerBackupFactor(q.CBF)
|
||||
|
||||
return p, nil
|
||||
}
|
||||
|
||||
func clauseFromString(s string) netmap.Clause {
|
||||
switch strings.ToUpper(s) {
|
||||
case "SAME":
|
||||
return netmap.ClauseSame
|
||||
case "DISTINCT":
|
||||
return netmap.ClauseDistinct
|
||||
default:
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
func filterFromOrChain(expr *orChain, seen map[string]bool) (*netmap.Filter, error) {
|
||||
var fs []*netmap.Filter
|
||||
for _, ac := range expr.Clauses {
|
||||
f, err := filterFromAndChain(ac, seen)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fs = append(fs, f)
|
||||
}
|
||||
if len(fs) == 1 {
|
||||
return fs[0], nil
|
||||
}
|
||||
|
||||
f := netmap.NewFilter()
|
||||
f.SetOperation(netmap.OpOR)
|
||||
f.SetInnerFilters(fs...)
|
||||
return f, nil
|
||||
}
|
||||
|
||||
func filterFromAndChain(expr *andChain, seen map[string]bool) (*netmap.Filter, error) {
|
||||
var fs []*netmap.Filter
|
||||
for _, fe := range expr.Clauses {
|
||||
var f *netmap.Filter
|
||||
var err error
|
||||
if fe.Expr != nil {
|
||||
f, err = filterFromSimpleExpr(fe.Expr, seen)
|
||||
} else {
|
||||
f = netmap.NewFilter()
|
||||
f.SetName(fe.Reference)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fs = append(fs, f)
|
||||
}
|
||||
if len(fs) == 1 {
|
||||
return fs[0], nil
|
||||
}
|
||||
|
||||
f := netmap.NewFilter()
|
||||
f.SetOperation(netmap.OpAND)
|
||||
f.SetInnerFilters(fs...)
|
||||
return f, nil
|
||||
}
|
||||
|
||||
func filterFromSimpleExpr(se *simpleExpr, seen map[string]bool) (*netmap.Filter, error) {
|
||||
f := netmap.NewFilter()
|
||||
f.SetKey(se.Key)
|
||||
switch se.Op {
|
||||
case "EQ":
|
||||
f.SetOperation(netmap.OpEQ)
|
||||
case "NE":
|
||||
f.SetOperation(netmap.OpNE)
|
||||
case "GE":
|
||||
f.SetOperation(netmap.OpGE)
|
||||
case "GT":
|
||||
f.SetOperation(netmap.OpGT)
|
||||
case "LE":
|
||||
f.SetOperation(netmap.OpLE)
|
||||
case "LT":
|
||||
f.SetOperation(netmap.OpLT)
|
||||
default:
|
||||
return nil, fmt.Errorf("%w: '%s'", ErrUnknownOp, se.Op)
|
||||
}
|
||||
f.SetValue(se.Value)
|
||||
return f, nil
|
||||
}
|
282
pkg/policy/query_test.go
Normal file
282
pkg/policy/query_test.go
Normal file
|
@ -0,0 +1,282 @@
|
|||
package policy
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/v2/netmap"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestSimple(t *testing.T) {
|
||||
q := `REP 3`
|
||||
expected := new(netmap.PlacementPolicy)
|
||||
expected.SetFilters([]*netmap.Filter{})
|
||||
expected.SetSelectors([]*netmap.Selector{})
|
||||
expected.SetReplicas([]*netmap.Replica{newReplica("", 3)})
|
||||
|
||||
r, err := Parse(q)
|
||||
require.NoError(t, err)
|
||||
require.EqualValues(t, expected, r)
|
||||
}
|
||||
|
||||
func TestSimpleWithHRWB(t *testing.T) {
|
||||
q := `REP 3 CBF 4`
|
||||
expected := new(netmap.PlacementPolicy)
|
||||
expected.SetFilters([]*netmap.Filter{})
|
||||
expected.SetSelectors([]*netmap.Selector{})
|
||||
expected.SetReplicas([]*netmap.Replica{newReplica("", 3)})
|
||||
expected.SetContainerBackupFactor(4)
|
||||
|
||||
r, err := Parse(q)
|
||||
require.NoError(t, err)
|
||||
require.EqualValues(t, expected, r)
|
||||
}
|
||||
|
||||
func TestFromSelect(t *testing.T) {
|
||||
q := `REP 1 IN SPB
|
||||
SELECT 1 IN City FROM * AS SPB`
|
||||
expected := new(netmap.PlacementPolicy)
|
||||
expected.SetFilters([]*netmap.Filter{})
|
||||
expected.SetSelectors([]*netmap.Selector{
|
||||
newSelector(1, netmap.UnspecifiedClause, "City", "*", "SPB"),
|
||||
})
|
||||
expected.SetReplicas([]*netmap.Replica{newReplica("SPB", 1)})
|
||||
|
||||
r, err := Parse(q)
|
||||
require.NoError(t, err)
|
||||
require.EqualValues(t, expected, r)
|
||||
}
|
||||
|
||||
// https://github.com/nspcc-dev/neofs-node/issues/46
|
||||
func TestFromSelectNoAttribute(t *testing.T) {
|
||||
t.Run("Simple", func(t *testing.T) {
|
||||
q := `REP 2
|
||||
SELECT 6 FROM *`
|
||||
|
||||
expected := new(netmap.PlacementPolicy)
|
||||
expected.SetFilters([]*netmap.Filter{})
|
||||
expected.SetSelectors([]*netmap.Selector{newSelector(6, netmap.UnspecifiedClause, "", "*", "")})
|
||||
expected.SetReplicas([]*netmap.Replica{newReplica("", 2)})
|
||||
|
||||
r, err := Parse(q)
|
||||
require.NoError(t, err)
|
||||
require.EqualValues(t, expected, r)
|
||||
})
|
||||
|
||||
t.Run("with filter", func(t *testing.T) {
|
||||
q := `REP 2
|
||||
SELECT 6 FROM F
|
||||
FILTER StorageType EQ SSD AS F`
|
||||
|
||||
expected := new(netmap.PlacementPolicy)
|
||||
expected.SetFilters([]*netmap.Filter{newFilter("F", "StorageType", "SSD", netmap.EQ)})
|
||||
expected.SetSelectors([]*netmap.Selector{newSelector(6, netmap.UnspecifiedClause, "", "F", "")})
|
||||
expected.SetReplicas([]*netmap.Replica{newReplica("", 2)})
|
||||
|
||||
r, err := Parse(q)
|
||||
require.NoError(t, err)
|
||||
require.EqualValues(t, expected, r)
|
||||
})
|
||||
}
|
||||
|
||||
func TestFromSelectClause(t *testing.T) {
|
||||
q := `REP 4
|
||||
SELECT 3 IN Country FROM *
|
||||
SELECT 2 IN SAME City FROM *
|
||||
SELECT 1 IN DISTINCT Continent FROM *`
|
||||
expected := new(netmap.PlacementPolicy)
|
||||
expected.SetFilters([]*netmap.Filter{})
|
||||
expected.SetSelectors([]*netmap.Selector{
|
||||
newSelector(3, netmap.UnspecifiedClause, "Country", "*", ""),
|
||||
newSelector(2, netmap.Same, "City", "*", ""),
|
||||
newSelector(1, netmap.Distinct, "Continent", "*", ""),
|
||||
})
|
||||
expected.SetReplicas([]*netmap.Replica{newReplica("", 4)})
|
||||
|
||||
r, err := Parse(q)
|
||||
require.NoError(t, err)
|
||||
require.EqualValues(t, expected, r)
|
||||
}
|
||||
|
||||
func TestSimpleFilter(t *testing.T) {
|
||||
q := `REP 1
|
||||
SELECT 1 IN City FROM Good
|
||||
FILTER Rating GT 7 AS Good`
|
||||
expected := new(netmap.PlacementPolicy)
|
||||
expected.SetReplicas([]*netmap.Replica{newReplica("", 1)})
|
||||
expected.SetSelectors([]*netmap.Selector{
|
||||
newSelector(1, netmap.UnspecifiedClause, "City", "Good", ""),
|
||||
})
|
||||
expected.SetFilters([]*netmap.Filter{
|
||||
newFilter("Good", "Rating", "7", netmap.GT),
|
||||
})
|
||||
|
||||
r, err := Parse(q)
|
||||
require.NoError(t, err)
|
||||
require.EqualValues(t, expected, r)
|
||||
}
|
||||
|
||||
func TestFilterReference(t *testing.T) {
|
||||
q := `REP 1
|
||||
SELECT 2 IN City FROM Good
|
||||
FILTER Country EQ "RU" AS FromRU
|
||||
FILTER @FromRU AND Rating GT 7 AS Good`
|
||||
expected := new(netmap.PlacementPolicy)
|
||||
expected.SetReplicas([]*netmap.Replica{newReplica("", 1)})
|
||||
expected.SetSelectors([]*netmap.Selector{
|
||||
newSelector(2, netmap.UnspecifiedClause, "City", "Good", ""),
|
||||
})
|
||||
expected.SetFilters([]*netmap.Filter{
|
||||
newFilter("FromRU", "Country", "RU", netmap.EQ),
|
||||
newFilter("Good", "", "", netmap.AND,
|
||||
newFilter("FromRU", "", "", netmap.UnspecifiedOperation),
|
||||
newFilter("", "Rating", "7", netmap.GT)),
|
||||
})
|
||||
|
||||
r, err := Parse(q)
|
||||
require.NoError(t, err)
|
||||
require.EqualValues(t, expected, r)
|
||||
}
|
||||
|
||||
func TestFilterOps(t *testing.T) {
|
||||
q := `REP 1
|
||||
SELECT 2 IN City FROM Good
|
||||
FILTER A GT 1 AND B GE 2 AND C LT 3 AND D LE 4
|
||||
AND E EQ 5 AND F NE 6 AS Good`
|
||||
expected := new(netmap.PlacementPolicy)
|
||||
expected.SetReplicas([]*netmap.Replica{newReplica("", 1)})
|
||||
expected.SetSelectors([]*netmap.Selector{
|
||||
newSelector(2, netmap.UnspecifiedClause, "City", "Good", ""),
|
||||
})
|
||||
expected.SetFilters([]*netmap.Filter{
|
||||
newFilter("Good", "", "", netmap.AND,
|
||||
newFilter("", "A", "1", netmap.GT),
|
||||
newFilter("", "B", "2", netmap.GE),
|
||||
newFilter("", "C", "3", netmap.LT),
|
||||
newFilter("", "D", "4", netmap.LE),
|
||||
newFilter("", "E", "5", netmap.EQ),
|
||||
newFilter("", "F", "6", netmap.NE)),
|
||||
})
|
||||
|
||||
r, err := Parse(q)
|
||||
require.NoError(t, err)
|
||||
require.EqualValues(t, expected, r)
|
||||
}
|
||||
|
||||
func TestWithFilterPrecedence(t *testing.T) {
|
||||
q := `REP 7 IN SPB
|
||||
SELECT 1 IN City FROM SPBSSD AS SPB
|
||||
FILTER City EQ "SPB" AND SSD EQ true OR City EQ "SPB" AND Rating GE 5 AS SPBSSD`
|
||||
expected := new(netmap.PlacementPolicy)
|
||||
expected.SetReplicas([]*netmap.Replica{newReplica("SPB", 7)})
|
||||
expected.SetSelectors([]*netmap.Selector{
|
||||
newSelector(1, netmap.UnspecifiedClause, "City", "SPBSSD", "SPB"),
|
||||
})
|
||||
expected.SetFilters([]*netmap.Filter{
|
||||
newFilter("SPBSSD", "", "", netmap.OR,
|
||||
newFilter("", "", "", netmap.AND,
|
||||
newFilter("", "City", "SPB", netmap.EQ),
|
||||
newFilter("", "SSD", "true", netmap.EQ)),
|
||||
newFilter("", "", "", netmap.AND,
|
||||
newFilter("", "City", "SPB", netmap.EQ),
|
||||
newFilter("", "Rating", "5", netmap.GE))),
|
||||
})
|
||||
|
||||
r, err := Parse(q)
|
||||
require.NoError(t, err)
|
||||
require.EqualValues(t, expected, r)
|
||||
}
|
||||
|
||||
func TestValidation(t *testing.T) {
|
||||
t.Run("MissingSelector", func(t *testing.T) {
|
||||
q := `REP 3 IN RU`
|
||||
_, err := Parse(q)
|
||||
require.True(t, errors.Is(err, ErrUnknownSelector), "got: %v", err)
|
||||
})
|
||||
t.Run("MissingFilter", func(t *testing.T) {
|
||||
q := `REP 3
|
||||
SELECT 1 IN City FROM MissingFilter`
|
||||
_, err := Parse(q)
|
||||
require.True(t, errors.Is(err, ErrUnknownFilter), "got: %v", err)
|
||||
})
|
||||
t.Run("UnknownOp", func(t *testing.T) {
|
||||
q := `REP 3
|
||||
SELECT 1 IN City FROM F
|
||||
FILTER Country KEK RU AS F`
|
||||
_, err := Parse(q)
|
||||
require.True(t, errors.Is(err, ErrUnknownOp), "got: %v", err)
|
||||
})
|
||||
t.Run("TypoInREP", func(t *testing.T) {
|
||||
q := `REK 3`
|
||||
_, err := Parse(q)
|
||||
require.Error(t, err)
|
||||
})
|
||||
t.Run("InvalidFilterName", func(t *testing.T) {
|
||||
q := `REP 3
|
||||
SELECT 1 IN City FROM F
|
||||
FILTER Good AND Country EQ RU AS F
|
||||
FILTER Rating EQ 5 AS Good`
|
||||
_, err := Parse(q)
|
||||
require.Error(t, err)
|
||||
})
|
||||
t.Run("InvalidNumberInREP", func(t *testing.T) {
|
||||
q := `REP 0`
|
||||
_, err := Parse(q)
|
||||
require.True(t, errors.Is(err, ErrInvalidNumber), "got: %v", err)
|
||||
})
|
||||
t.Run("InvalidNumberInREP", func(t *testing.T) {
|
||||
q := `REP 1 IN Good
|
||||
SELECT 0 IN City FROM *`
|
||||
_, err := Parse(q)
|
||||
require.True(t, errors.Is(err, ErrInvalidNumber), "got: %v", err)
|
||||
})
|
||||
}
|
||||
|
||||
func TestFilterStringSymbols(t *testing.T) {
|
||||
q := `REP 1 IN S
|
||||
SELECT 1 FROM F AS S
|
||||
FILTER "UN-LOCODE" EQ "RU LED" AS F`
|
||||
|
||||
expected := new(netmap.PlacementPolicy)
|
||||
expected.SetReplicas([]*netmap.Replica{
|
||||
newReplica("S", 1),
|
||||
})
|
||||
expected.SetSelectors([]*netmap.Selector{
|
||||
newSelector(1, netmap.UnspecifiedClause, "", "F", "S"),
|
||||
})
|
||||
expected.SetFilters([]*netmap.Filter{
|
||||
newFilter("F", "UN-LOCODE", "RU LED", netmap.EQ),
|
||||
})
|
||||
|
||||
r, err := Parse(q)
|
||||
require.NoError(t, err)
|
||||
require.EqualValues(t, expected, r)
|
||||
}
|
||||
|
||||
func newFilter(name, key, value string, op netmap.Operation, sub ...*netmap.Filter) *netmap.Filter {
|
||||
f := new(netmap.Filter)
|
||||
f.SetName(name)
|
||||
f.SetKey(key)
|
||||
f.SetValue(value)
|
||||
f.SetOp(op)
|
||||
f.SetFilters(sub)
|
||||
return f
|
||||
}
|
||||
|
||||
func newReplica(s string, c uint32) *netmap.Replica {
|
||||
r := new(netmap.Replica)
|
||||
r.SetSelector(s)
|
||||
r.SetCount(c)
|
||||
return r
|
||||
}
|
||||
|
||||
func newSelector(count uint32, c netmap.Clause, attr, f, name string) *netmap.Selector {
|
||||
s := new(netmap.Selector)
|
||||
s.SetCount(count)
|
||||
s.SetClause(c)
|
||||
s.SetAttribute(attr)
|
||||
s.SetFilter(f)
|
||||
s.SetName(name)
|
||||
return s
|
||||
}
|
Loading…
Reference in a new issue