Categorygithub.com/ONSdigital/rm-survey-service
modulepackage
10.51.0+incompatible
Repository: https://github.com/onsdigital/rm-survey-service.git
Documentation: pkg.go.dev

# README

Codacy Badge Docker Pulls Build Status

Survey Service

This repository contains the Survey service. This microservice is a RESTful web service implemented using Go. This service features structured JSON logging, a self-bootstrapping database schema and database connection code that retries the connection if it's not available, increasing the time between each attempt. This eliminates the need to deploy services in a specific order.

Prerequisites

  • Install the Godep package manager using go get github.com/tools/godep
  • Run godep get to download and install the other dependencies managed by Godep

API

See API.md for API documentation.

Building

Install Go and ensure your GOPATH environment variable is set (usually it's ~/go).

Make

A Makefile is provided for compiling the code:

make

The compiled executable is placed within the build directory tree.

Docker Image

To build the Docker image, first compile the code using make then from the project root run:

make docker

Running

First compile the code using make then execute the binary in the background using ./surveysvc & from within the bin directory within the build directory tree.

The following environment variables may be overridden:

Environment VariablePurposeDefault Value
DATABASE_URLPostgreSQL postgres user connection stringpostgres://postgres:password@localhost/postgres?sslmode=disable
PORTHTTP listener port:8080
security_user_nameHTTP basic authentication user nameN/A
security_user_passwordHTTP basic authentication passwordN/A
CONN_MAX_LIFETIMEMax lifetime of connection in pool in seconds0, so there is no time limit
MAX_IDLE_CONNMax idle connections to have in pool2

Docker Image and PostgreSQL

To start Docker containers for both PostgreSQL and the Survey service, run:

docker-compose up -d

To stop and remove the two Docker containers, run:

docker-compose down

Testing

Run the unit tests using:

make test

To run the integration tests using make run:

make integration-test

This will build a docker image from source and run the container then run all tests including integration tests.

Deployment

To deploy to Cloud Foundry, run one of the targets below depending on the Cloud Foundry space you wish to push to:

make push-ci
make push-demo
make push-dev
make push-int
make push-test

Cleaning

To clobber the build directory tree that's created when running make, run:

make clean

Copyright

Copyright (C) 2017 Crown Copyright (Office for National Statistics)

# Packages

No description provided by the author

# Functions

LogError log out error messages.
LogInfo log out info log messages.