Giter VIP home page Giter VIP logo

userdatalink's Introduction

User Service with Search Functionality using gRPC as transportation layer

Software Architecture Patterns and paradiagms used -

  • Repository Pattern → used in Repository-Layer/Database layer inside the internal/database directory to make business logic and database layer logic decoupled. In future if needed just make the struct and implement the UserRepository interface to the desired database (Postgres/Cassandra/MongoDb) such that there will be no need to make any changes in the UserService Service layer.
  • Separation Of Concern (from SOLID) → there is a separation between the transportation layer gRPC and the Service layer and the repository layer
  • Dependency Inversion Principle (from SOLID) → Dependency of UserRepository is injected in the UserService to perform Db-calls.
  • Builder Pattern from Design Principles → used in the constructor of the UserService which itself configure the gRPC's Reflection and bind the PORT to the service.
  • Idiomatic practices encouraged by the Golang Community → efficient use of maps, slices etc.

Protocol Buffers v3 Definition

  • UserService Proto Definition-
+-------------+--------------------+---------------------------+----------------------------+
|   SERVICE   |        RPC         |       REQUEST TYPE        |       RESPONSE TYPE        |
+-------------+--------------------+---------------------------+----------------------------+
| UserService | GetUserById        | GetUserByIdRequest        | GetUserByIdResponse        |
| UserService | GetUsersListByIds  | GetUsersListByIdsRequest  | GetUsersListByIdsResponse  |
| UserService | GetUsersByCriteria | GetUsersByCriteriaRequest | GetUsersByCriteriaResponse |
+-------------+--------------------+---------------------------+----------------------------+
  • Available Proto Message Types-
+----------------------------+
|          MESSAGE           |
+----------------------------+
| GetUserByIdRequest         |
| GetUserByIdResponse        |
| GetUsersByCriteriaRequest  |
| GetUsersByCriteriaResponse |
| GetUsersListByIdsRequest   |
| GetUsersListByIdsResponse  |
+----------------------------+
  • GetUserById RPC types-

    • Request
    +-------+------------+----------+
    | FIELD |    TYPE    | REPEATED |
    +-------+------------+----------+
    | id    | TYPE_INT64 | false    |
    +-------+------------+----------+
    
    
    • Response
    +-------+---------------------+----------+
    | FIELD |        TYPE         | REPEATED |
    +-------+---------------------+----------+
    | user  | TYPE_MESSAGE (User) | false    |
    +-------+---------------------+----------+
    
  • GetUsersListByIds RPC types-

    • Request
    +-------+------------+----------+
    | FIELD |    TYPE    | REPEATED |
    +-------+------------+----------+
    | ids   | TYPE_INT64 | true     |
    +-------+------------+----------+
    
    
    • Response
    +-------+---------------------+----------+
    | FIELD |        TYPE         | REPEATED |
    +-------+---------------------+----------+
    | users | TYPE_MESSAGE (User) | true     |
    +-------+---------------------+----------+
    
  • GetUsersByCriteria RPC types-

    • Request
    +-------+---------------------------+----------+
    | FIELD |           TYPE            | REPEATED |
    +-------+---------------------------+----------+
    | type  | TYPE_ENUM (UserCriterias) | false    |
    | value | TYPE_STRING               | false    |
    +-------+---------------------------+----------+
    
    
    • Response
    +-------+---------------------+----------+
    | FIELD |        TYPE         | REPEATED |
    +-------+---------------------+----------+
    | users | TYPE_MESSAGE (User) | true     |
    +-------+---------------------+----------+
    

For the request and response of RPC calls checkout the user_service.proto

  • Grpc Interceptor Logging for Incoming Requests alt-logging-image

Environment Variable

To run this project, The environment variable PORT must be in the accessible scope which is used to set the port where the gRPC server will be listening for the incoming connections.

Steps To Run

  • Without Docker in Linux/WSL Environment:
    • make run - will execute the source code.
    • make build - will build the executable binary from the source code.
  • With Docker:
    • docker build . -t user-service - will build image from Dockerfile.
    • docker run -d --restart=always -p 8080:8080 user-service - will run the image inside container.

userdatalink's People

Contributors

ansh-devs avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.