Coder Social home page Coder Social logo

claygod / microservice Goto Github PK

View Code? Open in Web Editor NEW
115.0 9.0 15.0 11 MB

This library provides a simple microservice framework based on clean architecture principles with a working example implemented.

License: Other

Go 100.00%
golang go microservices microservice clean-architecture framework

microservice's Introduction

Microservice

API documentation Mentioned in Awesome Go forks stars Go Report Card

The framework for the creation of microservices, written in Golang. This package is implemented using clean architecture principles. A good article on implementing these principles in Golang: http://manuel.kiessling.net/2012/09/28/applying-the-clean-architecture-to-go-applications/

Endpoints

Code in /services/gateways/gatein/gatein.go

  • / welcome handler
  • /health_check for SRE
  • /readyness for kubernetes
  • /metrics prometheus metrics
  • /piblic/v1/bar/:key public route (example)

Using

Build and run main.go

Example requests:

  • localhost:8080/piblic/v1/bar/one
  • localhost:8080/piblic/v1/bar/123
  • localhost:8080/piblic/v1/bar/secret -> response 404
  • localhost:8080/piblic/v1/bar/looonnngggggkkkeeyyyyyyy

Clean architecture

Distribution of architectural entities by layers

Entity

Path /domain

Usecases

Path /usecases

Interfaces

Path /service

Infrastructure

Path /app , /config and core

Config

Types of variables that support the use of environment variables in the configuration (a pointer is required, or will be ignored!) :

  • string
  • float32, float64
  • int, int8, int16, int32, int64
  • uint, uint8, uint16, uint32, uint64

The default configuration file:

  • config/config.toml

Specify in the command line another file:

  • yourservice -config other.toml

Use environment variables in configuration:

  • yourservice -env true

Command line xample:

  • foo -config stage.toml -env true

Configuration with environment tag example:

type Config struct {
	MaxIDLenght *int `env:"FOO_MAX_ID_LENGHT"`
}

Dependencies

  • github.com/BurntSushi/toml
  • github.com/claygod/tools
  • github.com/google/uuid
  • github.com/julienschmidt/httprouter
  • github.com/pborman/getopt
  • github.com/prometheus/client_golang
  • github.com/prometheus/tsdb
  • github.com/sirupsen/logrus

ToDo

  • Use environment variables in configuration
  • Add support for metrics
  • Use protocol gRPC

Conclusion

Microservice does not claim the laurels of the only true solution, but on occasion, I hope, will help you create your own micro-architecture of the service, becoming the prototype for future applications.

Give us a star!

If you like or are using this project to learn or start your solution, please give it a star. Thank you!

License

GNU GENERAL PUBLIC LICENSE Version 3

Copyright © 2017-2024 Eduard Sesigin. All rights reserved. Contacts: [email protected]

microservice's People

Contributors

claygod avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.