Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

poc-hello-world/namer-service

Repository files navigation

Namer service

GitHub License: MIT Gitpod: ready-to-code

Mergify Status Maintenance status: best-effort

Proof-of-Concept (PoC) application that returns a name. It is indented to be called by another application that composes a "Greeting name!" output.

For example for "Hello world!" this app would be the one providing the "world".

Architecture diagram showing the flow: Hello service, a React app, calls Greeting service to get a greeting (eg "hello") and calls Naming service to get a name (eg "world"). Hello service then adds the answer together for the final result: "Hello World!"

Intended use

The purpose of this application is to be used for microservices tech demos and example implementations of tools.

It is in no way, shape, or form a reference for best practices, a good example, or a comprehensive anything. It is a minimal skeleton app with simple logic that can easily be extended.

For more complex demos see:

Usage

This repository is configured with support for GitPod for easy development.

Local application commands:

go build -o app # to build the app

go test # to run the tests

./app # to run the app (if not already running)

Docker commands:

docker run --interactive --tty --rm \
  --publish 5003:5003 \
  public.ecr.aws/poc-hello-world/namer-service:latest

Endpoints exposed by the application:

# curl -v http://localhost:5003
  *   Trying ::1...
  * TCP_NODELAY set
  * Connected to localhost (::1) port 5003 (#0)
  > GET / HTTP/1.1
  > Host: localhost:5003
  > User-Agent: curl/7.64.1
  > Accept: */*
  >
  < HTTP/1.1 200 OK
  < Access-Control-Allow-Headers: Accept, Accept-Language, Content-Type, X-Version, X-Reply-Service
  < Access-Control-Allow-Methods: GET, OPTIONS
  < Access-Control-Allow-Origin: *
  < Content-Type: application/json
  < X-Reply-Service: namer-service
  < X-Version: dev
  < Date: Thu, 1 Apr 1000 10:10:09 GMT
  < Content-Length: 17
  <
  {"name":"world"}

# curl -v http://localhost:5003/status/alive
  *   Trying ::1...
  * TCP_NODELAY set
  * Connected to localhost (::1) port 5003 (#0)
  > GET /status/alive HTTP/1.1
  > Host: localhost:5003
  > User-Agent: curl/7.64.1
  > Accept: */*
  >
  < HTTP/1.1 200 OK
  < Access-Control-Allow-Headers: Accept, Accept-Language, Content-Type, X-Version, X-Reply-Service
  < Access-Control-Allow-Methods: GET, OPTIONS
  < Access-Control-Allow-Origin: *
  < Content-Type: application/json
  < X-Reply-Service: namer-service
  < X-Version: dev
  < Date: Thu, 1 Apr 1000 10:10:10 GMT
  < Content-Length: 38
  <

  {"status":"Namer service is alive"}

# curl -v http://localhost:5003/status/heathy
  *   Trying ::1...
  * TCP_NODELAY set
  * Connected to localhost (::1) port 5003 (#0)
  > GET /status/healthy HTTP/1.1
  > Host: localhost:5003
  > User-Agent: curl/7.64.1
  > Accept: */*
  >
  < HTTP/1.1 200 OK
  < Access-Control-Allow-Headers: Accept, Accept-Language, Content-Type, X-Version, X-Reply-Service
  < Access-Control-Allow-Methods: GET, OPTIONS
  < Access-Control-Allow-Origin: *
  < Content-Type: application/json
  < X-Reply-Service: namer-service
  < X-Version: dev
  < Date: Thu, 1 Apr 1000 10:10:11 GMT
  < Content-Length: 40
  <

  {"status":"Namer service is healthy"}

Configuration and forking

This repository is fork-friendly!

  • fork this repository
  • go to the "Actions" tab and enable GitHub Actions
  • setup relevant secrets
    • to build and push a container image to Amazon ECR
      • AWS_ACCESS_KEY_ID looking something like AKIAIOSFODNN7EXAMPLE
      • AWS_SECRET_ACCESS_KEY looking something like wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
  • change relevant values in .github/workflows/app-build-and-push.yaml
  • change something in the code and create a new Pull Request

Forks

If you extend this application to do something, please create a Pull Request back with a link to your fork.

Fork link Extras added
+ dynamically read name from DynamoDB

License

This project is provided under the MIT License. See LICENSE for more information.