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

package service

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

Package service encapsulates the client, server and other interfaces to provide a complete micro service.

Index

Package Files

options.go service.go

type Option Uses

type Option func(*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

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

func NewOptions Uses

func NewOptions(opts ...Option) Options

type Service Uses

type Service interface {
    // The service name
    Name() string
    // Init initialises options
    Init(...Option)
    // 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 for a micro service

Directories

PathSynopsis
grpc
grpc/proto
mucpPackage mucp initialises a mucp service

Package service imports 7 packages (graph) and is imported by 3 packages. Updated 2020-02-06. Refresh now. Tools for package owners.