Documentation ¶
Overview ¶
Package octopus_meta
Package octopus_meta
Package octopus_meta
Package octopus_meta
Package octopus_meta
Package octopus_meta
Package octopus_meta
Package octopus_meta
Package octopus_meta
Index ¶
- Constants
- Variables
- func AutoEnv()
- func AutoLoad() (map[string]App, error)
- func DelAppMeta(appName string) error
- func Info() (string, string, string)
- func Load(p string) (map[string]App, error)
- func NewAppMeta(appName string) error
- func NewMetaDir(p string) error
- func SaveAppMeta(app App, appName string) error
- func SetOctopusMetaDir(p string)
- type Alarm
- type AlarmExtends
- type App
- type CMD
- type Meta
- type MetaData
- type Octopus
- type OctopusJSON
- type ResourceLimit
- type RunData
- type Runtime
Constants ¶
View Source
const ( SourceOther = "other" SourceApp = "app" SourceSys = "system" SourceContainer = "container" )
View Source
const ( MetaAutoLoadDir = ".octopus" MetaAutoLoadDirNoHide = "octopusMeta" MetaSuffix = ".pig" )
View Source
const ( TypeService = "Service" // 服务 TypeWebFront = "FrontEnd" // 前端 TypeNoEngine = "NoEngine" // 前端 TypeMiddleWare = "MiddleWare" // 中间件 TypeDataStore = "DataStore" // 数据层 TypeModule = "Module" // 模块 TypeContainer = "Container" // 容器 )
View Source
const ( Published = "published" // 已发布 Testing = "testing" // 测试中 Unreleased = "unreleased" // 待发布 Beta = "beta" // beta版本 )
app的发布状态
View Source
const ( ConfNginx = "nginx" ConfGunicorn = "gunicorn" )
配置文件类型
Variables ¶
View Source
var ( ErrMetaDir = errors.New("metadata dir is not exist") ErrWalkMetaDir = errors.New("failed to walk metadata to load app configs") ErrLoadPart = errors.New("failed to load part of apps") ErrAPP = errors.New("failed to find app by name") ErrNotPtr = errors.New("v is not a pointer") )
View Source
var DefaultApp = App{ Type: TypeService, ReleaseStatus: Published, EngDes: "default english description", CHSDes: "默认中文描述", ManageCMD: CMD{ Start: "start.sh", Stop: "stop.sh", Restart: "restart.sh", ForceKill: "kill.sh", Check: "check.sh", }, Meta: Meta{ Author: "", Domain: "", Language: []string{}, CreateDate: "", Version: "1.0.0", DynamicConf: false, ConfType: "", ConfPath: "", }, RunData: RunData{ Envs: []string{}, Ports: []int{}, RandomPort: true, Host: "localhost", }, }
View Source
var OctopusIterator = Octopus{Type: "default", AutoEnv: true}
View Source
var OctopusMetaDir = ""
View Source
var OriginJSON = originJSON{}
OriginJSON 使用go encoding/json
Functions ¶
func NewAppMeta ¶
NewAppMeta 创建新的空app meta 自动加载目录和全局目录都不存在时 调用SetOctopusMetaDir来设置全局使用的路径
func SetOctopusMetaDir ¶
func SetOctopusMetaDir(p string)
SetOctopusMetaDir 设置配置需要读取的默认路径 后续所有的读取都会走这个路径 autoload时不生效
Types ¶
type Alarm ¶ added in v1.0.6
type Alarm struct { Title string `json:"title" bson:"title"` Level string `json:"level" bson:"level"` Message string `json:"message" bson:"message"` AlarmExtends `json:",omitempty" bson:",inline"` }
Alarm 告警信息模型 在使用时 存储数据库时增加mongo model
type AlarmExtends ¶ added in v1.0.6
type AlarmExtends struct { Source string `json:"source" bson:"source"` // 告警来源 User string `json:"user" bson:"user"` // 操作用户 }
AlarmExtends 告警扩展信息
type App ¶
type App struct { Name string `json:"name" validate:"required" bson:"name" yaml:"name"` // 服务名称 ID string `json:"id" validate:"required" bson:"id" yaml:"id"` // 服务唯一ID Type string `json:"type" bson:"type" yaml:"type"` // service | middleware ReleaseStatus string `json:"release_status" bson:"release_status" yaml:"release_status"` // published | pending | testing EngDes string `json:"eng_des" bson:"eng_des" yaml:"eng_des"` // 英文描述 CHSDes string `json:"chs_des" bson:"chs_des" yaml:"chs_des"` // 中文描述 Link string `json:"link" bson:"link" yaml:"link"` // 服务对外提供的URL链接 // 管理项 ManageCMD CMD `json:"manage_cmd" bson:"manage_cmd" yaml:"manage_cmd"` // 管理命令组 // 元数据 Meta Meta `json:"meta" bson:"meta" yaml:"meta"` // 服务元数据 // 动态依赖配置 RunData RunData `json:"run_data" bson:"run_data" yaml:"run_data"` // 服务运行依赖 Runtime Runtime `json:"runtime" bson:"runtime" yaml:"runtime"` // 服务运行时数据 ResourceLimit ResourceLimit `json:"resource_limit" bson:"resource_limit" yaml:"resource_limit"` // 运行时资源限制 }
App model for app
type CMD ¶
type CMD struct { Start string `json:"start" bson:"start" yaml:"start"` Stop string `json:"stop" bson:"stop" yaml:"stop"` Restart string `json:"restart" bson:"restart" yaml:"restart"` ForceKill string `json:"force_kill" bson:"force_kill" yaml:"force_kill"` Check string `json:"check" bson:"check" yaml:"check"` }
CMD 服务的管理脚本
type Meta ¶
type Meta struct { Author string `json:"author" bson:"author" yaml:"author"` Domain string `json:"domain" bson:"domain" yaml:"domain"` Language []string `json:"language" bson:"language" yaml:"language"` CreateDate string `json:"create_date" bson:"create_date" yaml:"create_date"` Version string `json:"version" bson:"version" yaml:"version"` DynamicConf bool `json:"dynamic_conf" bson:"dynamic_conf" yaml:"dynamic_conf"` // 是否需要生成配置文件 支持nginx | gunicorn ConfType string `json:"conf_type" bson:"conf_type" yaml:"conf_type"` // nginx | gunicorn ConfPath string `json:"conf_path" bson:"conf_path" yaml:"conf_path"` // 配置文件路径 支持绝对和相对路径 }
Meta 服务的元数据
type Octopus ¶ added in v1.0.1
Octopus 初始化或使用全局定义的octopus
func (*Octopus) ParseString ¶ added in v1.0.1
ParseString 从字符串中解析
type OctopusJSON ¶ added in v1.0.5
type ResourceLimit ¶ added in v1.0.4
type ResourceLimit struct { MinCpu int `json:"min_cpu" bson:"min_cpu" yaml:"min_cpu"` // 最小cpu使用率 % MaxCpu int `json:"max_cpu" bson:"max_cpu" yaml:"max_cpu"` // 最大cpu使用率 % MinMem int `json:"min_mem" bson:"min_mem" yaml:"min_mem"` // 最小内存使用率 bytes MaxMem int `json:"max_mem" bson:"max_mem" yaml:"max_mem"` // 最大内存使用率 bytes AveCpuPeak int `json:"ave_cpu_peak" bson:"ave_cpu_peak" yaml:"ave_cpu_peak"` // 稳定负载下平均cpu峰值 AveMemPeak int `json:"ave_mem_peak" bson:"ave_mem_peak" yaml:"ave_mem_peak"` // 稳定负载下平均mem峰值 MaxRead int `json:"max_read" bson:"max_read" yaml:"max_read"` // 最大读取速率 MaxWrite int `json:"max_write" bson:"max_write" yaml:"max_write"` // 最大写入速率 MaxRequest int `json:"max_request" bson:"max_request" yaml:"max_request"` // 单位时间最大请求数 MaxClient int `json:"max_client" bson:"max_client" yaml:"max_client"` // 单位时间最大客户端连接数 }
ResourceLimit 运行时资源限制
type RunData ¶
type RunData struct { Envs []string `json:"envs" bson:"envs" yaml:"envs"` // just like `Name=Diri` Ports []int `json:"ports" bson:"ports" yaml:"ports"` RandomPort bool `json:"random_port" bson:"random_port" yaml:"random_port"` // if using random port Host string `json:"host" bson:"host" yaml:"host"` // always must be localhost RunDep []string `json:"run_dep" bson:"run_dep" yaml:"run_dep"` // 运行时依赖的其他模块 异常时无法启动此服务 StopChain []string `json:"stop_chain" bson:"stop_chain" yaml:"stop_chain"` // 谨慎使用 停止调用链(与此服务相关的链上服务都将停止) }
RunData 运行时依赖
type Runtime ¶ added in v1.0.7
type Runtime struct { Pid string `json:"pid" bson:"pid" yaml:"pid"` // 仅记录主pid Ports []int `json:"ports" bson:"ports" yaml:"ports"` StopOperation bool `json:"stop_operation" bson:"stop_operation" yaml:"stop_operation"` // 是否为手动停止的服务 手动停止后不再进行检查和尝试拉起 }
Runtime 运行时数据 不会持久化到文件内部 端口ports 拷贝自RunData
Click to show internal directories.
Click to hide internal directories.