Documentation ¶
Index ¶
- Variables
- func NewContext(ctx context.Context, s Service) context.Context
- func RegisterHandler(s server.Server, h interface{}, opts ...server.HandlerOption) error
- type Option
- func Address(addr string) 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 Context(ctx context.Context) 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 Version(v string) Option
- func WrapCall(w ...client.CallWrapper) Option
- func WrapClient(w ...client.Wrapper) Option
- func WrapHandler(w ...server.HandlerWrapper) Option
- type Options
- type Service
Constants ¶
This section is empty.
Variables ¶
var ( DefaultSelector = selector.NewSelector() DefaultRegistry = mdns.NewRegistry() DefaultClient = cgrpc.NewClient() DefaultServer = sgrpc.NewServer() )
var (
HeaderPrefix = "Micro-Lite-"
)
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
Types ¶
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
type Options ¶
type Options struct { Broker broker.Broker Client client.Client Server server.Server Registry registry.Registry Selector selector.Selector // 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 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.
Directories ¶
Path | Synopsis |
---|---|
handler
Package handler provides http handlers
|
Package handler provides http handlers |
handler/api
Package api provides an http-rpc handler which provides the entire http request over rpc
|
Package api provides an http-rpc handler which provides the entire http request over rpc |
handler/broker
Package broker provides a go-micro/broker handler
|
Package broker provides a go-micro/broker handler |
handler/cloudevents
Package cloudevents provides a cloudevents handler publishing the event using the go-micro/client
|
Package cloudevents provides a cloudevents handler publishing the event using the go-micro/client |
handler/event
Package event provides a handler which publishes an event
|
Package event provides a handler which publishes an event |
handler/file
Package file serves file relative to the current directory
|
Package file serves file relative to the current directory |
handler/http
Package http is a http reverse proxy handler
|
Package http is a http reverse proxy handler |
handler/registry
Package registry is a go-micro/registry handler
|
Package registry is a go-micro/registry handler |
handler/rpc
Package rpc is a go-micro rpc handler.
|
Package rpc is a go-micro rpc handler. |
handler/udp
Package udp reads and write from a udp connection
|
Package udp reads and write from a udp connection |
handler/unix
Package unix reads from a unix socket expecting it to be in /tmp/path
|
Package unix reads from a unix socket expecting it to be in /tmp/path |
handler/web
Package web contains the web handler including websocket support
|
Package web contains the web handler including websocket support |
proto
Package go_api is a generated protocol buffer package.
|
Package go_api is a generated protocol buffer package. |
resolver
Package resolver resolves a http request to an endpoint
|
Package resolver resolves a http request to an endpoint |
resolver/grpc
Package grpc resolves a grpc service like /greeter.Say/Hello to greeter service
|
Package grpc resolves a grpc service like /greeter.Say/Hello to greeter service |
router
Package router provides api service routing
|
Package router provides api service routing |
router/registry
Package registry provides a dynamic api service router
|
Package registry provides a dynamic api service router |
server
Package server provides an API gateway server which handles inbound requests
|
Package server provides an API gateway server which handles inbound requests |
server/acme
Package acme abstracts away various ACME libraries
|
Package acme abstracts away various ACME libraries |
server/acme/autocert
Package autocert is the ACME provider from golang.org/x/crypto/acme/autocert This provider does not take any config.
|
Package autocert is the ACME provider from golang.org/x/crypto/acme/autocert This provider does not take any config. |
server/http
Package http provides a http server with features; acme, cors, etc
|
Package http provides a http server with features; acme, cors, etc |
Package client is an interface for an RPC client
|
Package client is an interface for an RPC 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 |
rpc
Package rpc provides an rpc client
|
Package rpc provides an rpc client |
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. |
examples
|
|
greeter/api/rpc/proto/hello
Package go_micro_api_greeter is a generated protocol buffer package.
|
Package go_micro_api_greeter is a generated protocol buffer package. |
greeter/proto
Package go_micro_srv_greeter is a generated protocol buffer package.
|
Package go_micro_srv_greeter is a generated protocol buffer package. |
service/proto
Package greeter is a generated protocol buffer package.
|
Package greeter is a generated protocol buffer package. |
stream/server/proto
Package stream is a generated protocol buffer package.
|
Package stream is a generated protocol buffer package. |
libs
|
|
Package metadata is a way of defining message headers
|
Package metadata is a way of defining message headers |
Package registry is an interface for service discovery
|
Package registry is an interface for service discovery |
mdns
Package mdns is a multicast dns registry
|
Package mdns is a multicast dns registry |
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 |
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. |
grpc
Package grpc provides a grpc server
|
Package grpc provides a grpc server |
rpc
Package rpc provides an rpc server
|
Package rpc provides an rpc server |