service

package
v1.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2023 License: Apache-2.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handle

func Handle(h interface{}, opts ...server.HandlerOption) error

Handle is syntactic sugar for registering a handler

func Run

func Run()

Run the default service and waits for it to exist

func Subscribe

func Subscribe(topic string, h interface{}, opts ...server.SubscriberOption) error

Subscribe is syntactic sugar for registering a subscriber

Types

type Event

type Event struct {
	// contains filtered or unexported fields
}

Event is an object messages are published to

func NewEvent

func NewEvent(topic string) *Event

NewEvent creates a new event publisher

func (*Event) Publish

func (e *Event) Publish(ctx context.Context, msg interface{}) error

Publish a message to an event

type Option

type Option func(o *Options)

func Address

func Address(addr string) Option

Address sets the address of the server

func AfterStart

func AfterStart(fn func() error) Option

AfterStart run funcs after service starts

func AfterStop

func AfterStop(fn func() error) Option

AfterStop run funcs after service stops

func BeforeStart

func BeforeStart(fn func() error) Option

BeforeStart run funcs before service starts

func BeforeStop

func BeforeStop(fn func() error) Option

BeforeStop run funcs before service stops

func HandleSignal

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

func Metadata(md map[string]string) Option

Metadata associated with the service

func Name

func Name(n string) Option

Name of the service

func RegisterInterval

func RegisterInterval(t time.Duration) Option

RegisterInterval specifies the interval on which to re-register

func RegisterTTL

func RegisterTTL(t time.Duration) Option

RegisterTTL specifies the TTL to use when registering the service

func Version

func Version(v string) Option

Version of the service

func WrapCall

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

WrapCall is a convenience method for wrapping a Client CallFunc

func WrapClient

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

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

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

func WrapSubscriber

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

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

type Options

type Options struct {
	Cmd cmd.Cmd

	Name    string
	Version string

	// Before and After funcs
	BeforeStart []func() error
	BeforeStop  []func() error
	AfterStart  []func() error
	AfterStop   []func() error

	Signal bool
}

Options for micro service

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is a Micro Service which honours the go-micro/service interface

func New

func New(opts ...Option) *Service

New returns a new Micro Service

func (*Service) Client

func (s *Service) Client() client.Client

func (*Service) Handle

func (s *Service) Handle(v interface{}) error

Handle registers a handler

func (*Service) Init

func (s *Service) Init(opts ...Option)

func (*Service) Model

func (s *Service) Model() model.Model

func (*Service) Name

func (s *Service) Name() string

Name of the service

func (*Service) Options

func (s *Service) Options() Options

func (*Service) Run

func (s *Service) Run() error

Run the service

func (*Service) Server

func (s *Service) Server() server.Server

func (*Service) Start

func (s *Service) Start() error

func (*Service) Stop

func (s *Service) Stop() error

func (*Service) String

func (s *Service) String() string

func (*Service) Subscribe

func (s *Service) Subscribe(topic string, v interface{}) error

Subscribe registers a subscriber

func (*Service) Version

func (s *Service) Version() string

Version of the service

Directories

