cmd

package
v0.0.0-...-ab8afbf Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2021 License: MIT Imports: 27 Imported by: 0

README

cmd

cmd 是cli(命令行)的入口.

root 是项目的根入口. 定义了项目所需的配置项和配置加载方式等功能.


server 表示该项目提供的默认的 web 服务入口, 用于定义路由规则, 创建web服务器等. 可定义多个业务的路由规则, 如 user.GET/POST/PUT, file.GET/POST/PUT.

grpc 表示该项目提供的默认的 rpc 服务入口.

server/grpc 一般只有一个. 当一个项目对外提供多个 web/grpc 服务时, 要么多个服务可以合并, 要么是项目业务划分不好, 需要考虑项目划分.

bootstrap 用于注入依赖/依赖反转, 根据需求更改其中的注册项. 提取公共资源(如services等)的创建方法, 重复用于 server/grpc 等服务的初始化. 脚本独自创建依赖的服务, 因为大多数脚本依赖资源比较单一, 且严格受控制


task1 表示该项目提供的脚本任务, 如定时清理缓存, 处理数据等. 可以有多个, 按业务名称命名.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute()

Types

type Bootstrap

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

func (*Bootstrap) GetDB

func (b *Bootstrap) GetDB() *database.DB

func (*Bootstrap) GetDemoSvc

func (b *Bootstrap) GetDemoSvc() toddler.DemoService

func (*Bootstrap) GetLogger

func (b *Bootstrap) GetLogger() *flog.Logger

func (*Bootstrap) Teardown

func (b *Bootstrap) Teardown()

type GrpcOption

type GrpcOption struct {
	Port int `mapstructure:"port" yaml:"port"`
}

type Options

type Options struct {
	Logging log.Options      `mapstructure:"logger"`
	DB      database.Options `mapstructure:"db" yaml:"db"`
	Grpc    GrpcOption       `mapstructure:"grpc" yaml:"grpc"`
	Server  ServerOption     `mapstructure:"server" yaml:"server"`
}

type ServerOption

type ServerOption struct {
	Host            string   `mapstructure:"host" yaml:"host"`
	Port            uint     `mapstructure:"port" yaml:"port"`
	CorsAllowOrigin []string `mapstructure:"cors_allow_origin"`
	DefaultExpired  int64    `mapstructure:"default_expired"`
}

Jump to

Keyboard shortcuts

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