play-microservices

所属分类:微服务
开发工具:GO
文件大小:0KB
下载次数:0
上传日期:2023-07-26 20:58:52
上 传 者sh-1993
说明:  一个简单的作业调度器微服务应用程序,使用各种编程语言为不同的服务演示灵活性...,
(A simple job scheduler microservice application using various programming languages for different services to demonstrate the flexibility of microservices architecture in terms of independence from specific technologies..)

文件列表:
.env (297, 2023-09-20)
LICENSE (1072, 2023-09-20)
api-gateway/ (0, 2023-09-20)
api-gateway/.env (70, 2023-09-20)
api-gateway/api-gateway-service/ (0, 2023-09-20)
api-gateway/api-gateway-service/Dockerfile (647, 2023-09-20)
api-gateway/api-gateway-service/Dockerfile.test (255, 2023-09-20)
api-gateway/api-gateway-service/build_grpc.sh (396, 2023-09-20)
api-gateway/api-gateway-service/cmd/ (0, 2023-09-20)
api-gateway/api-gateway-service/cmd/main.go (739, 2023-09-20)
api-gateway/api-gateway-service/config/ (0, 2023-09-20)
api-gateway/api-gateway-service/config/.env (41, 2023-09-20)
api-gateway/api-gateway-service/config/config.go (2085, 2023-09-20)
api-gateway/api-gateway-service/docs/ (0, 2023-09-20)
api-gateway/api-gateway-service/docs/docs.go (24235, 2023-09-20)
api-gateway/api-gateway-service/docs/swagger.json (23472, 2023-09-20)
api-gateway/api-gateway-service/docs/swagger.yaml (12388, 2023-09-20)
api-gateway/api-gateway-service/go.mod (2173, 2023-09-20)
api-gateway/api-gateway-service/go.sum (16515, 2023-09-20)
api-gateway/api-gateway-service/internal/ (0, 2023-09-20)
api-gateway/api-gateway-service/internal/api/ (0, 2023-09-20)
api-gateway/api-gateway-service/internal/api/interceptors/ (0, 2023-09-20)
api-gateway/api-gateway-service/internal/api/interceptors/auth_interceptor.go (1398, 2023-09-20)
api-gateway/api-gateway-service/internal/api/router.go (2482, 2023-09-20)
api-gateway/api-gateway-service/internal/models/ (0, 2023-09-20)
api-gateway/api-gateway-service/internal/models/job.go (2871, 2023-09-20)
api-gateway/api-gateway-service/internal/models/job/ (0, 2023-09-20)
api-gateway/api-gateway-service/internal/models/job/grpc/ (0, 2023-09-20)
api-gateway/api-gateway-service/internal/models/job/grpc/client_service.go (2291, 2023-09-20)
api-gateway/api-gateway-service/internal/models/job/handler/ (0, 2023-09-20)
api-gateway/api-gateway-service/internal/models/job/handler/handler.go (6171, 2023-09-20)
api-gateway/api-gateway-service/internal/models/report.go (1044, 2023-09-20)
api-gateway/api-gateway-service/internal/models/report/ (0, 2023-09-20)
api-gateway/api-gateway-service/internal/models/report/grpc/ (0, 2023-09-20)
api-gateway/api-gateway-service/internal/models/report/grpc/client_service.go (1235, 2023-09-20)
api-gateway/api-gateway-service/internal/models/report/handler/ (0, 2023-09-20)
api-gateway/api-gateway-service/internal/models/report/handler/handler.go (2292, 2023-09-20)
api-gateway/api-gateway-service/internal/models/user.go (2219, 2023-09-20)
api-gateway/api-gateway-service/internal/models/user/ (0, 2023-09-20)
... ...

![Play microservice](https://github.com/KhaledHosseini/play-microservices/blob/master/pms.png) # play-microservices A simple job scheduler app using microservices architecture. Users can sign up (as admin or normal role). - Admins can query the list of all users. - Admins can schedule email jobs to be run in the future. - Admins can query the reports. Just run `docker-compose up` from the root directory. Then go to http://localhost:3000/ ![Image1](https://github.com/KhaledHosseini/play-microservices/blob/master/https://github.com/KhaledHosseini/play-microservices/blob/master/plan/image1.png) ![Image2](https://github.com/KhaledHosseini/play-microservices/blob/master/https://github.com/KhaledHosseini/play-microservices/blob/master/plan/image2.png) ## Articles: - Plan: [Read](https://github.com/KhaledHosseini/play-microservices/blob/master/https://dev.to/khaledhosseini/play-microservices-birds-eye-view-3d44) - Authentication service: Rust [Read](https://github.com/KhaledHosseini/play-microservices/blob/master/https://dev.to/khaledhosseini/play-microservices-authentication-4di3) - Scheduler service: Go [Read](https://github.com/KhaledHosseini/play-microservices/blob/master/https://dev.to/khaledhosseini/play-microservices-scheduler-19km) - Email service: Python [Read](https://github.com/KhaledHosseini/play-microservices/blob/master/https://dev.to/khaledhosseini/play-microservices-email-service-1kmc) - Report service: Python [Read](https://github.com/KhaledHosseini/play-microservices/blob/master/https://dev.to/khaledhosseini/play-microservices-report-service-4jcm) - API gateway service: Go [Read](https://github.com/KhaledHosseini/play-microservices/blob/master/https://dev.to/khaledhosseini/play-microservices-api-gateway-service-4a9j) - Client service: Typescript [Read](https://github.com/KhaledHosseini/play-microservices/blob/master/https://dev.to/khaledhosseini/play-microservices-client-service-4jbf) - Integration via docker-compose: [Read](https://github.com/KhaledHosseini/play-microservices/blob/master/https://dev.to/khaledhosseini/play-microservices-integration-via-docker-compose-2ddc) - Security: [Read](https://github.com/KhaledHosseini/play-microservices/blob/master/https://dev.to/khaledhosseini/play-microservices-security-45e4) --- ## Choreography ![Choreography](https://github.com/KhaledHosseini/play-microservices/blob/master/https://github.com/KhaledHosseini/play-microservices/blob/master/plan/choreography.svg) --- ## CI / CD Flow diagram ![Choreography](https://github.com/KhaledHosseini/play-microservices/blob/master/https://github.com/KhaledHosseini/play-microservices/blob/master/plan/developement_environment.svg) --- ## Technologies per service - **_Auth service_** - [Rust](https://github.com/KhaledHosseini/play-microservices/blob/master/https://www.rust-lang.org/): Programming language - [postgres](https://github.com/KhaledHosseini/play-microservices/blob/master/https://www.postgresql.org/): database - [redis](https://github.com/KhaledHosseini/play-microservices/blob/master/https://redis.io/): cache - [Tonic](https://github.com/KhaledHosseini/play-microservices/blob/master/https://github.com/hyperium/tonic): gRPC framework for Rust - [Diesel](https://github.com/KhaledHosseini/play-microservices/blob/master/https://diesel.rs/): Query builder and ORM for our database communication. - [Redis ](https://github.com/KhaledHosseini/play-microservices/blob/master/https://docs.rs/redis): For our redis server communications in rust. - **_Scheduler service_** - [Golang](https://github.com/KhaledHosseini/play-microservices/blob/master/https://go.dev/) : programming language - [gRPC-GO](https://github.com/KhaledHosseini/play-microservices/blob/master/https://pkg.go.dev/google.golang.org/grpc): gRPC framework for golang - [Mongo driver](https://github.com/KhaledHosseini/play-microservices/blob/master/https://pkg.go.dev/go.mongodb.org/mongo-driver): Query builder for our database communication. - [Kafka go](https://github.com/KhaledHosseini/play-microservices/blob/master/https://pkg.go.dev/github.com/segmentio/kafka-go) for our message broker communications from go. - [Quartz ](https://github.com/KhaledHosseini/play-microservices/blob/master/github.com/reugn/go-quartz) for scheduling purposes. - **_Email job executor service_** - [Python](https://github.com/KhaledHosseini/play-microservices/blob/master/https://www.python.org/) : programming language - [Kafka-python](https://github.com/KhaledHosseini/play-microservices/blob/master/https://pypi.org/project/kafka-python/): For our message broker communications from go. - **_Reports service_** - [Python](https://github.com/KhaledHosseini/play-microservices/blob/master/https://python.org/) : programming language - [grpc](https://github.com/KhaledHosseini/play-microservices/blob/master/https://pypi.org/project/grpc/): gRPC framework for python - [Pymongo](https://github.com/KhaledHosseini/play-microservices/blob/master/https://pypi.org/project/pymongo/): Query builder for our database communication. - [Kafka-Python](https://github.com/KhaledHosseini/play-microservices/blob/master/https://pypi.org/project/kafka-python/) for our message broker communications from python. - [grpcio-tools](https://github.com/KhaledHosseini/play-microservices/blob/master/https://pypi.org/project/grpcio-tools/) For compiling .proto files to python. - **_API gateway service_** - [Golang](https://github.com/KhaledHosseini/play-microservices/blob/master/https://go.dev/) : programming language - [gRPC-GO](https://github.com/KhaledHosseini/play-microservices/blob/master/https://pkg.go.dev/google.golang.org/grpc): gRPC framework for golang - [Gin](https://github.com/KhaledHosseini/play-microservices/blob/master/https://gin-gonic.com/): Is a web framework written in Golang - [gin-swagger](https://github.com/KhaledHosseini/play-microservices/blob/master/https://github.com/swaggo/gin-swagger) for our rest api documentation. - **_Client service_** - [Typescript](https://github.com/KhaledHosseini/play-microservices/blob/master/https://www.typescriptlang.org/) : Programming language - [Next.js](https://github.com/KhaledHosseini/play-microservices/blob/master/https://nextjs.org/): Web framework that can be used for developing backend and front-end applications. - [Tailwind css](https://github.com/KhaledHosseini/play-microservices/blob/master/https://tailwindcss.com/): A utility-first CSS framework - [react-hook-form](https://github.com/KhaledHosseini/play-microservices/blob/master/https://react-hook-form.com/docs) - [TanStack Query](https://github.com/KhaledHosseini/play-microservices/blob/master/https://tanstack.com/query/latest): An asynchronous state management. --- ## How to add my simple service? - Backend GRPC service - Create and develop your gRPC service independently. For authentication, consider accepting an environment variable called `AUTH_PUBLIC_KEY_FILE` to read authentication public key for verifying authorization header which is a simple jwt with `role` (admin or user ) for authorization. - Do the follwing to the api-gateway service (For more info see [Here](https://github.com/KhaledHosseini/play-microservices/blob/master/https://dev.to/khaledhosseini/play-microservices-api-gateway-service-4a9j)). - Put your .proto file inside proto folder. Run `source build_grpc.sh` to compile your .proto file. - In api-gateway, inside `internal/models` folder create a file named `` and create the necessary rest layer models and the conversion to/from proto models. - Add `_URL` to the config/config.go - Create a folder named `` inside `internal/models` - Inside `` folder create a folder named grpc and then a file named client_service.go. Put your grpc service communication logic here (Read `_URL` from config). - Inside `` folder create a folder named handler and then a file named handler.go. Put your rest api for your grpc model here. - Add your rest-api end points to internal/api/router.go - Front-end service - Check the api-gateway rest api from [here](https://github.com/KhaledHosseini/play-microservices/blob/master/http://localhost:5010/swagger/index.html). - Develop your client application to communicate with the rest api. Finally add your service to the docker-compose.yml of the play-microservices. Add `_URL` to the api gateway environment variables. Also add `AUTH_PUBLIC_KEY_FILE=/run/secrets/auth-access-public-key` environemt variable to your service. --- ## Developing / Debuging Services have been developed independently from each other. To debug each of the services, just run `docker-compose up -d --build` from the folder of the service. Then using [VSCode](https://github.com/KhaledHosseini/play-microservices/blob/master/https://code.visualstudio.com/) extension [Dev Containers](https://github.com/KhaledHosseini/play-microservices/blob/master/https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) attach to the running container (Each service has several other dependent services in developement. Select the main service). Then open `usr/src/app` folder inside the container and finally run the appropriate commands based on the project (For more information on how to debug the services, see articles above). Example: Auth service - cd to `auth` folder - Run `docker-compose up -d --build` - While running, click on the bottom left button to open a remote window via [Dev Containers](https://github.com/KhaledHosseini/play-microservices/blob/master/https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) - Select attach to running container then select `authentication-service`. Wait until the vscode new window starts. - Open folder `usr/src/app` inside container. This folder is mounted to `auth-service` folder inside the host. - Open a new terminal and run `cargo run` - Start debugging. For more info see [Here](https://github.com/KhaledHosseini/play-microservices/blob/master/https://dev.to/khaledhosseini/play-microservices-authentication-4di3) --- ## Roadmap - Add tests - Add tracing - Deploy to CI/CD environment via Jenkins --- ## License MIT License

近期下载者

相关文件


收藏者