44 Commits

Author SHA1 Message Date
a23c289e80 Fixed entrypoints
All checks were successful
ci/woodpecker/push/workflow Pipeline was successful
2025-11-05 15:26:17 +01:00
8262d6c672 Woodpecker fixes
Some checks failed
ci/woodpecker/push/workflow Pipeline failed
2025-11-05 15:23:32 +01:00
9ad3fe5283 Fixes in reconnecting on connection lost (api-cache, db-postgres) issue
Some checks failed
ci/woodpecker/push/workflow Pipeline failed
2025-11-05 15:20:08 +01:00
f9fcf3095a Added base woodpecker task
All checks were successful
ci/woodpecker/push/workflow Pipeline was successful
2025-11-05 15:18:41 +01:00
7fdb902a11 Refactoring - part3 2025-10-28 19:25:08 +01:00
a8010a82e4 Refactoring - part2 2025-10-27 18:50:43 +01:00
6c8f51066d Refactoring - part 1 2025-10-27 17:09:55 +01:00
b89aac8978 Refactored AddProduct handler and ActionUI 2025-10-25 21:16:45 +02:00
995f81422d Refactor: Added ProductRepositoryInterface to cover ProductRepository dependency
Some checks reported errors
continuous-integration/drone/push Build encountered an error
2025-10-24 10:26:57 +02:00
25d54efb7d A lot of refactoring - part1
Some checks reported errors
continuous-integration/drone Build encountered an error
2025-10-23 11:39:53 +02:00
50d32c9619 Added possibility to run app in local env 2025-10-21 14:58:05 +02:00
f1d130ae0c Update 2025-03-16 14:28:54 +01:00
8d62caf5f7 Update 2025-03-16 14:21:15 +01:00
Piotr Biernat
13c3c386a5 Refactor 2024-12-24 14:22:49 +01:00
Piotr Biernat
5b87c14d65 update 2024-12-06 14:18:01 +01:00
5feb115f62 Update 2024-12-05 16:57:56 +01:00
5b1bf92845 refactor, TLS support, v0.5 2024-07-20 19:21:38 +02:00
5317cbe6e7 fixes 2024-07-19 22:46:43 +02:00
6900ef5621 added .env.dist 2024-07-19 21:52:22 +02:00
0151c19e8f Huge refactoring 2024-07-19 21:24:31 +02:00
b276fa9e81 huge refactor 2024-07-18 18:29:40 +02:00
43567151f6 .drone.yml added /etc/hosts volume
Some checks failed
continuous-integration/drone Build is failing
2024-06-01 15:00:28 +02:00
cd4f875a6c Update repo url
Some checks failed
continuous-integration/drone Build is failing
2024-05-31 19:43:06 +02:00
41c3257cf0 Refactor & fixes 2024-04-17 19:14:07 +02:00
b3ac3b7395 Rollbck after git srv migration changes 2024-04-04 20:22:54 +02:00
a621073a70 Rollbck after git srv migration changes 2024-04-04 20:22:25 +02:00
adf5234577 Update after git srv migration 2024-04-02 21:20:16 +02:00
66acbb0cda Update 2023-05-22 21:57:17 +02:00
8fac6f7e61 Refactor
Some checks failed
continuous-integration/drone/push Build is failing
2023-04-10 15:13:53 +02:00
11cc3e5f4c Added LICENSE
Some checks failed
continuous-integration/drone/push Build is failing
2023-03-30 22:15:27 +02:00
7cf3cc3c65 update
Some checks failed
continuous-integration/drone/push Build is failing
2023-03-20 17:11:04 +01:00
193abd2ed7 Refactoring
Some checks failed
continuous-integration/drone/push Build is failing
2022-12-25 23:18:19 +01:00
ab362d3b56 Added migrations
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-17 06:36:55 +01:00
8f5727ad10 fixes
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-16 01:01:15 +01:00
4571ee1154 Added wait-for-it.sh script
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-07 02:43:27 +01:00
39b94713b8 Added KV Config support and updated build scripts
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-05 23:47:35 +01:00
c322316430 build fix
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-02 23:36:41 +01:00
270b07a437 Skip logging of health check requests
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-02 21:53:03 +01:00
32f148ea95 Refactor. Consul TTl fix, gracefull shutdown
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-02 20:11:53 +01:00
bf47c8645d update
Some checks failed
continuous-integration/drone/push Build is failing
2022-12-02 14:31:12 +01:00
6f7952d166 vendor support and image build optimalization
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-01 05:51:11 +01:00
d143b31734 Refactored docker image builder script
All checks were successful
continuous-integration/drone/push Build is passing
2022-11-30 02:08:36 +01:00
49671344df CQ fix
All checks were successful
continuous-integration/drone/push Build is passing
2022-11-29 23:32:59 +01:00
27b1f1fb35 :Huge REFACTORING
Some checks failed
continuous-integration/drone/push Build is failing
2022-11-29 22:40:58 +01:00
45 changed files with 2005 additions and 21 deletions

25
.gitignore vendored
View File

@@ -1,17 +1,14 @@
# ---> Go
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
deploy/.env
!deploy/.env.dist
!deploy/.env.docker
deploy/.env.local
# Test binary, built with `go test -c`
*.test
deploy/server
deploy/worker
deploy/scheduler
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# Dependency directories (remove the comment below to include it)
# vendor/
!deploy/certs/.gitkeep
deploy/certs/*
.vscode/
__debug_bin

69
.woodpecker/workflow.yaml Normal file
View File

@@ -0,0 +1,69 @@
variables:
- &golang_image 'docker.io/golang:1.24'
- &buildx_plugin 'docker.io/woodpeckerci/plugin-docker-buildx:6.0.3'
- &platforms_release 'linux/amd64'
- &build_args 'CI_COMMIT_SHA=${CI_COMMIT_SHA},CI_COMMIT_BRANCH=${CI_COMMIT_BRANCH},CI_COMMIT_TAG=${CI_COMMIT_TAG}'
- publish_logins: &publish_logins
- registry: git.ego.freeddns.org
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
- event: [pull_request, tag]
- event: push
branch: develop
steps:
- name: vendor
image: *golang_image
pull: true
commands:
- cd src/ && go mod vendor
- name: analyze
image: *golang_image
depends_on:
- vendor
commands:
- cd src && go vet ./...
- name: static-check
image: *golang_image
depends_on:
- vendor
commands:
- go install honnef.co/go/tools/cmd/staticcheck@latest
- cd src && staticcheck ./...
- name: lint
image: *golang_image
depends_on:
- vendor
commands:
- echo "Lint"
- go install golang.org/x/lint/golint@latest
- golint src/app/... src/cmd/... src/infra/... src/internal/...
- name: build-image
image: *buildx_plugin
depends_on: [vendor, analyze, static-check, lint]
settings:
repo: git.ego.freeddns.org/egommerce/catalog-svc
tag: builder
dockerfile: deploy/docker/Dockerfile.builder
logins: *publish_logins
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- name: push-image
image: *buildx_plugin
depends_on:
- build-image
settings:
repo: git.ego.freeddns.org/egommerce/catalog-svc
tag: dev
build_args:
BUILDER_IMAGE: git.ego.freeddns.org/egommerce/catalog-svc:builder
SVC_NAME: "catalog-svc"
SVC_VER: "1.0"
dockerfile: deploy/docker/Dockerfile.target
logins: *publish_logins
volumes:
- /var/run/docker.sock:/var/run/docker.sock

173
LICENSE.md Normal file
View File

@@ -0,0 +1,173 @@
# Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible.
**Using Creative Commons Public Licenses**
Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses.
* __Considerations for licensors:__ Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. [More considerations for licensors](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensors).
* __Considerations for the public:__ By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensors permission is not necessary for any reasonfor example, because of any applicable exception or limitation to copyrightthen that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. [More considerations for the public](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensees).
## Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License
By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
### Section 1 Definitions.
a. __Adapted Material__ means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
b. __Adapter's License__ means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
c. __BY-NC-SA Compatible License__ means a license listed at [creativecommons.org/compatiblelicenses](http://creativecommons.org/compatiblelicenses), approved by Creative Commons as essentially the equivalent of this Public License.
d. __Copyright and Similar Rights__ means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
e. __Effective Technological Measures__ means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
f. __Exceptions and Limitations__ means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
g. __License Elements__ means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution, NonCommercial, and ShareAlike.
h. __Licensed Material__ means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
i. __Licensed Rights__ means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
j. __Licensor__ means the individual(s) or entity(ies) granting rights under this Public License.
k. __NonCommercial__ means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange.
l. __Share__ means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
m. __Sui Generis Database Rights__ means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
n. __You__ means the individual or entity exercising the Licensed Rights under this Public License. __Your__ has a corresponding meaning.
### Section 2 Scope.
a. ___License grant.___
1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
A. reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and
B. produce, reproduce, and Share Adapted Material for NonCommercial purposes only.
2. __Exceptions and Limitations.__ For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
3. __Term.__ The term of this Public License is specified in Section 6(a).
4. __Media and formats; technical modifications allowed.__ The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
5. __Downstream recipients.__
A. __Offer from the Licensor Licensed Material.__ Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
B. __Additional offer from the Licensor Adapted Material.__ Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapters License You apply.
C. __No downstream restrictions.__ You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
6. __No endorsement.__ Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
b. ___Other rights.___
1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
2. Patent and trademark rights are not licensed under this Public License.
3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial purposes.
### Section 3 License Conditions.
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
a. ___Attribution.___
1. If You Share the Licensed Material (including in modified form), You must:
A. retain the following if it is supplied by the Licensor with the Licensed Material:
i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
ii. a copyright notice;
iii. a notice that refers to this Public License;
iv. a notice that refers to the disclaimer of warranties;
v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
b. ___ShareAlike.___
In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply.
1. The Adapters License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-NC-SA Compatible License.
2. You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material.
3. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply.
### Section 4 Sui Generis Database Rights.
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial purposes only;
b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and
c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
### Section 5 Disclaimer of Warranties and Limitation of Liability.
a. __Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.__
b. __To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.__
c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
### Section 6 Term and Termination.
a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
2. upon express reinstatement by the Licensor.
For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
### Section 7 Other Terms and Conditions.
a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
### Section 8 Interpretation.
a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
> Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at [creativecommons.org/policies](http://creativecommons.org/policies), Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses.
>
> Creative Commons may be contacted at creativecommons.org

32
Makefile Normal file
View File

@@ -0,0 +1,32 @@
DEPLOY_DIR := ./deploy
SRC_DIR := ./src
build-image-dev:
- sh ${DEPLOY_DIR}/scripts/image-build.sh dev
build-image-prod:
- sh ${DEPLOY_DIR}/scripts/image-build.sh
push-image-dev:
- sh ${DEPLOY_DIR}/scripts/image-push.sh dev
push-image-prod:
- sh ${DEPLOY_DIR}/scripts/image-push.sh
build-local-scheduler:
- go build -C ${SRC_DIR} -o ../deploy/scheduler cmd/scheduler/main.go
run-local-scheduler:
- cd deploy/ && ./scheduler
build-local-server:
- go build -C ${SRC_DIR} -o ../deploy/server cmd/server/main.go
run-local-server:
- cd deploy/ && ./server
build-local-worker:
- go build -C ${SRC_DIR} -o ../deploy/worker cmd/worker/main.go
run-local-worker:
- cd deploy/ && ./worker

6
bin/entrypoint.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/usr/bin/env sh
# run migrations
migrate.sh
exec "$@"

25
bin/migrate.sh Normal file
View File

@@ -0,0 +1,25 @@
#!/usr/bin/env sh
# ensure migrate env is initialized
$(migrate version >/dev/null 2>&1)
version=$?
if [ $version != "0" ]
then
echo "Creating base table..."
$(migrate init >/dev/null 2>&1)
init=$?
fi
# check again
$(migrate version >/dev/null 2>&1)
version=$?
if [ $version != "0" ]
then
echo "Unable to run migrations."
exit 1
fi
# run migrations
migrate up
exit $version

View File

@@ -1,7 +0,0 @@
package main
import "fmt"
func main() {
fmt.Println("Catalog services")
}

12
deploy/.env.dist Normal file
View File

@@ -0,0 +1,12 @@
SERVER_ADDR=:443
APP_NAME=catalog-svc
APP_DOMAIN=catalog.service.ego.io
API_DATABASE_URL=postgres://postgres:12345678@db-postgres:5432/egommerce
API_CACHE_ADDR=api-cache:6379
API_CACHE_USERNAME=default
API_CACHE_PASSWORD=12345678
API_MONGODB_URL=mongodb://mongodb:12345678@mongo-db:27017
API_EVENTBUS_URL=amqp://guest:guest@api-eventbus:5672

13
deploy/.env.docker Normal file
View File

@@ -0,0 +1,13 @@
SERVER_ADDR=:443
APP_NAME=catalog-svc
APP_DOMAIN=catalog.service.ego.io
API_LOGGER_ADDR=api-logger:24224
API_DATABASE_URL=postgres://postgres:12345678@db-postgres:5432/egommerce
API_CACHE_ADDR=api-cache:6379
API_CACHE_USERNAME=default
API_CACHE_PASSWORD=12345678
API_MONGODB_URL=mongodb://mongodb:12345678@mongo-db:27017
API_EVENTBUS_URL=amqp://guest:guest@api-eventbus:5672

View File

@@ -0,0 +1,17 @@
# Builder
FROM golang:alpine
ARG BIN_OUTPUT=/go/bin
ARG GO_SERVER=cmd/server/main.go
ARG GO_WORKER=cmd/worker/main.go
ARG GO_SCHEDULER=cmd/scheduler/main.go
ARG GO_MIGRATE=cmd/migrate/main.go
WORKDIR /go/src/app
COPY src ./
RUN export CGO_ENABLED=0 ; export GOOS=linux ; export GOARCH=amd64 && \
go build -ldflags="-w -s" -o "$BIN_OUTPUT/server" $GO_SERVER && \
go build -ldflags="-w -s" -o "$BIN_OUTPUT/worker" $GO_WORKER && \
go build -ldflags="-w -s" -o "$BIN_OUTPUT/scheduler" $GO_SCHEDULER && \
go build -ldflags="-w -s" -o "$BIN_OUTPUT/migrate" $GO_MIGRATE

View File

@@ -0,0 +1,34 @@
# Builder
ARG BUILDER_IMAGE
FROM ${BUILDER_IMAGE} AS builder
# Destination image - server
# FROM gcr.io/distroless/base-debian10
FROM alpine:3.22
ARG SVC_NAME
ARG SVC_VER
ARG BUILD_TIME
LABEL dev.egommerce.image.author="Piotr Biernat"
LABEL dev.egommerce.image.vendor="Egommerce"
LABEL dev.egommerce.image.service=${SVC_NAME}
LABEL dev.egommerce.image.version=${SVC_VER}
LABEL dev.egommerce.image.build_time=${BUILD_TIME}
WORKDIR /
COPY --from=builder /go/bin/server /usr/local/bin/server
COPY --from=builder /go/bin/migrate /usr/local/bin/migrate
COPY --from=builder /go/bin/scheduler /usr/local/bin/scheduler
COPY --from=builder /go/bin/worker /usr/local/bin/worker
COPY deploy/.env.docker /.env
COPY ./bin/* /usr/local/bin/
RUN chmod 755 /usr/local/bin/entrypoint.sh /usr/local/bin/migrate.sh
EXPOSE 443
ENTRYPOINT ["entrypoint.sh"]
CMD ["sh", "-c", "/usr/local/bin/server"]

61
deploy/scripts/image-build.sh Executable file
View File

@@ -0,0 +1,61 @@
#!/bin/sh
# RUN IN REPO ROOT DIR !!
export IMAGE_PREFIX="git.ego.freeddns.org/egommerce/catalog"
export BUILDER_IMAGE="egommerce-builder:catalog"
export BUILD_TIME=$(date +"%Y%m%d%H%M%S")
export SERVER_IMAGE="$IMAGE_PREFIX-svc"
# export WORKER_IMAGE="$IMAGE_PREFIX-worker"
TARGET=${1:-latest}
[ ! -d "src/vendor" ] && sh -c "cd src; go mod vendor"
echo "Building target $IMAGE_PREFIX images..."
docker build --rm -t "$BUILDER_IMAGE" -f deploy/docker/Dockerfile.builder .
if [ $TARGET = "latest" ]
then
# PROD
docker build \
--build-arg SVC_NAME=catalog-svc \
--build-arg SVC_VER="1.0" \
--build-arg BUILDER_IMAGE=$BUILDER_IMAGE \
--build-arg BUILD_TIME \
--rm --cache-from $SERVER_IMAGE:$TARGET \
-t $SERVER_IMAGE:$TARGET \
-f deploy/docker/Dockerfile.target . > /dev/null 2>&1 && echo "Successfully tagged $SERVER_IMAGE:$TARGET"
# WORKER - TODO REMOVE IN FUTURE - cause we copy worker binary to the server image
# docker build \
# --build-arg SVC_NAME=catalog-worker \
# --build-arg SVC_VER="1.0" \
# --build-arg BIN_OUTPUT=/go/bin/worker \
# --build-arg BUILDER_IMAGE=$BUILDER_IMAGE \
# --build-arg BUILD_TIME \
# --rm --cache-from $WORKER_IMAGE:$TARGET \
# -t $WORKER_IMAGE:$TARGET \
# -f deploy/docker/Dockerfile.target . >/dev/null 2>&1 && echo "Successfully tagged $WORKER_IMAGE:$TARGET"
else
# DEV
docker build \
--build-arg SVC_NAME=catalog-svc \
--build-arg SVC_VER="dev" \
--build-arg BUILDER_IMAGE=$BUILDER_IMAGE \
--build-arg BUILD_TIME \
--rm --no-cache -t $SERVER_IMAGE:$TARGET \
-f deploy/docker/Dockerfile.target . > /dev/null 2>&1 && echo "Successfully tagged $SERVER_IMAGE:$TARGET"
# WORKER
# docker build \
# --build-arg SVC_NAME=catalog-worker \
# --build-arg SVC_VER="dev" \
# --build-arg BIN_OUTPUT=/go/bin/worker \
# --build-arg BUILDER_IMAGE=$BUILDER_IMAGE \
# --build-arg BUILD_TIME \
# --rm --no-cache \
# -t $WORKER_IMAGE:$TARGET \
# -f deploy/docker/Dockerfile.target . >/dev/null 2>&1 && echo "Successfully tagged $WORKER_IMAGE:$TARGET"
fi
echo "Done."

16
deploy/scripts/image-push.sh Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/sh
# RUN IN REPO ROOT DIR !!
export IMAGE_BASE="git.ego.freeddns.org/egommerce/catalog"
export SERVER_IMAGE="$IMAGE_BASE-svc"
# export WORKER_IMAGE="$IMAGE_BASE-worker"
TARGET=${1:-latest}
echo $DOCKER_PASSWORD | docker login git.ego.freeddns.org -u $DOCKER_USERNAME --password-stdin
docker push "$SERVER_IMAGE:$TARGET"
# docker push "$WORKER_IMAGE:$TARGET"
# Restart container
# TODO

17
src/.gitignore vendored Normal file
View File

@@ -0,0 +1,17 @@
# ---> Go
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Test binary, built with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
.env
# Dependency directories (remove the comment below to include it)
vendor/

1
src/app.run Normal file
View File

@@ -0,0 +1 @@
634930

40
src/app/app.go Normal file
View File

@@ -0,0 +1,40 @@
package app
import (
"log"
"os"
"os/signal"
"syscall"
)
type App struct {
worker WorkerInterface
}
func NewApp(worker WorkerInterface) *App {
return &App{
worker: worker,
}
}
func (app *App) Start(while chan struct{}) error {
go func(while chan struct{}) {
sigint := make(chan os.Signal, 1)
signal.Notify(sigint, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
<-sigint
log.Println("Received signal:", sigint)
app.Shutdown()
close(while)
}(while)
return app.worker.Start()
}
func (app *App) Shutdown() {
app.worker.OnShutdown()
}
func (app *App) RegisterPlugin(plugin Plugin) {
app.worker.addPlugin(plugin.name, plugin.connect, &app.worker)
}

66
src/app/config.go Normal file
View File

@@ -0,0 +1,66 @@
package app
import (
"fmt"
"os"
"time"
cnf "git.ego.freeddns.org/egommerce/go-api-pkg/config"
)
const (
defName = "catalog-svc"
defNetAddr = ":443"
defDomain = "catalog-svc"
defCacheAddr = "api-cache:6379"
defCacheUsername = "default"
defCachePassword = "12345678"
defDbURL = "postgres://postgres:12345678@db-postgres:5432/egommerce"
defEventbusURL = "amqp://guest:guest@api-eventbus:5672"
defEventbusExchange = "api-events"
defEventbusQueue = "catalog-svc"
defMongoDbURL = "mongodb://mongodb:12345678@db-mongo:27017"
)
type Config struct {
ID string
Name string
Domain string
NetAddr string
IdleTimeout time.Duration // miliseconds
ReadTimeout time.Duration // miliseconds
WriteTimeout time.Duration // miliseconds
DbURL string `json:"db_url"`
CacheAddr string `json:"cache_addr"`
CacheUsername string `json:"cache_username"`
CachePassword string `json:"cache_password"`
EventbusURL string `json:"eventbus_url"`
EventbusExchange string `json:"eventbus_exchange"`
EventbusQueue string `json:"eventbus_queue"`
MongoDbUrl string `json:"mongodb_url"`
}
func NewConfig(name string) *Config {
c := new(Config)
c.ID, _ = os.Hostname()
c.Name = name
c.Domain = cnf.GetEnv("APP_DOMAIN", defDomain)
c.NetAddr = cnf.GetEnv("SERVER_ADDR", defNetAddr)
c.CacheAddr = cnf.GetEnv("API_CACHE_ADDR", defCacheAddr)
c.CacheUsername = cnf.GetEnv("API_CACHE_USERNAME", defCacheUsername)
c.CachePassword = cnf.GetEnv("API_CACHE_PASSWORD", defCachePassword)
c.DbURL = cnf.GetEnv("API_DATABASE_URL", defDbURL)
c.EventbusURL = cnf.GetEnv("API_EVENTBUS_URL", defEventbusURL)
c.EventbusQueue = defEventbusQueue // FIXME env var
c.EventbusExchange = defEventbusExchange // FIXME env var
c.MongoDbUrl = cnf.GetEnv("API_MONGO_URL", defMongoDbURL)
return c
}
func (c *Config) getAppFullName() string {
return fmt.Sprintf("%s_%s", c.Name, c.ID)
}

16
src/app/interface.go Normal file
View File

@@ -0,0 +1,16 @@
package app
type (
Application interface {
Start()
RegisterPlugin(Plugin)
Shutdown()
}
WorkerInterface interface { // its process inside Application, not RabbitMQ Worker...
Start() error
OnShutdown()
addPlugin(name string, fn PluginConnectFn, w *WorkerInterface)
}
)

166
src/app/plugins.go Normal file
View File

@@ -0,0 +1,166 @@
package app
import (
"context"
"log"
"time"
redis "github.com/go-redis/redis/v8"
"github.com/jackc/pgx/v5/pgxpool"
amqp "github.com/rabbitmq/amqp091-go"
)
type (
Plugin struct {
name string
connect PluginConnectFn
}
PluginConnectFn func(w *WorkerInterface) any // returns connection handle
)
type PluginManager struct {
plugins map[string]any
}
func NewPluginManager() *PluginManager {
return &PluginManager{
plugins: make(map[string]any),
}
}
func (pm *PluginManager) addPlugin(name string, fn PluginConnectFn, w *WorkerInterface) {
pm.plugins[name] = fn(w)
}
func (pm *PluginManager) GetCache() *redis.Client {
return (pm.plugins["cache"]).(*redis.Client)
}
func (pm *PluginManager) GetDatabase() *pgxpool.Pool {
return (pm.plugins["database"]).(*pgxpool.Pool)
}
func (pm *PluginManager) GetEventbus() *amqp.Channel {
return (pm.plugins["eventbus"]).(*amqp.Channel)
}
func CachePlugin(cnf *Config, w WorkerInterface) Plugin {
connectFn := func(w WorkerInterface) *redis.Client {
log.Println("establishing api-cache connection...")
return redis.NewClient(&redis.Options{
Addr: cnf.CacheAddr,
Username: cnf.CacheUsername,
Password: cnf.CachePassword,
DB: 0, // TODO
DialTimeout: 100 * time.Millisecond, // TODO
})
}
// checking if the connection is still alive and try to reconnect when it is not
go func(conn *redis.Client) {
tick := time.NewTicker(5 * time.Second) // is 5 seconds is not too much?
defer tick.Stop()
// for {
// select {
// case <-tick.C:
// if err := conn.Ping(context.Background()).Err(); err != nil {
// log.Println("lost connection with api-cache. Reconnecting...")
// conn = connectFn()
// }
// }
// }
for range tick.C {
if err := conn.Ping(context.Background()).Err(); err != nil {
log.Println("lost connection with api-cache. Reconnecting...")
conn = connectFn(w)
}
}
}(connectFn(w))
return Plugin{
name: "cache",
connect: func(w *WorkerInterface) any {
return connectFn(*w)
},
}
}
func DatabasePlugin(cnf *Config, w WorkerInterface) Plugin {
connectFn := func(w WorkerInterface) *pgxpool.Pool {
log.Println("establishing db-postgres connection...")
conn, err := pgxpool.New(context.Background(), cnf.DbURL)
if err != nil {
log.Printf("failed to connect to the database: %s. Err: %s\n", cnf.DbURL, err.Error())
return nil
// os.Exit(1)
}
return conn
}
// checking if the connection is still alive and try to reconnect when it is not
go func(conn *pgxpool.Pool) {
tick := time.NewTicker(5 * time.Second) // is 5 seconds is not too much?
defer tick.Stop()
for range tick.C {
if err := conn.Ping(context.Background()); err != nil {
log.Println("lost connection with db-postgres. Reconnecting...")
conn = connectFn(w)
}
}
}(connectFn(w))
return Plugin{
name: "database",
connect: func(w *WorkerInterface) any {
return connectFn(*w)
},
}
}
func EventbusPlugin(cnf *Config, w WorkerInterface) Plugin { // FIXME cant deal with two steps connection to the eventbus, replace it with Kafka which is faster and simpler
connectFn := func(w WorkerInterface) *amqp.Channel {
log.Println("establishing api-eventbus connection...")
conn, err := amqp.Dial(cnf.EventbusURL)
if err != nil {
log.Printf("failed to connect to the eventbus: %s. Err: %v\n", cnf.EventbusURL, err.Error())
return nil
}
chn, err := conn.Channel()
if err != nil {
log.Printf("failed to open new eventbus channel. Err: %v\n", err.Error())
return nil
}
return chn
}
// checking if the connection is still alive and try to reconnect when it is not
go func(chn *amqp.Channel) {
tick := time.NewTicker(5 * time.Second) // is 5 seconds is not too much?
defer tick.Stop()
for range tick.C {
if chn != nil || !chn.IsClosed() {
log.Println("lost connection with api-eventbus. Reconnecting...")
chn = connectFn(w)
}
}
}(connectFn(w))
return Plugin{
name: "eventbus",
connect: func(w *WorkerInterface) any {
return connectFn(*w)
},
}
}

45
src/app/scheduler.go Normal file
View File

@@ -0,0 +1,45 @@
package app
import (
"log"
"github.com/onatm/clockwerk"
)
type Scheduler struct {
*PluginManager
}
func NewScheduler(c *Config) *Scheduler {
return &Scheduler{
PluginManager: NewPluginManager(),
}
}
func (c *Scheduler) Start() error {
// job := NewCachePermissionsJob(c)
sch := clockwerk.New()
// sch.Every(30 * time.Minute).Do(job)
sch.Start()
return nil
}
func (c *Scheduler) OnShutdown() {
log.Println("Scheduler is going down...")
c.GetDatabase().Close()
c.GetCache().Close()
}
// func (s *Server) addPlugin(name string, fn PluginFn) {
// s.plugins[name] = fn()
// }
// func (c *Scheduler) getCache() *redis.Client {
// return (c.handlers["cache"]).(*redis.Client)
// }
// func (c *Scheduler) getDatabase() *pgxpool.Pool {
// return (c.handlers["database"]).(*pgxpool.Pool)
// }

141
src/app/server.go Normal file
View File

@@ -0,0 +1,141 @@
package app
import (
"crypto/tls"
"log"
"net"
"time"
jwt "github.com/gofiber/contrib/jwt"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/google/uuid"
commonDTO "git.ego.freeddns.org/egommerce/api-entities/common/dto"
cnf "git.ego.freeddns.org/egommerce/go-api-pkg/config"
"git.ego.freeddns.org/egommerce/catalog-service/internal/http"
)
var defaultCORS = cors.New(
cors.Config{
// DEV CONFIG
AllowOrigins: "*",
AllowMethods: "GET, POST, PATCH, PUT, DELETE, OPTIONS",
AllowHeaders: "Accept, Authorization, Content-Type, Vary, X-Request-Id",
// PROD CONFIG
// AllowOrigins: "http://egommerce.io:3001", // client(reactjs) app url
// AllowCredentials: true,
// AllowMethods: "GET, POST, PATCH, PUT, DELETE",
},
)
type (
Server struct {
*fiber.App
*PluginManager
ID string
addr string // e.g. "127.0.0.1:443"
}
)
func NewServer(c *Config) *Server {
return &Server{
ID: c.ID,
App: fiber.New(fiber.Config{
AppName: c.ID,
ServerHeader: c.getAppFullName(),
ReadTimeout: c.ReadTimeout * time.Millisecond,
WriteTimeout: c.WriteTimeout * time.Millisecond,
IdleTimeout: c.IdleTimeout * time.Millisecond,
}),
PluginManager: NewPluginManager(),
addr: c.NetAddr,
}
}
func (s *Server) Start() error {
s.setupMiddleware()
s.setupRouter()
crt, err := tls.LoadX509KeyPair("certs/catalog-svc.crt", "certs/catalog-svc.key")
if err != nil {
log.Fatal("failed to load certificates:", err)
}
tlsCnf := &tls.Config{Certificates: []tls.Certificate{crt}}
ln, _ := net.Listen("tcp", s.addr)
ln = tls.NewListener(ln, tlsCnf)
return s.Listener(ln)
}
func (s *Server) OnShutdown() {
log.Printf("Server %s is going down...", s.ID)
s.GetDatabase().Close()
s.GetEventbus().Close()
s.GetCache().Close()
s.Shutdown()
}
// func GetRequestID(c *fiber.Ctx) (string, error) {
// var hdr = new(HeaderRequestID)
// if err := c.ReqHeaderParser(hdr); err != nil {
// return "", err
// }
// return hdr.RequestID, nil
// }
func (s *Server) setupRouter() {
s.Options("*", defaultCORS)
s.Use(defaultCORS)
s.Get("/health", http.HealthHandlerFn(s.GetDatabase(), s.GetEventbus(), s.GetCache()))
s.Group("/v1").
Get("/product", http.ListProductsHandlerFn(s.GetDatabase())).
Get("/product/:id", http.ShowProductHandlerFn(s.GetDatabase()))
// Post("/product", http.AddProductHandlerFn(s.getDatabase(), s.getCache()))
// Delete("/product", http.RemoveProductFromBasketHandlerFn(s.getDatabase(), s.getCache()))
}
func (s *Server) setupMiddleware() {
s.Use(LoggingMiddleware())
s.Use(XRequestIDMiddleware())
}
func LoggingMiddleware() func(c *fiber.Ctx) error {
return func(c *fiber.Ctx) error {
log.Printf("Request: %s, remote: %s, via: %s",
c.Request().URI().String(),
c.Context().RemoteIP().String(),
string(c.Context().UserAgent()),
)
return c.Next()
}
}
func XRequestIDMiddleware() func(c *fiber.Ctx) error {
return func(c *fiber.Ctx) error {
c.Set("X-Request-ID", uuid.New().String())
return c.Next()
}
}
func JWTProtected() func(c *fiber.Ctx) error {
secret := []byte(cnf.GetEnv("JWT_ACCESS_TOKEN_SECRET_KEY", "FallbackAccessTokenSecret"))
return jwt.New(jwt.Config{
SigningKey: jwt.SigningKey{Key: secret},
ContextKey: "jwt",
ErrorHandler: func(c *fiber.Ctx, err error) error {
return c.Status(fiber.StatusUnauthorized).JSON(commonDTO.ErrorResponseDTO{Error: "unauthorized"})
},
})
}

90
src/app/worker.go Normal file
View File

@@ -0,0 +1,90 @@
package app
import (
"encoding/json"
"log"
amqp "github.com/rabbitmq/amqp091-go"
"git.ego.freeddns.org/egommerce/catalog-service/internal/cli/worker"
)
type (
CommandHandler func() error
Worker struct {
*PluginManager
queueName string
handlers map[string]CommandHandler
}
)
func NewWorker(c *Config) *Worker {
return &Worker{
PluginManager: NewPluginManager(),
queueName: c.EventbusQueue,
handlers: make(map[string]CommandHandler),
}
}
func (w *Worker) Start() error {
// fmt.Printf("eventbus: %#v", w.GetEventbus())
chn := w.GetEventbus()
// chn, err := conn.Channel()
// if err != nil {
// log.Println("failed to open eventbus channel: ", err.Error())
// }
if !chn.IsClosed() {
w.consumeCommands(chn)
}
return nil
}
func (w *Worker) OnShutdown() {
w.GetEventbus().Close()
}
func (w *Worker) consumeCommands(ch *amqp.Channel) error {
msgs, err := ch.Consume(
w.queueName,
"",
false,
false,
false,
false,
nil,
)
if err != nil {
return err
}
for d := range msgs {
var cmd map[string]any
if err := json.Unmarshal(d.Body, &cmd); err != nil {
log.Println("failed to unmarshal command - invalid body JSON")
continue
}
if cmdName, ok := cmd["id"].(string); ok {
switch cmdName {
case "TestCommand":
var testCmd worker.TestCommand
if err := json.Unmarshal(d.Body, &testCmd); err == nil {
go func() { // FIXME - worries about concurency issues...
if err := testCmd.Handle(); err == nil {
d.Ack(false) // manual ACK
} else {
log.Println(err.Error())
}
}()
}
}
}
}
return nil
}

39
src/cmd/health/main.go Normal file
View File

@@ -0,0 +1,39 @@
package main
import (
"flag"
"fmt"
"os"
)
const usageText = `This program runs healthcheck on the app.
Usage:
go run cmd/health/main.go
`
func init() {
flag.Usage = func() {
fmt.Print(usageText)
flag.PrintDefaults()
os.Exit(2)
}
flag.Parse()
}
func main() {
var exitCode = 1
if isOk := healthCheck(); isOk {
exitCode = 0
}
os.Exit(exitCode)
}
func healthCheck() bool {
run, err := os.Open("./app.run")
if err != nil {
return false
}
defer run.Close()
return true
}

73
src/cmd/migrate/main.go Normal file
View File

@@ -0,0 +1,73 @@
package main
import (
"flag"
"fmt"
"log"
"os"
"github.com/go-pg/migrations/v8"
"github.com/go-pg/pg/v10"
cnf "git.ego.freeddns.org/egommerce/go-api-pkg/config"
)
const (
defMigrationsTableName = "catalog.migrations"
)
const usageText = `This program runs command on the db. Supported commands are:
- init - creates version info table in the database
- up - runs all available migrations.
- up [target] - runs available migrations up to the target one.
- down - reverts last migration.
- reset - reverts all migrations.
- version - prints current db version.
- set_version [version] - sets db version without running migrations.
Usage:
go run cmd/migrate/main.go <command> [args]
`
func main() {
flag.Usage = func() {
fmt.Print(usageText)
flag.PrintDefaults()
os.Exit(2)
}
flag.Parse()
if cnf.ErrLoadingEnvs != nil {
log.Panicln(cnf.ErrLoadingEnvs)
}
// c := cnf.NewConfig("catalog-migrator")
// dbURL := baseCnf.GetEnv("DATABASE_URL", defDbURL)
db := pg.Connect(&pg.Options{ // FIXME
Addr: "postgres-db:5432",
User: "postgres",
Password: "12345678",
Database: "egommerce",
})
defer db.Close()
mTbl := cnf.GetEnv("MIGRATIONS_TABLE_NAME", defMigrationsTableName)
mig := migrations.NewCollection()
mig.SetTableName(mTbl)
if err := mig.DiscoverSQLMigrations("./migrations"); err != nil {
log.Printf("migration dicovery error: %#v\n", err)
}
oldVersion, newVersion, err := mig.Run(db, flag.Args()...)
if err != nil {
log.Printf("migration runner error: %#v", err)
os.Exit(1)
}
if newVersion != oldVersion {
log.Printf("migrated from version %d to %d\n", oldVersion, newVersion)
} else {
log.Printf("version is %d\n", oldVersion)
}
os.Exit(0)
}

34
src/cmd/scheduler/main.go Normal file
View File

@@ -0,0 +1,34 @@
package main
import (
"log"
"os"
cnf "git.ego.freeddns.org/egommerce/go-api-pkg/config"
"git.ego.freeddns.org/egommerce/catalog-service/app"
)
func main() {
if cnf.ErrLoadingEnvs != nil {
log.Panicln(cnf.ErrLoadingEnvs)
}
cnf := app.NewConfig("catalog-scheduler")
srv := app.NewScheduler(cnf)
a := app.NewApp(srv)
a.RegisterPlugin(app.CachePlugin(cnf, srv))
a.RegisterPlugin(app.DatabasePlugin(cnf, srv))
a.RegisterPlugin(app.EventbusPlugin(cnf, srv))
while := make(chan struct{})
err := a.Start(while)
<-while
if err != nil {
log.Fatalf("failed to run scheduler. Reason: %v\n", err)
os.Exit(1)
}
os.Exit(0)
}

33
src/cmd/server/main.go Normal file
View File

@@ -0,0 +1,33 @@
package main
import (
"log"
"os"
cnf "git.ego.freeddns.org/egommerce/go-api-pkg/config"
"git.ego.freeddns.org/egommerce/catalog-service/app"
)
func main() {
if cnf.ErrLoadingEnvs != nil {
log.Panicln(cnf.ErrLoadingEnvs.Error())
}
cnf := app.NewConfig("catalog-svc")
srv := app.NewServer(cnf)
a := app.NewApp(srv)
a.RegisterPlugin(app.CachePlugin(cnf, srv))
a.RegisterPlugin(app.DatabasePlugin(cnf, srv))
a.RegisterPlugin(app.EventbusPlugin(cnf, srv))
while := make(chan struct{})
err := a.Start(while)
<-while
if err != nil {
log.Fatalf("failed to start server. reason: %v\n", err)
}
os.Exit(0)
}

34
src/cmd/worker/main.go Normal file
View File

@@ -0,0 +1,34 @@
package main
import (
"log"
"os"
cnf "git.ego.freeddns.org/egommerce/go-api-pkg/config"
"git.ego.freeddns.org/egommerce/catalog-service/app"
)
func main() {
if cnf.ErrLoadingEnvs != nil {
log.Fatalln("error loading .env file.")
}
cnf := app.NewConfig("catalog-worker")
srv := app.NewWorker(cnf)
a := app.NewApp(srv)
a.RegisterPlugin(app.CachePlugin(cnf, srv))
a.RegisterPlugin(app.DatabasePlugin(cnf, srv))
a.RegisterPlugin(app.EventbusPlugin(cnf, srv))
while := make(chan struct{})
err := a.Start(while)
<-while
if err != nil {
log.Fatalf("failed to start worker. Reason: %v\n", err)
os.Exit(1)
}
os.Exit(0)
}

56
src/go.mod Normal file
View File

@@ -0,0 +1,56 @@
module git.ego.freeddns.org/egommerce/catalog-service
go 1.24.0
toolchain go1.24.1
require (
git.ego.freeddns.org/egommerce/api-entities v0.3.36
git.ego.freeddns.org/egommerce/go-api-pkg v0.5.3
github.com/georgysavva/scany/v2 v2.1.4
github.com/go-pg/migrations/v8 v8.1.0
github.com/go-pg/pg/v10 v10.15.0
github.com/go-redis/redis/v8 v8.11.5
github.com/gofiber/contrib/jwt v1.1.2
github.com/gofiber/fiber/v2 v2.52.9
github.com/google/uuid v1.6.0
github.com/jackc/pgx/v5 v5.7.6
github.com/onatm/clockwerk v1.1.0
github.com/rabbitmq/amqp091-go v1.10.0
)
require (
github.com/MicahParks/keyfunc/v2 v2.1.0 // indirect
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-pg/zerochecker v0.2.0 // indirect
github.com/golang-jwt/jwt/v5 v5.2.2 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/joho/godotenv v1.5.1 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lib/pq v1.10.2 // 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.16 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.52.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
github.com/vmihailenco/bufpool v0.1.11 // indirect
github.com/vmihailenco/msgpack/v5 v5.3.4 // indirect
github.com/vmihailenco/tagparser v0.1.2 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
golang.org/x/crypto v0.43.0 // indirect
golang.org/x/sync v0.17.0 // indirect
golang.org/x/sys v0.37.0 // indirect
golang.org/x/text v0.30.0 // indirect
mellium.im/sasl v0.3.1 // indirect
)

260
src/go.sum Normal file
View File

@@ -0,0 +1,260 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
git.ego.freeddns.org/egommerce/api-entities v0.3.36 h1:vqIR7CCcRmO7xBpRUnmQuF0DlXozpbBf5w7ud62otvw=
git.ego.freeddns.org/egommerce/api-entities v0.3.36/go.mod h1:IqynARw+06GOm4eZGZuepmbi7bUxWBnOB4jd5cI7jf8=
git.ego.freeddns.org/egommerce/go-api-pkg v0.5.3 h1:so+OWWVJEg6JZ5XOSmCpfW7Pd7IL6ETH0QsC6zCwndo=
git.ego.freeddns.org/egommerce/go-api-pkg v0.5.3/go.mod h1:T3ia8iprzlTRznPVXYCgEzQb/1UvIcdn9FHabE58vy0=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/MicahParks/keyfunc/v2 v2.1.0 h1:6ZXKb9Rp6qp1bDbJefnG7cTH8yMN1IC/4nf+GVjO99k=
github.com/MicahParks/keyfunc/v2 v2.1.0/go.mod h1:rW42fi+xgLJ2FRRXAfNx9ZA8WpD4OeE/yHVMteCkw9k=
github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M=
github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cockroachdb/cockroach-go/v2 v2.2.0 h1:/5znzg5n373N/3ESjHF5SMLxiW4RKB05Ql//KWfeTFs=
github.com/cockroachdb/cockroach-go/v2 v2.2.0/go.mod h1:u3MiKYGupPPjkn3ozknpMUpxPaNLTFWAya419/zv6eI=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/georgysavva/scany/v2 v2.1.4 h1:nrzHEJ4oQVRoiKmocRqA1IyGOmM/GQOEsg9UjMR5Ip4=
github.com/georgysavva/scany/v2 v2.1.4/go.mod h1:fqp9yHZzM/PFVa3/rYEC57VmDx+KDch0LoqrJzkvtos=
github.com/go-pg/migrations/v8 v8.1.0 h1:bc1wQwFoWRKvLdluXCRFRkeaw9xDU4qJ63uCAagh66w=
github.com/go-pg/migrations/v8 v8.1.0/go.mod h1:o+CN1u572XHphEHZyK6tqyg2GDkRvL2bIoLNyGIewus=
github.com/go-pg/pg/v10 v10.4.0/go.mod h1:BfgPoQnD2wXNd986RYEHzikqv9iE875PrFaZ9vXvtNM=
github.com/go-pg/pg/v10 v10.15.0 h1:6DQwbaxJz/e4wvgzbxBkBLiL/Uuk87MGgHhkURtzx24=
github.com/go-pg/pg/v10 v10.15.0/go.mod h1:FIn/x04hahOf9ywQ1p68rXqaDVbTRLYlu4MQR0lhoB8=
github.com/go-pg/zerochecker v0.2.0 h1:pp7f72c3DobMWOb2ErtZsnrPaSvHd2W4o9//8HtF4mU=
github.com/go-pg/zerochecker v0.2.0/go.mod h1:NJZ4wKL0NmTtz0GKCoJ8kym6Xn/EQzXRl2OnAe7MmDo=
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
github.com/gofiber/contrib/jwt v1.1.2 h1:GmWnOqT4A15EkA8IPXwSpvNUXZR4u5SMj+geBmyLAjs=
github.com/gofiber/contrib/jwt v1.1.2/go.mod h1:CpIwrkUQ3Q6IP8y9n3f0wP9bOnSKx39EDp2fBVgMFVk=
github.com/gofiber/fiber/v2 v2.52.9 h1:YjKl5DOiyP3j0mO61u3NTmK7or8GzzWzCFzkboyP5cw=
github.com/gofiber/fiber/v2 v2.52.9/go.mod h1:YEcBbO/FB+5M1IZNBP9FO3J9281zgPAreiI1oqg8nDw=
github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw=
github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU=
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
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/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
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/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgx/v5 v5.7.6 h1:rWQc5FwZSPX58r1OQmkuaNicxdmExaEz5A2DO2hUuTk=
github.com/jackc/pgx/v5 v5.7.6/go.mod h1:aruU7o91Tc2q2cFp5h4uP3f6ztExVpyVv88Xl/8Vl8M=
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
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.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
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.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=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
github.com/onatm/clockwerk v1.1.0 h1:Ig2tTdZGtYWM1n5sDcf/LZ9zKe5l569G8jIPejHS0DM=
github.com/onatm/clockwerk v1.1.0/go.mod h1:9R0U2KkwobOCqRvPtIAt0qHgaCWbo3kjvySmmMth2Ao=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
github.com/onsi/ginkgo v1.14.2/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc=
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/rabbitmq/amqp091-go v1.10.0 h1:STpn5XsHlHGcecLmMFCtg7mqq0RnD+zFr4uzukfVhBw=
github.com/rabbitmq/amqp091-go v1.10.0/go.mod h1:Hy4jKW5kQART1u+JkDTF9YYOQUHXqMuhrgxOEeS7G4o=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
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/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc h1:9lRDQMhESg+zvGYmW5DyG0UqvY96Bu5QYsTLvCHdrgo=
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc/go.mod h1:bciPuU6GHm1iF1pBvUfxfsH0Wmnc2VbpgvbI9ZWuIRs=
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.52.0 h1:wqBQpxH71XW0e2g+Og4dzQM8pk34aFYlA1Ga8db7gU0=
github.com/valyala/fasthttp v1.52.0/go.mod h1:hf5C4QnVMkNXMspnsUlfM3WitlgYflyhHYoKol/szxQ=
github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8=
github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc=
github.com/vmihailenco/bufpool v0.1.11 h1:gOq2WmBrq0i2yW5QJ16ykccQ4wH9UyEsgLm6czKAd94=
github.com/vmihailenco/bufpool v0.1.11/go.mod h1:AFf/MOy3l2CFTKbxwt0mp2MwnqjNEs5H/UxrkA5jxTQ=
github.com/vmihailenco/msgpack/v4 v4.3.11/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4=
github.com/vmihailenco/msgpack/v5 v5.0.0-beta.1/go.mod h1:xlngVLeyQ/Qi05oQxhQ+oTuqa03RjMwMfk/7/TCs+QI=
github.com/vmihailenco/msgpack/v5 v5.3.4 h1:qMKAwOV+meBw2Y8k9cVwAy7qErtYCwBzZ2ellBfvnqc=
github.com/vmihailenco/msgpack/v5 v5.3.4/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc=
github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
github.com/vmihailenco/tagparser v0.1.2 h1:gnjoVuB/kljJ5wICEEOpx98oXMWPLj22G67Vbd1qPqc=
github.com/vmihailenco/tagparser v0.1.2/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
go.opentelemetry.io/otel v0.13.0/go.mod h1:dlSNewoRYikTkotEnxdmuBHgzT+k/idJSfDv/FxEnOY=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.43.0 h1:dduJYIi3A3KOfdGOHX8AVZ/jGiyPa3IbBozJ5kNuE04=
golang.org/x/crypto v0.43.0/go.mod h1:BFbav4mRNlXJL4wNeejLpWxB7wMbc79PdRGhWKncxR0=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201016165138-7b1cca2348c0/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.45.0 h1:RLBg5JKixCy82FtLJpeNlVM0nrSqpCRYzVU1n8kj0tM=
golang.org/x/net v0.45.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201017003518-b09fb700fbb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
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.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k=
golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
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.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
mellium.im/sasl v0.2.1/go.mod h1:ROaEDLQNuf9vjKqE1SrAfnsobm2YKXT1gnN1uDp1PjQ=
mellium.im/sasl v0.3.1 h1:wE0LW6g7U83vhvxjC1IY8DnXM+EU095yeo8XClvCdfo=
mellium.im/sasl v0.3.1/go.mod h1:xm59PUYpZHhgQ9ZqoJ5QaCqzWMi8IeS49dhp6plPCzw=

View File

@@ -0,0 +1,11 @@
package repository
import entity "git.ego.freeddns.org/egommerce/api-entities/catalog/entity"
type ProductRepositoryInterface interface {
FindAll() ([]entity.Product, error)
FindByID(id string) (*entity.Product, error)
Create(user *entity.Product) (string, error)
Update(user *entity.Product) (*entity.Product, error)
Delete(id int64) (bool, error)
}

View File

@@ -0,0 +1,67 @@
package repository
import (
"context"
"errors"
entity "git.ego.freeddns.org/egommerce/api-entities/catalog/entity"
"github.com/georgysavva/scany/v2/pgxscan"
"github.com/jackc/pgx/v5/pgxpool"
)
type ProductRepository struct {
db *pgxpool.Pool
}
func NewProductRepository(db *pgxpool.Pool) *ProductRepository {
return &ProductRepository{db}
}
func (r *ProductRepository) FindAll() ([]entity.Product, error) {
products := []entity.Product{}
sql := `SELECT id, name, slug, price, created_at, updated_at FROM catalog.product`
rows, err := r.db.Query(context.Background(), sql)
if err != nil {
return nil, err
}
if err := pgxscan.ScanAll(&products, rows); err != nil {
return nil, err
}
return products, nil
}
func (r *ProductRepository) FindByID(id string) (*entity.Product, error) {
product := new(entity.Product)
sql := `SELECT id, name, slug, price, created_at, updated_at FROM catalog.product WHERE id=$1`
err := pgxscan.Get(context.Background(), r.db, product, sql, id)
if err != nil {
return nil, err
}
return product, nil
}
func (r *ProductRepository) Create(product *entity.Product) (string, error) {
var id string
sql := `INSERT INTO catalog.product(name, slug, price) VALUES($1, $2, $3) LIMIT 1 RETURNING id`
err := r.db.QueryRow(context.Background(), sql, product.Name, product.Slug, product.Price).Scan(&id)
if err != nil {
return "", errors.New("db error: " + err.Error())
}
return id, nil
}
func (r *ProductRepository) Update(product *entity.Product) (*entity.Product, error) {
return &entity.Product{}, nil
}
func (r *ProductRepository) Delete(id int64) (bool, error) {
return true, nil
}

View File

@@ -0,0 +1,6 @@
package worker
type Command interface {
Name() string
Handle() error
}

View File

@@ -0,0 +1,23 @@
package worker
import (
"log"
"time"
)
type TestCommand struct {
ID string `json:"id"`
Data map[string]any // json object
}
func (c TestCommand) Name() string {
return "TestCommand"
}
func (c TestCommand) Handle() error {
log.Printf("processing command by the new way: %v", c.Data)
time.Sleep(5 * time.Second)
log.Printf("done... %s", c.ID)
return nil
}

View File

@@ -0,0 +1,20 @@
package event
const (
EVENT_PRODUCT_ADDED_TO_BASKET = "event.ProductAddedToBasket"
EVENT_PRODUCT_REMOVED_FROM_BASKET = "event.ProductRemovedFromBasket"
)
type ProductAddedToBasket struct {
*Event
ProductID int `json:"product_id"`
Quantity int `json:"quantity"`
BasketID string `json:"basket_id"`
}
type ProductRemovedFromBasket struct {
*Event
ProductID int `json:"product_id"`
Quantity int `json:"quantity"`
BasketID string `json:"basket_id"`
}

View File

@@ -0,0 +1,14 @@
package event
type Event struct {
Command string `json:"command"`
RequestID string `json:"request_id"`
}
func NewEvent(command, reqID string) *Event {
em := new(Event)
em.Command = command
em.RequestID = reqID
return em
}

View File

@@ -0,0 +1,11 @@
package event
const (
EVENT_WAREHOUSE_STOCK_UPDATED = "event.WarehouseStockUpdatedEvent"
)
type WarehouseStockUpdatedEvent struct {
*Event
ProductID string `json:"product_id"`
NewQty int `json:"new_qty"`
}

View File

@@ -0,0 +1,28 @@
package http
// import (
// "github.com/gofiber/fiber/v2"
// dto "git.ego.freeddns.org/egommerce/api-entities/catalog/dto"
// "git.ego.freeddns.org/egommerce/catalog-service/infra/repository"
// "git.ego.freeddns.org/egommerce/catalog-service/internal/service"
// "git.ego.freeddns.org/egommerce/catalog-service/internal/ui"
// )
// func AddProductHandlerFn(c *fiber.Ctx) error {
// req := new(dto.AddProductRequestDTO) // bad DTo should be sth like dto.AddProductRequestDTO // adding product not product to the basket...
// if err := c.BodyParser(req); err != nil {
// return s.Error(c, fiber.StatusBadRequest, "error parsing input: "+err.Error())
// }
// productRepo := repository.NewProductRepository(s.GetDatabase())
// catalogSrv := service.NewCatalogService(productRepo, s.getEventbus())
// res, err := ui.NewAddToBasketActionUI(catalogSrv).Execute(req)
// if err != nil {
// return s.Error(c, fiber.StatusBadRequest, "unable to add product to the basket")
// }
// return c.JSON(res)
// }

View File

@@ -0,0 +1,35 @@
package http
import (
"context"
redis "github.com/go-redis/redis/v8"
"github.com/gofiber/fiber/v2"
"github.com/jackc/pgx/v5/pgxpool"
amqp "github.com/rabbitmq/amqp091-go"
)
type HealthResponse struct {
Status string `json:"status,omitempty"`
}
func HealthHandlerFn(db *pgxpool.Pool, bus *amqp.Channel, cache *redis.Client) fiber.Handler {
return func(c *fiber.Ctx) error {
// Only 404 indicate service as not-healthy
if err := db.Ping(context.Background()); err != nil {
return c.SendStatus(fiber.StatusNotFound)
}
if closed := bus.IsClosed(); closed {
return c.SendStatus(fiber.StatusNotFound)
}
if err := cache.Ping(context.Background()).Err(); err != nil {
return c.SendStatus(fiber.StatusNotFound)
}
return c.JSON(&HealthResponse{
Status: "OK",
})
}
}

View File

@@ -0,0 +1,83 @@
package http
import (
"github.com/gofiber/fiber/v2"
"github.com/jackc/pgx/v5/pgxpool"
commonDTO "git.ego.freeddns.org/egommerce/api-entities/common/dto"
"git.ego.freeddns.org/egommerce/catalog-service/infra/repository"
"git.ego.freeddns.org/egommerce/catalog-service/internal/ui"
)
func ListProductsHandlerFn(db *pgxpool.Pool) fiber.Handler {
return func(c *fiber.Ctx) error {
productRepo := repository.NewProductRepository(db)
// time.Sleep(time.Duration(2 * time.Second)) // for frontend dev tests
products, err := ui.NewListProductsActionUI(productRepo).Execute()
if err != nil {
return c.Status(fiber.StatusNotFound).JSON(&commonDTO.ErrorResponseDTO{Error: err.Error()})
}
return c.JSON(products)
}
}
// func (s *Server) AddProductToBasketHandlerFn(c *fiber.Ctx) error {
// reqID, _ := s.GetRequestID(c)
// req := new(dto.AddProductToBasketRequestDTO)
// if err := c.BodyParser(req); err != nil {
// return s.Error(c, fiber.StatusBadRequest, err.Error())
// }
// basketID := prepareBasket(c)
// qty := 1
// if req.Quantity != 0 {
// qty = req.Quantity
// }
// catalogSrv := service.NewCatalogService(s.GetDatabase(), s.getEventbus())
// res, err := ui.AddProductToBasket(catalogSrv, req.ProductID, qty, basketID, reqID)
// if err != nil {
// // s.GetLogger().Log("AddProductToBasketHandler error: ", err)
// if res.ProductID == 0 {
// return s.Error(c, fiber.StatusNotFound, fmt.Sprintf("Product #%d not exists", req.ProductID))
// }
// return s.Error(c, fiber.StatusBadRequest, "failed to add product to the basket")
// }
// return c.JSON(res)
// }
// func (s *Server) RemoveProductFromBasketHandlerFn(c *fiber.Ctx) error {
// reqID, _ := s.GetRequestID(c)
// req := new(dto.RemoveProductFromBasketRequestDTO)
// if err := c.BodyParser(req); err != nil {
// return s.Error(c, fiber.StatusBadRequest, err.Error())
// }
// basketID := prepareBasket(c)
// qty := 1
// if req.Quantity != 0 {
// qty = req.Quantity
// }
// catalogSrv := service.NewCatalogService(s.GetDatabase(), s.getEventbus())
// res, err := ui.RemoveProductFromBasket(catalogSrv, req.ProductID, qty, basketID, reqID)
// if err != nil {
// return s.Error(c, 400, "Failed to remove product from the basket")
// }
// return c.JSON(res)
// }
// func prepareBasket(c *fiber.Ctx) string { // TODO: Remove ASAP
// basketID := c.Cookies(service.BasketIdCookieName)
// if len(basketID) == 0 {
// basketID = uuid.New().String()
// c.Cookie(&fiber.Cookie{Name: service.BasketIdCookieName, Value: basketID})
// }
// return basketID
// }

View File

@@ -0,0 +1,30 @@
package http
import (
"github.com/gofiber/fiber/v2"
"github.com/jackc/pgx/v5/pgxpool"
commonDTO "git.ego.freeddns.org/egommerce/api-entities/common/dto"
"git.ego.freeddns.org/egommerce/catalog-service/infra/repository"
"git.ego.freeddns.org/egommerce/catalog-service/internal/ui"
)
func ShowProductHandlerFn(db *pgxpool.Pool) fiber.Handler {
return func(c *fiber.Ctx) error {
// req := new(dto.GetProductRequestDTO)
// if err := c.BodyParser(req); err != nil {
// return s.Error(c, fiber.StatusBadRequest, "error parsing input")
// }
id := c.Params("id")
productRepo := repository.NewProductRepository(db)
product, err := ui.NewShowProductActionUI(productRepo).Execute(id)
if err != nil {
return c.Status(fiber.StatusNotFound).JSON(&commonDTO.ErrorResponseDTO{Error: err.Error()})
}
return c.JSON(product)
}
}

View File

@@ -0,0 +1,16 @@
package service
import (
"git.ego.freeddns.org/egommerce/catalog-service/infra/repository"
amqp "github.com/rabbitmq/amqp091-go"
)
type CatalogService struct {
productRepo *repository.ProductRepository
ebCh *amqp.Channel
}
func NewCatalogService(productRepo *repository.ProductRepository, chn *amqp.Channel) *CatalogService {
return &CatalogService{productRepo, chn}
}

View File

@@ -0,0 +1,32 @@
package ui
// type AddProductActionUI struct {
// catalogSrv *service.CatalogService
// }
// func NewAddToBasketActionUI(catalogSrv *service.CatalogService) *AddProductActionUI {
// return &AddProductActionUI{catalogSrv: catalogSrv}
// }
// func (ui *AddProductActionUI) Execute(req *catalogDTO.AddProductRequestDTO) (catalogEntity.Product, error) {
// log.Printf("Adding product: #%s", req.Name)
// // msg := &event.ProductAddedToBasket{ // FIXME:move level up (ui)??
// // Event: event.NewEvent("AddProductToBasket", reqID),
// // BasketID: basketID,
// // ProductID: productID,
// // Quantity: qty,
// // }
// // rabbitmq.Publish(s.ebCh, "api-events", "catalog.basket.productAddedToBasket", msg)
// // rabbitmq.Publish(s.ebCh, "api-events", "catalog.warehouse.productAddedToBasket", msg)
// res := catalogEntity.Product{ // TMP
// ID: "123-456-789-000",
// Name: "Test oroduct name",
// Slug: "slug-short-url",
// Price: 120,
// CreatedAt: time.Now(),
// }
// return res, nil
// }

View File

@@ -0,0 +1 @@
package ui

View File

@@ -0,0 +1,24 @@
package ui
import (
catalogEntity "git.ego.freeddns.org/egommerce/api-entities/catalog/entity"
"git.ego.freeddns.org/egommerce/catalog-service/infra/repository"
)
type ListProductsActionUI struct {
repo repository.ProductRepositoryInterface
}
func NewListProductsActionUI(repo repository.ProductRepositoryInterface) *ListProductsActionUI {
return &ListProductsActionUI{repo: repo}
}
func (ui *ListProductsActionUI) Execute() ([]catalogEntity.Product, error) {
products, err := ui.repo.FindAll() // FIXME Add Sorting and filtering?
if err != nil {
return nil, err
}
return products, nil
}

View File

@@ -0,0 +1,24 @@
package ui
import (
catalogEntity "git.ego.freeddns.org/egommerce/api-entities/catalog/entity"
"git.ego.freeddns.org/egommerce/catalog-service/infra/repository"
)
type ShowProductActionUI struct {
repo repository.ProductRepositoryInterface
}
func NewShowProductActionUI(repo repository.ProductRepositoryInterface) *ShowProductActionUI {
return &ShowProductActionUI{repo: repo}
}
func (ui *ShowProductActionUI) Execute(id string) (*catalogEntity.Product, error) {
product, err := ui.repo.FindByID(id)
if err != nil {
return nil, err
}
return product, nil
}