This is Go implementation of User access microservice.
We use Postgres for storage and Kafka for Asynchronous notification of user changes
This service provide a GRPC API at port :50051
service UserService {
rpc AddUser(UserRequest) returns (UserResponse) {}
rpc UpdateUser(UserRequest) returns (UserResponse) {}
rpc RemoveUser(UserRequest) returns (UserResponse) {}
rpc GetUsers(GetUsersRequest) returns (GetUsersResponse) {}
}
message UserRequest {
string id = 1;
string first_name = 2;
string last_name = 3;
string nickname = 4;
string password = 5;
string email = 6;
string country = 7;
}
The API has below endpoints:
Create a new User This endpoint accepts a JSON payload containing a user data.
Request Payload
Example request payload:
{
"first_name": "Mohamed",
"last_name": "Aly",
"nickname": "MA",
"password": "pw2",
"email": "[email protected]",
"country": "FIN"
}
Return a paginated list of Users, allowing for filtering by certain criteria (e.g. all Users with the country "UK")
Update a user Request Payload
{
"first_name": "Mohamed",
"last_name": "Aly",
"nickname": "MA",
"password": "pw2",
"email": "[email protected]",
"country": "FIN"
}
Delete a user
health check
This layout is following pattern:
merkleTree
└───
├── .github
│ └── workflows
│ └── go.yml
├── cmd
│ └── main.go
│ └── app
│ └── setup.go
│ └── app.go
│ └── context.go
├── internal
│ └── app
│ └── handler.go
│ └── user_service.go
│ └── notifier
│ └── kafka_notifier.go
│ └── repository
│ └── user_repository.go
│ └── domain
│ └── user.go
├── pkg
│ └── grpc
│ └── grpcServer.go
│ └── user.pb.go
│ └── user._grpc.pb.go
│ └── user.proto
├── build
│ └── Dockerfile
├── Makefile
├── README.md
└── <source packages>
user-svc is available in github user-svc
go get github.com/reactivejson/users-svc
make environment-start
go run cmd/main.go
make build
make test
make environment-start
make test-integration
make docker-build
This will build this application docker image so-called user-svc