go-microservice-1

module
v0.0.0-...-2671613 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: Apache-2.0

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

Directories

Path Synopsis
cmd
internal
api/http/healthcheck
Package healthcheck provides primitives to interact with the openapi HTTP API.
Package healthcheck provides primitives to interact with the openapi HTTP API.
api/http/metrics
Package metrics returns a hand marshalled /metrics response.
Package metrics returns a hand marshalled /metrics response.
api/http/openapi
Package openapi returns a hand marshalled openapi.json response.
Package openapi returns a hand marshalled openapi.json response.
api/http/private
Package private provides primitives to interact with the openapi HTTP API.
Package private provides primitives to interact with the openapi HTTP API.
api/http/public
Package public provides primitives to interact with the openapi HTTP API.
Package public provides primitives to interact with the openapi HTTP API.
config
The scope of this file is: - Define the configuration struct.
The scope of this file is: - Define the configuration struct.
interface/presenter/echo
Package echo holds the presenter interfaces to use with the echo framework
Package echo holds the presenter interfaces to use with the echo framework
interface/presenter/event
Package event holds the presenter component for the asynchronous kafka events
Package event holds the presenter component for the asynchronous kafka events
interface/repository/client
Package client represent the interfaces to integrate to 3rd party micro-services.
Package client represent the interfaces to integrate to 3rd party micro-services.
test/builder
Package builder to help on building data models.
Package builder to help on building data models.
test/integration
Package smoke contains all the smoke test for the service
Package smoke contains all the smoke test for the service
usecase/repository/client
Package client holds the client implementation
Package client holds the client implementation
usecase/repository/event
Package event hold the event producers
Package event hold the event producers
usecase/repository/s3
Package s3 holds the load and storage primitives for S3 buckets
Package s3 holds the load and storage primitives for S3 buckets

Jump to

Keyboard shortcuts

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