Create & Init Project...

This commit is contained in:
2019-04-22 18:49:16 +08:00
commit fc4fa37393
25440 changed files with 4054998 additions and 0 deletions

42
app/admin/main/cache/cmd/BUILD vendored Normal file
View File

@@ -0,0 +1,42 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_binary",
"go_library",
)
go_binary(
name = "cmd",
embed = [":go_default_library"],
tags = ["automanaged"],
)
go_library(
name = "go_default_library",
srcs = ["main.go"],
data = ["test.toml"],
importpath = "go-common/app/admin/main/cache/cmd",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/admin/main/cache/conf:go_default_library",
"//app/admin/main/cache/http:go_default_library",
"//library/ecode/tip:go_default_library",
"//library/log:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

50
app/admin/main/cache/cmd/db.sql vendored Normal file
View File

@@ -0,0 +1,50 @@
use bilibili_apm_v2;
CREATE TABLE `overlord_appid` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`tree_id` int(11) NOT NULL DEFAULT '0' COMMENT '服务树id',
`app_id` varchar(50) NOT NULL DEFAULT '' COMMENT '业务appid',
`cid` int(11) NOT NULL DEFAULT '0' COMMENT '关联集群id',
`ctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`mtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_appids_name` (`tree_id`, `cid`),
KEY `ix_appid` (`app_id`),
KEY `ix_mtime` (`mtime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='业务关联集群';
CREATE TABLE `overlord_cluster` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`name` varchar(50) NOT NULL DEFAULT '' COMMENT '集群名字',
`type` varchar(20) NOT NULL DEFAULT '' COMMENT '集群类型',
`zone` varchar(20) NOT NULL DEFAULT 'sh001' COMMENT '机房',
`hash_method` varchar(20) NOT NULL DEFAULT '' COMMENT 'hash方法',
`hash_distribution` varchar(20) NOT NULL DEFAULT '' COMMENT '分布策略',
`hashtag` varchar(10) NOT NULL DEFAULT '' COMMENT 'hash tag',
`listen_proto` varchar(10) NOT NULL DEFAULT 'tcp' COMMENT '监听协议',
`listen_addr` varchar(30) NOT NULL DEFAULT '' COMMENT '监听地址',
`nodeconn` int(11) NOT NULL DEFAULT '1' COMMENT '跟节点连接数',
`dial` int(11) NOT NULL DEFAULT '1000' COMMENT 'dial 超时',
`read` int(11) NOT NULL DEFAULT '1000' COMMENT 'read超时',
`write` int(11) NOT NULL DEFAULT '1000' COMMENT 'write 超时',
`ping_fail_limit` int(11) NOT NULL DEFAULT '3' COMMENT '失败检测次数',
`auto_eject` tinyint(4) NOT NULL DEFAULT '1' COMMENT 'auto eject',
`ctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`mtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_name` (`name`),
KEY `ix_mtime` (`mtime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='集群';
CREATE TABLE `overlord_node` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`cid` int(11) NOT NULL DEFAULT '0' COMMENT '关联集群id',
`alias` varchar(50) NOT NULL DEFAULT '' COMMENT '节点别名',
`addr` varchar(50) NOT NULL DEFAULT '' COMMENT '节点地址',
`weight` int(11) NOT NULL DEFAULT '1' COMMENT '节点权重',
`ctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`mtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_cid_alias` (`cid`,`alias`),
KEY `ix_mtime` (`mtime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='节点';

39
app/admin/main/cache/cmd/main.go vendored Normal file
View File

@@ -0,0 +1,39 @@
package main
import (
"flag"
"os"
"os/signal"
"syscall"
"go-common/app/admin/main/cache/conf"
"go-common/app/admin/main/cache/http"
ecode "go-common/library/ecode/tip"
"go-common/library/log"
)
func main() {
flag.Parse()
if err := conf.Init(); err != nil {
panic(err)
}
log.Init(conf.Conf.Log)
defer log.Close()
log.Info("cache start")
ecode.Init(conf.Conf.Ecode)
http.Init(conf.Conf)
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
for {
s := <-c
log.Info("cache get a signal %s", s.String())
switch s {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
log.Info("cache exit")
return
case syscall.SIGHUP:
default:
return
}
}
}

12
app/admin/main/cache/cmd/test.toml vendored Normal file
View File

@@ -0,0 +1,12 @@
[mysql]
dsn = "test:test@tcp(172.16.33.205:3308)/bilibili_apm_v2?timeout=5s&readTimeout=5s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 5
idle = 1
idleTimeout = "4h"
[httpClient]
key = "test"
secret = "e6c4c252dc7e3d8a90805eecd7c73396"
dial = "1s"
timeout = "10s"
keepAlive = "60s"