Skip to content

Amirhossein2000/RequestTasker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Summary

  • This app serves as an asynchronous request sender.
  • The project follows the principles of Domain-Driven Design (DDD) in its structure.
  • A message broker is utilized to improve scalability and prevent data loss.
  • Three entities are stored in the database.
  • The Server service manages two HTTP endpoints for registering requests and exposing results.
  • The Tasker service produces and consumes tasks (requests), sending them to third-party servers and storing the results in the database.
  • The API development approach prioritizes documentation, employing a document-first methodology, with code generation facilitated by oapi-codegen.

Request Tasker Flow

Request Tasker Database Schema

Dependencies

go install github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen@latest
go get -u github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen
go install github.com/vektra/mockery/[email protected]
brew install go-task
brew install mockery
brew install golang-migrate

Taskfile

Instead of a Makefile, this project uses a Taskfile. Check Taskfile.yml for a list of commands and descriptions.

Run

task dep-up
task run

API Documentation

Chcek this api.yml openapi file.

Configs

  • All configurations are in the .env file.
  • The Docker container overwrites a few configurations in ./dep/.env.

Testing

This project includes both mocked and integration tests implemented with Mockery and testcontainer. Run all tests with the command: task test.

To run specific tests:

  • task test-usecase
  • task test-api
  • task test-tasker
  • task test-db
  • task test-kafka

In the case of any changes in interfaces, it's requried to run the task generate-mock command.

Additional Considerations for the Future

  • Currently, there is no retry mechanism for failed requests. If a dead-letter queue is added to this project, failed requests can be retried.
  • Optimize test environment by leveraging local infrastructure instead of creating and deleting containers for each test.
  • Add health_check.
  • Use Transaction for sql queries.
  • Separate api and worker to different build binary files or use the component separation in the same binary way.

About

This app serves as an asynchronous request sender.

Resources

Stars

Watchers

Forks