ProductPromotion
Logo

Go.Lang

made by https://0x3d.site

GitHub - claygod/microservice: This library provides a simple microservice framework based on clean architecture principles with a working example implemented.
This library provides a simple microservice framework based on clean architecture principles with a working example implemented. - claygod/microservice
Visit Site

GitHub - claygod/microservice: This library provides a simple microservice framework based on clean architecture principles with a working example implemented.

GitHub - claygod/microservice: This library provides a simple microservice framework based on clean architecture principles with a working example implemented.

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/

Install

git clone ginhub.com/claygod/microservice
cd microservice
make build
make run

Go to localhost:8080 in your web browser

Endpoints

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

  • / welcome handler
  • /healthz/ready for SRE
  • /healthz for kubernetes
  • /readyness for kubernetes
  • /metrics prometheus metrics
  • /swagger generate swagger fo api
  • /piblic/v1/bar/:key public route (example)

[!CAUTION] Requests from an external balancer should be forwarded not to the root of endpoints, but to /public. Then service routes with metrics and other private information will be inaccessible to external users.

Using

Build and run main.go

Example requests:

  • localhost:8080/piblic/v1/bar/one -> {"Data":"three"}
  • localhost:8080/piblic/v1/bar/secret -> response 404
  • localhost:8080/piblic/v1/bar/looooonnngggoooooggkkkeeyyyyyyy -> response 400 (not valid)
  • localhost:8080/healthz/ready -> minute first 5 sec - 503 after 200 (for example!)
  • localhost:8080/healthz -> minute first 5 sec - 503 after 200 (for example!)
  • localhost:8080/readyness -> response 200
  • localhost:8080/swagger -> json-swagger

Swagger

After starting the application, the first time route /swagger is called, the swagger file config/swagger.yaml is regenerated.

Environment

Add to ENV export GATE_IN_TITLE=Yo-ho-ho! :+1: ang open in browser http://localhost:8080/ :tada:

Clean architecture

[!IMPORTANT] Distribution of architectural entities by layers

Entity

Path /domain

Usecases

Path /usecases

Interfaces

Path /service

Infrastructure

Path /app , /config and core

Config

The default configuration file:

  • config/config.yaml

Specify in the command line another file:

  • yourservice -config other.yaml

Dependencies

github.com/claygod/tools v0.0.0-20211122181936-bab1329a2e3d
github.com/dsbasko/go-cfg v1.2.0
github.com/google/uuid v1.3.0
github.com/julienschmidt/httprouter v1.3.0
github.com/pborman/getopt v1.1.0
github.com/prometheus/client_golang v1.11.0
github.com/savaki/swag v0.0.0-20170722173931-3a75479e44a3
sigs.k8s.io/yaml v1.4.0

github.com/BurntSushi/toml v1.3.2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/caarlos0/env/v10 v10.0.0 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.22.1 // indirect
github.com/golang/protobuf v1.4.3 // indirect
github.com/joho/godotenv v1.5.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.26.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/crypto v0.19.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/protobuf v1.26.0-rc.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect

ToDo

  • Use environment variables in configuration
  • Add support for metrics
  • Input validate
  • Swagger 2.0
  • 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!

[!TIP] 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

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

Articles
to learn more about the golang concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about GoLang.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory