go-micro: github.com/micro/go-micro Index | Files | Directories

package micro

import "github.com/micro/go-micro"

Package micro is a pluggable framework for microservices


Package Files

function.go micro.go options.go publisher.go service.go wrapper.go


var (
    HeaderPrefix = "Micro-"

func NewContext Uses

func NewContext(ctx context.Context, s Service) context.Context

NewContext returns a new Context with the Service embedded within it.

func RegisterHandler Uses

func RegisterHandler(s server.Server, h interface{}, opts ...server.HandlerOption) error

RegisterHandler is syntactic sugar for registering a handler

func RegisterSubscriber Uses

func RegisterSubscriber(topic string, s server.Server, h interface{}, opts ...server.SubscriberOption) error

RegisterSubscriber is syntactic sugar for registering a subscriber

type Function Uses

type Function interface {
    // Inherits Service interface
    // 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 Uses

func NewFunction(opts ...Option) Function

NewFunction returns a new Function for a one time executing Service

type Option Uses

type Option func(*Options)

func Action Uses

func Action(a func(*cli.Context)) Option

func Address Uses

func Address(addr string) Option

Address sets the address of the server

func AfterStart Uses

func AfterStart(fn func() error) Option

func AfterStop Uses

func AfterStop(fn func() error) Option

func BeforeStart Uses

func BeforeStart(fn func() error) Option

func BeforeStop Uses

func BeforeStop(fn func() error) Option

func Broker Uses

func Broker(b broker.Broker) Option

func Client Uses

func Client(c client.Client) Option

func Cmd Uses

func Cmd(c cmd.Cmd) Option

func Context Uses

func Context(ctx context.Context) Option

Context specifies a context for the service. Can be used to signal shutdown of the service. Can be used for extra option values.

func Flags Uses

func Flags(flags ...cli.Flag) Option

func Metadata Uses

func Metadata(md map[string]string) Option

Metadata associated with the service

func Name Uses

func Name(n string) Option

Name of the service

func RegisterInterval Uses

func RegisterInterval(t time.Duration) Option

RegisterInterval specifies the interval on which to re-register

func RegisterTTL Uses

func RegisterTTL(t time.Duration) Option

RegisterTTL specifies the TTL to use when registering the service

func Registry Uses

func Registry(r registry.Registry) Option

Registry sets the registry for the service and the underlying components

func Selector Uses

func Selector(s selector.Selector) Option

Selector sets the selector for the service client

func Server Uses

func Server(s server.Server) Option

func Transport Uses

func Transport(t transport.Transport) Option

Transport sets the transport for the service and the underlying components

func Version Uses

func Version(v string) Option

Version of the service

func WrapCall Uses

func WrapCall(w ...client.CallWrapper) Option

WrapCall is a convenience method for wrapping a Client CallFunc

func WrapClient Uses

func WrapClient(w ...client.Wrapper) Option

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 Uses

func WrapHandler(w ...server.HandlerWrapper) Option

WrapHandler adds a handler Wrapper to a list of options passed into the server

func WrapSubscriber Uses

func WrapSubscriber(w ...server.SubscriberWrapper) Option

WrapSubscriber adds a subscriber Wrapper to a list of options passed into the server

type Options Uses

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 Uses

type Publisher interface {
    Publish(ctx context.Context, msg interface{}, opts ...client.PublishOption) error

Publisher is syntactic sugar for publishing

func NewPublisher Uses

func NewPublisher(topic string, c client.Client) Publisher

NewPublisher returns a new Publisher

type Service Uses

type Service interface {
    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 Uses

func FromContext(ctx context.Context) (Service, bool)

FromContext retrieves a Service from the Context.

func NewService Uses

func NewService(opts ...Option) Service

NewService creates and returns a new Service based on the packages within.


brokerPackage broker is an interface used for asynchronous messaging
broker/httpPackage http provides a http based message broker
broker/memoryPackage memory provides a memory broker
clientPackage client is an interface for an RPC client
client/mockPackage mock provides a mock client for testing
client/rpcPackage rpc provides an rpc client
cmdPackage cmd is an interface for parsing the command line
codecPackage codec is an interface for encoding messages
codec/bytesPackage bytes provides a bytes codec which does not encode or decode anything
codec/grpcPackage grpc provides a grpc codec
codec/jsonPackage json provides a json codec
codec/jsonrpcPackage jsonrpc provides a json-rpc 1.0 codec
codec/protoPackage proto provides a proto codec
codec/protorpcPackage proto is a generated protocol buffer package.
errorsPackage errors provides a way to return detailed information for an RPC request error.
metadataPackage metadata is a way of defining message headers
registryPackage mdns is a multicast dns registry
registry/gossipPackage gossip provides a gossip registry based on hashicorp/memberlist
registry/gossip/protoPackage gossip is a generated protocol buffer package.
registry/mdnsPackage mdns provides a multicast dns registry
registry/memoryPackage memory provides an in-memory registry
selectorPackage selector is a way to pick a list of service nodes
selector/dnsPackage dns provides a dns SRV selector
selector/registryPackage registry uses the go-micro registry for selection
selector/staticPackage static provides a static resolver which returns the name/ip passed in without any change
serverPackage server is an interface for a micro server
server/debug/protoPackage debug is a generated protocol buffer package.
server/rpcPackage rpc provides an rpc server
transportPackage transport is an interface for synchronous communication
transport/httpPackage http returns a http2 transport using net/http
transport/memoryPackage memory is an in-memory transport

Package micro imports 15 packages (graph) and is imported by 268 packages. Updated 2019-04-22. Refresh now. Tools for package owners.