Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/MIDAZ-288 #292

Merged
merged 42 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
d9246bf
fix: standardize telemetry and logger shutdown in ledger and transact…
qnen Nov 21, 2024
3cf681d
fix: update wire gen with standardize telemetry shutdown in ledger gr…
qnen Nov 21, 2024
0165a7c
feat: add base to the swagger documentation and telemetry root span h…
qnen Nov 21, 2024
aaf0d29
chore: update codeowners group names :wrench:
qnen Nov 22, 2024
7597ac2
feat: update swagger documentation base using envs and generate docs …
qnen Nov 22, 2024
65ea499
feat: add swagger documentation to onboarding context on ledger servi…
qnen Nov 22, 2024
fad4b08
feat: add swagger documentation to the portfolio context on ledger se…
qnen Nov 22, 2024
cef9e22
feat: add swagger documentation generated for ledger :sparkles:
qnen Nov 22, 2024
269b5c1
refactor: change ledger architecture :hammer:
MartinezAvellan Nov 22, 2024
1a2c76e
fix: make lint :bug:
MartinezAvellan Nov 22, 2024
fe491ef
chore(release): update version in .env.example to v1.29.0
lerian-studio Nov 22, 2024
fcd6d6b
feat: update architecture final stage :sparkles:
MartinezAvellan Nov 22, 2024
9c2ffc5
feat: add swagger documentation generated for transaction :sparkles:
qnen Nov 22, 2024
ef13013
fix: adjust makefile remove wire. :bug:
MartinezAvellan Nov 22, 2024
1d14e3c
refactor: metadata and mongodb :hammer:
MartinezAvellan Nov 23, 2024
a215250
refactor: server and config :hammer:
MartinezAvellan Nov 23, 2024
fe1e078
refactor: redis :hammer:
MartinezAvellan Nov 23, 2024
ca2e217
refactor: rabbitmq :hammer:
MartinezAvellan Nov 23, 2024
cbe3779
refactor: move files from up directory :hammer:
MartinezAvellan Nov 23, 2024
3cca3f8
refactor: organization :hammer:
MartinezAvellan Nov 23, 2024
660907b
refactor: ledger :hammer:
MartinezAvellan Nov 23, 2024
325a14e
refactor: asset :hammer:
MartinezAvellan Nov 23, 2024
ceae9dc
refactor: product :hammer:
MartinezAvellan Nov 23, 2024
c0c9d25
refactor: portfolio :hammer:
MartinezAvellan Nov 23, 2024
70e37ff
refactor: account :hammer:
MartinezAvellan Nov 23, 2024
ac9f3eb
refactor: update import names :hammer:
MartinezAvellan Nov 23, 2024
36b62d4
fix: lint :bug:
MartinezAvellan Nov 23, 2024
cbecfbc
Merge remote-tracking branch 'origin/feature/adding-repobeats-activit…
MartinezAvellan Nov 25, 2024
837637e
Merge remote-tracking branch 'origin/feature/MIDAZ-265' into feature/…
MartinezAvellan Nov 25, 2024
8bb5853
fix: fix merge with two others repos :bug:
MartinezAvellan Nov 25, 2024
d417fe2
fix: update with lint warning :bug:
MartinezAvellan Nov 25, 2024
c0d1d14
fix: update imports :bug:
MartinezAvellan Nov 25, 2024
125cfc7
fix: update imports names :bug:
MartinezAvellan Nov 25, 2024
80a0206
fix: reorganize imports :bug:
MartinezAvellan Nov 25, 2024
9e501c4
fix: update erros and imports :bug:
MartinezAvellan Nov 25, 2024
348e2a4
Merge branch 'develop' into feature/MIDAZ-288
MartinezAvellan Nov 25, 2024
a4f2e32
Revert "feat: add swagger documentation generated for transaction :sp…
qnen Nov 25, 2024
dbdfcf5
feat: adjust small issues from swagger docs :sparkles:
qnen Nov 25, 2024
bce4111
fix: adjust lint issues :bug:
qnen Nov 25, 2024
26ca506
Merge remote-tracking branch 'origin/feature/MIDAZ-265' into feature/…
MartinezAvellan Nov 25, 2024
ad73b11
fix: merge MIDAZ-265 :bug:
MartinezAvellan Nov 25, 2024
4847ffd
fix: update make file :bug:
MartinezAvellan Nov 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion common/mopentelemetry/otel.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package mopentelemetry

