Documentation ¶
Overview ¶
Package micro is a pluggable framework for microservices
Index ¶
- Variables
- func NewContext(ctx context.Context, s Service) context.Context
- func RegisterHandler(s server.Server, h interface{}, opts ...server.HandlerOption) error
- func RegisterSubscriber(topic string, s server.Server, h interface{}, opts ...server.SubscriberOption) error
- type Function
- type Option
- func Action(a func(*cli.Context)) Option
- func AfterStart(fn func() error) Option
- func AfterStop(fn func() error) Option
- func BeforeStart(fn func() error) Option
- func BeforeStop(fn func() error) Option
- func Broker(b broker.Broker) Option
- func Client(c client.Client) Option
- func Cmd(c cmd.Cmd) Option
- func Context(ctx context.Context) Option
- func Flags(flags ...cli.Flag) Option
- func Metadata(md map[string]string) Option
- func Name(n string) Option
- func RegisterInterval(t time.Duration) Option
- func RegisterTTL(t time.Duration) Option
- func Registry(r registry.Registry) Option
- func Selector(s selector.Selector) Option
- func Server(s server.Server) Option
- func Transport(t transport.Transport) Option
- func Version(v string) Option
- func WrapCall(w ...client.CallWrapper) Option
- func WrapClient(w ...client.Wrapper) Option
- func WrapHandler(w ...server.HandlerWrapper) Option
- func WrapSubscriber(w ...server.SubscriberWrapper) Option
- type Options
- type Publisher
- type Service
Constants ¶
This section is empty.
Variables ¶
var (
HeaderPrefix = "Micro-"
)
Functions ¶
func NewContext ¶
NewContext returns a new Context with the Service embedded within it.
func RegisterHandler ¶
func RegisterHandler(s server.Server, h interface{}, opts ...server.HandlerOption) error
RegisterHandler is syntactic sugar for registering a handler
func RegisterSubscriber ¶
func RegisterSubscriber(topic string, s server.Server, h interface{}, opts ...server.SubscriberOption) error
RegisterSubscriber is syntactic sugar for registering a subscriber
Types ¶
type Function ¶
type Function interface { // Inherits Service interface Service // Done signals to complete execution Done() error // Handle registers an RPC handler Handle(v interface{}) error // Subscribe registers a subscriber Subscribe(topic string, v interface{}) error }
Function is a one time executing Service
func NewFunction ¶
NewFunction returns a new Function for a one time executing Service
type Option ¶
type Option func(*Options)
func AfterStart ¶
func BeforeStart ¶
func BeforeStop ¶
func Context ¶
Context specifies a context for the service. Can be used to signal shutdown of the service. Can be used for extra option values.
func RegisterInterval ¶
RegisterInterval specifies the interval on which to re-register
func RegisterTTL ¶
RegisterTTL specifies the TTL to use when registering the service
func WrapCall ¶
func WrapCall(w ...client.CallWrapper) Option
WrapCall is a convenience method for wrapping a Client CallFunc
func WrapClient ¶
WrapClient is a convenience method for wrapping a Client with some middleware component. A list of wrappers can be provided. Wrappers are applied in reverse order so the last is executed first.
func WrapHandler ¶
func WrapHandler(w ...server.HandlerWrapper) Option
WrapHandler adds a handler Wrapper to a list of options passed into the server
func WrapSubscriber ¶
func WrapSubscriber(w ...server.SubscriberWrapper) Option
WrapSubscriber adds a subscriber Wrapper to a list of options passed into the server
type Options ¶
type Options struct { Broker broker.Broker Cmd cmd.Cmd Client client.Client Server server.Server Registry registry.Registry Transport transport.Transport // Before and After funcs BeforeStart []func() error BeforeStop []func() error AfterStart []func() error AfterStop []func() error // Other options for implementations of the interface // can be stored in a context Context context.Context }
type Publisher ¶
type Publisher interface {
Publish(ctx context.Context, msg interface{}, opts ...client.PublishOption) error
}
Publisher is syntactic sugar for publishing
type Service ¶
type Service interface { Init(...Option) Options() Options Client() client.Client Server() server.Server Run() error String() string }
Service is an interface that wraps the lower level libraries within go-micro. Its a convenience method for building and initialising services.
func FromContext ¶
FromContext retrieves a Service from the Context.
func NewService ¶
NewService creates and returns a new Service based on the packages within.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
acme
module
|
|
certmagic
Module
|
|
auth
module
|
|
jwt
Module
|
|
jwt/codec/jsonrpc
Module
|
|
jwt/errors
Module
|
|
jwt/server
Module
|
|
jwt/server/debug
Module
|
|
jwt/server/debug/proto
Module
|
|
jwt/server/rpc
Module
|
|
jwt/token
Module
|
|
jwt/token/registry/mdns
Module
|
|
server/debug/proto
Module
|
|
Package broker is an interface used for asynchronous messaging
|
Package broker is an interface used for asynchronous messaging |
http
Package http provides a http based message broker
|
Package http provides a http based message broker |
memory
Package memory provides a memory broker
|
Package memory provides a memory broker |
gocloud
Module
|
|
gocloud/selector
Module
|
|
gocloud/selector/dns
Module
|
|
gocloud/selector/registry
Module
|
|
gocloud/selector/static
Module
|
|
gocloud/server/mock
Module
|
|
googlepubsub
Module
|
|
grpc
Module
|
|
grpc/proto
Module
|
|
kafka
Module
|
|
mqtt
Module
|
|
mqtt/transport/http
Module
|
|
nats
Module
|
|
nsq
Module
|
|
proxy
Module
|
|
proxy/broker/memory
Module
|
|
rabbitmq
Module
|
|
rabbitmq/broker
Module
|
|
rabbitmq/broker/http
Module
|
|
rabbitmq/broker/memory
Module
|
|
rabbitmq/codec/protorpc
Module
|
|
redis
Module
|
|
redis/broker
Module
|
|
redis/broker/http
Module
|
|
redis/broker/memory
Module
|
|
segmentio
Module
|
|
snssqs
Module
|
|
snssqs/registry/gossip
Module
|
|
snssqs/registry/gossip/proto
Module
|
|
snssqs/selector/static
Module
|
|
sqs
Module
|
|
stan
Module
|
|
stomp
Module
|
|
stomp/registry/gossip/proto
Module
|
|
Package client is an interface for an RPC client
|
Package client is an interface for an RPC client |
mock
Package mock provides a mock client for testing
|
Package mock provides a mock client for testing |
rpc
Package rpc provides an rpc client
|
Package rpc provides an rpc client |
grpc
Module
|
|
grpc/codec/proto
Module
|
|
http
Module
|
|
http/codec/jsonrpc
Module
|
|
http/test
Module
|
|
mucp
Module
|
|
mucp/cmd
Module
|
|
Package cmd is an interface for parsing the command line
|
Package cmd is an interface for parsing the command line |
Package codec is an interface for encoding messages
|
Package codec is an interface for encoding messages |
bytes
Package bytes provides a bytes codec which does not encode or decode anything
|
Package bytes provides a bytes codec which does not encode or decode anything |
grpc
Package grpc provides a grpc codec
|
Package grpc provides a grpc codec |
json
Package json provides a json codec
|
Package json provides a json codec |
jsonrpc
Package jsonrpc provides a json-rpc 1.0 codec
|
Package jsonrpc provides a json-rpc 1.0 codec |
proto
Package proto provides a proto codec
|
Package proto provides a proto codec |
protorpc
Package proto is a generated protocol buffer package.
|
Package proto is a generated protocol buffer package. |
bsonrpc
Module
|
|
bsonrpc/client/rpc
Module
|
|
bsonrpc/metadata
Module
|
|
json-iterator
Module
|
|
jsonrpc2
Module
|
|
msgpackrpc
Module
|
|
segmentio
Module
|
|
config
module
|
|
broker/memory
Module
|
|
client/mock
Module
|
|
encoder
Module
|
|
encoder/cue
Module
|
|
encoder/hcl
Module
|
|
encoder/hcl/client/mock
Module
|
|
encoder/hcl/client/rpc
Module
|
|
encoder/toml
Module
|
|
encoder/transport/http
Module
|
|
encoder/xml
Module
|
|
encoder/xml/server/debug
Module
|
|
encoder/xml/transport/http
Module
|
|
encoder/yaml
Module
|
|
source
Module
|
|
source/codec/jsonrpc
Module
|
|
source/configmap
Module
|
|
source/consul
Module
|
|
source/consul/client/mock
Module
|
|
source/consul/codec/proto
Module
|
|
source/etcd
Module
|
|
source/grpc
Module
|
|
source/grpc/codec
Module
|
|
source/grpc/codec/bytes
Module
|
|
source/grpc/codec/grpc
Module
|
|
source/grpc/codec/json
Module
|
|
source/grpc/codec/jsonrpc
Module
|
|
source/grpc/codec/proto
Module
|
|
source/grpc/codec/protorpc
Module
|
|
source/grpc/proto
Module
|
|
source/mucp
Module
|
|
source/mucp/proto
Module
|
|
source/nacos
Module
|
|
source/nacos/registry/memory
Module
|
|
source/pkger
Module
|
|
source/runtimevar
Module
|
|
source/selector/registry
Module
|
|
source/url
Module
|
|
source/url/transport
Module
|
|
source/url/transport/http
Module
|
|
source/url/transport/memory
Module
|
|
source/vault
Module
|
|
Package errors provides a way to return detailed information for an RPC request error.
|
Package errors provides a way to return detailed information for an RPC request error. |
events
module
|
|
nats
Module
|
|
nats/codec/bytes
Module
|
|
redis
Module
|
|
redis/codec/grpc
Module
|
|
redis/selector/registry
Module
|
|
logger
module
|
|
apex
Module
|
|
broker/memory
Module
|
|
logrus
Module
|
|
windowseventlog
Module
|
|
windowseventlog/cmd
Module
|
|
zap
Module
|
|
zap/codec/proto
Module
|
|
zerolog
Module
|
|
zerolog/broker
Module
|
|
zerolog/broker/http
Module
|
|
zerolog/broker/memory
Module
|
|
zerolog/client
Module
|
|
zerolog/client/mock
Module
|
|
zerolog/client/rpc
Module
|
|
zerolog/cmd
Module
|
|
zerolog/codec
Module
|
|
zerolog/codec/bytes
Module
|
|
zerolog/codec/grpc
Module
|
|
zerolog/codec/grpc/broker
Module
|
|
zerolog/codec/grpc/codec
Module
|
|
zerolog/codec/grpc/errors
Module
|
|
zerolog/codec/grpc/metadata
Module
|
|
zerolog/codec/grpc/registry
Module
|
|
zerolog/codec/grpc/selector
Module
|
|
zerolog/codec/json
Module
|
|
zerolog/codec/jsonrpc
Module
|
|
zerolog/codec/proto
Module
|
|
zerolog/codec/protorpc
Module
|
|
zerolog/errors
Module
|
|
zerolog/metadata
Module
|
|
zerolog/registry
Module
|
|
zerolog/registry/consul
Module
|
|
zerolog/registry/gossip
Module
|
|
zerolog/registry/mdns
Module
|
|
zerolog/registry/memory
Module
|
|
zerolog/selector
Module
|
|
zerolog/selector/dns
Module
|
|
zerolog/selector/registry
Module
|
|
zerolog/selector/static
Module
|
|
zerolog/server
Module
|
|
zerolog/server/debug
Module
|
|
zerolog/server/debug/proto
Module
|
|
zerolog/server/mock
Module
|
|
zerolog/server/rpc
Module
|
|
zerolog/transport
Module
|
|
zerolog/transport/http
Module
|
|
zerolog/transport/memory
Module
|
|
Package metadata is a way of defining message headers
|
Package metadata is a way of defining message headers |
proxy
module
|
|
http
Module
|
|
selector/registry
Module
|
|
Package mdns is a multicast dns registry Package registry is an interface for service discovery
|
Package mdns is a multicast dns registry Package registry is an interface for service discovery |
gossip
Package Gossip provides a gossip registry based on hashicorp/memberlist
|
Package Gossip provides a gossip registry based on hashicorp/memberlist |
gossip/proto
Package gossip is a generated protocol buffer package.
|
Package gossip is a generated protocol buffer package. |
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 |
cache
Module
|
|
etcd
Module
|
|
etcd/broker/memory
Module
|
|
eureka
Module
|
|
eureka/mock
Module
|
|
eureka/mock/registry/mdns
Module
|
|
eureka/server/debug/proto
Module
|
|
kubernetes
Module
|
|
kubernetes/broker
Module
|
|
kubernetes/broker/http
Module
|
|
kubernetes/broker/memory
Module
|
|
kubernetes/client
Module
|
|
kubernetes/client/api
Module
|
|
kubernetes/client/mock
Module
|
|
kubernetes/client/watch
Module
|
|
kubernetes/cmd
Module
|
|
kubernetes/codec
Module
|
|
kubernetes/codec/bytes
Module
|
|
kubernetes/codec/grpc
Module
|
|
kubernetes/codec/json
Module
|
|
kubernetes/codec/jsonrpc
Module
|
|
kubernetes/codec/proto
Module
|
|
kubernetes/codec/protorpc
Module
|
|
kubernetes/errors
Module
|
|
kubernetes/metadata
Module
|
|
kubernetes/registry
Module
|
|
kubernetes/registry/consul
Module
|
|
kubernetes/registry/gossip
Module
|
|
kubernetes/registry/mdns
Module
|
|
kubernetes/registry/memory
Module
|
|
kubernetes/selector
Module
|
|
kubernetes/selector/dns
Module
|
|
kubernetes/selector/registry
Module
|
|
kubernetes/selector/static
Module
|
|
kubernetes/server
Module
|
|
kubernetes/server/debug
Module
|
|
kubernetes/server/mock
Module
|
|
kubernetes/server/rpc
Module
|
|
kubernetes/transport
Module
|
|
kubernetes/transport/http
Module
|
|
kubernetes/transport/memory
Module
|
|
multi
Module
|
|
multi/registry/gossip/proto
Module
|
|
nacos
Module
|
|
nats
Module
|
|
nats/codec/proto
Module
|
|
proxy
Module
|
|
proxy/transport/memory
Module
|
|
zookeeper
Module
|
|
Package selector is a way to pick a list of service nodes
|
Package selector is a way to pick a list of service nodes |
dns
Package dns provides a dns SRV selector
|
Package dns provides a dns SRV selector |
registry
Package registry uses the go-micro registry for selection
|
Package registry uses the go-micro registry for selection |
static
Package static provides a static resolver which returns the name/ip passed in without any change
|
Package static provides a static resolver which returns the name/ip passed in without any change |
label
Module
|
|
shard
Module
|
|
Package server is an interface for a micro server
|
Package server is an interface for a micro server |
debug/proto
Package debug is a generated protocol buffer package.
|
Package debug is a generated protocol buffer package. |
rpc
Package rpc provides an rpc server
|
Package rpc provides an rpc server |
grpc
Module
|
|
grpc/proto
Module
|
|
grpc/proto/registry/memory
Module
|
|
grpc/registry
Module
|
|
grpc/registry/consul
Module
|
|
grpc/registry/gossip
Module
|
|
grpc/registry/gossip/proto
Module
|
|
grpc/registry/mdns
Module
|
|
grpc/registry/memory
Module
|
|
http
Module
|
|
http/errors
Module
|
|
mucp
Module
|
|
store
module
|
|
client
Module
|
|
client/mock
Module
|
|
client/rpc
Module
|
|
cockroach
Module
|
|
cockroach/client/rpc
Module
|
|
cockroach/selector/dns
Module
|
|
consul
Module
|
|
file
Module
|
|
memcached
Module
|
|
memcached/registry/gossip
Module
|
|
memory
Module
|
|
mysql
Module
|
|
mysql/broker
Module
|
|
mysql/broker/http
Module
|
|
mysql/broker/memory
Module
|
|
mysql/client
Module
|
|
mysql/client/mock
Module
|
|
mysql/client/rpc
Module
|
|
mysql/cmd
Module
|
|
mysql/codec
Module
|
|
mysql/codec/bytes
Module
|
|
mysql/codec/grpc
Module
|
|
mysql/codec/json
Module
|
|
mysql/codec/jsonrpc
Module
|
|
mysql/codec/proto
Module
|
|
mysql/codec/protorpc
Module
|
|
mysql/errors
Module
|
|
mysql/metadata
Module
|
|
mysql/registry
Module
|
|
mysql/registry/consul
Module
|
|
mysql/registry/gossip
Module
|
|
mysql/registry/gossip/proto
Module
|
|
mysql/registry/mdns
Module
|
|
mysql/registry/memory
Module
|
|
mysql/selector
Module
|
|
mysql/selector/dns
Module
|
|
mysql/selector/registry
Module
|
|
mysql/selector/static
Module
|
|
mysql/server
Module
|
|
mysql/server/debug
Module
|
|
mysql/server/debug/proto
Module
|
|
mysql/server/mock
Module
|
|
mysql/server/rpc
Module
|
|
mysql/transport
Module
|
|
mysql/transport/http
Module
|
|
mysql/transport/memory
Module
|
|
redis
Module
|
|
selector
Module
|
|
selector/registry
Module
|
|
sync
module
|
|
consul
Module
|
|
etcd
Module
|
|
etcd/client/mock
Module
|
|
etcd/codec/jsonrpc
Module
|
|
memory
Module
|
|
memory/broker/http
Module
|
|
memory/selector/dns
Module
|
|
Package transport is an interface for synchronous communication
|
Package transport is an interface for synchronous communication |
http
Package http returns a http2 transport using net/http
|
Package http returns a http2 transport using net/http |
memory
Package memory is an in-memory transport
|
Package memory is an in-memory transport |
grpc
Module
|
|
grpc/proto
Module
|
|
nats
Module
|
|
quic
Module
|
|
rabbitmq
Module
|
|
rabbitmq/transport/memory
Module
|
|
tcp
Module
|
|
utp
Module
|
|
wrapper
module
|
|
breaker
Module
|
|
breaker/codec
Module
|
|
breaker/codec/bytes
Module
|
|
breaker/codec/grpc
Module
|
|
breaker/codec/json
Module
|
|
breaker/codec/jsonrpc
Module
|
|
breaker/codec/proto
Module
|
|
breaker/codec/protorpc
Module
|
|
breaker/codec/protorpc/cmd
Module
|
|
breaker/codec/protorpc/codec
Module
|
|
breaker/gobreaker
Module
|
|
breaker/hystrix
Module
|
|
breaker/hystrix/client
Module
|
|
breaker/hystrix/client/mock
Module
|
|
breaker/hystrix/codec/bytes
Module
|
|
breaker/server/debug
Module
|
|
endpoint
Module
|
|
endpoint/registry/gossip
Module
|
|
metadata
Module
|
|
monitoring
Module
|
|
monitoring/prometheus
Module
|
|
monitoring/victoriametrics
Module
|
|
ratelimiter
Module
|
|
ratelimiter/broker/http
Module
|
|
ratelimiter/ratelimit
Module
|
|
ratelimiter/server
Module
|
|
ratelimiter/server/debug
Module
|
|
ratelimiter/server/mock
Module
|
|
ratelimiter/server/rpc
Module
|
|
ratelimiter/uber
Module
|
|
registry/memory
Module
|
|
select
Module
|
|
select/roundrobin
Module
|
|
select/shard
Module
|
|
select/version
Module
|
|
service
Module
|
|
service/selector/dns
Module
|
|
trace
Module
|
|
trace/awsxray
Module
|
|
trace/codec/grpc
Module
|
|
trace/datadog
Module
|
|
trace/datadog/broker
Module
|
|
trace/datadog/broker/http
Module
|
|
trace/datadog/broker/memory
Module
|
|
trace/datadog/client
Module
|
|
trace/datadog/client/mock
Module
|
|
trace/datadog/client/rpc
Module
|
|
trace/datadog/cmd
Module
|
|
trace/datadog/codec
Module
|
|
trace/datadog/codec/bytes
Module
|
|
trace/datadog/codec/grpc
Module
|
|
trace/datadog/codec/json
Module
|
|
trace/datadog/codec/jsonrpc
Module
|
|
trace/datadog/codec/proto
Module
|
|
trace/datadog/codec/protorpc
Module
|
|
trace/datadog/errors
Module
|
|
trace/datadog/metadata
Module
|
|
trace/datadog/registry
Module
|
|
trace/datadog/registry/mdns
Module
|
|
trace/datadog/selector
Module
|
|
trace/datadog/selector/dns
Module
|
|
trace/datadog/server
Module
|
|
trace/datadog/server/debug
Module
|
|
trace/datadog/server/mock
Module
|
|
trace/datadog/server/rpc
Module
|
|
trace/datadog/transport
Module
|
|
trace/datadog/transport/http
Module
|
|
trace/opencensus
Module
|
|
trace/opentracing
Module
|
|
trace/registry/mdns
Module
|
|
trace/server/debug/proto
Module
|
|
trace/server/rpc
Module
|
|
validator
Module
|