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 {
    // The service name
    Name() string
    // Init initialises options
    // Options returns the current options
    Options() Options
    // Client is used to call services
    Client() client.Client
    // Server is for handling requests and events
    Server() server.Server
    // Run the service
    Run() error
    // The service implementation
    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.


agentPackage agent provides an interface for building robots
agent/commandPackage command is an interface for defining bot commands
agent/inputPackage input is an interface for bot inputs
agent/protoPackage go_micro_bot is a generated protocol buffer package.
api/handlerPackage handler provides http handlers
api/handler/apiPackage api provides an http-rpc handler which provides the entire http request over rpc
api/handler/brokerPackage broker provides a go-micro/broker handler
api/handler/cloudeventsPackage cloudevents provides a cloudevents handler publishing the event using the go-micro/client
api/handler/eventPackage event provides a handler which publishes an event
api/handler/filePackage file serves file relative to the current directory
api/handler/httpPackage http is a http reverse proxy handler
api/handler/registryPackage registry is a go-micro/registry handler
api/handler/rpcPackage rpc is a go-micro rpc handler.
api/handler/udpPackage udp reads and write from a udp connection
api/handler/unixPackage unix reads from a unix socket expecting it to be in /tmp/path
api/handler/webPackage web contains the web handler including websocket support
api/protoPackage go_api is a generated protocol buffer package.
api/resolverPackage resolver resolves a http request to an endpoint
api/resolver/grpcPackage grpc resolves a grpc service like /greeter.Say/Hello to greeter service
api/resolver/hostPackage host resolves using http host
api/resolver/microPackage micro provides a micro rpc resolver which prefixes a namespace
api/resolver/pathPackage path resolves using http path
api/resolver/vpathPackage vpath resolves using http path and recognised versioned urls
api/routerPackage router provides api service routing
api/router/registryPackage registry provides a dynamic api service router
api/serverPackage server provides an API gateway server which handles inbound requests
api/server/acmePackage acme abstracts away various ACME libraries
api/server/acme/autocertPackage autocert is the ACME interpreter from golang.org/x/crypto/acme/autocert
api/server/httpPackage http provides a http server with features; acme, cors, etc
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
broker/natsPackage nats provides a NATS broker
broker/servicePackage service provides the broker service client
clientPackage client is an interface for an RPC client
client/grpcPackage grpc provides a gRPC client
client/mockPackage mock provides a mock client for testing
client/mucpPackage mucp provides an mucp client
client/poolPackage pool is a connection pool
client/selectorPackage selector is a way to pick a list of service nodes
client/selector/dnsPackage dns provides a dns SRV selector
client/selector/registryPackage registry uses the go-micro registry for selection
client/selector/routerPackage router is a network/router selector
client/selector/staticPackage static provides a static resolver which returns the name/ip passed in without any change
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.
codec/textPackage text reads any text/* content-type
configPackage config is an interface for dynamic configuration.
config/cmdPackage cmd is an interface for parsing the command line
config/encoderPackage encoder handles source encoding formats
config/loaderpackage loader manages loading from multiple sources
config/optionsPackage options provides a way to initialise options
config/readerPackage reader parses change sets and provides config values
config/sourcePackage source is the interface for sources
config/source/filePackage file is a file source.
config/source/memoryPackage memory is a memory source
dataPackage data is an interface for data access
data/store/consulPackage consul is a consul implementation of kv
errorsPackage errors provides a way to return detailed information for an RPC request error.
metadataPackage metadata is a way of defining message headers
monitorPackage monitor monitors service health
networkPackage network is for creating internetworks
network/handlerPackage handler implements network RPC handler
network/resolverPackage resolver resolves network names to addresses
network/resolver/dnsPackage dns resolves names to dns records
network/resolver/dnssrvPackage dns srv resolves names to dns srv records
network/resolver/httpPackage http resolves names to network addresses using a http request
network/resolver/registryPackage registry resolves names using the go-micro registry
network/resolver/staticPackage static is a static resolver
pluginPackage plugin provides the ability to load plugins
proxyPackage proxy is a transparent proxy built on the go-micro/server
proxy/grpcPackage grpc transparently forwards the grpc protocol using a go-micro client.
proxy/httpPackage http provides a micro rpc to http proxy
proxy/mucpPackage mucp transparently forwards the incoming request using a go-micro client.
registryPackage mdns is a multicast dns registry
registry/cachePackage cache provides a registry cache
registry/etcdPackage etcd provides an etcd service registry
registry/mdnsPackage mdns provides a multicast dns registry
registry/memoryPackage memory provides an in-memory registry
registry/servicePackage service uses the registry service
routerPackage router provides a network routing control plane
runtimePackage runtime is a service runtime manager
runtime/packagePackage packager creates a binary image.
runtime/package/dockerPackage docker builds docker images
runtime/package/goPackage golang is a go package manager
runtime/processPackage process executes a binary
runtime/process/osPackage os runs processes locally
runtime/sourcePackage source retrieves source code
runtime/source/gitPackage git provides a git source
runtime/source/goPackage golang is a source for Go
serverPackage server is an interface for a micro server
server/grpcPackage grpc provides a grpc server
server/mucpPackage mucp provides an mucp server
servicePackage service encapsulates the client, server and other interfaces to provide a complete micro service.
service/mucpPackage mucp initialises a mucp service
storePackage store is an interface for distribute data storage.
store/etcdPackage etcd is an etcd v3 implementation of kv
store/memoryPackage memory is a in-memory store store
syncPackage sync is a distributed synchronization framework
sync/eventPackage event provides a distributed log interface
sync/leaderPackage leader provides leader election
sync/lockPackage lock provides distributed locking
sync/lock/consulPackage consul is a consul implemenation of lock
sync/lock/etcdPackage etcd is an etcd implementation of lock
sync/taskPackage task provides an interface for distributed jobs
sync/task/brokerPackage broker provides a distributed task manager built on the micro broker
sync/task/localPackage local provides a local task runner
sync/timePackage time provides clock synchronization
sync/time/localPackage local provides a local clock
sync/time/ntpPackage ntp provides ntp synchronized time
transportPackage transport is an interface for synchronous connection based communication
transport/grpcPackage grpc provides a grpc transport
transport/httpPackage http returns a http2 transport using net/http
transport/memoryPackage memory is an in-memory transport
transport/quicPackage quic provides a QUIC based transport
tunnelPackage tunnel provides gre network tunnelling
tunnel/brokerPackage broker is a tunnel broker
tunnel/transportPackage transport provides a tunnel transport
util/backoffPackage backoff provides backoff functionality
util/ioPackage io is for io management
util/logPackage log is a global internal logger
util/muxPackage mux provides proxy muxing
util/socketPackage socket provides a pseudo socket
webPackage web provides web based micro services

Package micro imports 19 packages (graph) and is imported by 358 packages. Updated 2019-10-13. Refresh now. Tools for package owners.