Categorygithub.com/avisiedo/go-microservice-1
repository
0.0.0-20241210120417-267161374232
Repository: https://github.com/avisiedo/go-microservice-1.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

go-microservice-1

The goal of this repository is to inspire a getting started golang microservice which use a design first approach and provide a productive way to create resources for the API.

Getting started

  • Pre-requisites
# Install required packages
$ sudo dnf install git golang make podman podman-compose delve

# Create and edit the file confis/config.yaml
$ cp -vf configs/config.example.yaml configs/config.yaml

# Install local tools
$ make tidy
$ make install-tools

# Build all the requirements and start the local infra
$ make compose-build compose-clean clean build compose-up

Day to day:

  • Start the service: make run

  • Run some test request by: ./test/sripts/todos-list.sh

  • Run tests by: make test or make test-unit or make test-integration

  • Open apicurio to load, edit and save the openapi specification by: make apicurio-start

If you want to use TDD, then start implementing some tests to fail, and cover every small change. Run tests by test, test-unit or test-integration make rules and add the necessary code.

Repository layout

/api - Contain all the APIs
  /http - Contain the openapi specification.
  /event - Contain json schema to define the event formats.
/internal
  /data - the database model
  /handler - the http and event handlers
    /http
    /event
  /infrastructure
    All the code directly related with
    frameworks and libraries.
  /interface
    The interfaces for presenter, interactor and
    repositories are stored here.
    /presenter
      Adapter between the framework and the
      business logic independent code; every
      http handler and middleware has a
      presenter that wrap the interactor.
    /repository
      Data input/output of the system.
      /client
        /http
        /event
      /db
      /s3
    /interactor
      Free form layout to represent the business
      logic; this is framework independent.
  /usecase
    Same layout that interface, with the implementation.
  /test
    Test helper, mocks, integration tests.
    /mock
    /integration - Hold all the integration tests.
    /builder
      /db
      /api
/test
  /data
    /http
    /event
  /scripts
  /http

    

Acknowledgements