cli

package
v0.5.23 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCmds

func GetCmds(options *Options) []cli.Command

GetCmds 获取所有命令

func GetSrvConfig

func GetSrvConfig(app *ServiceApp, args ...string) *service.Config

GetSrvConfig SrvCfg

func NewContext

func NewContext(ctx context.Context, s AppInfo) context.Context

NewContext returns a new Context that carries value.

func RegisterFunc

func RegisterFunc(f ...func(cfg *Options) cli.Command)

RegisterFunc 注册函数,用于异步加载

Types

type App

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

App cli app

func New

func New(opts ...Option) *App

New 创建app

func (*App) Start

func (a *App) Start() (err error)

Start 启动应用程序

type AppInfo

type AppInfo interface {
	ID() string
	// Name() string
	// Version() string
	Metadata() map[string]string
	Endpoint() []string
}

func FromContext

func FromContext(ctx context.Context) (s AppInfo, ok bool)

FromContext returns the Transport value stored in ctx, if any.

type AppMode

type AppMode string
const (
	Debug   AppMode = "debug"
	Release AppMode = "release"
)

type AppService

type AppService struct {
	service.Service

	ServiceName string
	DisplayName string
	Description string
	Arguments   []string
	// contains filtered or unexported fields
}

type Option

type Option func(*Options)

Option 配置选项

func Command added in v0.5.12

func Command(cmd cli.Command) Option

func ID

func ID(id string) Option

ID with service id.

func IpMask

func IpMask(mask string) Option

IpMask

func LogParams added in v0.5.12

func LogParams(opts ...log.ConfigOption) Option

ServiceDependencies

func Metadata

func Metadata(md map[string]string) Option

Metadata with service metadata.

func RegistrarTimeout added in v0.5.11

func RegistrarTimeout(timeout int64) Option

func Server

func Server(srv ...transport.Server) Option

Server with transport servers.

func ServiceDependencies

func ServiceDependencies(dependencies ...string) Option

ServiceDependencies

func ServiceOption

func ServiceOption(key string, val interface{}) Option

ServiceOption

func StartedHook added in v0.1.4

func StartedHook(hook func(context.Context) error) Option

StartedHook

func StartingHook added in v0.1.11

func StartingHook(hook func(context.Context) error) Option

StartingHook

func TraceAddr

func TraceAddr(addr string) Option

TraceAddr

func WithAppMode

func WithAppMode(mode AppMode) Option

WithAppMode

func WithConfigSource added in v0.2.6

func WithConfigSource(fileList ...config.Source) Option

WithAppMode

type Options

type Options struct {
	Id        string
	Metadata  map[string]string
	Endpoints []*url.URL

	Registrar        registry.Registrar
	Config           config.Config
	RegistrarTimeout time.Duration
	StopTimeout      time.Duration
	Servers          []transport.Server
	StartingHooks    []func(ctx context.Context) error
	StartedHooks     []func(ctx context.Context) error
	// contains filtered or unexported fields
}

type ServiceApp

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

ServiceApp ServiceApp

func GetSrvApp

func GetSrvApp(c *cli.Context) *ServiceApp

GetSrvApp SrvCfg

func (*ServiceApp) Endpoint

func (p *ServiceApp) Endpoint() []registry.ServerItem

func (*ServiceApp) ID

func (p *ServiceApp) ID() string

func (*ServiceApp) Metadata

func (p *ServiceApp) Metadata() map[string]string

func (*ServiceApp) Start

func (p *ServiceApp) Start(s service.Service) (err error)

Start Start

func (*ServiceApp) Stop

func (p *ServiceApp) Stop(s service.Service) (err error)

Stop Stop

Jump to

Keyboard shortcuts

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