staging #11

Merged
skeris merged 11 commits from staging into main 2025-07-25 15:55:39 +00:00
26 changed files with 312 additions and 207 deletions

25
.env

@ -1,25 +1,16 @@
# MongoDB settings
MONGO_HOST="127.0.0.1"
MONGO_PORT="27020"
MONGO_USER="test"
MONGO_PASSWORD="test"
MONGO_DB="admin"
MONGO_AUTH="admin"
MONGO_URL = "mongodb://test:test@localhost:27020/"
MONGO_DB_NAME = "admin"
# Kafka settings
KAFKA_BROKERS="localhost:9092"
KAFKA_TOPIC="test-topic"
KAFKA_GROUP="mailnotifier"
KAFKA_TOPIC_MAIL_NOTIFIER="test-topic"
# SMTP settings
SMTP_API_URL="https://api.smtp.bz/v1/smtp/send"
SMTP_HOST="connect.mailclient.bz"
SMTP_PORT="587"
SMTP_UNAME="kotilion.95@gmail.com"
SMTP_PASS="vWwbCSg4bf0p"
SMTP_API_KEY="P0YsjUB137upXrr1NiJefHmXVKW1hmBWlpev"
SMTP_SENDER="noreply@mailing.pena.digital"
API_URL="https://api.smtp.bz/v1/smtp/send"
MAIL_API_KEY="P0YsjUB137upXrr1NiJefHmXVKW1hmBWlpev"
MAIL_SENDER="noreply@mailing.pena.digital"
# URL settings
CustomerURL = "http://localhost:8080"
QuizRPCURL = "localhost:9000"
CUSTOMER_MICROSERVICE_GRPC_URL = "http://localhost:8080"
QUIZ_CORE_MICROSERVICE_GRPC_URL = "localhost:9000"

@ -0,0 +1,24 @@
name: Deploy
run-name: ${{ gitea.actor }} build image and push to container registry
on:
push:
branches:
- 'main'
- 'staging'
jobs:
CreateImage:
runs-on: [hubstaging]
uses: http://gitea.pena/PenaDevops/actions.git/.gitea/workflows/build-image.yml@v1.1.5
with:
runner: hubstaging
secrets:
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
DeployService:
runs-on: [hubstaging]
needs: CreateImage
uses: http://gitea.pena/PenaDevops/actions.git/.gitea/workflows/deploy.yml@v1.1.4-p7
with:
runner: hubstaging

14
.gitea/workflows/lint.yml Normal file

@ -0,0 +1,14 @@
name: Lint
run-name: ${{ gitea.actor }} produce linting
on:
push:
branches:
- 'dev'
jobs:
Lint:
runs-on: [hubstaging]
uses: http://gitea.pena/PenaDevops/actions.git/.gitea/workflows/lint.yml@v1.1.2
with:
runner: hubstaging

@ -1,25 +0,0 @@
include:
- project: "devops/pena-continuous-integration"
file: "/templates/docker/build-template.gitlab-ci.yml"
- project: "devops/pena-continuous-integration"
file: "/templates/docker/deploy-template.gitlab-ci.yml"
stages:
- build
- deploy
build-app:
extends: .build_template
deploy-to-staging:
extends: .deploy_template
rules:
- if: "$CI_COMMIT_BRANCH == $STAGING_BRANCH"
after_script:
- ls
deploy-to-prod:
rules:
- if: "$CI_COMMIT_BRANCH == $PRODUCTION_BRANCH"
tags:
- prod
extends: .deploy_template

@ -1,5 +1,5 @@
# BUILD
FROM golang:1.22.0-alpine AS build
FROM gitea.pena/penadevops/container-images/golang:main as build
# Update packages and clear cache
RUN apk add --no-cache curl
@ -8,14 +8,13 @@ WORKDIR /app
RUN apk add git
# Add main files to app
ADD . .
RUN git config --global url."https://buildToken:glpat-axA8ttckx3aPf_xd2Dym@penahub.gitlab.yandexcloud.net/".insteadOf "https://penahub.gitlab.yandexcloud.net/"
# Download go depences
RUN go mod download
# Build app
RUN GOOS=linux go build -o bin ./cmd/main.go
# PRODUCTION
FROM alpine:3.18.3 AS production
FROM gitea.pena/penadevops/container-images/alpine:main
# Install packages
RUN apk --no-cache add ca-certificates

10
Taskfile.dist.yml Normal file

@ -0,0 +1,10 @@
version: "3"
tasks:
update-linter:
cmds:
- go get -u gitea.pena/PenaSide/linters-golang
lint:
cmds:
- task: update-linter
- cmd: golangci-lint run -v -c $(go list -f '{{"{{"}}.Dir{{"}}"}}' -m gitea.pena/PenaSide/linters-golang)/.golangci.yml

@ -4,11 +4,12 @@ import (
"context"
"fmt"
"go.uber.org/zap"
"mailnotifier/internal/app"
"mailnotifier/internal/initialize"
"gitea.pena/PenaSide/notifier/internal/app"
"gitea.pena/PenaSide/notifier/internal/initialize"
"os"
"os/signal"
"syscall"
_ "gitea.pena/PenaSide/linters-golang/pkg/dummy"
)
func main() {

73
cmd/validator/main.go Normal file

@ -0,0 +1,73 @@
package main
import (
"errors"
"gitea.pena/PenaSide/common/validate"
"gitea.pena/PenaSide/notifier/internal/initialize"
"github.com/caarlos0/env/v8"
"log"
)
func main() {
cfg, err := loadConfig()
if err != nil {
log.Fatalf("Error loading config: %v", err)
}
if err = validateNotEmpty([]string{
cfg.CustomerMicroserviceGRPC,
cfg.QuizCoreMicroserviceGRPC,
}); err != nil {
log.Fatalf("Error validating not empty values: %v", err)
}
if err = validateSMTP(cfg.External.MailClientCfg); err != nil {
log.Fatalf("Error validating SMTP: %v", err)
}
if err = validate.ValidateMongo(cfg.External.Database); err != nil {
log.Fatalf("Error validating Mongo: %v", err)
}
if err = validate.ValidateKafka([]string{cfg.KafkaBrokers}, cfg.KafkaTopicMailNotifier); err != nil {
log.Fatalf("Error validating Kafka: %v", err)
}
}
func loadConfig() (*initialize.Config, error) {
var cfg initialize.Config
if err := env.Parse(&cfg); err != nil {
return nil, err
}
return &cfg, nil
}
func validateNotEmpty(values []string) error {
for _, value := range values {
if value == "" {
return errors.New("important cfg value is empty")
}
}
return nil
}
func validateSMTP(cfg initialize.MailClientCfg) error {
if cfg.Sender == "" {
return errors.New("smtp sender is empty")
}
if cfg.ApiURL == "" {
return errors.New("smtp api url is empty")
}
if cfg.ApiKey == "" {
return errors.New("smtp api key is empty")
}
err := validate.ValidateSmtp(cfg.ApiKey)
if err != nil {
return err
}
return nil
}

@ -2,25 +2,15 @@ version: "3.3"
services:
mailnotifier:
hostname: mailnotifier
container_name: mailnotifier
image: $CI_REGISTRY_IMAGE/staging:$CI_COMMIT_REF_SLUG.$CI_PIPELINE_ID
image: gitea.pena:3000/penaside/notifier/staging:$GITHUB_RUN_NUMBER
tty: true
environment:
- MONGO_HOST=10.8.0.6
- MONGO_PORT=27017
- MONGO_USER=mailnotifier
- MONGO_PASSWORD=vWwbCSg4bf0p
- MONGO_DB=mailnotifier
- MONGO_AUTH=mailnotifier
- KAFKA_BROKERS=10.8.0.6:9092
- KAFKA_TOPIC=mailnotifier
- SMTP_API_URL=https://api.smtp.bz/v1/smtp/send
- SMTP_HOST=connect.mailclient.bz
- SMTP_PORT=587
- SMTP_UNAME=kotilion.95@gmail.com
- SMTP_PASS=vWwbCSg4bf0p
- SMTP_API_KEY=P0YsjUB137upXrr1NiJefHmXVKW1hmBWlpev
- SMTP_SENDER=noreply@mailing.pena.digital
- CUSTOMER_URL=10.8.0.6:8086
- QUIZ_RPC_URL=10.8.0.5:9000
MONGO_URL: mongodb://mailnotifier:vWwbCSg4bf0p@10.7.0.6:27017/?authSource=verification
MONGO_DB_NAME: mailnotifier
KAFKA_BROKERS: 10.7.0.6:9092
KAFKA_TOPIC_MAIL_NOTIFIER: mailnotifier
API_URL: https://api.smtp.bz/v1/smtp/send
MAIL_SENDER: kotilion.95@gmail.com
MAIL_API_KEY: P0YsjUB137upXrr1NiJefHmXVKW1hmBWlpev
CUSTOMER_MICROSERVICE_GRPC_URL: 10.7.0.6:8086
QUIZ_CORE_MICROSERVICE_GRPC_URL: 10.7.0.5:9000

35
go.mod

@ -1,31 +1,42 @@
module mailnotifier
module gitea.pena/PenaSide/notifier
go 1.21.6
go 1.23.2
toolchain go1.23.3
require (
gitea.pena/PenaSide/common v0.0.0-20241231090536-2454377ad2a0
gitea.pena/PenaSide/linters-golang v0.0.0-20241207122018-933207374735
github.com/caarlos0/env/v8 v8.0.0
github.com/gofiber/fiber/v2 v2.51.0
github.com/joho/godotenv v1.5.1
github.com/twmb/franz-go v1.16.1
github.com/twmb/franz-go v1.18.0
go.mongodb.org/mongo-driver v1.14.0
go.uber.org/zap v1.27.0
google.golang.org/grpc v1.63.0
google.golang.org/protobuf v1.33.0
penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240223054633-6cb3d5ce45b6
)
require (
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/go-ini/ini v1.67.0 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/golang/snappy v0.0.1 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/klauspost/compress v1.17.4 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/minio/md5-simd v1.1.2 // indirect
github.com/minio/minio-go/v7 v7.0.81 // indirect
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
github.com/pierrec/lz4/v4 v4.1.19 // indirect
github.com/pierrec/lz4/v4 v4.1.21 // indirect
github.com/pioz/faker v1.7.3 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/twmb/franz-go/pkg/kmsg v1.7.0 // indirect
github.com/rs/xid v1.6.0 // indirect
github.com/twmb/franz-go/pkg/kmsg v1.9.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.50.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
@ -34,10 +45,10 @@ require (
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
go.uber.org/multierr v1.10.0 // indirect
golang.org/x/crypto v0.19.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.19.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
)

69
go.sum

@ -1,9 +1,20 @@
gitea.pena/PenaSide/common v0.0.0-20241231090536-2454377ad2a0 h1:B4+DAND6gJnCsc9DZY6XyMVLzD23nI8whk8xI7XKGrM=
gitea.pena/PenaSide/common v0.0.0-20241231090536-2454377ad2a0/go.mod h1:U7QFuvkrIWyb/m/SOyrsroS7DJntjcr9k7kNy3vtPdU=
gitea.pena/PenaSide/linters-golang v0.0.0-20241207122018-933207374735 h1:jDVeUhGBTXBibmW5dmtJg2m2+z5z2Rf6J4G0LpjVoJ0=
gitea.pena/PenaSide/linters-golang v0.0.0-20241207122018-933207374735/go.mod h1:gdd+vOT6up9STkEbxa2qESLIMZFjCmRbkcheFQCVgZU=
github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs=
github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/caarlos0/env/v8 v8.0.0 h1:POhxHhSpuxrLMIdvTGARuZqR4Jjm8AYmoi/JKlcScs0=
github.com/caarlos0/env/v8 v8.0.0/go.mod h1:7K4wMY9bH0esiXSSHlfHLX5xKGQMnkH5Fk4TDSSSzfo=
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/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA=
github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/gofiber/fiber/v2 v2.51.0 h1:JNACcZy5e2tGApWB2QrRpenTWn0fq0hkFm6k0C86gKQ=
github.com/gofiber/fiber/v2 v2.51.0/go.mod h1:xaQRZQJGqnKOQnbQw+ltvku3/h8QxvNi8o6JiJ7Ll0U=
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
@ -14,8 +25,11 @@ 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/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4=
github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM=
github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
@ -23,20 +37,30 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
github.com/minio/minio-go/v7 v7.0.81 h1:SzhMN0TQ6T/xSBu6Nvw3M5M8voM+Ht8RH3hE8S7zxaA=
github.com/minio/minio-go/v7 v7.0.81/go.mod h1:84gmIilaX4zcvAWWzJ5Z1WI5axN+hAbM5w25xf8xvC0=
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0=
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
github.com/pierrec/lz4/v4 v4.1.19 h1:tYLzDnjDXh9qIxSTKHwXwOYmm9d887Y7Y1ZkyXYHAN4=
github.com/pierrec/lz4/v4 v4.1.19/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=
github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
github.com/pioz/faker v1.7.3 h1:Tez8Emuq0UN+/d6mo3a9m/9ZZ/zdfJk0c5RtRatrceM=
github.com/pioz/faker v1.7.3/go.mod h1:xSpay5w/oz1a6+ww0M3vfpe40pSIykeUPeWEc3TvVlc=
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/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/twmb/franz-go v1.16.1 h1:rpWc7fB9jd7TgmCyfxzenBI+QbgS8ZfJOUQE+tzPtbE=
github.com/twmb/franz-go v1.16.1/go.mod h1:/pER254UPPGp/4WfGqRi+SIRGE50RSQzVubQp6+N4FA=
github.com/twmb/franz-go/pkg/kmsg v1.7.0 h1:a457IbvezYfA5UkiBvyV3zj0Is3y1i8EJgqjJYoij2E=
github.com/twmb/franz-go/pkg/kmsg v1.7.0/go.mod h1:se9Mjdt0Nwzc9lnjJ0HyDtLyBnaBDAd7pCje47OhSyw=
github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU=
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/twmb/franz-go v1.18.0 h1:25FjMZfdozBywVX+5xrWC2W+W76i0xykKjTdEeD2ejw=
github.com/twmb/franz-go v1.18.0/go.mod h1:zXCGy74M0p5FbXsLeASdyvfLFsBvTubVqctIaa5wQ+I=
github.com/twmb/franz-go/pkg/kmsg v1.9.0 h1:JojYUph2TKAau6SBtErXpXGC7E3gg4vGZMv9xFU/B6M=
github.com/twmb/franz-go/pkg/kmsg v1.9.0/go.mod h1:CMbfazviCyY6HM0SXuG5t9vOwYDHRCSrJJyBAe5paqg=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.50.0 h1:H7fweIlBm0rXLs2q0XbalvJ6r0CUPFWK3/bB4N13e9M=
@ -62,35 +86,36 @@ go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/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.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
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.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
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.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
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/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
@ -101,7 +126,7 @@ google.golang.org/grpc v1.63.0 h1:WjKe+dnvABXyPJMD7KDNLxtoGk5tgk+YFWN6cBWjZE8=
google.golang.org/grpc v1.63.0/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
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=
penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240223054633-6cb3d5ce45b6 h1:oV+/HNX+JPoQ3/GUx08hio7d45WpY0AMGrFs7j70QlA=
penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240223054633-6cb3d5ce45b6/go.mod h1:lTmpjry+8evVkXWbEC+WMOELcFkRD1lFMc7J09mOndM=

@ -2,11 +2,11 @@ package app
import (
"context"
"gitea.pena/PenaSide/notifier/internal/clients"
"gitea.pena/PenaSide/notifier/internal/initialize"
"gitea.pena/PenaSide/notifier/internal/repository"
"gitea.pena/PenaSide/notifier/internal/workers"
"go.uber.org/zap"
"mailnotifier/internal/clients"
"mailnotifier/internal/initialize"
"mailnotifier/internal/repository"
"mailnotifier/internal/workers"
)
func Run(ctx context.Context, config initialize.Config, logger *zap.Logger) error {
@ -36,21 +36,12 @@ func Run(ctx context.Context, config initialize.Config, logger *zap.Logger) erro
repo := repository.NewRepository(mdb.Collection("notify"))
mailClient := clients.NewMailClient(clients.Deps{
SmtpHost: config.SmtpHost,
SmtpApiUrl: config.SmtpApiUrl,
SmtpPort: config.SmtpPort,
SmtpSender: config.SmtpSender,
Username: config.SmtpUsername,
Password: config.SmtpPassword,
ApiKey: config.SmtpApiKey,
Logger: logger,
})
mailClient := clients.NewMailClient(config.External.MailClientCfg)
quizClient := clients.NewQuizClient(config.QuizRPCURL, logger)
quizClient := clients.NewQuizClient(config.QuizCoreMicroserviceGRPC, logger)
customerClient := clients.NewCustomerClient(clients.CustomerDeps{
Url: config.CustomerURL,
Url: config.CustomerMicroserviceGRPC,
Logger: logger,
})

@ -3,9 +3,9 @@ package clients
import (
"encoding/json"
"fmt"
"gitea.pena/PenaSide/notifier/internal/models"
"github.com/gofiber/fiber/v2"
"go.uber.org/zap"
"mailnotifier/internal/models"
)
type Customer struct {
@ -41,7 +41,7 @@ func (c *Customer) GetAccount(userID string) (models.Account, error) {
statusCode, body, errs := resp.Bytes()
if errs != nil {
c.logger.Error("Error sending request:", zap.Error(errs[0]))
c.logger.Error(errSendingRequest.Error(), zap.Error(errs[0]))
return account, errs[0]
}

@ -0,0 +1,7 @@
package clients
import "errors"
var (
errSendingRequest = errors.New("error sending request")
)

@ -3,34 +3,31 @@ package clients
import (
"bytes"
"fmt"
"gitea.pena/PenaSide/notifier/internal/initialize"
"github.com/gofiber/fiber/v2"
"go.uber.org/zap"
"html/template"
"mime/multipart"
)
type Deps struct {
SmtpApiUrl string
SmtpHost string
SmtpPort string
SmtpSender string
Username string
Password string
ApiKey string
FiberClient *fiber.Client
Logger *zap.Logger
}
type MailClient struct {
deps Deps
smtpApiUrl string
smtpSender string
apiKey string
fiberClient *fiber.Client
logger *zap.Logger
}
func NewMailClient(deps Deps) *MailClient {
func NewMailClient(deps initialize.MailClientCfg) *MailClient {
if deps.FiberClient == nil {
deps.FiberClient = fiber.AcquireClient()
}
return &MailClient{
deps: deps,
smtpApiUrl: deps.ApiURL,
smtpSender: deps.Sender,
apiKey: deps.ApiKey,
fiberClient: deps.FiberClient,
logger: deps.Logger,
}
}
@ -43,13 +40,13 @@ type SenderDeps struct {
func (m *MailClient) MailSender(data SenderDeps) error {
tmpl, err := template.New("email").Parse(data.Tmpl)
if err != nil {
m.deps.Logger.Error("Error parsing HTML template:", zap.Error(err))
m.logger.Error("Error parsing HTML template:", zap.Error(err))
return err
}
var buf bytes.Buffer
if err = tmpl.Execute(&buf, nil); err != nil {
m.deps.Logger.Error("Error executing template:", zap.Error(err))
m.logger.Error("Error executing template:", zap.Error(err))
return err
}
@ -59,7 +56,7 @@ func (m *MailClient) MailSender(data SenderDeps) error {
writer := multipart.NewWriter(form)
fields := map[string]string{
"from": m.deps.SmtpSender,
"from": m.smtpSender,
"to": data.Email,
"subject": data.Subject,
"html": htmlBody,
@ -75,20 +72,20 @@ func (m *MailClient) MailSender(data SenderDeps) error {
return err
}
req := m.deps.FiberClient.Post(m.deps.SmtpApiUrl).Body(form.Bytes()).ContentType(writer.FormDataContentType())
if m.deps.ApiKey != "" {
req.Set("Authorization", m.deps.ApiKey)
req := m.fiberClient.Post(m.smtpApiUrl).Body(form.Bytes()).ContentType(writer.FormDataContentType())
if m.apiKey != "" {
req.Set("Authorization", m.apiKey)
}
statusCode, body, errs := req.Bytes()
if errs != nil {
m.deps.Logger.Error("Error sending request:", zap.Error(errs[0]))
m.logger.Error(errSendingRequest.Error(), zap.Error(errs[0]))
return errs[0]
}
if statusCode != fiber.StatusOK {
err = fmt.Errorf("the SMTP service returned an error: %s Response body: %s", statusCode, body)
m.deps.Logger.Error("Error sending email:", zap.Error(err))
m.logger.Error("Error sending email:", zap.Error(err))
return err
}

@ -2,10 +2,10 @@ package clients
import (
"context"
"gitea.pena/PenaSide/notifier/internal/proto/notifyer"
"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"mailnotifier/internal/proto/notifyer"
)
type QuizClient struct {
@ -20,10 +20,13 @@ func NewQuizClient(address string, logger *zap.Logger) *QuizClient {
}
}
var coreRpcHost = "core rpc host"
var request = "request"
func (q *QuizClient) GetQuizzes(ctx context.Context, req *notifyer.GetQuizzesRequest) (*notifyer.GetQuizzesResponse, error) {
connection, err := grpc.NewClient(q.address, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
q.logger.Error("failed to connect on GetQuizzes of core rpc", zap.Error(err), zap.String("core rpc host", q.address))
q.logger.Error("failed to connect on GetQuizzes of core rpc", zap.Error(err), zap.String(coreRpcHost, q.address))
return nil, err
}
defer func() {
@ -36,7 +39,7 @@ func (q *QuizClient) GetQuizzes(ctx context.Context, req *notifyer.GetQuizzesReq
response, err := client.GetQuizzes(ctx, req)
if err != nil {
q.logger.Error("failed to GetQuizzes core rpc", zap.Error(err), zap.Any("request", req))
q.logger.Error("failed to GetQuizzes core rpc", zap.Error(err), zap.Any(request, req))
return nil, err
}
@ -46,7 +49,7 @@ func (q *QuizClient) GetQuizzes(ctx context.Context, req *notifyer.GetQuizzesReq
func (q *QuizClient) GetStartedQuizzes(ctx context.Context, req *notifyer.GetStartedQuizzesRequest) (*notifyer.GetStartedQuizzesResponse, error) {
connection, err := grpc.NewClient(q.address, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
q.logger.Error("failed to connect on GetStartedQuizzes of core rpc", zap.Error(err), zap.String("core rpc host", q.address))
q.logger.Error("failed to connect on GetStartedQuizzes of core rpc", zap.Error(err), zap.String(coreRpcHost, q.address))
return nil, err
}
defer func() {
@ -59,7 +62,7 @@ func (q *QuizClient) GetStartedQuizzes(ctx context.Context, req *notifyer.GetSta
response, err := client.GetStartedQuizzes(ctx, req)
if err != nil {
q.logger.Error("failed to GetStartedQuizzes core rpc", zap.Error(err), zap.Any("request", req))
q.logger.Error("failed to GetStartedQuizzes core rpc", zap.Error(err), zap.Any(request, req))
return nil, err
}

@ -1,30 +1,33 @@
package initialize
import (
"gitea.pena/PenaSide/common/mongo"
"github.com/caarlos0/env/v8"
"github.com/gofiber/fiber/v2"
"github.com/joho/godotenv"
"go.uber.org/zap"
"log"
)
type Config struct {
MongoHost string `env:"MONGO_HOST" envDefault:"127.0.0.1"`
MongoPort string `env:"MONGO_PORT" envDefault:"27020"`
MongoUser string `env:"MONGO_USER" envDefault:"test"`
MongoPassword string `env:"MONGO_PASSWORD" envDefault:"test"`
MongoDatabase string `env:"MONGO_DB" envDefault:"admin"`
MongoAuth string `env:"MONGO_AUTH" envDefault:"admin"`
KafkaBrokers string `env:"KAFKA_BROKERS"`
KafkaTopic string `env:"KAFKA_TOPIC"`
KafkaGroup string `env:"KAFKA_GROUP" default:"mailnotifier"`
SmtpApiUrl string `env:"SMTP_API_URL"`
SmtpHost string `env:"SMTP_HOST"`
SmtpPort string `env:"SMTP_PORT"`
SmtpUsername string `env:"SMTP_UNAME"`
SmtpPassword string `env:"SMTP_PASS"`
SmtpApiKey string `env:"SMTP_API_KEY"`
SmtpSender string `env:"SMTP_SENDER"`
CustomerURL string `env:"CUSTOMER_URL"`
QuizRPCURL string `env:"QUIZ_RPC_URL"`
KafkaBrokers string `env:"KAFKA_BROKERS,required"`
KafkaTopicMailNotifier string `env:"KAFKA_TOPIC_MAIL_NOTIFIER,required"`
CustomerMicroserviceGRPC string `env:"CUSTOMER_MICROSERVICE_GRPC_URL,required"`
QuizCoreMicroserviceGRPC string `env:"QUIZ_CORE_MICROSERVICE_GRPC_URL,required"`
External External
}
type External struct {
MailClientCfg MailClientCfg
Database mongo.Configuration
}
type MailClientCfg struct {
ApiURL string `env:"API_URL,required"`
ApiKey string `env:"MAIL_API_KEY,required"`
Sender string `env:"MAIL_SENDER,required"`
FiberClient *fiber.Client
Logger *zap.Logger
}
func LoadConfig() (*Config, error) {

@ -9,8 +9,8 @@ import (
func KafkaConsumerInit(ctx context.Context, config Config) (*kgo.Client, error) {
kafkaClient, err := kgo.NewClient(
kgo.SeedBrokers(config.KafkaBrokers),
kgo.ConsumerGroup(config.KafkaGroup),
kgo.ConsumeTopics(config.KafkaTopic),
kgo.ConsumerGroup("mailnotifier"),
kgo.ConsumeTopics(config.KafkaTopicMailNotifier),
kgo.ConsumeResetOffset(kgo.NewOffset().AfterMilli(time.Now().UnixMilli())),
)
if err != nil {

@ -2,8 +2,8 @@ package initialize
import (
"context"
mg "gitea.pena/PenaSide/common/mongo"
"go.mongodb.org/mongo-driver/mongo"
mg "penahub.gitlab.yandexcloud.net/backend/penahub_common/mongo"
"time"
)
@ -11,17 +11,8 @@ func MongoInit(ctx context.Context, config Config) (*mongo.Database, error) {
newCtx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
cfg := mg.Configuration{
Host: config.MongoHost,
Port: config.MongoPort,
User: config.MongoUser,
Password: config.MongoPassword,
Auth: config.MongoAuth,
DatabaseName: config.MongoDatabase,
}
deps := mg.ConnectDeps{
Configuration: &cfg,
Configuration: &config.External.Database,
Timeout: 10 * time.Second,
}

@ -2,10 +2,9 @@ package repository
import (
"context"
"gitea.pena/PenaSide/notifier/internal/models"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"mailnotifier/internal/models"
//"time"
)
type Repository struct {
@ -37,13 +36,13 @@ func (r *Repository) GetMany(ctx context.Context) ([]models.Message, error) {
// from := time.Now().AddDate(0, 0, -7)
//
filter := bson.D{
{"$and", bson.A{
{Key: "$and", Value: bson.A{
bson.D{
{"$or", bson.A{
bson.D{{"sendRegistration", false}},
bson.D{{"sendNoneCreated", false}},
bson.D{{"sendUnpublished", false}},
bson.D{{"sendPaid", false}},
{Key: "$or", Value: bson.A{
bson.D{{Key: "sendRegistration", Value: false}},
bson.D{{Key: "sendNoneCreated", Value: false}},
bson.D{{Key: "sendUnpublished", Value: false}},
bson.D{{Key: "sendPaid", Value: false}},
}},
},
// bson.D{

@ -8,9 +8,9 @@ import (
"github.com/twmb/franz-go/pkg/kgo"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.uber.org/zap"
"mailnotifier/internal/clients"
"mailnotifier/internal/models"
"mailnotifier/internal/repository"
"gitea.pena/PenaSide/notifier/internal/clients"
"gitea.pena/PenaSide/notifier/internal/models"
"gitea.pena/PenaSide/notifier/internal/repository"
"time"
)

@ -4,9 +4,9 @@ import (
"context"
_ "embed"
"go.uber.org/zap"
"mailnotifier/internal/clients"
"mailnotifier/internal/proto/notifyer"
"mailnotifier/internal/repository"
"gitea.pena/PenaSide/notifier/internal/clients"
"gitea.pena/PenaSide/notifier/internal/proto/notifyer"
"gitea.pena/PenaSide/notifier/internal/repository"
"time"
)

@ -5,9 +5,9 @@ package workers
// "context"
// _ "embed"
// "go.uber.org/zap"
// "mailnotifier/internal/clients"
// "mailnotifier/internal/models"
// "mailnotifier/internal/repository"
// "gitea.pena/PenaSide/notifier/internal/clients"
// "gitea.pena/PenaSide/notifier/internal/models"
// "gitea.pena/PenaSide/notifier/internal/repository"
//)
//
////go:embed mail/register.tmpl

@ -4,8 +4,8 @@ import (
"context"
"fmt"
"go.uber.org/zap"
"mailnotifier/internal/clients"
"mailnotifier/internal/proto/notifyer"
"gitea.pena/PenaSide/notifier/internal/clients"
"gitea.pena/PenaSide/notifier/internal/proto/notifyer"
"testing"
)

@ -5,7 +5,7 @@ import (
"encoding/json"
"fmt"
"github.com/twmb/franz-go/pkg/kgo"
"mailnotifier/internal/models"
"gitea.pena/PenaSide/notifier/internal/models"
"testing"
"time"
)

@ -3,9 +3,10 @@ package test
import (
"context"
"fmt"
"mailnotifier/internal/initialize"
"mailnotifier/internal/models"
"mailnotifier/internal/repository"
"gitea.pena/PenaSide/common/mongo"
"gitea.pena/PenaSide/notifier/internal/initialize"
"gitea.pena/PenaSide/notifier/internal/models"
"gitea.pena/PenaSide/notifier/internal/repository"
"testing"
"time"
)
@ -13,12 +14,12 @@ import (
func TestInsertAndGetMany(t *testing.T) {
crx := context.Background()
mdb, err := initialize.MongoInit(crx, initialize.Config{
MongoHost: "127.0.0.1",
MongoPort: "27020",
MongoUser: "test",
MongoPassword: "test",
MongoDatabase: "admin",
MongoAuth: "admin",
External: initialize.External{
Database: mongo.Configuration{
URL: "mongodb://test:test@localhost:27020/",
DatabaseName: "admin",
},
},
})
if err != nil {
panic(err)