diff --git a/.github/workflows/daily-build.yml b/.github/workflows/daily-build.yml index 9314a7d..46c3568 100644 --- a/.github/workflows/daily-build.yml +++ b/.github/workflows/daily-build.yml @@ -4,6 +4,9 @@ on: schedule: - cron: '0 */12 * * *' +env: + BALLERINA_VERSION: 2201.8.4 # Update this with the latest Ballerina version + jobs: build: if: github.repository_owner == 'ballerina-guides' @@ -23,7 +26,7 @@ jobs: - uses: ballerina-platform/setup-ballerina@v1 name: Install Ballerina with: - version: 2201.2.3 + version: ${{ env.BALLERINA_VERSION }} - name: Pack gRPC Stub Module working-directory: "client_stubs" run: bal pack diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 99e5b4c..d25f679 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -6,6 +6,9 @@ on: branches-ignore: - master +env: + BALLERINA_VERSION: 2201.8.4 # Update this with the latest Ballerina version + jobs: build: if: github.repository_owner == 'ballerina-guides' @@ -25,7 +28,7 @@ jobs: - uses: ballerina-platform/setup-ballerina@v1 name: Install Ballerina with: - version: 2201.2.3 + version: ${{ env.BALLERINA_VERSION }} - name: Pack gRPC Stub Module working-directory: "client_stubs" run: bal pack diff --git a/adservice/docker/Config.toml b/adservice/docker/Config.toml index d03bdd8..abf282a 100644 --- a/adservice/docker/Config.toml +++ b/adservice/docker/Config.toml @@ -3,9 +3,5 @@ tracingEnabled=true tracingProvider="jaeger" [ballerinax.jaeger] -agentHostname="jaeger" -agentPort=55680 -samplerType="const" -samplerParam=1.0 -reporterFlushInterval=2000 -reporterBufferSize=1000 +agentHostname="localhost" +agentPort=4317 diff --git a/adservice/k8s/Config.toml b/adservice/k8s/Config.toml index d03bdd8..abf282a 100644 --- a/adservice/k8s/Config.toml +++ b/adservice/k8s/Config.toml @@ -3,9 +3,5 @@ tracingEnabled=true tracingProvider="jaeger" [ballerinax.jaeger] -agentHostname="jaeger" -agentPort=55680 -samplerType="const" -samplerParam=1.0 -reporterFlushInterval=2000 -reporterBufferSize=1000 +agentHostname="localhost" +agentPort=4317 diff --git a/cartservice/docker/Config.toml b/cartservice/docker/Config.toml index 7ff56a5..abf282a 100644 --- a/cartservice/docker/Config.toml +++ b/cartservice/docker/Config.toml @@ -2,10 +2,6 @@ tracingEnabled=true tracingProvider="jaeger" -[ballerinax.jaeger] -agentHostname="jaeger" -agentPort=55680 -samplerType="const" -samplerParam=1.0 -reporterFlushInterval=2000 -reporterBufferSize=1000 +[ballerinax.jaeger] +agentHostname="localhost" +agentPort=4317 diff --git a/cartservice/k8s/Config.toml b/cartservice/k8s/Config.toml index d03bdd8..abf282a 100644 --- a/cartservice/k8s/Config.toml +++ b/cartservice/k8s/Config.toml @@ -3,9 +3,5 @@ tracingEnabled=true tracingProvider="jaeger" [ballerinax.jaeger] -agentHostname="jaeger" -agentPort=55680 -samplerType="const" -samplerParam=1.0 -reporterFlushInterval=2000 -reporterBufferSize=1000 +agentHostname="localhost" +agentPort=4317 diff --git a/checkoutservice/docker/Config.toml b/checkoutservice/docker/Config.toml index 9ad48f3..56870fb 100644 --- a/checkoutservice/docker/Config.toml +++ b/checkoutservice/docker/Config.toml @@ -10,9 +10,5 @@ tracingEnabled=true tracingProvider="jaeger" [ballerinax.jaeger] -agentHostname="jaeger" -agentPort=55680 -samplerType="const" -samplerParam=1.0 -reporterFlushInterval=2000 -reporterBufferSize=1000 +agentHostname="localhost" +agentPort=4317 diff --git a/checkoutservice/k8s/Config.toml b/checkoutservice/k8s/Config.toml index ac02a3d..c2c3e99 100644 --- a/checkoutservice/k8s/Config.toml +++ b/checkoutservice/k8s/Config.toml @@ -16,9 +16,5 @@ tracingEnabled=true tracingProvider="jaeger" [ballerinax.jaeger] -agentHostname="jaeger" -agentPort=55680 -samplerType="const" -samplerParam=1.0 -reporterFlushInterval=2000 -reporterBufferSize=1000 +agentHostname="localhost" +agentPort=4317 diff --git a/client_stubs/docker/Config.toml b/client_stubs/docker/Config.toml new file mode 100644 index 0000000..56870fb --- /dev/null +++ b/client_stubs/docker/Config.toml @@ -0,0 +1,14 @@ +catalogHost="catalog" +cartHost="cart" +currencyHost="currency" +shippingHost="shipping" +paymentHost="payment" +emailHost="email" + +[ballerina.observe] +tracingEnabled=true +tracingProvider="jaeger" + +[ballerinax.jaeger] +agentHostname="localhost" +agentPort=4317 diff --git a/client_stubs/k8s/Config.toml b/client_stubs/k8s/Config.toml new file mode 100644 index 0000000..c2c3e99 --- /dev/null +++ b/client_stubs/k8s/Config.toml @@ -0,0 +1,20 @@ +catalogHost="catalog-service" +cartHost="cart-service" +currencyHost="currency-service" +shippingHost="shipping-service" +paymentHost="payment-service" +emailHost="email-service" +cartTimeout=3.0 +catalogTimeout=3.0 +currencyTimeout=3.0 +shippingTimeout=3.0 +paymentTimeout=3.0 +emailTimeout=3.0 + +[ballerina.observe] +tracingEnabled=true +tracingProvider="jaeger" + +[ballerinax.jaeger] +agentHostname="localhost" +agentPort=4317 diff --git a/currencyservice/docker/Config.toml b/currencyservice/docker/Config.toml index d03bdd8..abf282a 100644 --- a/currencyservice/docker/Config.toml +++ b/currencyservice/docker/Config.toml @@ -3,9 +3,5 @@ tracingEnabled=true tracingProvider="jaeger" [ballerinax.jaeger] -agentHostname="jaeger" -agentPort=55680 -samplerType="const" -samplerParam=1.0 -reporterFlushInterval=2000 -reporterBufferSize=1000 +agentHostname="localhost" +agentPort=4317 diff --git a/currencyservice/k8s/Config.toml b/currencyservice/k8s/Config.toml index d03bdd8..abf282a 100644 --- a/currencyservice/k8s/Config.toml +++ b/currencyservice/k8s/Config.toml @@ -3,9 +3,5 @@ tracingEnabled=true tracingProvider="jaeger" [ballerinax.jaeger] -agentHostname="jaeger" -agentPort=55680 -samplerType="const" -samplerParam=1.0 -reporterFlushInterval=2000 -reporterBufferSize=1000 +agentHostname="localhost" +agentPort=4317 diff --git a/docker-compose.yml b/docker-compose.yml index e9a7abe..4c967b4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: ports: - 16686:16686 - 13133:13133 - - 55680:55680 + - 4317:4317 ads: image: wso2inc/ads-service:v0.1.0 volumes: diff --git a/emailservice/ObserveConfig.toml b/emailservice/ObserveConfig.toml index d03bdd8..abf282a 100644 --- a/emailservice/ObserveConfig.toml +++ b/emailservice/ObserveConfig.toml @@ -3,9 +3,5 @@ tracingEnabled=true tracingProvider="jaeger" [ballerinax.jaeger] -agentHostname="jaeger" -agentPort=55680 -samplerType="const" -samplerParam=1.0 -reporterFlushInterval=2000 -reporterBufferSize=1000 +agentHostname="localhost" +agentPort=4317 diff --git a/emailservice/docker/Config.toml b/emailservice/docker/Config.toml new file mode 100644 index 0000000..56870fb --- /dev/null +++ b/emailservice/docker/Config.toml @@ -0,0 +1,14 @@ +catalogHost="catalog" +cartHost="cart" +currencyHost="currency" +shippingHost="shipping" +paymentHost="payment" +emailHost="email" + +[ballerina.observe] +tracingEnabled=true +tracingProvider="jaeger" + +[ballerinax.jaeger] +agentHostname="localhost" +agentPort=4317 diff --git a/emailservice/email_service.bal b/emailservice/email_service.bal index 73fe777..d11c183 100644 --- a/emailservice/email_service.bal +++ b/emailservice/email_service.bal @@ -43,14 +43,16 @@ service "EmailService" on new grpc:Listener(9097) { private final gmail:Client gmailClient; function init() returns error? { - self.gmailClient = check new ({ - auth: { - refreshUrl: gmail:REFRESH_URL, - refreshToken: gmailConfig.refreshToken, - clientId: gmailConfig.clientId, - clientSecret: gmailConfig.clientSecret + self.gmailClient = check new gmail:Client( + config = { + auth: { + refreshToken: gmailConfig.refreshToken, + clientId: gmailConfig.clientId, + clientSecret: gmailConfig.clientSecret + } } - }); + ); + log:printInfo("Email service gRPC server started."); } @@ -62,12 +64,11 @@ service "EmailService" on new grpc:Listener(9097) { log:printInfo(string `Received a request to send order confirmation email to ${request.email}.`); gmail:MessageRequest messageRequest = { - recipient: request.email, + to: [request.email], subject: "Your Confirmation Email", - messageBody: (check getConfirmationHtml(request.'order)).toString(), - contentType: gmail:TEXT_HTML + bodyInHtml: (check getConfirmationHtml(request.'order)).toString() }; - gmail:Message|error sendMessageResponse = self.gmailClient->sendMessage(messageRequest); + gmail:Message|error sendMessageResponse = check self.gmailClient->/users/[request.email]/messages/send.post(messageRequest); if sendMessageResponse is error { log:printError("An error occurred when sending the order confirmation email ", sendMessageResponse); return sendMessageResponse; diff --git a/emailservice/k8s/Config.toml b/emailservice/k8s/Config.toml index d03bdd8..abf282a 100644 --- a/emailservice/k8s/Config.toml +++ b/emailservice/k8s/Config.toml @@ -3,9 +3,5 @@ tracingEnabled=true tracingProvider="jaeger" [ballerinax.jaeger] -agentHostname="jaeger" -agentPort=55680 -samplerType="const" -samplerParam=1.0 -reporterFlushInterval=2000 -reporterBufferSize=1000 +agentHostname="localhost" +agentPort=4317 diff --git a/frontend/README.md b/frontend/README.md index ee59a78..0294cbc 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -31,11 +31,13 @@ AuthInterceptor authInterceptor = new; cors: { allowOrigins: ["http://localhost:3000"], allowCredentials: true - }, - interceptors: [new AuthInterceptor()] + } } -service / on new http:Listener (9098) { +service http:InterceptableService / on new http:Listener (9098) { + public function createInterceptors() returns AuthInterceptor { + return authInterceptor; + } } ``` diff --git a/frontend/docker/Config.toml b/frontend/docker/Config.toml index b403517..d34b451 100644 --- a/frontend/docker/Config.toml +++ b/frontend/docker/Config.toml @@ -11,9 +11,5 @@ tracingEnabled=true tracingProvider="jaeger" [ballerinax.jaeger] -agentHostname="jaeger" -agentPort=55680 -samplerType="const" -samplerParam=1.0 -reporterFlushInterval=2000 -reporterBufferSize=1000 +agentHostname="localhost" +agentPort=4317 diff --git a/frontend/k8s/Config.toml b/frontend/k8s/Config.toml index d6bcd45..f5952bc 100644 --- a/frontend/k8s/Config.toml +++ b/frontend/k8s/Config.toml @@ -18,9 +18,5 @@ tracingEnabled=true tracingProvider="jaeger" [ballerinax.jaeger] -agentHostname="jaeger" -agentPort=55680 -samplerType="const" -samplerParam=1.0 -reporterFlushInterval=2000 -reporterBufferSize=1000 +agentHostname="localhost" +agentPort=4317 diff --git a/frontend/service.bal b/frontend/service.bal index fe7f218..91fa6ba 100644 --- a/frontend/service.bal +++ b/frontend/service.bal @@ -64,14 +64,13 @@ service class AuthInterceptor { cors: { allowOrigins: ["http://localhost:3000"], allowCredentials: true - }, - interceptors: [new AuthInterceptor()] + } } @display { label: "Frontend", id: "frontend" } -service / on new http:Listener(9098) { +service http:InterceptableService / on new http:Listener(9098) { function init() { log:printInfo("Frontend server started."); @@ -370,4 +369,8 @@ service / on new http:Listener(9098) { return from stubs:CartItem {product_id} in cart.items select product_id; } + + public function createInterceptors() returns AuthInterceptor { + return new AuthInterceptor(); + } } diff --git a/paymentservice/docker/Config.toml b/paymentservice/docker/Config.toml index d03bdd8..abf282a 100644 --- a/paymentservice/docker/Config.toml +++ b/paymentservice/docker/Config.toml @@ -3,9 +3,5 @@ tracingEnabled=true tracingProvider="jaeger" [ballerinax.jaeger] -agentHostname="jaeger" -agentPort=55680 -samplerType="const" -samplerParam=1.0 -reporterFlushInterval=2000 -reporterBufferSize=1000 +agentHostname="localhost" +agentPort=4317 diff --git a/paymentservice/k8s/Config.toml b/paymentservice/k8s/Config.toml index d03bdd8..abf282a 100644 --- a/paymentservice/k8s/Config.toml +++ b/paymentservice/k8s/Config.toml @@ -3,9 +3,5 @@ tracingEnabled=true tracingProvider="jaeger" [ballerinax.jaeger] -agentHostname="jaeger" -agentPort=55680 -samplerType="const" -samplerParam=1.0 -reporterFlushInterval=2000 -reporterBufferSize=1000 +agentHostname="localhost" +agentPort=4317 diff --git a/productcatalogservice/docker/Config.toml b/productcatalogservice/docker/Config.toml index d03bdd8..abf282a 100644 --- a/productcatalogservice/docker/Config.toml +++ b/productcatalogservice/docker/Config.toml @@ -3,9 +3,5 @@ tracingEnabled=true tracingProvider="jaeger" [ballerinax.jaeger] -agentHostname="jaeger" -agentPort=55680 -samplerType="const" -samplerParam=1.0 -reporterFlushInterval=2000 -reporterBufferSize=1000 +agentHostname="localhost" +agentPort=4317 diff --git a/productcatalogservice/k8s/Config.toml b/productcatalogservice/k8s/Config.toml index d03bdd8..abf282a 100644 --- a/productcatalogservice/k8s/Config.toml +++ b/productcatalogservice/k8s/Config.toml @@ -3,9 +3,5 @@ tracingEnabled=true tracingProvider="jaeger" [ballerinax.jaeger] -agentHostname="jaeger" -agentPort=55680 -samplerType="const" -samplerParam=1.0 -reporterFlushInterval=2000 -reporterBufferSize=1000 +agentHostname="localhost" +agentPort=4317 diff --git a/recommendationservice/docker/Config.toml b/recommendationservice/docker/Config.toml index 0cacf8b..2b2f487 100644 --- a/recommendationservice/docker/Config.toml +++ b/recommendationservice/docker/Config.toml @@ -5,9 +5,5 @@ tracingEnabled=true tracingProvider="jaeger" [ballerinax.jaeger] -agentHostname="jaeger" -agentPort=55680 -samplerType="const" -samplerParam=1.0 -reporterFlushInterval=2000 -reporterBufferSize=1000 +agentHostname="localhost" +agentPort=4317 diff --git a/recommendationservice/k8s/Config.toml b/recommendationservice/k8s/Config.toml index 2f1b026..fa026c0 100644 --- a/recommendationservice/k8s/Config.toml +++ b/recommendationservice/k8s/Config.toml @@ -6,9 +6,5 @@ tracingEnabled=true tracingProvider="jaeger" [ballerinax.jaeger] -agentHostname="jaeger" -agentPort=55680 -samplerType="const" -samplerParam=1.0 -reporterFlushInterval=2000 -reporterBufferSize=1000 +agentHostname="localhost" +agentPort=4317 diff --git a/shippingservice/docker/Config.toml b/shippingservice/docker/Config.toml index d03bdd8..abf282a 100644 --- a/shippingservice/docker/Config.toml +++ b/shippingservice/docker/Config.toml @@ -3,9 +3,5 @@ tracingEnabled=true tracingProvider="jaeger" [ballerinax.jaeger] -agentHostname="jaeger" -agentPort=55680 -samplerType="const" -samplerParam=1.0 -reporterFlushInterval=2000 -reporterBufferSize=1000 +agentHostname="localhost" +agentPort=4317 diff --git a/shippingservice/k8s/Config.toml b/shippingservice/k8s/Config.toml index d03bdd8..abf282a 100644 --- a/shippingservice/k8s/Config.toml +++ b/shippingservice/k8s/Config.toml @@ -3,9 +3,5 @@ tracingEnabled=true tracingProvider="jaeger" [ballerinax.jaeger] -agentHostname="jaeger" -agentPort=55680 -samplerType="const" -samplerParam=1.0 -reporterFlushInterval=2000 -reporterBufferSize=1000 +agentHostname="localhost" +agentPort=4317