micro

package module
v0.0.0-...-cca27e0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

README

micro

Golang

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func F

func F(name string, fc func(context.Context) error) *warpServiceFunc

F warp func service

func Pprof

func Pprof(ctx context.Context, duration time.Duration) error

func Trace

func Trace(ctx context.Context, duration time.Duration) error

Types

type Init

type Init interface {
	Init(context.Context) error
}

Init interface

type InitFunc

type InitFunc func(context.Context) error

InitFunc implements Runnable interface

func (InitFunc) Init

func (init InitFunc) Init(ctx context.Context) error

Init init

type Option

type Option func(*Options)

Option function

func Context

func Context(ctx context.Context) Option

Context specifies a context for the service.

func Name

func Name(name string) Option

Name service name

type Options

type Options struct {
	AppName string // 程序名称
	PID     int    // 进程ID
	LocIP   string // 地IP
	Uptime  time.Time

	Context context.Context
}

Options options

type RunFunc

type RunFunc func(context.Context) error

RunFunc implements Runnable interface

func (RunFunc) Run

func (run RunFunc) Run(ctx context.Context) error

Run run

type Runnable

type Runnable interface {
	Run(context.Context) error
}

Runnable implements run method

type Service

type Service interface {
	// Name The service name
	Name() string
	// Prepare prepare initialises options
	Prepare(...Option)
	// Options returns the current options
	Options() Options

	// Run the service
	Run() error

	Regist(Runnable)
	RegistFunc(RunFunc)
}

Service is an interface that wraps the lower level libraries within go-micro. Its a convenience method for building and initialising services.

func New

func New(opts ...Option) Service

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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