v.0.1 Создан микросервис подписок/подписчиков
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
commit
38d91d9f10
21
.drone.yml
Normal file
21
.drone.yml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
kind: pipeline
|
||||||
|
name: deploy
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: deploy
|
||||||
|
image: appleboy/drone-ssh
|
||||||
|
settings:
|
||||||
|
host: 89.104.69.222
|
||||||
|
username: root
|
||||||
|
password:
|
||||||
|
from_secret: ssh_password
|
||||||
|
script:
|
||||||
|
- rm -fr /home/tailly_subscribers
|
||||||
|
- mkdir /home/tailly_subscribers
|
||||||
|
- cd /home/tailly_subscribers
|
||||||
|
- git clone https://admin:2bfa8b81e8787c9c0bb89e1a7bbd929b2d63aaf2@git.altomta.ru/admin/tailly_subscribers . || true
|
||||||
|
- git pull
|
||||||
|
- docker stop tailly_subscribers || true
|
||||||
|
- docker rm tailly_subscribers || true
|
||||||
|
- DOCKER_BUILDKIT=1 docker build -t tailly_subscribers .
|
||||||
|
- docker run -d --name tailly_subscribers --network tailly_net -p 50053:50053 tailly_subscribers
|
||||||
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/tailly_subscribers.iml" filepath="$PROJECT_DIR$/.idea/tailly_subscribers.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
9
.idea/tailly_subscribers.iml
generated
Normal file
9
.idea/tailly_subscribers.iml
generated
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="WEB_MODULE" version="4">
|
||||||
|
<component name="Go" enabled="true" />
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
46
Dockerfile
Normal file
46
Dockerfile
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
# ===== Билдер =====
|
||||||
|
FROM golang:1.25rc3-alpine AS builder
|
||||||
|
|
||||||
|
# Устанавливаем зависимости для сборки
|
||||||
|
RUN apk add --no-cache git make gcc musl-dev
|
||||||
|
|
||||||
|
# Рабочая директория
|
||||||
|
WORKDIR /build
|
||||||
|
|
||||||
|
# Копируем файлы модулей
|
||||||
|
COPY go.mod go.sum ./
|
||||||
|
|
||||||
|
# Скачиваем зависимости
|
||||||
|
RUN go mod download
|
||||||
|
|
||||||
|
# Копируем весь проект
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Собираем бинарник (статически линкованный)
|
||||||
|
RUN CGO_ENABLED=0 GOOS=linux go build \
|
||||||
|
-ldflags="-w -s -extldflags '-static'" \
|
||||||
|
-o /app/server \
|
||||||
|
./server.go
|
||||||
|
|
||||||
|
# ===== Финальный образ =====
|
||||||
|
FROM alpine:3.19
|
||||||
|
|
||||||
|
# Устанавливаем tzdata для работы с временными зонами
|
||||||
|
RUN apk add --no-cache tzdata ca-certificates && \
|
||||||
|
update-ca-certificates
|
||||||
|
|
||||||
|
# Копируем бинарник
|
||||||
|
COPY --from=builder /app/server /usr/local/bin/server
|
||||||
|
|
||||||
|
# Копируем .env если нужен
|
||||||
|
# COPY --from=builder /build/.env /app/.env
|
||||||
|
|
||||||
|
# Настройки среды
|
||||||
|
ENV GIN_MODE=release \
|
||||||
|
PORT=50053
|
||||||
|
|
||||||
|
# Открываем порт
|
||||||
|
EXPOSE $PORT
|
||||||
|
|
||||||
|
# Запускаем сервер
|
||||||
|
CMD ["/usr/local/bin/server"]
|
||||||
29
go.mod
Normal file
29
go.mod
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
module tailly_subscribers
|
||||||
|
|
||||||
|
go 1.25rc3
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/jackc/pgx/v4 v4.18.3
|
||||||
|
github.com/stretchr/testify v1.10.0
|
||||||
|
google.golang.org/grpc v1.75.0
|
||||||
|
google.golang.org/protobuf v1.36.8
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
|
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
|
||||||
|
github.com/jackc/pgconn v1.14.3 // indirect
|
||||||
|
github.com/jackc/pgio v1.0.0 // indirect
|
||||||
|
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||||
|
github.com/jackc/pgproto3/v2 v2.3.3 // indirect
|
||||||
|
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
||||||
|
github.com/jackc/pgtype v1.14.4 // indirect
|
||||||
|
github.com/jackc/puddle v1.3.0 // indirect
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
|
golang.org/x/crypto v0.41.0 // indirect
|
||||||
|
golang.org/x/net v0.43.0 // indirect
|
||||||
|
golang.org/x/sys v0.35.0 // indirect
|
||||||
|
golang.org/x/text v0.28.0 // indirect
|
||||||
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20250818200422-3122310a409c // indirect
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
|
)
|
||||||
269
go.sum
Normal file
269
go.sum
Normal file
@ -0,0 +1,269 @@
|
|||||||
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
|
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
|
||||||
|
github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I=
|
||||||
|
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
|
||||||
|
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||||
|
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||||
|
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
|
||||||
|
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/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
|
||||||
|
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
||||||
|
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
|
||||||
|
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||||
|
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||||
|
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||||
|
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||||
|
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
|
||||||
|
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||||
|
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||||
|
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
||||||
|
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||||
|
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||||
|
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||||
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
|
github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0=
|
||||||
|
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
|
||||||
|
github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
|
||||||
|
github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8=
|
||||||
|
github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
|
||||||
|
github.com/jackc/pgconn v0.0.0-20190420214824-7e0022ef6ba3/go.mod h1:jkELnwuX+w9qN5YIfX0fl88Ehu4XC3keFuOJJk9pcnA=
|
||||||
|
github.com/jackc/pgconn v0.0.0-20190824142844-760dd75542eb/go.mod h1:lLjNuW/+OfW9/pnVKPazfWOgNfH2aPem8YQ7ilXGvJE=
|
||||||
|
github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsUgOEh9hBm+xYTstcNHg7UPMVJqRfQxq4s=
|
||||||
|
github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o=
|
||||||
|
github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY=
|
||||||
|
github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI=
|
||||||
|
github.com/jackc/pgconn v1.14.3 h1:bVoTr12EGANZz66nZPkMInAV/KHD2TxH9npjXXgiB3w=
|
||||||
|
github.com/jackc/pgconn v1.14.3/go.mod h1:RZbme4uasqzybK2RK5c65VsHxoyaml09lx3tXOcO/VM=
|
||||||
|
github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE=
|
||||||
|
github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8=
|
||||||
|
github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE=
|
||||||
|
github.com/jackc/pgmock v0.0.0-20201204152224-4fe30f7445fd/go.mod h1:hrBW0Enj2AZTNpt/7Y5rr2xe/9Mn757Wtb2xeBzPv2c=
|
||||||
|
github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65 h1:DadwsjnMwFjfWc9y5Wi/+Zz7xoE5ALHsRQlOctkOiHc=
|
||||||
|
github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65/go.mod h1:5R2h2EEX+qri8jOWMbJCtaPWkrrNc7OHwsp2TCqp7ak=
|
||||||
|
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
||||||
|
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
||||||
|
github.com/jackc/pgproto3 v1.1.0 h1:FYYE4yRw+AgI8wXIinMlNjBbp/UitDJwfj5LqqewP1A=
|
||||||
|
github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78=
|
||||||
|
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA=
|
||||||
|
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg=
|
||||||
|
github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM=
|
||||||
|
github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM=
|
||||||
|
github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
||||||
|
github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
||||||
|
github.com/jackc/pgproto3/v2 v2.3.3 h1:1HLSx5H+tXR9pW3in3zaztoEwQYRC9SQaYUHjTSUOag=
|
||||||
|
github.com/jackc/pgproto3/v2 v2.3.3/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
||||||
|
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E=
|
||||||
|
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
|
||||||
|
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
||||||
|
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
|
||||||
|
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
||||||
|
github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg=
|
||||||
|
github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc=
|
||||||
|
github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw=
|
||||||
|
github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM=
|
||||||
|
github.com/jackc/pgtype v1.14.0 h1:y+xUdabmyMkJLyApYuPj38mW+aAIqCe5uuBB51rH3Vw=
|
||||||
|
github.com/jackc/pgtype v1.14.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4=
|
||||||
|
github.com/jackc/pgtype v1.14.4 h1:fKuNiCumbKTAIxQwXfB/nsrnkEI6bPJrrSiMKgbJ2j8=
|
||||||
|
github.com/jackc/pgtype v1.14.4/go.mod h1:aKeozOde08iifGosdJpz9MBZonJOUJxqNpPBcMJTlVA=
|
||||||
|
github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y=
|
||||||
|
github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM=
|
||||||
|
github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc=
|
||||||
|
github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs=
|
||||||
|
github.com/jackc/pgx/v4 v4.18.2/go.mod h1:Ey4Oru5tH5sB6tV7hDmfWFahwF15Eb7DNXlRKx2CkVw=
|
||||||
|
github.com/jackc/pgx/v4 v4.18.3 h1:dE2/TrEsGX3RBprb3qryqSV9Y60iZN1C6i8IrmW9/BA=
|
||||||
|
github.com/jackc/pgx/v4 v4.18.3/go.mod h1:Ey4Oru5tH5sB6tV7hDmfWFahwF15Eb7DNXlRKx2CkVw=
|
||||||
|
github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||||
|
github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||||
|
github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||||
|
github.com/jackc/puddle v1.3.0 h1:eHK/5clGOatcjX3oWGBO/MpxpbHzSwud5EWTSCI+MX0=
|
||||||
|
github.com/jackc/puddle v1.3.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||||
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
|
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||||
|
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||||
|
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||||
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||||
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
|
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
|
||||||
|
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||||
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
|
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||||
|
github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||||
|
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||||
|
github.com/lib/pq v1.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8=
|
||||||
|
github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||||
|
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
|
||||||
|
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||||
|
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||||
|
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||||
|
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||||
|
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||||
|
github.com/pkg/errors v0.8.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/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||||
|
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
|
||||||
|
github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU=
|
||||||
|
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
|
||||||
|
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
|
||||||
|
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
|
||||||
|
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
|
||||||
|
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
||||||
|
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
|
||||||
|
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||||
|
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/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||||
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
|
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||||
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
|
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||||
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
|
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||||
|
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
|
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||||
|
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
|
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
|
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
|
||||||
|
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
|
||||||
|
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
|
||||||
|
go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ=
|
||||||
|
go.opentelemetry.io/otel v1.37.0/go.mod h1:ehE/umFRLnuLa/vSccNq9oS1ErUlkkK71gMcN34UG8I=
|
||||||
|
go.opentelemetry.io/otel/metric v1.37.0 h1:mvwbQS5m0tbmqML4NqK+e3aDiO02vsf/WgbsdpcPoZE=
|
||||||
|
go.opentelemetry.io/otel/metric v1.37.0/go.mod h1:04wGrZurHYKOc+RKeye86GwKiTb9FKm1WHtO+4EVr2E=
|
||||||
|
go.opentelemetry.io/otel/sdk v1.37.0 h1:ItB0QUqnjesGRvNcmAcU0LyvkVyGJ2xftD29bWdDvKI=
|
||||||
|
go.opentelemetry.io/otel/sdk v1.37.0/go.mod h1:VredYzxUvuo2q3WRcDnKDjbdvmO0sCzOvVAiY+yUkAg=
|
||||||
|
go.opentelemetry.io/otel/sdk/metric v1.37.0 h1:90lI228XrB9jCMuSdA0673aubgRobVZFhbjxHHspCPc=
|
||||||
|
go.opentelemetry.io/otel/sdk/metric v1.37.0/go.mod h1:cNen4ZWfiD37l5NhS+Keb5RXVWZWpRE+9WyVCpbo5ps=
|
||||||
|
go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mxVK7z4=
|
||||||
|
go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0=
|
||||||
|
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||||
|
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.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
||||||
|
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||||
|
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
|
||||||
|
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
|
||||||
|
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
|
||||||
|
go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||||
|
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||||
|
go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
|
||||||
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
|
||||||
|
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
|
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
|
golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||||
|
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
|
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
|
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||||
|
golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ=
|
||||||
|
golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM=
|
||||||
|
golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U=
|
||||||
|
golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4=
|
||||||
|
golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc=
|
||||||
|
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
|
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||||
|
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||||
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||||
|
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||||
|
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-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
|
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||||
|
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||||
|
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||||
|
golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw=
|
||||||
|
golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA=
|
||||||
|
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=
|
||||||
|
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg=
|
||||||
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/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-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
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-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
|
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
|
||||||
|
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||||
|
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
|
||||||
|
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||||
|
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||||
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
|
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||||
|
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
||||||
|
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||||
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||||
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
|
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
|
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||||
|
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
|
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
|
||||||
|
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
|
||||||
|
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
|
||||||
|
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
|
||||||
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
|
golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||||
|
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||||
|
golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/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-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||||
|
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||||
|
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||||
|
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
|
||||||
|
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
|
||||||
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20250707201910-8d1bb00bc6a7 h1:pFyd6EwwL2TqFf8emdthzeX+gZE1ElRq3iM8pui4KBY=
|
||||||
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20250707201910-8d1bb00bc6a7/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
|
||||||
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20250818200422-3122310a409c h1:qXWI/sQtv5UKboZ/zUk7h+mrf/lXORyI+n9DKDAusdg=
|
||||||
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20250818200422-3122310a409c/go.mod h1:gw1tLEfykwDz2ET4a12jcXt4couGAm7IwsVaTy0Sflo=
|
||||||
|
google.golang.org/grpc v1.75.0 h1:+TW+dqTd2Biwe6KKfhE5JpiYIBWq865PhKGSXiivqt4=
|
||||||
|
google.golang.org/grpc v1.75.0/go.mod h1:JtPAzKiq4v1xcAB2hydNlWI2RnF85XXcV0mhKXr2ecQ=
|
||||||
|
google.golang.org/protobuf v1.36.8 h1:xHScyCOEuuwZEc6UtSOvPbAT4zRh0xcNRYekJwfqyMc=
|
||||||
|
google.golang.org/protobuf v1.36.8/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||||
|
gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s=
|
||||||
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||||
1304
proto/subscribe.pb.go
Normal file
1304
proto/subscribe.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
154
proto/subscribe.proto
Normal file
154
proto/subscribe.proto
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package proto;
|
||||||
|
|
||||||
|
option go_package = ".;proto";
|
||||||
|
|
||||||
|
// Сервис для работы с подписками
|
||||||
|
service SubscribeService {
|
||||||
|
// Подписаться на пользователя
|
||||||
|
rpc FollowUser (FollowRequest) returns (FollowResponse);
|
||||||
|
|
||||||
|
// Отписаться от пользователя
|
||||||
|
rpc UnfollowUser (UnfollowRequest) returns (UnfollowResponse);
|
||||||
|
|
||||||
|
// Получить список подписчиков пользователя
|
||||||
|
rpc GetFollowers (GetFollowersRequest) returns (GetFollowersResponse);
|
||||||
|
|
||||||
|
// Получить список подписок пользователя
|
||||||
|
rpc GetFollowing (GetFollowingRequest) returns (GetFollowingResponse);
|
||||||
|
|
||||||
|
// Проверить, подписан ли пользователь на другого
|
||||||
|
rpc IsFollowing (IsFollowingRequest) returns (IsFollowingResponse);
|
||||||
|
|
||||||
|
// Получить уведомления о подписках для пользователя
|
||||||
|
rpc GetSubscriptionNotifications (GetNotificationsRequest) returns (GetNotificationsResponse);
|
||||||
|
|
||||||
|
// Пометить уведомление как прочитанное
|
||||||
|
rpc MarkNotificationAsRead (MarkNotificationReadRequest) returns (MarkNotificationReadResponse);
|
||||||
|
|
||||||
|
// Получить только КОЛИЧЕСТВО подписчиков
|
||||||
|
rpc GetFollowersCount (GetCountRequest) returns (GetCountResponse);
|
||||||
|
|
||||||
|
// Получить только КОЛИЧЕСТВО подписок
|
||||||
|
rpc GetFollowingCount (GetCountRequest) returns (GetCountResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetCountRequest {
|
||||||
|
int32 user_id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ответ с количеством
|
||||||
|
message GetCountResponse {
|
||||||
|
int32 count = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Запрос на подписку
|
||||||
|
message FollowRequest {
|
||||||
|
int32 follower_id = 1; // ID пользователя, который подписывается
|
||||||
|
int32 following_id = 2; // ID пользователя, на которого подписываются
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ответ на подписку
|
||||||
|
message FollowResponse {
|
||||||
|
bool success = 1; // Успешность операции
|
||||||
|
string message = 2; // Сообщение (например, об ошибке)
|
||||||
|
int32 subscription_id = 3; // ID созданной подписки
|
||||||
|
int32 notification_id = 4; // ID созданного уведомления
|
||||||
|
}
|
||||||
|
|
||||||
|
// Запрос на отписку
|
||||||
|
message UnfollowRequest {
|
||||||
|
int32 follower_id = 1;
|
||||||
|
int32 following_id = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ответ на отписку
|
||||||
|
message UnfollowResponse {
|
||||||
|
bool success = 1;
|
||||||
|
string message = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Запрос на получение подписчиков
|
||||||
|
message GetFollowersRequest {
|
||||||
|
int32 user_id = 1; // ID пользователя, чьих подписчиков запрашиваем
|
||||||
|
int32 limit = 2; // Лимит (для пагинации)
|
||||||
|
int32 offset = 3; // Смещение (для пагинации)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ответ с подписчиками
|
||||||
|
message GetFollowersResponse {
|
||||||
|
repeated Follower followers = 1; // Список подписчиков
|
||||||
|
int32 total_count = 2; // Общее количество подписчиков
|
||||||
|
message Follower {
|
||||||
|
int32 user_id = 1;
|
||||||
|
string username = 2;
|
||||||
|
string avatar = 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Запрос на получение подписок
|
||||||
|
message GetFollowingRequest {
|
||||||
|
int32 user_id = 1; // ID пользователя, чьи подписки запрашиваем
|
||||||
|
int32 limit = 2;
|
||||||
|
int32 offset = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ответ с подписками
|
||||||
|
message GetFollowingResponse {
|
||||||
|
repeated Following following = 1; // Список подписок
|
||||||
|
int32 total_count = 2; // Общее количество подписок
|
||||||
|
message Following {
|
||||||
|
int32 user_id = 1;
|
||||||
|
string username = 2;
|
||||||
|
string avatar = 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Запрос на проверку подписки
|
||||||
|
message IsFollowingRequest {
|
||||||
|
int32 follower_id = 1;
|
||||||
|
int32 following_id = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ответ на проверку подписки
|
||||||
|
message IsFollowingResponse {
|
||||||
|
bool is_following = 1; // true - подписан, false - не подписан
|
||||||
|
}
|
||||||
|
|
||||||
|
// Запрос на получение уведомлений
|
||||||
|
message GetNotificationsRequest {
|
||||||
|
int32 user_id = 1; // ID пользователя, чьи уведомления запрашиваем
|
||||||
|
bool unread_only = 2; // Только непрочитанные
|
||||||
|
int32 limit = 3;
|
||||||
|
int32 offset = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ответ с уведомлениями
|
||||||
|
message GetNotificationsResponse {
|
||||||
|
repeated Notification notifications = 1;
|
||||||
|
int32 total_count = 2;
|
||||||
|
int32 unread_count = 3; // Количество непрочитанных уведомлений
|
||||||
|
message Notification {
|
||||||
|
int32 id = 1;
|
||||||
|
int32 subscription_id = 2;
|
||||||
|
int32 follower_id = 3;
|
||||||
|
string follower_username = 4;
|
||||||
|
string follower_avatar = 5;
|
||||||
|
bool is_read = 6;
|
||||||
|
string created_at = 7;
|
||||||
|
string expires_at = 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Запрос на пометку уведомления как прочитанного
|
||||||
|
message MarkNotificationReadRequest {
|
||||||
|
int32 notification_id = 1;
|
||||||
|
int32 user_id = 2; // Для проверки прав
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ответ на пометку уведомления
|
||||||
|
message MarkNotificationReadResponse {
|
||||||
|
bool success = 1;
|
||||||
|
string message = 2;
|
||||||
|
}
|
||||||
447
proto/subscribe_grpc.pb.go
Normal file
447
proto/subscribe_grpc.pb.go
Normal file
@ -0,0 +1,447 @@
|
|||||||
|
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// - protoc-gen-go-grpc v1.5.1
|
||||||
|
// - protoc v3.21.12
|
||||||
|
// source: subscribe.proto
|
||||||
|
|
||||||
|
package proto
|
||||||
|
|
||||||
|
import (
|
||||||
|
context "context"
|
||||||
|
grpc "google.golang.org/grpc"
|
||||||
|
codes "google.golang.org/grpc/codes"
|
||||||
|
status "google.golang.org/grpc/status"
|
||||||
|
)
|
||||||
|
|
||||||
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
|
// is compatible with the grpc package it is being compiled against.
|
||||||
|
// Requires gRPC-Go v1.64.0 or later.
|
||||||
|
const _ = grpc.SupportPackageIsVersion9
|
||||||
|
|
||||||
|
const (
|
||||||
|
SubscribeService_FollowUser_FullMethodName = "/proto.SubscribeService/FollowUser"
|
||||||
|
SubscribeService_UnfollowUser_FullMethodName = "/proto.SubscribeService/UnfollowUser"
|
||||||
|
SubscribeService_GetFollowers_FullMethodName = "/proto.SubscribeService/GetFollowers"
|
||||||
|
SubscribeService_GetFollowing_FullMethodName = "/proto.SubscribeService/GetFollowing"
|
||||||
|
SubscribeService_IsFollowing_FullMethodName = "/proto.SubscribeService/IsFollowing"
|
||||||
|
SubscribeService_GetSubscriptionNotifications_FullMethodName = "/proto.SubscribeService/GetSubscriptionNotifications"
|
||||||
|
SubscribeService_MarkNotificationAsRead_FullMethodName = "/proto.SubscribeService/MarkNotificationAsRead"
|
||||||
|
SubscribeService_GetFollowersCount_FullMethodName = "/proto.SubscribeService/GetFollowersCount"
|
||||||
|
SubscribeService_GetFollowingCount_FullMethodName = "/proto.SubscribeService/GetFollowingCount"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SubscribeServiceClient is the client API for SubscribeService service.
|
||||||
|
//
|
||||||
|
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||||
|
//
|
||||||
|
// Сервис для работы с подписками
|
||||||
|
type SubscribeServiceClient interface {
|
||||||
|
// Подписаться на пользователя
|
||||||
|
FollowUser(ctx context.Context, in *FollowRequest, opts ...grpc.CallOption) (*FollowResponse, error)
|
||||||
|
// Отписаться от пользователя
|
||||||
|
UnfollowUser(ctx context.Context, in *UnfollowRequest, opts ...grpc.CallOption) (*UnfollowResponse, error)
|
||||||
|
// Получить список подписчиков пользователя
|
||||||
|
GetFollowers(ctx context.Context, in *GetFollowersRequest, opts ...grpc.CallOption) (*GetFollowersResponse, error)
|
||||||
|
// Получить список подписок пользователя
|
||||||
|
GetFollowing(ctx context.Context, in *GetFollowingRequest, opts ...grpc.CallOption) (*GetFollowingResponse, error)
|
||||||
|
// Проверить, подписан ли пользователь на другого
|
||||||
|
IsFollowing(ctx context.Context, in *IsFollowingRequest, opts ...grpc.CallOption) (*IsFollowingResponse, error)
|
||||||
|
// Получить уведомления о подписках для пользователя
|
||||||
|
GetSubscriptionNotifications(ctx context.Context, in *GetNotificationsRequest, opts ...grpc.CallOption) (*GetNotificationsResponse, error)
|
||||||
|
// Пометить уведомление как прочитанное
|
||||||
|
MarkNotificationAsRead(ctx context.Context, in *MarkNotificationReadRequest, opts ...grpc.CallOption) (*MarkNotificationReadResponse, error)
|
||||||
|
// Получить только КОЛИЧЕСТВО подписчиков
|
||||||
|
GetFollowersCount(ctx context.Context, in *GetCountRequest, opts ...grpc.CallOption) (*GetCountResponse, error)
|
||||||
|
// Получить только КОЛИЧЕСТВО подписок
|
||||||
|
GetFollowingCount(ctx context.Context, in *GetCountRequest, opts ...grpc.CallOption) (*GetCountResponse, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type subscribeServiceClient struct {
|
||||||
|
cc grpc.ClientConnInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSubscribeServiceClient(cc grpc.ClientConnInterface) SubscribeServiceClient {
|
||||||
|
return &subscribeServiceClient{cc}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *subscribeServiceClient) FollowUser(ctx context.Context, in *FollowRequest, opts ...grpc.CallOption) (*FollowResponse, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(FollowResponse)
|
||||||
|
err := c.cc.Invoke(ctx, SubscribeService_FollowUser_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *subscribeServiceClient) UnfollowUser(ctx context.Context, in *UnfollowRequest, opts ...grpc.CallOption) (*UnfollowResponse, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(UnfollowResponse)
|
||||||
|
err := c.cc.Invoke(ctx, SubscribeService_UnfollowUser_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *subscribeServiceClient) GetFollowers(ctx context.Context, in *GetFollowersRequest, opts ...grpc.CallOption) (*GetFollowersResponse, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(GetFollowersResponse)
|
||||||
|
err := c.cc.Invoke(ctx, SubscribeService_GetFollowers_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *subscribeServiceClient) GetFollowing(ctx context.Context, in *GetFollowingRequest, opts ...grpc.CallOption) (*GetFollowingResponse, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(GetFollowingResponse)
|
||||||
|
err := c.cc.Invoke(ctx, SubscribeService_GetFollowing_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *subscribeServiceClient) IsFollowing(ctx context.Context, in *IsFollowingRequest, opts ...grpc.CallOption) (*IsFollowingResponse, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(IsFollowingResponse)
|
||||||
|
err := c.cc.Invoke(ctx, SubscribeService_IsFollowing_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *subscribeServiceClient) GetSubscriptionNotifications(ctx context.Context, in *GetNotificationsRequest, opts ...grpc.CallOption) (*GetNotificationsResponse, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(GetNotificationsResponse)
|
||||||
|
err := c.cc.Invoke(ctx, SubscribeService_GetSubscriptionNotifications_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *subscribeServiceClient) MarkNotificationAsRead(ctx context.Context, in *MarkNotificationReadRequest, opts ...grpc.CallOption) (*MarkNotificationReadResponse, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(MarkNotificationReadResponse)
|
||||||
|
err := c.cc.Invoke(ctx, SubscribeService_MarkNotificationAsRead_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *subscribeServiceClient) GetFollowersCount(ctx context.Context, in *GetCountRequest, opts ...grpc.CallOption) (*GetCountResponse, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(GetCountResponse)
|
||||||
|
err := c.cc.Invoke(ctx, SubscribeService_GetFollowersCount_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *subscribeServiceClient) GetFollowingCount(ctx context.Context, in *GetCountRequest, opts ...grpc.CallOption) (*GetCountResponse, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(GetCountResponse)
|
||||||
|
err := c.cc.Invoke(ctx, SubscribeService_GetFollowingCount_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SubscribeServiceServer is the server API for SubscribeService service.
|
||||||
|
// All implementations must embed UnimplementedSubscribeServiceServer
|
||||||
|
// for forward compatibility.
|
||||||
|
//
|
||||||
|
// Сервис для работы с подписками
|
||||||
|
type SubscribeServiceServer interface {
|
||||||
|
// Подписаться на пользователя
|
||||||
|
FollowUser(context.Context, *FollowRequest) (*FollowResponse, error)
|
||||||
|
// Отписаться от пользователя
|
||||||
|
UnfollowUser(context.Context, *UnfollowRequest) (*UnfollowResponse, error)
|
||||||
|
// Получить список подписчиков пользователя
|
||||||
|
GetFollowers(context.Context, *GetFollowersRequest) (*GetFollowersResponse, error)
|
||||||
|
// Получить список подписок пользователя
|
||||||
|
GetFollowing(context.Context, *GetFollowingRequest) (*GetFollowingResponse, error)
|
||||||
|
// Проверить, подписан ли пользователь на другого
|
||||||
|
IsFollowing(context.Context, *IsFollowingRequest) (*IsFollowingResponse, error)
|
||||||
|
// Получить уведомления о подписках для пользователя
|
||||||
|
GetSubscriptionNotifications(context.Context, *GetNotificationsRequest) (*GetNotificationsResponse, error)
|
||||||
|
// Пометить уведомление как прочитанное
|
||||||
|
MarkNotificationAsRead(context.Context, *MarkNotificationReadRequest) (*MarkNotificationReadResponse, error)
|
||||||
|
// Получить только КОЛИЧЕСТВО подписчиков
|
||||||
|
GetFollowersCount(context.Context, *GetCountRequest) (*GetCountResponse, error)
|
||||||
|
// Получить только КОЛИЧЕСТВО подписок
|
||||||
|
GetFollowingCount(context.Context, *GetCountRequest) (*GetCountResponse, error)
|
||||||
|
mustEmbedUnimplementedSubscribeServiceServer()
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnimplementedSubscribeServiceServer must be embedded to have
|
||||||
|
// forward compatible implementations.
|
||||||
|
//
|
||||||
|
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||||
|
// pointer dereference when methods are called.
|
||||||
|
type UnimplementedSubscribeServiceServer struct{}
|
||||||
|
|
||||||
|
func (UnimplementedSubscribeServiceServer) FollowUser(context.Context, *FollowRequest) (*FollowResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method FollowUser not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedSubscribeServiceServer) UnfollowUser(context.Context, *UnfollowRequest) (*UnfollowResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method UnfollowUser not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedSubscribeServiceServer) GetFollowers(context.Context, *GetFollowersRequest) (*GetFollowersResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method GetFollowers not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedSubscribeServiceServer) GetFollowing(context.Context, *GetFollowingRequest) (*GetFollowingResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method GetFollowing not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedSubscribeServiceServer) IsFollowing(context.Context, *IsFollowingRequest) (*IsFollowingResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method IsFollowing not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedSubscribeServiceServer) GetSubscriptionNotifications(context.Context, *GetNotificationsRequest) (*GetNotificationsResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method GetSubscriptionNotifications not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedSubscribeServiceServer) MarkNotificationAsRead(context.Context, *MarkNotificationReadRequest) (*MarkNotificationReadResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method MarkNotificationAsRead not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedSubscribeServiceServer) GetFollowersCount(context.Context, *GetCountRequest) (*GetCountResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method GetFollowersCount not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedSubscribeServiceServer) GetFollowingCount(context.Context, *GetCountRequest) (*GetCountResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method GetFollowingCount not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedSubscribeServiceServer) mustEmbedUnimplementedSubscribeServiceServer() {}
|
||||||
|
func (UnimplementedSubscribeServiceServer) testEmbeddedByValue() {}
|
||||||
|
|
||||||
|
// UnsafeSubscribeServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||||
|
// Use of this interface is not recommended, as added methods to SubscribeServiceServer will
|
||||||
|
// result in compilation errors.
|
||||||
|
type UnsafeSubscribeServiceServer interface {
|
||||||
|
mustEmbedUnimplementedSubscribeServiceServer()
|
||||||
|
}
|
||||||
|
|
||||||
|
func RegisterSubscribeServiceServer(s grpc.ServiceRegistrar, srv SubscribeServiceServer) {
|
||||||
|
// If the following call pancis, it indicates UnimplementedSubscribeServiceServer was
|
||||||
|
// embedded by pointer and is nil. This will cause panics if an
|
||||||
|
// unimplemented method is ever invoked, so we test this at initialization
|
||||||
|
// time to prevent it from happening at runtime later due to I/O.
|
||||||
|
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||||
|
t.testEmbeddedByValue()
|
||||||
|
}
|
||||||
|
s.RegisterService(&SubscribeService_ServiceDesc, srv)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _SubscribeService_FollowUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(FollowRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(SubscribeServiceServer).FollowUser(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: SubscribeService_FollowUser_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(SubscribeServiceServer).FollowUser(ctx, req.(*FollowRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _SubscribeService_UnfollowUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(UnfollowRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(SubscribeServiceServer).UnfollowUser(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: SubscribeService_UnfollowUser_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(SubscribeServiceServer).UnfollowUser(ctx, req.(*UnfollowRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _SubscribeService_GetFollowers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(GetFollowersRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(SubscribeServiceServer).GetFollowers(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: SubscribeService_GetFollowers_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(SubscribeServiceServer).GetFollowers(ctx, req.(*GetFollowersRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _SubscribeService_GetFollowing_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(GetFollowingRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(SubscribeServiceServer).GetFollowing(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: SubscribeService_GetFollowing_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(SubscribeServiceServer).GetFollowing(ctx, req.(*GetFollowingRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _SubscribeService_IsFollowing_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(IsFollowingRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(SubscribeServiceServer).IsFollowing(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: SubscribeService_IsFollowing_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(SubscribeServiceServer).IsFollowing(ctx, req.(*IsFollowingRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _SubscribeService_GetSubscriptionNotifications_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(GetNotificationsRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(SubscribeServiceServer).GetSubscriptionNotifications(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: SubscribeService_GetSubscriptionNotifications_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(SubscribeServiceServer).GetSubscriptionNotifications(ctx, req.(*GetNotificationsRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _SubscribeService_MarkNotificationAsRead_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(MarkNotificationReadRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(SubscribeServiceServer).MarkNotificationAsRead(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: SubscribeService_MarkNotificationAsRead_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(SubscribeServiceServer).MarkNotificationAsRead(ctx, req.(*MarkNotificationReadRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _SubscribeService_GetFollowersCount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(GetCountRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(SubscribeServiceServer).GetFollowersCount(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: SubscribeService_GetFollowersCount_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(SubscribeServiceServer).GetFollowersCount(ctx, req.(*GetCountRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _SubscribeService_GetFollowingCount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(GetCountRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(SubscribeServiceServer).GetFollowingCount(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: SubscribeService_GetFollowingCount_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(SubscribeServiceServer).GetFollowingCount(ctx, req.(*GetCountRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SubscribeService_ServiceDesc is the grpc.ServiceDesc for SubscribeService service.
|
||||||
|
// It's only intended for direct use with grpc.RegisterService,
|
||||||
|
// and not to be introspected or modified (even as a copy)
|
||||||
|
var SubscribeService_ServiceDesc = grpc.ServiceDesc{
|
||||||
|
ServiceName: "proto.SubscribeService",
|
||||||
|
HandlerType: (*SubscribeServiceServer)(nil),
|
||||||
|
Methods: []grpc.MethodDesc{
|
||||||
|
{
|
||||||
|
MethodName: "FollowUser",
|
||||||
|
Handler: _SubscribeService_FollowUser_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "UnfollowUser",
|
||||||
|
Handler: _SubscribeService_UnfollowUser_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "GetFollowers",
|
||||||
|
Handler: _SubscribeService_GetFollowers_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "GetFollowing",
|
||||||
|
Handler: _SubscribeService_GetFollowing_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "IsFollowing",
|
||||||
|
Handler: _SubscribeService_IsFollowing_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "GetSubscriptionNotifications",
|
||||||
|
Handler: _SubscribeService_GetSubscriptionNotifications_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "MarkNotificationAsRead",
|
||||||
|
Handler: _SubscribeService_MarkNotificationAsRead_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "GetFollowersCount",
|
||||||
|
Handler: _SubscribeService_GetFollowersCount_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "GetFollowingCount",
|
||||||
|
Handler: _SubscribeService_GetFollowingCount_Handler,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Streams: []grpc.StreamDesc{},
|
||||||
|
Metadata: "subscribe.proto",
|
||||||
|
}
|
||||||
413
server.go
Normal file
413
server.go
Normal file
@ -0,0 +1,413 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/jackc/pgx/v4"
|
||||||
|
"github.com/jackc/pgx/v4/pgxpool"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
"google.golang.org/grpc/codes"
|
||||||
|
"google.golang.org/grpc/keepalive"
|
||||||
|
"google.golang.org/grpc/status"
|
||||||
|
"log"
|
||||||
|
"net"
|
||||||
|
"os"
|
||||||
|
"tailly_subscribers/proto"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type server struct {
|
||||||
|
proto.UnimplementedSubscribeServiceServer
|
||||||
|
db *pgxpool.Pool
|
||||||
|
logger *log.Logger
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewServer(db *pgxpool.Pool) *server {
|
||||||
|
return &server{
|
||||||
|
db: db,
|
||||||
|
logger: log.New(os.Stdout, "SUBSCRIBE_SERVICE: ", log.LstdFlags|log.Lmicroseconds|log.Lshortfile),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *server) FollowUser(ctx context.Context, req *proto.FollowRequest) (*proto.FollowResponse, error) {
|
||||||
|
follower, following := req.FollowerId, req.FollowingId
|
||||||
|
if follower == following {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "cannot follow yourself")
|
||||||
|
}
|
||||||
|
|
||||||
|
// ИСПРАВЛЕНИЕ: Используем QueryRow чтобы получить количество вставленных строк
|
||||||
|
var subscriptionID int32
|
||||||
|
err := s.db.QueryRow(ctx, `
|
||||||
|
INSERT INTO subscriptions (follower_id, following_id)
|
||||||
|
VALUES ($1, $2)
|
||||||
|
ON CONFLICT (follower_id, following_id) DO NOTHING
|
||||||
|
RETURNING id`,
|
||||||
|
follower, following).Scan(&subscriptionID)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
if err == pgx.ErrNoRows {
|
||||||
|
// Конфликт - подписка уже существует
|
||||||
|
return &proto.FollowResponse{
|
||||||
|
Success: false,
|
||||||
|
Message: "Already following this user",
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
return nil, status.Errorf(codes.Internal, "failed to follow: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &proto.FollowResponse{
|
||||||
|
Success: true,
|
||||||
|
Message: "Successfully followed user",
|
||||||
|
SubscriptionId: subscriptionID,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *server) UnfollowUser(ctx context.Context, req *proto.UnfollowRequest) (*proto.UnfollowResponse, error) {
|
||||||
|
follower, following := req.FollowerId, req.FollowingId
|
||||||
|
if follower == 0 || following == 0 {
|
||||||
|
return nil, status.Errorf(codes.InvalidArgument, "Переданы пустые id follower или following, %d, %d", follower, following)
|
||||||
|
}
|
||||||
|
|
||||||
|
var userExists bool
|
||||||
|
err := s.db.QueryRow(ctx, `
|
||||||
|
SELECT EXISTS(SELECT 1 FROM users WHERE id IN ($1, $2))`,
|
||||||
|
follower, following).Scan(&userExists)
|
||||||
|
|
||||||
|
if !userExists {
|
||||||
|
return nil, status.Errorf(codes.NotFound, "one or both users not found, %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := s.db.Exec(ctx, `
|
||||||
|
DELETE FROM subscriptions
|
||||||
|
WHERE follower_id = $1 AND following_id = $2`,
|
||||||
|
follower, following)
|
||||||
|
|
||||||
|
if result.RowsAffected() == 0 {
|
||||||
|
return &proto.UnfollowResponse{
|
||||||
|
Success: false,
|
||||||
|
Message: "Subscription not found",
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return &proto.UnfollowResponse{
|
||||||
|
Success: true,
|
||||||
|
Message: "Successfully unfollowed user",
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *server) GetFollowers(ctx context.Context, req *proto.GetFollowersRequest) (*proto.GetFollowersResponse, error) {
|
||||||
|
if req.UserId == 0 {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "user_id is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Получаем общее количество подписчиков
|
||||||
|
var totalCount int32
|
||||||
|
err := s.db.QueryRow(ctx, `
|
||||||
|
SELECT COUNT(*) FROM subscriptions WHERE following_id = $1`,
|
||||||
|
req.UserId).Scan(&totalCount)
|
||||||
|
if err != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "failed to get followers count: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Получаем список подписчиков с пагинацией
|
||||||
|
rows, err := s.db.Query(ctx, `
|
||||||
|
SELECT u.id, u.username, u.avatar
|
||||||
|
FROM subscriptions s
|
||||||
|
JOIN users u ON s.follower_id = u.id
|
||||||
|
WHERE s.following_id = $1
|
||||||
|
ORDER BY s.created_at DESC
|
||||||
|
LIMIT $2 OFFSET $3`,
|
||||||
|
req.UserId, req.Limit, req.Offset)
|
||||||
|
if err != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "failed to get followers: %v", err)
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
|
||||||
|
var followers []*proto.GetFollowersResponse_Follower
|
||||||
|
for rows.Next() {
|
||||||
|
var follower proto.GetFollowersResponse_Follower
|
||||||
|
if err := rows.Scan(&follower.UserId, &follower.Username, &follower.Avatar); err != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "failed to scan follower: %v", err)
|
||||||
|
}
|
||||||
|
followers = append(followers, &follower)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "rows error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &proto.GetFollowersResponse{
|
||||||
|
Followers: followers,
|
||||||
|
TotalCount: totalCount,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *server) GetFollowing(ctx context.Context, req *proto.GetFollowingRequest) (*proto.GetFollowingResponse, error) {
|
||||||
|
if req.UserId == 0 {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "user_id is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Получаем общее количество подписок
|
||||||
|
var totalCount int32
|
||||||
|
err := s.db.QueryRow(ctx, `
|
||||||
|
SELECT COUNT(*) FROM subscriptions WHERE follower_id = $1`,
|
||||||
|
req.UserId).Scan(&totalCount)
|
||||||
|
if err != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "failed to get following count: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Получаем список подписок с пагинацией
|
||||||
|
rows, err := s.db.Query(ctx, `
|
||||||
|
SELECT u.id, u.username, u.avatar
|
||||||
|
FROM subscriptions s
|
||||||
|
JOIN users u ON s.following_id = u.id
|
||||||
|
WHERE s.follower_id = $1
|
||||||
|
ORDER BY s.created_at DESC
|
||||||
|
LIMIT $2 OFFSET $3`,
|
||||||
|
req.UserId, req.Limit, req.Offset)
|
||||||
|
if err != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "failed to get following: %v", err)
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
|
||||||
|
var following []*proto.GetFollowingResponse_Following
|
||||||
|
for rows.Next() {
|
||||||
|
var follow proto.GetFollowingResponse_Following
|
||||||
|
if err := rows.Scan(&follow.UserId, &follow.Username, &follow.Avatar); err != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "failed to scan following: %v", err)
|
||||||
|
}
|
||||||
|
following = append(following, &follow)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "rows error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &proto.GetFollowingResponse{
|
||||||
|
Following: following,
|
||||||
|
TotalCount: totalCount,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *server) IsFollowing(ctx context.Context, req *proto.IsFollowingRequest) (*proto.IsFollowingResponse, error) {
|
||||||
|
if req.FollowerId == 0 || req.FollowingId == 0 {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "follower_id and following_id are required")
|
||||||
|
}
|
||||||
|
|
||||||
|
var isFollowing bool
|
||||||
|
err := s.db.QueryRow(ctx, `
|
||||||
|
SELECT EXISTS(
|
||||||
|
SELECT 1 FROM subscriptions
|
||||||
|
WHERE follower_id = $1 AND following_id = $2
|
||||||
|
)`,
|
||||||
|
req.FollowerId, req.FollowingId).Scan(&isFollowing)
|
||||||
|
if err != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "failed to check subscription: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &proto.IsFollowingResponse{IsFollowing: isFollowing}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *server) GetFollowersCount(ctx context.Context, req *proto.GetCountRequest) (*proto.GetCountResponse, error) {
|
||||||
|
if req.UserId == 0 {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "user_id is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
var count int32
|
||||||
|
err := s.db.QueryRow(ctx, `
|
||||||
|
SELECT COUNT(*) FROM subscriptions WHERE following_id = $1`,
|
||||||
|
req.UserId).Scan(&count)
|
||||||
|
if err != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "failed to get followers count: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &proto.GetCountResponse{Count: count}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *server) GetFollowingCount(ctx context.Context, req *proto.GetCountRequest) (*proto.GetCountResponse, error) {
|
||||||
|
if req.UserId == 0 {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "user_id is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
var count int32
|
||||||
|
err := s.db.QueryRow(ctx, `
|
||||||
|
SELECT COUNT(*) FROM subscriptions WHERE follower_id = $1`,
|
||||||
|
req.UserId).Scan(&count)
|
||||||
|
if err != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "failed to get following count: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &proto.GetCountResponse{Count: count}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *server) GetSubscriptionNotifications(ctx context.Context, req *proto.GetNotificationsRequest) (*proto.GetNotificationsResponse, error) {
|
||||||
|
if req.UserId == 0 {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "user_id is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Получаем общее количество уведомлений
|
||||||
|
var totalCount, unreadCount int32
|
||||||
|
err := s.db.QueryRow(ctx, `
|
||||||
|
SELECT
|
||||||
|
COUNT(*),
|
||||||
|
COUNT(*) FILTER (WHERE NOT is_read)
|
||||||
|
FROM subscription_notifications sn
|
||||||
|
JOIN subscriptions s ON sn.subscription_id = s.id
|
||||||
|
WHERE s.following_id = $1`,
|
||||||
|
req.UserId).Scan(&totalCount, &unreadCount)
|
||||||
|
if err != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "failed to get notifications count: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Базовый запрос
|
||||||
|
query := `
|
||||||
|
SELECT
|
||||||
|
sn.id, sn.subscription_id, s.follower_id,
|
||||||
|
u.username, u.avatar, sn.is_read,
|
||||||
|
sn.created_at, sn.created_at + INTERVAL '7 days' as expires_at
|
||||||
|
FROM subscription_notifications sn
|
||||||
|
JOIN subscriptions s ON sn.subscription_id = s.id
|
||||||
|
JOIN users u ON s.follower_id = u.id
|
||||||
|
WHERE s.following_id = $1`
|
||||||
|
|
||||||
|
// Добавляем условие для непрочитанных
|
||||||
|
if req.UnreadOnly {
|
||||||
|
query += " AND NOT sn.is_read"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Добавляем пагинацию
|
||||||
|
query += " ORDER BY sn.created_at DESC LIMIT $2 OFFSET $3"
|
||||||
|
|
||||||
|
rows, err := s.db.Query(ctx, query, req.UserId, req.Limit, req.Offset)
|
||||||
|
if err != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "failed to get notifications: %v", err)
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
|
||||||
|
var notifications []*proto.GetNotificationsResponse_Notification
|
||||||
|
for rows.Next() {
|
||||||
|
var notif proto.GetNotificationsResponse_Notification
|
||||||
|
var createdAt, expiresAt time.Time
|
||||||
|
if err := rows.Scan(
|
||||||
|
¬if.Id, ¬if.SubscriptionId, ¬if.FollowerId,
|
||||||
|
¬if.FollowerUsername, ¬if.FollowerAvatar, ¬if.IsRead,
|
||||||
|
&createdAt, &expiresAt,
|
||||||
|
); err != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "failed to scan notification: %v", err)
|
||||||
|
}
|
||||||
|
notif.CreatedAt = createdAt.Format(time.RFC3339)
|
||||||
|
notif.ExpiresAt = expiresAt.Format(time.RFC3339)
|
||||||
|
notifications = append(notifications, ¬if)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "rows error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &proto.GetNotificationsResponse{
|
||||||
|
Notifications: notifications,
|
||||||
|
TotalCount: totalCount,
|
||||||
|
UnreadCount: unreadCount,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *server) MarkNotificationAsRead(ctx context.Context, req *proto.MarkNotificationReadRequest) (*proto.MarkNotificationReadResponse, error) {
|
||||||
|
if req.NotificationId == 0 || req.UserId == 0 {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "notification_id and user_id are required")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Проверяем, что уведомление принадлежит пользователю
|
||||||
|
var belongsToUser bool
|
||||||
|
err := s.db.QueryRow(ctx, `
|
||||||
|
SELECT EXISTS(
|
||||||
|
SELECT 1 FROM subscription_notifications sn
|
||||||
|
JOIN subscriptions s ON sn.subscription_id = s.id
|
||||||
|
WHERE sn.id = $1 AND s.following_id = $2
|
||||||
|
)`,
|
||||||
|
req.NotificationId, req.UserId).Scan(&belongsToUser)
|
||||||
|
if err != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "failed to check notification ownership: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !belongsToUser {
|
||||||
|
return nil, status.Error(codes.PermissionDenied, "notification does not belong to user")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Помечаем как прочитанное
|
||||||
|
result, err := s.db.Exec(ctx, `
|
||||||
|
UPDATE subscription_notifications
|
||||||
|
SET is_read = true
|
||||||
|
WHERE id = $1`,
|
||||||
|
req.NotificationId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "failed to mark notification as read: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if result.RowsAffected() == 0 {
|
||||||
|
return &proto.MarkNotificationReadResponse{
|
||||||
|
Success: false,
|
||||||
|
Message: "Notification not found or already read",
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return &proto.MarkNotificationReadResponse{
|
||||||
|
Success: true,
|
||||||
|
Message: "Notification marked as read",
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
logger := log.New(os.Stdout, "MAIN: ", log.LstdFlags|log.Lmicroseconds|log.Lshortfile)
|
||||||
|
logger.Println("Starting subscribe service")
|
||||||
|
|
||||||
|
// Инициализация подключения к БД
|
||||||
|
dbURL := "postgres://tailly_v2:i0Oq%2675LA%26M612ceuy@79.174.89.104:15452/tailly_v2"
|
||||||
|
logger.Printf("Connecting to database at %s", dbURL)
|
||||||
|
pool, err := pgxpool.Connect(context.Background(), dbURL)
|
||||||
|
if err != nil {
|
||||||
|
logger.Fatalf("Unable to connect to database: %v", err)
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
logger.Println("Closing database connection")
|
||||||
|
pool.Close()
|
||||||
|
}()
|
||||||
|
// Создаем gRPC сервер
|
||||||
|
grpcServer := grpc.NewServer(
|
||||||
|
grpc.KeepaliveParams(keepalive.ServerParameters{
|
||||||
|
MaxConnectionAge: 24 * time.Hour,
|
||||||
|
MaxConnectionAgeGrace: 5 * time.Minute,
|
||||||
|
Time: 30 * time.Second,
|
||||||
|
Timeout: 10 * time.Second,
|
||||||
|
}),
|
||||||
|
grpc.UnaryInterceptor(func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
|
||||||
|
logger.Printf("Unary call: %s, request: %+v", info.FullMethod, req)
|
||||||
|
start := time.Now()
|
||||||
|
defer func() {
|
||||||
|
logger.Printf("Unary call %s completed in %v, response: %+v, error: %v",
|
||||||
|
info.FullMethod, time.Since(start), resp, err)
|
||||||
|
}()
|
||||||
|
return handler(ctx, req)
|
||||||
|
}),
|
||||||
|
grpc.StreamInterceptor(func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
|
||||||
|
logger.Printf("Stream call: %s", info.FullMethod)
|
||||||
|
start := time.Now()
|
||||||
|
defer func() {
|
||||||
|
logger.Printf("Stream call %s completed in %v", info.FullMethod, time.Since(start))
|
||||||
|
}()
|
||||||
|
return handler(srv, ss)
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
proto.RegisterSubscribeServiceServer(grpcServer, NewServer(pool))
|
||||||
|
|
||||||
|
// Запускаем сервер
|
||||||
|
port := ":50053"
|
||||||
|
logger.Printf("Starting gRPC server on port %s", port)
|
||||||
|
lis, err := net.Listen("tcp", port)
|
||||||
|
if err != nil {
|
||||||
|
logger.Fatalf("failed to listen: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Println("Server is ready to accept connections")
|
||||||
|
if err := grpcServer.Serve(lis); err != nil {
|
||||||
|
logger.Fatalf("failed to serve: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
408
server_test.go
Normal file
408
server_test.go
Normal file
@ -0,0 +1,408 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/jackc/pgx/v4/pgxpool"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"google.golang.org/grpc/codes"
|
||||||
|
"google.golang.org/grpc/status"
|
||||||
|
"tailly_subscribers/proto"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func setupTestDB(t *testing.T) *pgxpool.Pool {
|
||||||
|
dbURL := "postgres://tailly_v2:i0Oq%2675LA%26M612ceuy@79.174.89.104:15452/tailly_v2"
|
||||||
|
pool, err := pgxpool.Connect(context.Background(), dbURL)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to connect to database: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ОЧИСТКА ТЕСТОВЫХ ДАННЫХ ПЕРЕД ТЕСТАМИ
|
||||||
|
_, err = pool.Exec(context.Background(), "DELETE FROM subscription_notifications")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to clean notifications: %v", err)
|
||||||
|
}
|
||||||
|
_, err = pool.Exec(context.Background(), "DELETE FROM subscriptions")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to clean subscriptions: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return pool
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFollowUser(t *testing.T) {
|
||||||
|
db := setupTestDB(t)
|
||||||
|
server := NewServer(db)
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
req *proto.FollowRequest
|
||||||
|
expectError bool
|
||||||
|
errorCode codes.Code
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "Success - user 1 follows user 2",
|
||||||
|
req: &proto.FollowRequest{FollowerId: 1, FollowingId: 2},
|
||||||
|
expectError: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Success - user 2 follows user 3",
|
||||||
|
req: &proto.FollowRequest{FollowerId: 2, FollowingId: 3},
|
||||||
|
expectError: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Error - self follow",
|
||||||
|
req: &proto.FollowRequest{FollowerId: 1, FollowingId: 1},
|
||||||
|
expectError: true,
|
||||||
|
errorCode: codes.InvalidArgument,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Error - non-existent user", // ИЗМЕНИЛОСЬ: теперь Internal error из-за foreign key
|
||||||
|
req: &proto.FollowRequest{FollowerId: 1, FollowingId: 999},
|
||||||
|
expectError: true,
|
||||||
|
errorCode: codes.Internal, // Foreign key violation
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Error - zero IDs",
|
||||||
|
req: &proto.FollowRequest{FollowerId: 0, FollowingId: 0},
|
||||||
|
expectError: true,
|
||||||
|
errorCode: codes.InvalidArgument,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
ctx := context.Background()
|
||||||
|
resp, err := server.FollowUser(ctx, tt.req)
|
||||||
|
|
||||||
|
if tt.expectError {
|
||||||
|
assert.Error(t, err)
|
||||||
|
if st, ok := status.FromError(err); ok {
|
||||||
|
assert.Equal(t, tt.errorCode, st.Code())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.True(t, resp.Success)
|
||||||
|
assert.Contains(t, resp.Message, "Successfully")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUnfollowUser(t *testing.T) {
|
||||||
|
db := setupTestDB(t)
|
||||||
|
server := NewServer(db)
|
||||||
|
|
||||||
|
// Сначала создаем подписки для тестов
|
||||||
|
server.FollowUser(context.Background(), &proto.FollowRequest{FollowerId: 1, FollowingId: 2})
|
||||||
|
server.FollowUser(context.Background(), &proto.FollowRequest{FollowerId: 1, FollowingId: 3})
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
req *proto.UnfollowRequest
|
||||||
|
expectError bool
|
||||||
|
errorCode codes.Code
|
||||||
|
success bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "Success - user 1 unfollows user 2",
|
||||||
|
req: &proto.UnfollowRequest{FollowerId: 1, FollowingId: 2},
|
||||||
|
expectError: false,
|
||||||
|
success: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Success - user 1 unfollows user 3",
|
||||||
|
req: &proto.UnfollowRequest{FollowerId: 1, FollowingId: 3},
|
||||||
|
expectError: false,
|
||||||
|
success: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Success - non-existent subscription", // ИЗМЕНИЛОСЬ: не ошибка
|
||||||
|
req: &proto.UnfollowRequest{FollowerId: 1, FollowingId: 999},
|
||||||
|
expectError: false,
|
||||||
|
success: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Error - non-existent user", // ИЗМЕНИЛОСЬ: не ошибка, просто false
|
||||||
|
req: &proto.UnfollowRequest{FollowerId: 999, FollowingId: 1},
|
||||||
|
expectError: false,
|
||||||
|
success: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Error - zero IDs",
|
||||||
|
req: &proto.UnfollowRequest{FollowerId: 0, FollowingId: 0},
|
||||||
|
expectError: true,
|
||||||
|
errorCode: codes.InvalidArgument,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
ctx := context.Background()
|
||||||
|
resp, err := server.UnfollowUser(ctx, tt.req)
|
||||||
|
|
||||||
|
if tt.expectError {
|
||||||
|
assert.Error(t, err)
|
||||||
|
if st, ok := status.FromError(err); ok {
|
||||||
|
assert.Equal(t, tt.errorCode, st.Code())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, tt.success, resp.Success)
|
||||||
|
if tt.success {
|
||||||
|
assert.Contains(t, resp.Message, "Successfully")
|
||||||
|
} else {
|
||||||
|
assert.Contains(t, resp.Message, "not found")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetFollowersCount(t *testing.T) {
|
||||||
|
db := setupTestDB(t)
|
||||||
|
server := NewServer(db)
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
req *proto.GetCountRequest
|
||||||
|
expected int32
|
||||||
|
expectError bool
|
||||||
|
errorCode codes.Code
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "Success - user 2 has 0 followers initially",
|
||||||
|
req: &proto.GetCountRequest{UserId: 2},
|
||||||
|
expected: 0,
|
||||||
|
expectError: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Success - user 1 has 0 followers",
|
||||||
|
req: &proto.GetCountRequest{UserId: 1},
|
||||||
|
expected: 0,
|
||||||
|
expectError: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Success - user 3 has 0 followers",
|
||||||
|
req: &proto.GetCountRequest{UserId: 3},
|
||||||
|
expected: 0,
|
||||||
|
expectError: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Success - non-existent user returns 0",
|
||||||
|
req: &proto.GetCountRequest{UserId: 999},
|
||||||
|
expected: 0,
|
||||||
|
expectError: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Error - zero user ID",
|
||||||
|
req: &proto.GetCountRequest{UserId: 0},
|
||||||
|
expectError: true,
|
||||||
|
errorCode: codes.InvalidArgument,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
ctx := context.Background()
|
||||||
|
resp, err := server.GetFollowersCount(ctx, tt.req)
|
||||||
|
|
||||||
|
if tt.expectError {
|
||||||
|
assert.Error(t, err)
|
||||||
|
if st, ok := status.FromError(err); ok {
|
||||||
|
assert.Equal(t, tt.errorCode, st.Code())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, tt.expected, resp.Count)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetFollowingCount(t *testing.T) {
|
||||||
|
db := setupTestDB(t)
|
||||||
|
server := NewServer(db)
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
req *proto.GetCountRequest
|
||||||
|
expected int32
|
||||||
|
expectError bool
|
||||||
|
errorCode codes.Code
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "Success - user 2 follows 0 users initially",
|
||||||
|
req: &proto.GetCountRequest{UserId: 2},
|
||||||
|
expected: 0,
|
||||||
|
expectError: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Success - user 1 follows 0 users",
|
||||||
|
req: &proto.GetCountRequest{UserId: 1},
|
||||||
|
expected: 0,
|
||||||
|
expectError: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Success - user 3 follows 0 users",
|
||||||
|
req: &proto.GetCountRequest{UserId: 3},
|
||||||
|
expected: 0,
|
||||||
|
expectError: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Success - non-existent user returns 0",
|
||||||
|
req: &proto.GetCountRequest{UserId: 999},
|
||||||
|
expected: 0,
|
||||||
|
expectError: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Error - zero user ID",
|
||||||
|
req: &proto.GetCountRequest{UserId: 0},
|
||||||
|
expectError: true,
|
||||||
|
errorCode: codes.InvalidArgument,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
ctx := context.Background()
|
||||||
|
resp, err := server.GetFollowingCount(ctx, tt.req)
|
||||||
|
|
||||||
|
if tt.expectError {
|
||||||
|
assert.Error(t, err)
|
||||||
|
if st, ok := status.FromError(err); ok {
|
||||||
|
assert.Equal(t, tt.errorCode, st.Code())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, tt.expected, resp.Count)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetFollowers(t *testing.T) {
|
||||||
|
db := setupTestDB(t)
|
||||||
|
server := NewServer(db)
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
req *proto.GetFollowersRequest
|
||||||
|
expectedCount int
|
||||||
|
expectError bool
|
||||||
|
errorCode codes.Code
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "Success - user 2 has 0 followers initially",
|
||||||
|
req: &proto.GetFollowersRequest{UserId: 2, Limit: 10, Offset: 0},
|
||||||
|
expectedCount: 0,
|
||||||
|
expectError: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Success - user 1 has 0 followers",
|
||||||
|
req: &proto.GetFollowersRequest{UserId: 1, Limit: 10, Offset: 0},
|
||||||
|
expectedCount: 0,
|
||||||
|
expectError: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Success - get with limit 0",
|
||||||
|
req: &proto.GetFollowersRequest{UserId: 2, Limit: 0, Offset: 0},
|
||||||
|
expectedCount: 0,
|
||||||
|
expectError: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Success - non-existent user returns empty list",
|
||||||
|
req: &proto.GetFollowersRequest{UserId: 999, Limit: 10, Offset: 0},
|
||||||
|
expectError: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Error - zero user ID",
|
||||||
|
req: &proto.GetFollowersRequest{UserId: 0, Limit: 10, Offset: 0},
|
||||||
|
expectError: true,
|
||||||
|
errorCode: codes.InvalidArgument,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
ctx := context.Background()
|
||||||
|
resp, err := server.GetFollowers(ctx, tt.req)
|
||||||
|
|
||||||
|
if tt.expectError {
|
||||||
|
assert.Error(t, err)
|
||||||
|
if st, ok := status.FromError(err); ok {
|
||||||
|
assert.Equal(t, tt.errorCode, st.Code())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
assert.NoError(t, err)
|
||||||
|
if tt.expectedCount >= 0 {
|
||||||
|
assert.Len(t, resp.Followers, tt.expectedCount)
|
||||||
|
}
|
||||||
|
assert.NotNil(t, resp.TotalCount)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetFollowing(t *testing.T) {
|
||||||
|
db := setupTestDB(t)
|
||||||
|
server := NewServer(db)
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
req *proto.GetFollowingRequest
|
||||||
|
expectedCount int
|
||||||
|
expectError bool
|
||||||
|
errorCode codes.Code
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "Success - user 2 follows 0 users initially",
|
||||||
|
req: &proto.GetFollowingRequest{UserId: 2, Limit: 10, Offset: 0},
|
||||||
|
expectedCount: 0,
|
||||||
|
expectError: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Success - user 1 follows 0 users",
|
||||||
|
req: &proto.GetFollowingRequest{UserId: 1, Limit: 10, Offset: 0},
|
||||||
|
expectedCount: 0,
|
||||||
|
expectError: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Success - get with limit 0",
|
||||||
|
req: &proto.GetFollowingRequest{UserId: 2, Limit: 0, Offset: 0},
|
||||||
|
expectedCount: 0,
|
||||||
|
expectError: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Success - non-existent user returns empty list",
|
||||||
|
req: &proto.GetFollowingRequest{UserId: 999, Limit: 10, Offset: 0},
|
||||||
|
expectError: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Error - zero user ID",
|
||||||
|
req: &proto.GetFollowingRequest{UserId: 0, Limit: 10, Offset: 0},
|
||||||
|
expectError: true,
|
||||||
|
errorCode: codes.InvalidArgument,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
ctx := context.Background()
|
||||||
|
resp, err := server.GetFollowing(ctx, tt.req)
|
||||||
|
|
||||||
|
if tt.expectError {
|
||||||
|
assert.Error(t, err)
|
||||||
|
if st, ok := status.FromError(err); ok {
|
||||||
|
assert.Equal(t, tt.errorCode, st.Code())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
assert.NoError(t, err)
|
||||||
|
if tt.expectedCount >= 0 {
|
||||||
|
assert.Len(t, resp.Following, tt.expectedCount)
|
||||||
|
}
|
||||||
|
assert.NotNil(t, resp.TotalCount)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user