Path Synopsis
api
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/event
Package event provides a handler which publishes an event
Package event provides a handler which publishes an event
handler/http
Package http is a http reverse proxy handler
Package http is a http reverse proxy handler
handler/rpc
Package rpc is a go-micro rpc handler.
Package rpc is a go-micro rpc handler.
handler/web
Package web contains the web handler including websocket support
Package web contains the web handler including websocket support
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
resolver/host
Package host resolves using http host
Package host resolves using http host
resolver/path
Package path resolves using http path
Package path resolves using http path
resolver/subdomain
Package subdomain is a resolver which uses the subdomain to determine the domain to route to.
Package subdomain is a resolver which uses the subdomain to determine the domain to route to.
resolver/vpath
Package vpath resolves using http path and recognised versioned urls
Package vpath resolves using http path and recognised versioned urls
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/http
Package http provides a http server with features; acme, cors, etc
Package http provides a http server with features; acme, cors, etc
jwt
Package jwt is a jwt implementation of the auth interface
Package jwt is a jwt implementation of the auth interface
Package broker is the micro broker
Package broker is the micro broker
memory
Package memory provides a memory broker
Package memory provides a memory broker
util/tar
Package tar is a wrapper around archive/tar, it's used for archiving and unarchiving source from and into folders on the host.
Package tar is a wrapper around archive/tar, it's used for archiving and unarchiving source from and into folders on the host.
util/zip
Package zip is a wrapper around archive/zip, it's used for archiving and unarchiving source from and into folders on the host.
Package zip is a wrapper around archive/zip, it's used for archiving and unarchiving source from and into folders on the host.
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 client
mucp
Package mucp provides a transport agnostic RPC client
Package mucp provides a transport agnostic RPC client
Package config is an interface for dynamic configuration.
Package config is an interface for dynamic configuration.
env
Package env provides config from environment variables
Package env provides config from environment variables
Package context provides a context for accessing services
Package context provides a context for accessing services
metadata
Package metadata is a way of defining message headers
Package metadata is a way of defining message headers
handler
Package handler implements service debug handler embedded in go-micro services
Package handler implements service debug handler embedded in go-micro services
log
Package log provides debug logging
Package log provides debug logging
log/kubernetes
Package kubernetes is a logger implementing (github.com/micro/go-micro/v3/debug/log).Log
Package kubernetes is a logger implementing (github.com/micro/go-micro/v3/debug/log).Log
log/memory
Package memory provides an in memory log buffer
Package memory provides an in memory log buffer
profile
Package profile is for profilers
Package profile is for profilers
profile/http
Package http enables the http profiler
Package http enables the http profiler
profile/pprof
Package pprof provides a pprof profiler which writes output to /tmp/[name].{cpu,mem}.pprof
Package pprof provides a pprof profiler which writes output to /tmp/[name].{cpu,mem}.pprof
stats
Package stats provides runtime stats
Package stats provides runtime stats
trace
Package trace provides an interface for distributed tracing
Package trace provides an interface for distributed tracing
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.
Package events is for event streaming and storage
Package events is for event streaming and storage
Package log provides a log interface
Package log provides a log interface
Package metrics is for instrumentation and debugging
Package metrics is for instrumentation and debugging
Package model implements convenience methods for managing indexes on top of the Store.
Package model implements convenience methods for managing indexes on top of the Store.
sql
Package sql is for a sql database model
Package sql is for a sql database model
Package network implements micro network node
Package network implements micro network node
resolver
Package resolver resolves network names to addresses
Package resolver resolves network names to addresses
resolver/dns
Package dns resolves names to dns records
Package dns resolves names to dns records
resolver/dnssrv
Package dns srv resolves names to dns srv records
Package dns srv resolves names to dns srv records
resolver/http
Package http resolves names to network addresses using a http request
Package http resolves names to network addresses using a http request
resolver/noop
Package noop is a noop resolver
Package noop is a noop resolver
resolver/registry
Package registry resolves names using the go-micro registry
Package registry resolves names using the go-micro registry
resolver/static
Package static is a static resolver
Package static is a static resolver
transport
Package transport is an interface for synchronous connection based communication
Package transport is an interface for synchronous connection based communication
transport/memory
Package memory is an in-memory transport
Package memory is an in-memory transport
tunnel
Package tunnel provides gre network tunnelling
Package tunnel provides gre network tunnelling
tunnel/broker
Package broker is a tunnel broker
Package broker is a tunnel broker
tunnel/transport
Package transport provides a tunnel transport
Package transport provides a tunnel transport
Package proxy is a transparent proxy built on the go-micro/server
Package proxy is a transparent proxy built on the go-micro/server
grpc
Package grpc is a grpc proxy built for the go-micro/server
Package grpc is a grpc proxy built for the go-micro/server
http
Package http provides a micro rpc to http proxy
Package http provides a micro rpc to http proxy
mucp
Package mucp transparently forwards the incoming request using a go-micro client.
Package mucp transparently forwards the incoming request using a go-micro client.
Package registry is the micro registry
Package registry is the micro registry
cache
Package cache provides a registry cache
Package cache provides a registry cache
memory
Package memory provides an in-memory registry
Package memory provides an in-memory registry
noop
Package noop is a registry which does nothing
Package noop is a registry which does nothing
kubernetes
Package kubernetes is a kubernetes router which uses the service name and network to route
Package kubernetes is a kubernetes router which uses the service name and network to route
Package runtime is a service runtime manager
Package runtime is a service runtime manager
kubernetes
Package kubernetes implements kubernetes micro runtime
Package kubernetes implements kubernetes micro runtime
kubernetes/client
Package client provides an implementation of a restricted subset of kubernetes API client
Package client provides an implementation of a restricted subset of kubernetes API client
local/process
Package process executes a binary
Package process executes a binary
local/process/os
Package os runs processes locally
Package os runs processes locally
local/test/bar
Package main is used to test the local runtime, specifically the entrypoint function
Package main is used to test the local runtime, specifically the entrypoint function
local/test/foo/cmd/bar
Package main is used to test the local runtime, specifically the entrypoint function
Package main is used to test the local runtime, specifically the entrypoint function
local/test/foo/cmd/baz
Package main is used to test the local runtime, specifically the entrypoint function
Package main is used to test the local runtime, specifically the entrypoint function
local/test/qux/cmd/test
Package main is used to test the local runtime, specifically the entrypoint function
Package main is used to test the local runtime, specifically the entrypoint function
source
Package source retrieves source code
Package source retrieves source code
source/go
Package golang is a source for Go
Package golang is a source for Go
grpc
Package grpc provides a grpc server
Package grpc provides a grpc server
mucp
Package mucp provides a transport agnostic RPC server
Package mucp provides a transport agnostic RPC server
Package store is an interface for distributed data storage.
Package store is an interface for distributed data storage.
file
Package local is a file system backed store
Package local is a file system backed store
memory
Package memory is a in-memory store store
Package memory is a in-memory store store

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL