service-golang

command module
v0.0.0-...-a0fbff0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2023 License: MIT Imports: 8 Imported by: 0

README

service-golang

This is a simple example to build a microservice in Go. It has an HTTP server and RabbitMQ client packages.

Running it

The service needs MongoDB and RabbitMQ to run succesfully. Let's use docker-compose to run those servers.

docker-compose up -d mongodb rabbitmq

And now you can build and run the server:

go build && ./service-golang

Creating and image with docker

To run as a service we can create an image and use docker-compose to start the containers. First the image:

docker build . -t service:latest

Now we can run all the servers together using docker-compose.

docker-compose up -d

Accessing the API

To see a Hello World: localhost:8000.

To check the bitcoin variation on a period: localhost:8000/bitcoin/startdate/YYYY-MM-DD/enddate/YYYY-MM-DD

Stopping the services

Again with docker-compose:

docker-compose down

Documentation

Overview

Package main is a service example on how to start, wait and shutdown

Directories

Path Synopsis
Package cryptoasset contains the calculus for bitcoin variation day by day
Package cryptoasset contains the calculus for bitcoin variation day by day
Package dbmongo has the mongoDB client as singleton
Package dbmongo has the mongoDB client as singleton
Package httpserver contains the HTTP server and the routes
Package httpserver contains the HTTP server and the routes
Package queuerabbit contains all the RabbitMQ setup
Package queuerabbit contains all the RabbitMQ setup
Package servicemanager contains the functions to control the service shutdown
Package servicemanager contains the functions to control the service shutdown

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL