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

event.go function.go generate.go micro.go options.go service.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 Event Uses

type Event interface {
    // Publish publishes a message to the event topic
    Publish(ctx context.Context, msg interface{}, opts ...client.PublishOption) error

Event is used to publish messages to a topic

func NewEvent Uses

func NewEvent(topic string, c client.Client) Event

NewEvent creates a new event publisher

func NewPublisher Uses

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

Deprecated: NewPublisher returns a new Publisher

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) error) Option

Action can be used to parse user provided cli options

func Address Uses

func Address(addr string) Option

Address sets the address of the server

func AfterStart Uses

func AfterStart(fn func() error) Option

AfterStart run funcs after service starts

func AfterStop Uses

func AfterStop(fn func() error) Option

AfterStop run funcs after service stops

func Auth Uses

func Auth(a auth.Auth) Option

Auth sets the auth for the service

func BeforeStart Uses

func BeforeStart(fn func() error) Option

BeforeStart run funcs before service starts

func BeforeStop Uses

func BeforeStop(fn func() error) Option

BeforeStop run funcs before service stops

func Broker Uses

func Broker(b broker.Broker) Option

Broker to be used for service

func Client Uses

func Client(c client.Client) Option

Client to be used for service

func Cmd Uses

func Cmd(c cmd.Cmd) Option

func Config Uses

func Config(c config.Config) Option

Config sets the config for the service

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 and for extra option values.

func Flags Uses

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

Flags that can be passed to service

func HandleSignal Uses

func HandleSignal(b bool) Option

HandleSignal toggles automatic installation of the signal handler that traps TERM, INT, and QUIT. Users of this feature to disable the signal handler, should control liveness of the service through the context.

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 Profile Uses

func Profile(p profile.Profile) Option

Profile to be used for debug profile

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 Runtime Uses

func Runtime(r runtime.Runtime) Option

Runtime sets the runtime

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

Server to be used for service

func Store Uses

func Store(s store.Store) Option

Store sets the store to use

func Tracer Uses

func Tracer(t trace.Tracer) Option

