go-plugins

module
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2017 License: Apache-2.0

README

Go Plugins License GoDoc Travis CI Go Report Card

A repository for go-micro plugins.

Check out the Micro on NATS blog post to learn more about plugins.

Follow us on Twitter at @MicroHQ, join the Slack community here or check out the Mailing List.

What's here?

Directory Description
Broker Asynchronous Pub/Sub; NATS, NSQ, RabbitMQ, Kafka
Client Alternative clients; gRPC, HTTP
Codec RPC Encoding; BSON, Mercury
KV Key-Value; Memcached, Redis
Metrics Instrumentation; Statsd, Telegraf, Prometheus
Micro Micro Toolkit Plugins
Registry Service Discovery; Etcd, Gossip, NATS
Selector Node Selection; Label, Mercury
Server Alternative servers; gRPC, HTTP
Sync Locking/Leadership election; Consul, Etcd
Trace Distributed tracing; Zipkin
Transport Synchronous Request/Response; NATS, RabbitMQ
Wrappers Client/Server middleware; Circuit Breakers, Rate Limit

Community Contributions

Feature Description Author
Registry/Kubernetes Service discovery via the Kubernetes API @nickjackson
Registry/Zookeeper Service discovery using Zookeeper @HeavyHorst

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 Plugins
import (
	"github.com/micro/go-micro/cmd"
	_ "github.com/micro/go-plugins/broker/rabbitmq"
	_ "github.com/micro/go-plugins/registry/kubernetes"
	_ "github.com/micro/go-plugins/transport/nats"
)

func main() {
	// Parse CLI flags
	cmd.Init()
}

The same is achieved when calling service.Init

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

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

	// Parse CLI flags
	service.Init()
}
Use via CLI Flags

Activate via a command line flag

go run service.go --broker=rabbitmq --registry=kubernetes --transport=nats
Use Plugins Directly

CLI Flags provide a simple way to initialise plugins but you can do the same yourself.

import (
	"github.com/micro/go-micro"
	"github.com/micro/go-plugins/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 Pattern

You may want to swap out plugins using automation or add plugins to the micro toolkit. An easy way to do this is by maintaining a separate file for plugin imports and including it during the build.

Create file plugins.go

package main

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

Build with plugins.go

go build -o service main.go plugins.go

Run with plugins

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

Directories

Path Synopsis
agent
api
auth Module
cors Module
gzip Module
header Module
index Module
metrics Module
router Module
broker
googlepubsub
Package googlepubsub provides a Google cloud pubsub broker
Package googlepubsub provides a Google cloud pubsub broker
http
Package http provides a http broker
Package http provides a http broker
kafka
Package kafka provides a kafka broker using sarama cluster
Package kafka provides a kafka broker using sarama cluster
mqtt
Package mqtt provides an mqtt broker
Package mqtt provides an mqtt broker
nats
Package nats provides a NATS broker
Package nats provides a NATS broker
nsq
Package nsq provides an NSQ broker
Package nsq provides an NSQ broker
rabbitmq
Package rabbitmq provides a RabbitMQ broker
Package rabbitmq provides a RabbitMQ broker
redis
Package redis provides a Redis broker
Package redis provides a Redis broker
sidecar
Package sidecar is a broker using the micro sidecar
Package sidecar is a broker using the micro sidecar
sqs
gocloud Module
grpc Module
memory Module
proxy Module
segmentio Module
service Module
snssqs Module
stan Module
stomp Module
cache
redis Module
client
grpc
Package grpc provides a gRPC client Package grpc provides a gRPC options
Package grpc provides a gRPC client Package grpc provides a gRPC options
http
Package http provides a http client
Package http provides a http client
http/test
Package test is a generated protocol buffer package.
Package test is a generated protocol buffer package.
mock Module
codec
bsonrpc
Package bsonrpc provides a bson-rpc codec
Package bsonrpc provides a bson-rpc codec
jsonrpc
Package jsonrpc provides a json-rpc 1.0 codec
Package jsonrpc provides a json-rpc 1.0 codec
jsonrpc2
Package jsonrpc2 provides a json-rpc 2.0 codec Based on powerman/rpc-codec: The MIT License (MIT) Copyright (c) 2015 Alex Efros
Package jsonrpc2 provides a json-rpc 2.0 codec Based on powerman/rpc-codec: The MIT License (MIT) Copyright (c) 2015 Alex Efros
msgpackrpc
Package msgpackrpc provides a msgpack-rpc codec
Package msgpackrpc provides a msgpack-rpc codec
protorpc
Package protorpc provides a proto-rpc codec
Package protorpc provides a proto-rpc codec
json-iterator Module
segmentio Module
config
encoder/cue Module
source/consul Module
source/etcd Module
source/grpc Module
source/mucp Module
source/pkger Module
source/url Module
source/vault Module
events
stream/nats Module
examples
kv
logger
apex Module
logrus Module
zap Module
zerolog Module
metrics
micro
disable_rpc
Package disable_rpc disables the /rpc endpoint
Package disable_rpc disables the /rpc endpoint
gzip
Package gzip is a micro plugin for gzipping http response
Package gzip is a micro plugin for gzipping http response
index
Package index is a micro plugin for stripping a path index
Package index is a micro plugin for stripping a path index
ip_whitelist
Package ip_whitelist is a micro plugin for whitelisting ip addresses
Package ip_whitelist is a micro plugin for whitelisting ip addresses
router
Package router is a micro plugin for defining HTTP routes
Package router is a micro plugin for defining HTTP routes
stats_auth
stats_auth enables basic auth on the /stats endpoint
stats_auth enables basic auth on the /stats endpoint
trace/awsxray
Package awsxray is a micro plugin for whitelisting service requests
Package awsxray is a micro plugin for whitelisting service requests
trace/uuid
Package uuid is a micro plugin for adding a trace header
Package uuid is a micro plugin for adding a trace header
whitelist
Package whitelist is a micro plugin for whitelisting service requests
Package whitelist is a micro plugin for whitelisting service requests
auth Module
cors Module
header Module
metrics Module
proxy
http Module
registry
consul
Package consul provides a Consul registry
Package consul provides a Consul registry
discovery
Package discovery is an interface for scalable service discovery.
Package discovery is an interface for scalable service discovery.
etcd
Package etcd provides an etcd registry
Package etcd provides an etcd registry
etcdv3
Package etcdv3 provides an etcd version 3 registry
Package etcdv3 provides an etcd version 3 registry
eureka
Package eureka provides a Eureka registry
Package eureka provides a Eureka registry
eureka/mock
This file was generated by counterfeiter
This file was generated by counterfeiter
gossip
Package Gossip provides a gossip registry based on hashicorp/memberlist
Package Gossip provides a gossip registry based on hashicorp/memberlist
kubernetes
Package kubernetes provides a kubernetes registry
Package kubernetes provides a kubernetes registry
mdns
Package mdns provides a multicast DNS registry
Package mdns provides a multicast DNS registry
memory
Package memory provides an in-memory registry
Package memory provides an in-memory registry
nats
Package nats provides a NATS registry using broadcast queries
Package nats provides a NATS registry using broadcast queries
noop
Package noop is a registry which does nothing
Package noop is a registry which does nothing
sidecar
Package sidecar is a registry plugin for the micro sidecar
Package sidecar is a registry plugin for the micro sidecar
zookeeper
Package zookeeper provides a zookeeper registry
Package zookeeper provides a zookeeper registry
cache Module
multi Module
nacos Module
proxy Module
service Module
selector
blacklist
Package blacklist is a selector which includes blacklisting of nodes when they fail
Package blacklist is a selector which includes blacklisting of nodes when they fail
cache
Package cache is a caching selector.
Package cache is a caching selector.
label
Package label is a priority label based selector.
Package label is a priority label based selector.
named
Package named is a selector which always returns the name selected.
Package named is a selector which always returns the name selected.
static
Package static is a selector which always returns the name specified with a port-number appended.
Package static is a selector which always returns the name specified with a port-number appended.
server
grpc
Package grpc provides a grpc server
Package grpc provides a grpc server
http
Package http implements a go-micro.Server
Package http implements a go-micro.Server
service
kubernetes Module
store
cockroach Module
consul Module
memcached Module
mysql Module
redis Module
sync
leader/consul Module
lock/consul Module
lock/redis Module
trace
transport
grpc
Package grpc provides a grpc transport
Package grpc provides a grpc transport
grpc/proto
Package go_micro_grpc_transport is a generated protocol buffer package.
Package go_micro_grpc_transport is a generated protocol buffer package.
http
Package http provides a http transport
Package http provides a http transport
nats
Package nats provides a NATS transport
Package nats provides a NATS transport
rabbitmq
Package rabbitmq provides a RabbitMQ transport
Package rabbitmq provides a RabbitMQ transport
tcp
Package tcp provides a TCP transport
Package tcp provides a TCP transport
utp
Package utp implements a utp transport
Package utp implements a utp transport
memory Module
quic Module
web
kubernetes Module
wrapper
endpoint
Package endpoint provides a wrapper that executes other wrappers for specific methods
Package endpoint provides a wrapper that executes other wrappers for specific methods
ratelimiter/quota
Package quota implements a client side wrapper for rate limiting using the quota-srv
Package quota implements a client side wrapper for rate limiting using the quota-srv
select/roundrobin
Package roundrobin implements a roundrobin call strategy
Package roundrobin implements a roundrobin call strategy
select/shard
Package shard implements the sharding call strategy
Package shard implements the sharding call strategy
service
Package wrapper injects a go-micro.Service into the context
Package wrapper injects a go-micro.Service into the context
trace/awsxray
Package awsxray is a wrapper for AWS X-Ray distributed tracing
Package awsxray is a wrapper for AWS X-Ray distributed tracing
trace/opentracing
Package opentracing provides wrappers for OpenTracing
Package opentracing provides wrappers for OpenTracing
trace/datadog Module
validator Module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL