• Stars
    star
    114
  • Rank 308,031 (Top 7 %)
  • Language
    Go
  • License
    Other
  • Created almost 8 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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/

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-2022 Eduard Sesigin. All rights reserved. Contacts: [email protected]

More Repositories

1

transaction

Embedded database for accounts transactions.
Go
134
star
2

Bxog

Bxog is a simple and fast HTTP router for Go (HTTP request multiplexer).
Go
102
star
3

coffer

Simply ACID* key-value database. At the medium or even low latency it tries to provide greater throughput without losing the ACID properties of the database. The database provides the ability to create record headers at own discretion and use them as transactions. The maximum size of stored data is limited by the size of the computer's RAM.
Go
38
star
4

PiHex

PiHex Library, written in Go, generates a hexadecimal number sequence in the number Pi in the range from 0 to 10,000,000.
Go
20
star
5

mmoa

Monolithic Message-Oriented Application (MMOA)
Go
9
star
6

Rumba

Micro framework Rumba written in Lua language for web development faster and light sites or CMS that are hosted on Apache (with mod_lua module)
Lua
8
star
7

processing

Blockchain-like decentralized distributed DAG-registry for processing
Go
6
star
8

door

Nimble multiplexer for Fast HTTP server, written in Golang
Go
3
star
9

accounter

Transactions and accounting of accounts.
Go
2
star
10

Context

Written in Golang Context library stores designed to store the application context.
Go
1
star
11

exchange

Exchange engine
Go
1
star
12

BxogTest

Test router Bxog and its benchmark (and other popular routers - multiplexers, written in the Go)
Go
1
star
13

BxogV2

Based on the Bxog, but a slower router
Go
1
star
14

structer

Storage for structures (embedded) with the ability to search by field structure.
Go
1
star
15

dotcp

TCP server with RPC mode for JSON.
Go
1
star