Sign inSign up

efbar/minimal-service

By efbar

•Updated over 3 years ago

Just an HTTP server for useful microservices testing purposes

Image
0

322

efbar/minimal-service repository overview

⁠Minimal Service

CircleCI

⁠Docker Images

https://hub.docker.com/r/efbar/minimal-service⁠

⁠Dockerfile

https://github.com/efbar/minimal-service/blob/main/Dockerfile⁠

⁠Aim of the project

The purpose is to create a simple HTTP service to be used in microservices environments. This service can be deployed as raw binary or as a container and could be useful for testing service-to-service communication with focus on service discovery and service mesh scenarios.

⁠How it works

It accepts only two methods, GET and POST.

At every GET request, it will respond with the same sent body or none if empty or not present in request. It will add some useful headers like timing metrics related headers and who served the request. Request Content-Type could be application/json and text/plain, it will respond accordingly.

A POST request at path /bounce is accepted. Then it will check that body must include a json string:

{"rebound":"true","endpoint":"http://my.other.service"}

it will strictly check json keys and then it will do a GET request to the endpoint filled in endpoint key.

Every other body with any differences (unless the endpoint value) will be discarded and warned.

If the endpoint value has a valid and alive url and the next POST request ends positively, the response will have as Headers the ones received from the endpoint response, plus some others like Response-time, Request-time and Duration. The body will contain the endpoint's response HTTP status (OK 200).

In case of not 200 codes from the endpoint, the headers will be not modified and the body will contain 500 Internal Server Error.

⁠Features

The service has some features and you can set them with environment variables.

  • Choose the port where the service is listening to
  • Set a maximum delay time, so at every request received it will wait for a number of seconds in the range from 0 to the chosen value.
  • It will enable tracing to a Jaeger endpoint through the use of OpenTelemetry dependency. It traces status codes and headers.
  • Discard request entirely without any feedback or reject them with 500 http status response.
  • Consul Connect integration, setting some env variables, you can register this service to a Consul catalog.

This service can be started setting various environment variables, here the list:

Env variabledefaultvalue range
SERVICE_PORT9090
DELAY_MAX0
TRACING00 or 1
JAEGER_URLhttp://localhost:14268/api/tracesURI in form scheme://host:port/api/traces
DISCARD_QUOTA0from 0 to 100
REJECT00 or 1
DEBUG00 or 1
CONNECT00 or 1
CONSUL_SERVERhttp://127.0.0.1:8500URI in form scheme://host:port
⁠Health Status API

You can perform an health-check with a simple GET request at path /health. If up, it will respond with a 200 status and with Status OK string in body.

⁠Build, Test, Installation, Run and so on...

You can use Makefile:

Choose a command from list below
 usage: make <command>

  build
  run
  install
  test
  clean
  build-linux
  build-mac
  build-windows
  build-docker

Tag summary

Content type

Image

Digest

sha256:262c89867…

Size

14.6 MB

Last updated

over 3 years ago

docker pull efbar/minimal-service:1.0.2