Go Micro plugins
  • Go 99.7%
  • Shell 0.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Jörn Friedrich Dreyer 2332579305 do not try to unmarshal on deletes
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2025-05-12 17:27:54 +02:00
.github/workflows feat(action): release script 2022-11-01 18:25:52 +01:00
scripts fix go work 2024-07-25 21:47:28 +01:00
v2 feat: http server has open injection capability, like grpc server can inject listen. 2022-10-08 11:32:37 +08:00
v3 fix(server/grpc): initiate wg on configure call instead of constructor (#85) 2022-11-24 20:29:18 +01:00
v4 do not try to unmarshal on deletes 2025-05-12 17:27:54 +02:00
v5 docs: updates in readmes 2025-04-30 06:33:51 -04:00
.gitignore feat(registry): new registry Polaris (#72) 2022-10-20 16:31:54 +02:00
.golangci.yaml feat(store/nats-js-kv): Add kv based natsjs store 2023-12-14 16:54:41 +01:00
go.work fix(go.work): run go work sync 2025-05-12 17:27:54 +02:00
go.work.sum fix(go.work): run go work sync 2025-05-12 17:27:54 +02:00
LICENSE First 2022-04-07 11:27:35 +01:00
Makefile feat: add logger option to plugins (#78) 2022-10-20 12:36:36 +02:00
README.md Update README.md 2025-05-02 07:29:51 +01:00

Plugins License GoDoc

Plugins for Go Micro

Overview

Micro is built on a powerful pluggable architecture. Plugins can be swapped out with zero code changes. This repository contains plugins for all micro related tools. Read on for further info.

Getting Started

Contents

Contents of this repository:

Directory Description
Broker PubSub messaging; NATS, NSQ, RabbitMQ, Kafka
Client RPC Clients; gRPC, HTTP
Codec Message Encoding; BSON, Mercury
Micro Micro Toolkit Plugins
Registry Service Discovery; Etcd, Gossip, NATS
Selector Load balancing; Label, Cache, Static
Server RPC Servers; gRPC, HTTP
Transport Bidirectional Streaming; NATS, RabbitMQ
Wrapper Middleware; Circuit Breakers, Rate Limiting, Tracing, Monitoring

Usage

Plugins can be added to go-micro in the following ways. By doing so they'll be available to set via command line args or environment variables.

Import the plugins in a plugins.go file

package main

import (
	_ "github.com/micro/plugins/v5/broker/rabbitmq"
	_ "github.com/micro/plugins/v5/registry/kubernetes"
	_ "github.com/micro/plugins/v5/transport/nats"
)

Create your service and ensure you call service.Init

package main

import (
	"go-micro.dev/v5"
)

func main() {
	service := micro.NewService(
		// Set service name
		micro.Name("my.service"),
	)

	// Parse CLI flags
	service.Init()
}

Build your service

go build -o service ./main.go ./plugins.go

Env

Use environment variables to set the

MICRO_BROKER=rabbitmq \
MICRO_REGISTRY=kubernetes \ 
MICRO_TRANSPORT=nats \ 
./service

Flags

Or use command line flags to enable them

./service --broker=rabbitmq --registry=kubernetes --transport=nats

Options

Import and set as options when creating a new service

import (
	"go-micro.dev/v5"
	"github.com/micro/plugins/v5/registry/kubernetes"
)

func main() {
	registry := kubernetes.NewRegistry() //a default to using env vars for master API

	service := micro.NewService(
		// Set service name
		micro.Name("my.service"),
		// Set service registry
		micro.Registry(registry),
	)
}

Build

An anti-pattern is modifying the main.go file to include plugins. Best practice recommendation is to include plugins in a separate file and rebuild with it included. This allows for automation of building plugins and clean separation of concerns.

Create file plugins.go

package main

import (
	_ "github.com/micro/plugins/v5/broker/rabbitmq"
	_ "github.com/micro/plugins/v5/registry/kubernetes"
	_ "github.com/micro/plugins/v5/transport/nats"
)

Build with plugins.go

go build -o service main.go plugins.go

Run with plugins

MICRO_BROKER=rabbitmq \
MICRO_REGISTRY=kubernetes \
MICRO_TRANSPORT=nats \
service