Tracer sets the tracer for the service

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 {
    Auth      auth.Auth
    Broker    broker.Broker
    Cmd       cmd.Cmd
    Config    config.Config
    Client    client.Client
    Server    server.Server
    Store     store.Store
    Registry  registry.Registry
    Runtime   runtime.Runtime
    Transport transport.Transport
    Profile   profile.Profile

    // 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

    Signal bool

Options for micro service

type Publisher Uses

type Publisher = Event

Type alias to satisfy the deprecation

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.


acmePackage acme abstracts away various ACME libraries
acme/autocertPackage autocert is the ACME provider from golang.org/x/crypto/acme/autocert This provider does not take any config.
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/eventPackage event provides a handler which publishes an event
api/handler/httpPackage http is a http reverse proxy handler
api/handler/rpcPackage rpc is a go-micro rpc handler.
api/handler/webPackage web contains the web handler including websocket support
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/pathPackage path resolves using http path
api/resolver/subdomainPackage subdomain is a resolver which uses the subdomain to determine the domain to route to.
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 provider from golang.org/x/crypto/acme/autocert This provider does not take any config.
api/server/acme/certmagicPackage certmagic is the ACME provider from github.com/caddyserver/certmagic
api/server/httpPackage http provides a http server with features; acme, cors, etc
appPackage app encapsulates the client, server and other interfaces to provide a complete dapp
app/mucpPackage mucp provides an app implementation for Nitro
authPackage auth provides authentication and authorization capability
auth/providerPackage provider is an external auth provider e.g oauth
brokerPackage broker is an interface used for asynchronous messaging
broker/memoryPackage memory provides a memory broker
broker/natsPackage nats provides a NATS broker
buildPackage build is for building source into a package
build/dockerPackage docker builds docker images
build/golangPackage golang is a go package manager
build/tarPackage tar basically tarballs source code
cachePackage cache is a caching interface
cache/memoryPackage memory is an in memory cache
clientPackage client is an interface for an RPC client
client/rpcPackage rpc provides a transport agnostic RPC client
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
cmdPackage cmd is an interface for parsing the command line
cmd/protoc-gen-microprotoc-gen-micro is a plugin for the Google protocol buffer compiler to generate Go code.
cmd/protoc-gen-micro/generatorThe code generator for the plugin for the Google protocol buffer compiler.
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/protorpcProtorpc provides a net/rpc proto-rpc codec.
codec/textPackage text reads any text/* content-type
configPackage config is an interface for dynamic configuration.
config/encoderPackage encoder handles source encoding formats
config/loaderpackage loader manages loading from multiple sources
config/readerPackage reader parses change sets and provides config values
config/secretsPackage secrets is an interface for encrypting and decrypting secrets
config/secrets/boxPackage box is an asymmetric implementation of config/secrets using nacl/box
config/secrets/secretboxPackage secretbox is a config/secrets implementation that uses nacl/secretbox to do symmetric encryption / verification
config/sourcePackage source is the interface for sources
config/source/filePackage file is a file source.
config/source/memoryPackage memory is a memory source
dbPackage db is an interface for data storage
db/memoryPackage memory is a in-memory db.store
debug/handlerPackage handler implements service debug handler embedded in go-micro services
debug/logPackage log provides debug logging
debug/log/kubernetesPackage kubernetes is a logger implementing (github.com/micro/go-micro/v3/debug/log).Log
debug/log/memoryPackage memory provides an in memory log buffer
debug/profilePackage profile is for profilers
debug/profile/httpPackage http enables the http profiler
debug/profile/pprofPackage pprof provides a pprof profiler
debug/servicePackage service provides the service log
debug/statsPackage stats provides runtime stats
debug/tracePackage trace provides an interface for distributed tracing
errorsPackage errors provides a way to return detailed information for an RPC request error.
loggerPackage log provides a log interface
metadataPackage metadata is a way of defining message headers
networkPackage network is for creating internetworks
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
network/transport/grpcPackage grpc provides a grpc transport
network/tunnelPackage tunnel provides gre network tunnelling
network/tunnel/brokerPackage broker is a tunnel broker
network/tunnel/transportPackage transport provides a tunnel transport
pluginPackage plugin provides the ability to load plugins
pluginsPackage plugin provides the ability to load plugins
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/memoryPackage memory provides an in-memory registry
registry/servicePackage service uses the registry service
resolverPackage resolver resolves network names to addresses
resolver/dnsPackage dns resolves names to dns records
resolver/dnssrvPackage dns srv resolves names to dns srv records
resolver/httpPackage http resolves names to network addresses using a http request
resolver/registryPackage registry resolves names using the go-micro registry
resolver/staticPackage static is a static resolver
router/kubernetesPackage kubernetes is a kubernetes router which uses the service name and network to route
router/staticPackage static is a static router which returns the service name as the address + port
runtimePackage runtime is a service runtime manager
runtime/kubernetesPackage kubernetes implements kubernetes micro runtime
runtime/localPackage local provides a local runtime
runtime/local/buildPackage build builds a micro runtime package
runtime/local/build/dockerPackage docker builds docker images
runtime/local/build/goPackage golang is a go package manager
runtime/local/processPackage process executes a binary
runtime/local/process/osPackage os runs processes locally
runtime/local/sourcePackage source retrieves source code
runtime/local/source/goPackage golang is a source for Go
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/routerPackage router is a network/router selector
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
service/mucpPackage mucp initialises a mucp service
storePackage store is an interface for distributed data storage.
store/cachePackage cache implements a faulting style read cache on top of multiple micro stores
store/filePackage local is a file system backed store
store/memoryPackage memory is a in-memory store store
store/servicePackage service implements the store service interface
syncPackage sync is an interface for distributed synchronization
sync/etcdPackage etcd is an etcd implementation of lock
sync/memoryPackage memory provides a sync.Mutex implementation of the lock for local use
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
transport/socketPackage socket provides a net socket transport
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/jitterPackage jitter provides a random jitter
util/kubernetes/clientPackage client provides an implementation of a restricted subset of kubernetes API client
util/logPackage log is a global internal logger DEPRECATED: this is frozen package, use github.com/micro/go-micro/v2/logger
util/muxPackage mux provides proxy muxing
util/pkiPackage pki provides PKI all the PKI functions necessary to run micro over an untrusted network including a CA
util/poolPackage pool is a connection pool
util/qsonPackage qson implmenets decoding of URL query params into JSON and Go values (using JSON struct tags).
util/registry/cachePackage cache provides a registry cache
util/ringPackage ring provides a simple ring buffer for storing local data
util/socketPackage socket provides a pseudo socket
util/streamPackage stream encapsulates streams within streams
util/syncPackage syncs will sync multiple stores

Package micro imports 27 packages (graph) and is imported by 514 packages. Updated 2021-01-07. Refresh now. Tools for package owners.