Sign inSign up

kunupat/bar

By kunupat

•Updated almost 7 years ago

A Spring Boot Rest Service with two endpoints

Image
0

333

kunupat/bar repository overview

⁠A Spring Boot Rest Service with two endpoints

⁠Source Code

https://github.com/kunupat/bar⁠

⁠Docker Run

Use Docker environment variables to override spring.datasource.url, spring.datasource.username and spring.datasource.password properties. E.g.:


docker run 
-m 0.25g
-p 8081:8081 
-e spring.datasource.url=jdbc:postgresql://{your_db_url}/BarDB 
-e spring.datasource.username={your_db_user_name}
-e spring.datasource.password={your_db_user_password}
--rm 
--name bar.service.api 
81f62041be5a

Use SQL scripts listed under SQL section⁠ to create BarDB database and movies table.

⁠Endpoints

  1. /data : Fetch data from PostgreSQL
  2. /actuator/health : A health check endpoint

⁠URLs

  • Port: 8081
  • http://localhost:8081/data
  • http://localhost:8081/actuator/health

⁠SQL


CREATE DATABASE "BarDB"
    WITH 
    OWNER = postgres
    ENCODING = 'UTF8'
    LC_COLLATE = 'English_United States.1252'
    LC_CTYPE = 'English_United States.1252'
    TABLESPACE = pg_default
    CONNECTION LIMIT = -1;


CREATE TABLE movies(
   movie_id serial PRIMARY KEY,
   movie_name VARCHAR (50) NOT NULL,
   release_year VARCHAR (4) NOT NULL
);
commit;

insert into movies (movie_name, release_year) values('The Shawshank Redemption','1994');
insert into movies (movie_name, release_year) values('Se7en','1995');
insert into movies (movie_name, release_year) values('Fight Club','1999');
commit;

⁠Jaeger Env Vars


JAEGER_SERVICE_NAME=bar
JAEGER_SAMPLER_TYPE=const
JAEGER_SAMPLER_PARAM=1
JAEGER_REPORTER_LOG_SPANS=true
JAEGER_ENDPOINT=http://{Your_Jaeger_Server}:14268/api/traces

Tag summary

Content type

Image

Digest

Size

265.4 MB

Last updated

almost 7 years ago

docker pull kunupat/bar