import (
"context"
"os"

"github.com/LerianStudio/midaz/common"
"github.com/LerianStudio/midaz/common/constant"
"github.com/LerianStudio/midaz/common/mlog"
Expand All @@ -21,7 +23,6 @@ import (
semconv "go.opentelemetry.io/otel/semconv/v1.26.0"
"go.opentelemetry.io/otel/trace"
"google.golang.org/grpc/metadata"
"os"
)

type Telemetry struct {
Expand Down
55 changes: 55 additions & 0 deletions components/ledger_two/.air.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Config file for [Air](https://github.com/cosmtrek/air) in TOML format

# Working directory
# . or absolute path, please note that the directories following must be under root.
root = "."
tmp_dir = "cmd/tmp"

[build]
# Just plain old shell command. You could use `make` as well.
cmd = "go build -o ./cmd/tmp/main ./cmd/app"
# Binary file yields from `cmd`.
bin = "cmd/tmp/main"
# Customize binary, can setup environment variables when run your app.
full_bin = "APP_ENV=develop APP_USER=air ./cmd/tmp/main"
# Watch these filename extensions.
include_ext = ["go", "tpl", "tmpl", "html"]
# Ignore these filename extensions or directories.
exclude_dir = ["assets", "tmp", "vendor", "frontend/node_modules"]
# Watch these directories if you specified.
include_dir = []
# Exclude files.
exclude_file = []
# Exclude specific regular expressions.
exclude_regex = ["_test\\.go"]
# Exclude unchanged files.
exclude_unchanged = true
# Follow symlink for directories
follow_symlink = true
# This log file places in your tmp_dir.
log = "air.log"
# It's not necessary to trigger build each time file changes if it's too frequent.
delay = 1000 # ms
# Stop running old binary when build errors occur.
stop_on_error = true
# Send Interrupt signal before killing process (windows does not support this feature)
send_interrupt = false
# Delay after sending Interrupt signal
kill_delay = 500 # ms
# Add additional arguments when running binary (bin/full_bin). Will run './tmp/main hello world'.
args_bin = ["hello", "world"]

[log]
# Show log time
time = false

[color]
# Customize each part's color. If no color found, use the raw app log.
main = "magenta"
watcher = "cyan"
build = "yellow"
runner = "green"

[misc]
# Delete tmp directory on exit
clean_on_exit = true
69 changes: 69 additions & 0 deletions components/ledger_two/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# DEFAULT local
# ENV_NAME=production

# APP
VERSION=1.21.0
SERVER_PORT=3000
SERVER_ADDRESS=:${SERVER_PORT}

# PROTOBUF
PROTO_URL=localhost
PROTO_PORT=3001
PROTO_ADDRESS=:${PROTO_PORT}

# DB POSTGRESQL PRIMARY AND REPLICA
DB_HOST=primary-ledger
DB_USER=midaz
DB_NAME=ledger
DB_PASSWORD=lerian
DB_PORT=5701

DB_REPLICA_HOST=replica-ledger
DB_REPLICA_USER=midaz
DB_REPLICA_NAME=ledger
DB_REPLICA_PASSWORD=lerian
DB_REPLICA_PORT=5702

# MONGO DB
MONGO_HOST=mongodb
MONGO_NAME=ledger
MONGO_USER=midaz
MONGO_PASSWORD=lerian
MONGO_PORT=5703

# REDIS
REDIS_HOST=redis
REDIS_PORT=5704
REDIS_USER=midaz
REDIS_PASSWORD=lerian

# LOG LEVEL
LOG_LEVEL=debug

# CASDOOR
CASDOOR_PORT=8080
CASDOOR_ADDRESS=http://casdoor:${CASDOOR_PORT}
CASDOOR_CLIENT_ID=9670e0ca55a29a466d31
CASDOOR_CLIENT_SECRET=dd03f916cacf4a98c6a413d9c38ba102dce436a9
CASDOOR_ORGANIZATION_NAME=lerian
CASDOOR_APPLICATION_NAME=app-midaz
CASDOOR_ENFORCER_NAME=lerian-enforcer
CASDOOR_JWK_ADDRESS=${CASDOOR_ADDRESS}/.well-known/jwks

# OPEN TELEMETRY
OTEL_RESOURCE_SERVICE_NAME=ledger
OTEL_LIBRARY_NAME=github.com/LerianStudio/midaz/components/ledger
OTEL_RESOURCE_SERVICE_VERSION=${VERSION}
OTEL_RESOURCE_DEPLOYMENT_ENVIRONMENT=${ENV_NAME}
OTEL_EXPORTER_OTLP_ENDPOINT_PORT=4317
OTEL_EXPORTER_OTLP_ENDPOINT=otel-lgtm:${OTEL_EXPORTER_OTLP_ENDPOINT_PORT}

# RABBITMQ
RABBITMQ_HOST=rabbitmq
RABBITMQ_PORT_HOST=5672
RABBITMQ_PORT_AMPQ=15672
RABBITMQ_DEFAULT_USER=ledger
RABBITMQ_DEFAULT_PASS=lerian
RABBITMQ_EXCHANGE=transaction_operations_exchange
RABBITMQ_KEY=transaction_operations_key
RABBITMQ_QUEUE=ledger_accounts_queue
18 changes: 18 additions & 0 deletions components/ledger_two/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM golang:1.23-alpine AS builder

WORKDIR /ledger-two-app

COPY . .

RUN CGO_ENABLED=0 GOOS=linux go build -a -tags netgo -ldflags '-w -extldflags "-static"' -o /app components/ledger/cmd/main.go

FROM alpine:latest

COPY --from=builder /app /app

# Copy the migrations directory.
COPY --from=builder /ledger-app/components/ledger/migrations /components/ledger/migrations

EXPOSE 3000 3001

ENTRYPOINT ["/app"]
98 changes: 98 additions & 0 deletions components/ledger_two/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
service_name := ledger-service
bin_dir := ./.bin
artifacts_dir := ./artifacts

$(shell mkdir -p $(artifacts_dir))

.PHONY: info gen run test cover-html tidy help build up start down destroy stop restart logs logs-api ps login-timescale login-api db-shell

# Display available commands
info:
@echo " "
@echo " "
@echo "To run a specific command inside the ledger container using make, you can execute: "
@echo " "
@echo "make ledger COMMAND=\"any\" "
@echo " "
@echo "This command will run the specified command inside the ledger container. Replace \"any\" with the desired command you want to execute. "
@echo " "
@echo "## App commands:"
@echo " "
@echo " COMMAND=\"grpc-ledger-gen\" Generate proto files for ledger service."
@echo " COMMAND=\"wire\" Generates all project code to connect components using Wire."
@echo " COMMAND=\"run\" Executes the Go program in internal/main.go using .env configuration."
@echo " COMMAND=\"test\" Runs all Go tests in the project with verbose output."
@echo " COMMAND=\"cover-html\" Generates an HTML report from Go test coverage data."
@echo " COMMAND=\"tidy\" Cleans and updates Go dependencies in the go.mod file."
@echo " "
@echo "## Docker commands:"
@echo " "
@echo " COMMAND=\"build\" Builds all Docker images defined in docker-compose.yml."
@echo " COMMAND=\"up\" Starts and runs all services defined in docker-compose.yml."
@echo " COMMAND=\"start\" Starts existing containers defined in docker-compose.yml without creating them."
@echo " COMMAND=\"stop\" Stops running containers defined in docker-compose.yml without removing them."
@echo " COMMAND=\"down\" Stops and removes containers, networks, and volumes defined in docker-compose.yml."
@echo " COMMAND=\"destroy\" Stops and removes containers, networks, and volumes (including named volumes) defined in docker-compose.yml."
@echo " COMMAND=\"restart\" Stops and removes containers, networks, and volumes, then starts all services in detached mode."
@echo " COMMAND=\"logs\" Shows the last 100 lines of logs and follows live log output for services defined in docker-compose.yml."
@echo " COMMAND=\"logs-api\" Shows the last 100 lines of logs and follows live log output for the ledger service defined in docker-compose.yml."
@echo " COMMAND=\"ps\" Lists the status of containers defined in docker-compose.yml."
@echo " COMMAND=\"ledger-api\" Starts an interactive Bash shell session inside the running ledger container defined in docker-compose.yml."
@echo " COMMAND=\"db-shell\" Starts a PostgreSQL interactive terminal inside the ledger container, logging in as the postgres user."


grpc-ledger-gen:
protoc --proto_path=../../common/mgrpc --go-grpc_out=../../common/mgrpc --go_out=../../common/mgrpc ../../common/mgrpc/account/account.proto

wire:
@go generate ./...

run:
@go run cmd/main.go .env

test:
@go test -v ./...

cover-html:
@go tool cover -html=$(artifacts_dir)/coverage.out -o $(artifacts_dir)/coverage.html

tidy:
@go mod tidy

# Docker Compose Commands
build:
@docker-compose -f docker-compose.yml build

up:
@docker-compose -f docker-compose.yml up -d

start:
@docker-compose -f docker-compose.yml start

down:
@docker-compose -f docker-compose.yml down

destroy:
@docker-compose -f docker-compose.yml down -v

stop:
@docker-compose -f docker-compose.yml stop

restart:
docker-compose -f docker-compose.yml down && \
docker-compose -f docker-compose.yml up -d

logs:
@docker-compose -f docker-compose.yml logs --tail=100 -f

logs-api:
@docker-compose -f docker-compose.yml logs --tail=100 -f ledger

ps:
@docker-compose -f docker-compose.yml ps

ledger-api:
@docker-compose -f docker-compose.yml exec ledger /bin/bash

db-shell:
@docker-compose -f docker-compose.yml exec ledger psql -Upostgres
Loading
Loading