Skip to content

Example implementation of a profile microservice using Lagom

License

Notifications You must be signed in to change notification settings

danieldirks/lagom-profile-example

Repository files navigation

Profile Microservice

Example implementation of a profile microservice using Lagom

MIT License

Installation

Make sure you have a running Java environment and sbt set up.

Clone/download the repository and run sbt runAll inside the project root to start the microservice on port 9000. It will take a while to set up all dependencies on first run.

DISCLAIMER: This project is for educational purpose only.

Project structure

The API is defined in ProfileService and implemented in ProfileServiceImpl.

Lagom uses CQRS and Event Sourcing to store and execute requests. The entities behavior is defined in ProfileEntity, Commands, Queries (= Read-only commands) and Events in ProfileCommand and ProfileEvent and the state is stored in ProfileState.

The Profile message is located inside an additional subproject to allow usage outside this project. In real cloud platforms this should be a shared dependency to maintain message integrity across all microservices.

Usage

This should only demonstrate the use of Lagom's REST interface.

Action Method Description Parameters Request body Response body Code
Create profile PUT Creates a new profile with <email> and <name> and returns it. None ProfileCreate Profile cURL
Get profile GET Returns the profile UUID None Profile cURL
Update profile POST Updates the profile (id and email are currently immutable) UUID Profile Done cURL
Delete profile DELETE Deletes the profile UUID None Done cURL
Ping GET Use for health checks None None Done cURL

cURL

Create profile

curl -X PUT -d '{"name":"<name>","email":"<email>"}' localhost:9000/v1/profile

Get profile

curl localhost:9000/v1/profile/<uuid>

Update profile

curl -X POST -d '{"id":"<uuid>","email":"<email>","name":"<name>"}' localhost:9000/v1/profile/<uuid>

Delete profile

curl -X DELETE localhost:9000/v1/profile/<uuid>

Ping

curl localhost:9000/ping

License

The project is licensed under the MIT License.

About

Example implementation of a profile microservice using Lagom

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages