https://github.com/moleculer-go/moleculer
🚀 Progressive microservices framework for Go - based and compatible with https://github.com/moleculerjs/moleculer
https://github.com/moleculer-go/moleculer
fun go microservice microservice-framework microservices moleculer
Last synced: 29 days ago
JSON representation
🚀 Progressive microservices framework for Go - based and compatible with https://github.com/moleculerjs/moleculer
- Host: GitHub
- URL: https://github.com/moleculer-go/moleculer
- Owner: moleculer-go
- License: mit
- Created: 2019-01-15T04:30:55.000Z (about 7 years ago)
- Default Branch: develop
- Last Pushed: 2025-09-12T08:46:54.000Z (6 months ago)
- Last Synced: 2025-09-12T10:11:34.109Z (6 months ago)
- Topics: fun, go, microservice, microservice-framework, microservices, moleculer
- Language: Go
- Size: 3.37 MB
- Stars: 148
- Watchers: 11
- Forks: 28
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Moleculer Go
🚀 Progressive microservices framework for Go

Inspired and compatible with [Moleculer JS](https://github.com/moleculerjs/moleculer)
Simple, fast, light and fun to develop with. Also easy, very easy to test ;)
[](https://gitter.im/moleculer-go/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[](https://cloud.drone.io/moleculer-go/moleculer)
[](https://goreportcard.com/report/github.com/moleculer-go/moleculer)
[](https://coveralls.io/github/moleculer-go/moleculer?branch=master)
[](https://codecov.io/gh/moleculer-go/moleculer)

# Get Started
- [http://gomicro.services (Official site and Documentation)](http://gomicro.services)
- [Database examples](https://moleculer-go-site.herokuapp.com/docs/0.1/store.html)
## Example
```go
package main
import (
"fmt"
"github.com/moleculer-go/moleculer"
"github.com/moleculer-go/moleculer/broker"
)
type MathService struct {
}
func (s MathService) Name() string {
return "math"
}
func (s *MathService) Add(params moleculer.Payload) int {
return params.Get("a").Int() + params.Get("b").Int()
}
func (s *MathService) Sub(a int, b int) int {
return a - b
}
func main() {
var bkr = broker.New(&moleculer.Config{LogLevel: "error"})
bkr.Publish(&MathService{})
bkr.Start()
result := <-bkr.Call("math.add", map[string]int{
"a": 10,
"b": 130,
})
fmt.Println("result: ", result.Int())
//$ result: 140
bkr.Stop()
}
```
# Features
- Service Broker
- Transit and Transport
- Actions (request-reply)
- Events
- Mixins
- Load balancing for actions and events (random round-robin)
- Service registry & dynamic service discovery
- Versioned services
- Middlewares
- NATS Streaming Transporter
- TCP Transporter
- Redis Transporter
- JSON Serializer
# Installation
```bash
$ go get github.com/moleculer-go/moleculer
```
# Running examples
```bash
# simple moleculer db example with memory adaptor
$ go run github.com/moleculer-go/store/examples/users
# simple moleculer db example with Mongo adaptor
$ go run github.com/moleculer-go/store/examples/usersMongo
# simple moleculer db example with SQLite adaptor
$ go run github.com/moleculer-go/store/examples/usersSQLite
# complex moleculer db example with population of fields by other services
$ go run github.com/moleculer-go/store/examples/populates
```
# Running tests
```
# integration tests require mongo, nats streaming and rabbitmq
# run mongo
docker run -d -p 27017:27017 mongo
# run nats-streaming
docker run -d -p 4222:4222 nats-streaming -mc 0
# run rabbitmq
docker run -d -p 5672:5672 rabbitmq
# running all tests
go test ./...
# or
ginkgo -r
```