Skip to content

Commit

Permalink
[payment] rename paymentservice to payment (#1863)
Browse files Browse the repository at this point in the history
* rename paymentservice to payment

* rename paymentservice to payment

* rename paymentservice to payment

---------

Co-authored-by: Juliano Costa <julianocosta89@outlook.com>
  • Loading branch information
puckpuck and julianocosta89 authored Dec 23, 2024
1 parent 3868f0e commit 4c8e43f
Show file tree
Hide file tree
Showing 27 changed files with 58 additions and 56 deletions.
6 changes: 3 additions & 3 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ LOCUST_HEADLESS=false
LOAD_GENERATOR_DOCKERFILE=./src/load-generator/Dockerfile

# Payment Service
PAYMENT_SERVICE_PORT=50051
PAYMENT_SERVICE_ADDR=paymentservice:${PAYMENT_SERVICE_PORT}
PAYMENT_SERVICE_DOCKERFILE=./src/paymentservice/Dockerfile
PAYMENT_PORT=50051
PAYMENT_ADDR=payment:${PAYMENT_PORT}
PAYMENT_DOCKERFILE=./src/payment/Dockerfile

# Product Catalog Service
PRODUCT_CATALOG_SERVICE_PORT=3550
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/component-build-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ jobs:
tag_suffix: load-generator
context: ./
setup-qemu: true
- file: ./src/paymentservice/Dockerfile
tag_suffix: paymentservice
- file: ./src/payment/Dockerfile
tag_suffix: payment
context: ./
setup-qemu: true
- file: ./src/productcatalogservice/Dockerfile
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ test/tracetesting/tracetesting-vars.yaml
/src/fraud-detection/src/main/proto
/src/frontend/pb/
/src/frontend/protos/
/src/paymentservice/demo.proto
/src/payment/demo.proto
/src/shipping/proto/
/src/currency/proto

Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ the release.
([#1861](https://github.com/open-telemetry/opentelemetry-demo/pull/1861))
* [fraud-detection] rename frauddetectionservice to fraud-detection
([#1862](https://github.com/open-telemetry/opentelemetry-demo/pull/1862))
* [payment] rename paymentservice to payment
([#1863](https://github.com/open-telemetry/opentelemetry-demo/pull/1863))

## 1.12.0

Expand Down
4 changes: 2 additions & 2 deletions docker-compose-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ services:
- CURRENCY_ADDR
- EMAIL_ADDR
- FRONTEND_ADDR
- PAYMENT_SERVICE_ADDR
- PAYMENT_ADDR
- PRODUCT_CATALOG_SERVICE_ADDR
- RECOMMENDATION_SERVICE_ADDR
- SHIPPING_ADDR
Expand Down Expand Up @@ -73,7 +73,7 @@ services:
condition: service_started
frontend:
condition: service_started
paymentservice:
payment:
condition: service_started
productcatalogservice:
condition: service_started
Expand Down
18 changes: 9 additions & 9 deletions docker-compose.minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ services:
- CURRENCY_ADDR
- EMAIL_ADDR
- FLAGD_HOST
- PAYMENT_SERVICE_ADDR
- PAYMENT_ADDR
- PRODUCT_CATALOG_SERVICE_ADDR
- SHIPPING_ADDR
- OTEL_EXPORTER_OTLP_ENDPOINT
Expand All @@ -116,7 +116,7 @@ services:
condition: service_started
email:
condition: service_started
paymentservice:
payment:
condition: service_started
productcatalogservice:
condition: service_started
Expand Down Expand Up @@ -351,28 +351,28 @@ services:
logging: *logging

# Payment service
paymentservice:
image: ${IMAGE_NAME}:${DEMO_VERSION}-paymentservice
payment:
image: ${IMAGE_NAME}:${DEMO_VERSION}-payment
container_name: payment-service
build:
context: ./
dockerfile: ${PAYMENT_SERVICE_DOCKERFILE}
dockerfile: ${PAYMENT_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-paymentservice
- ${IMAGE_NAME}:${IMAGE_VERSION}-payment
deploy:
resources:
limits:
memory: 120M
restart: unless-stopped
ports:
- "${PAYMENT_SERVICE_PORT}"
- "${PAYMENT_PORT}"
environment:
- FLAGD_HOST
- PAYMENT_SERVICE_PORT
- PAYMENT_PORT
- OTEL_EXPORTER_OTLP_ENDPOINT
- OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE
- OTEL_RESOURCE_ATTRIBUTES
- OTEL_SERVICE_NAME=paymentservice
- OTEL_SERVICE_NAME=payment
depends_on:
otel-collector:
condition: service_started
Expand Down
18 changes: 9 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ services:
- CART_ADDR
- CURRENCY_ADDR
- EMAIL_ADDR
- PAYMENT_SERVICE_ADDR
- PAYMENT_ADDR
- PRODUCT_CATALOG_SERVICE_ADDR
- SHIPPING_ADDR
- KAFKA_SERVICE_ADDR
Expand All @@ -150,7 +150,7 @@ services:
condition: service_started
email:
condition: service_started
paymentservice:
payment:
condition: service_started
productcatalogservice:
condition: service_started
Expand Down Expand Up @@ -427,29 +427,29 @@ services:
logging: *logging

# Payment service
paymentservice:
image: ${IMAGE_NAME}:${DEMO_VERSION}-paymentservice
payment:
image: ${IMAGE_NAME}:${DEMO_VERSION}-payment
container_name: payment-service
build:
context: ./
dockerfile: ${PAYMENT_SERVICE_DOCKERFILE}
dockerfile: ${PAYMENT_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-paymentservice
- ${IMAGE_NAME}:${IMAGE_VERSION}-payment
deploy:
resources:
limits:
memory: 120M
restart: unless-stopped
ports:
- "${PAYMENT_SERVICE_PORT}"
- "${PAYMENT_PORT}"
environment:
- PAYMENT_SERVICE_PORT
- PAYMENT_PORT
- FLAGD_HOST
- FLAGD_PORT
- OTEL_EXPORTER_OTLP_ENDPOINT
- OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE
- OTEL_RESOURCE_ATTRIBUTES
- OTEL_SERVICE_NAME=paymentservice
- OTEL_SERVICE_NAME=payment
depends_on:
otel-collector:
condition: service_started
Expand Down
2 changes: 1 addition & 1 deletion docker-gen-proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ gen_proto_go checkoutservice
#gen_proto_cpp currency
#gen_proto_ruby email
#gen_proto_ts frontend
#gen_proto_js paymentservice
#gen_proto_js payment
gen_proto_go productcatalogservice
#gen_proto_php quote
gen_proto_python recommendationservice
Expand Down
2 changes: 1 addition & 1 deletion ide-gen-proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ gen_proto_go checkoutservice
# gen_proto_ruby email
gen_proto_ts frontend
gen_proto_ts react-native-app
gen_proto_js paymentservice
gen_proto_js payment
gen_proto_go productcatalogservice
# gen_proto_php quote
gen_proto_python recommendationservice
Expand Down
4 changes: 2 additions & 2 deletions renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
"groupName": "otel-collector",
},
{
"matchFileNames": ["src/paymentservice/**"],
"groupName": "paymentservice",
"matchFileNames": ["src/payment/**"],
"groupName": "payment",
},
{
"matchFileNames": ["src/productcatalogservice/**"],
Expand Down
4 changes: 2 additions & 2 deletions src/checkoutservice/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func main() {
svc.emailSvcClient = pb.NewEmailServiceClient(c)
defer c.Close()

mustMapEnv(&svc.paymentSvcAddr, "PAYMENT_SERVICE_ADDR")
mustMapEnv(&svc.paymentSvcAddr, "PAYMENT_ADDR")
c = mustCreateClient(svc.paymentSvcAddr)
svc.paymentSvcClient = pb.NewPaymentServiceClient(c)
defer c.Close()
Expand Down Expand Up @@ -442,7 +442,7 @@ func (cs *checkoutService) convertCurrency(ctx context.Context, from *pb.Money,

func (cs *checkoutService) chargeCard(ctx context.Context, amount *pb.Money, paymentInfo *pb.CreditCardInfo) (string, error) {
paymentService := cs.paymentSvcClient
if cs.isFeatureFlagEnabled(ctx, "paymentServiceUnreachable") {
if cs.isFeatureFlagEnabled(ctx, "paymentUnreachable") {
badAddress := "badAddress:50051"
c := mustCreateClient(badAddress)
paymentService = pb.NewPaymentServiceClient(c)
Expand Down
4 changes: 2 additions & 2 deletions src/flagd/demo.flagd.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
},
"defaultVariant": "off"
},
"paymentServiceFailure": {
"paymentFailure": {
"description": "Fail payment service charge requests n%",
"state": "ENABLED",
"variants": {
Expand All @@ -78,7 +78,7 @@
},
"defaultVariant": "off"
},
"paymentServiceUnreachable": {
"paymentUnreachable": {
"description": "Payment service is unavailable",
"state": "ENABLED",
"variants": {
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions src/paymentservice/Dockerfile → src/payment/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ FROM node:22-alpine AS build

WORKDIR /usr/src/app/

COPY ./src/paymentservice/package*.json ./
COPY ./src/payment/package*.json ./

RUN apk add --no-cache python3 make g++ && npm ci --omit=dev

Expand All @@ -19,8 +19,8 @@ WORKDIR /usr/src/app/
ENV NODE_ENV=production

COPY --chown=node:node --from=build /usr/src/app/node_modules/ ./node_modules/
COPY ./src/paymentservice/ ./
COPY ./src/payment/ ./
COPY ./pb/demo.proto ./

EXPOSE ${PAYMENT_SERVICE_PORT}
EXPOSE ${PAYMENT_PORT}
ENTRYPOINT [ "npm", "run", "start" ]
2 changes: 1 addition & 1 deletion src/paymentservice/README.md → src/payment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ Copy the `demo.proto` file to this directory and run `npm ci`
From the root directory, run:

```sh
docker compose build paymentservice
docker compose build payment
```
6 changes: 3 additions & 3 deletions src/paymentservice/charge.js → src/payment/charge.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const { FlagdProvider } = require('@openfeature/flagd-provider');
const flagProvider = new FlagdProvider();

const logger = require('./logger');
const tracer = trace.getTracer('paymentservice');
const meter = metrics.getMeter('paymentservice');
const tracer = trace.getTracer('payment');
const meter = metrics.getMeter('payment');
const transactionsCounter = meter.createCounter('app.payment.transactions');

const LOYALTY_LEVEL = ['platinum', 'gold', 'silver', 'bronze'];
Expand All @@ -26,7 +26,7 @@ module.exports.charge = async request => {

await OpenFeature.setProviderAndWait(flagProvider);

const numberVariant = await OpenFeature.getClient().getNumberValue("paymentServiceFailure", 0);
const numberVariant = await OpenFeature.getClient().getNumberValue("paymentFailure", 0);

if (numberVariant > 0) {
// n% chance to fail with app.loyalty.level=gold
Expand Down
4 changes: 2 additions & 2 deletions src/paymentservice/index.js → src/payment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ server.addService(health.service, new health.Implementation({

server.addService(otelDemoPackage.oteldemo.PaymentService.service, { charge: chargeServiceHandler })

server.bindAsync(`0.0.0.0:${process.env['PAYMENT_SERVICE_PORT']}`, grpc.ServerCredentials.createInsecure(), (err, port) => {
server.bindAsync(`0.0.0.0:${process.env['PAYMENT_PORT']}`, grpc.ServerCredentials.createInsecure(), (err, port) => {
if (err) {
return logger.error({ err })
}

logger.info(`PaymentService gRPC server started on port ${port}`)
logger.info(`payment gRPC server started on port ${port}`)
})

process.once('SIGINT', closeGracefully)
Expand Down
File renamed without changes.
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "paymentservice",
"name": "payment",
"description": "Payment Service",
"repository": "https://github.com/opentelemetry/opentelemetry-demo",
"main": "index.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

type: TestSuite
spec:
id: payment-service-all
name: 'Payment Service'
description: Run all Payment Service tests enabled in sequence
id: payment-all
name: 'Payment'
description: Run all Payment tests enabled in sequence
steps:
- ./valid-credit-card.yaml
- ./invalid-credit-card.yaml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec:
type: grpc
grpc:
protobufFile: ../../../pb/demo.proto
address: ${var:PAYMENT_SERVICE_ADDR}
address: ${var:PAYMENT_ADDR}
method: oteldemo.PaymentService.Charge
request: |-
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec:
type: grpc
grpc:
protobufFile: ../../../pb/demo.proto
address: ${var:PAYMENT_SERVICE_ADDR}
address: ${var:PAYMENT_ADDR}
method: oteldemo.PaymentService.Charge
request: |-
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec:
type: grpc
grpc:
protobufFile: ../../../pb/demo.proto
address: ${var:PAYMENT_SERVICE_ADDR}
address: ${var:PAYMENT_ADDR}
method: oteldemo.PaymentService.Charge
request: |-
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec:
type: grpc
grpc:
protobufFile: ../../../pb/demo.proto
address: ${var:PAYMENT_SERVICE_ADDR}
address: ${var:PAYMENT_ADDR}
method: oteldemo.PaymentService.Charge
request: |-
{
Expand Down
6 changes: 3 additions & 3 deletions test/tracetesting/run.bash
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
set -e

# Availalble services to test
ALL_SERVICES=("ad" "cart" "currency" "checkoutservice" "frontend" "email" "paymentservice" "productcatalogservice" "recommendationservice" "shipping")
ALL_SERVICES=("ad" "cart" "currency" "checkoutservice" "frontend" "email" "payment" "productcatalogservice" "recommendationservice" "shipping")

## Script variables
# Will contain the list of services to test
Expand Down Expand Up @@ -46,8 +46,8 @@ spec:
value: $EMAIL_ADDR
- key: FRONTEND_ADDR
value: $FRONTEND_ADDR
- key: PAYMENT_SERVICE_ADDR
value: $PAYMENT_SERVICE_ADDR
- key: PAYMENT_ADDR
value: $PAYMENT_ADDR
- key: PRODUCT_CATALOG_SERVICE_ADDR
value: $PRODUCT_CATALOG_SERVICE_ADDR
- key: RECOMMENDATION_SERVICE_ADDR
Expand Down

0 comments on commit 4c8e43f

Please sign in to comment.