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

View File

@@ -0,0 +1,43 @@
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_binary",
)
go_library(
name = "go_default_library",
srcs = ["main.go"],
data = ["secure-service-test.toml"],
importpath = "go-common/app/service/main/secure/cmd",
tags = ["automanaged"],
visibility = ["//visibility:private"],
deps = [
"//app/service/main/secure/conf:go_default_library",
"//app/service/main/secure/http:go_default_library",
"//app/service/main/secure/rpc/server:go_default_library",
"//app/service/main/secure/service:go_default_library",
"//library/log:go_default_library",
"//library/net/rpc:go_default_library",
"//library/net/trace:go_default_library",
],
)
go_binary(
name = "cmd",
embed = [":go_default_library"],
visibility = ["//visibility:public"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,63 @@
package main
import (
"flag"
"os"
"os/signal"
"syscall"
"time"
"go-common/app/service/main/secure/conf"
"go-common/app/service/main/secure/http"
rpc "go-common/app/service/main/secure/rpc/server"
"go-common/app/service/main/secure/service"
"go-common/library/log"
xrpc "go-common/library/net/rpc"
"go-common/library/net/trace"
)
var (
srv *service.Service
rpcSvr *xrpc.Server
)
func main() {
flag.Parse()
if err := conf.Init(); err != nil {
log.Error("conf.Init() error(%v)", err)
panic(err)
}
log.Init(conf.Conf.Log)
defer log.Close()
trace.Init(conf.Conf.Tracer)
defer trace.Close()
log.Info("credit-timer start")
srv = service.New(conf.Conf)
rpcSvr = rpc.New(conf.Conf, srv)
http.Init(srv)
signalHandler()
}
func signalHandler() {
var (
err error
ch = make(chan os.Signal, 1)
)
signal.Notify(ch, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
for {
si := <-ch
switch si {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
rpcSvr.Close()
time.Sleep(time.Second)
log.Info("get a signal %s, stop the consume process", si.String())
if err = srv.Close(); err != nil {
log.Error("srv close consumer error(%v)", err)
}
return
case syscall.SIGHUP:
default:
return
}
}
}

View File

@@ -0,0 +1,120 @@
[bm]
addr = "0.0.0.0:6812"
maxListen = 1000
timeout = "1s"
[httpClient]
key = "3c4e41f926e51656"
secret ="26a2095b60c24154521d24ae62b885bb"
dial = "500ms"
timeout = "2s"
keepAlive = "60s"
timer = 10
[httpClient.breaker]
window ="10s"
sleep ="10ms"
bucket = 10
ratio = 0.5
request = 100
[databus]
key = "0QNB0ZgFozbKUCQhbTq8"
secret = "0QNB0ZgFozbKUCQhbTq9"
group = "PassportBinlog-Login-S"
topic = "Passport-T"
action = "sub"
offset = "new"
buffer = 2048
name = "secure-service/databus"
proto = "tcp"
addr = "172.18.33.50:6205"
idle = 1
active = 1
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[mysql]
[mysql.secure]
addr = "172.22.34.101:3309"
dsn = "secure:cvETlGWr360LVzQPeJwydStxmA78Z4hX@tcp(172.22.34.101:3309)/bilibili_secure?timeout=5s&readTimeout=5s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 3
idle = 1
idleTimeout ="4h"
queryTimeout = "100ms"
execTimeout = "100ms"
tranTimeout = "200ms"
[mysql.secure.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[mysql.ddl]
addr = "172.22.34.101:3309"
dsn = "secure_ddl:c1GoSPd8O2KgBvkeRTbWMufNyzHiw6aV@tcp(172.22.34.101:3309)/bilibili_secure?timeout=5s&readTimeout=5s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 3
idle = 1
idleTimeout ="4h"
queryTimeout = "100ms"
execTimeout = "100ms"
tranTimeout = "200ms"
[mysql.ddl.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[rpcServer]
proto = "tcp"
addr = "0.0.0.0:6819"
weight = 10
[locationrpc]
timeout = "30s"
[redis]
name = "secure-service/secure"
proto = "tcp"
addr = "172.18.33.61:6839"
idle = 2
active = 20
dialTimeout = "100ms"
readTimeout = "350ms"
writeTimeout = "350ms"
idleTimeout = "80s"
expire = "1h"
doubleCheck="720h"
[memcache]
name = "secure-service"
proto = "tcp"
addr = "172.18.33.61:11212"
idle = 1
active = 10
dialTimeout = "100ms"
readTimeout = "200ms"
writeTimeout = "200ms"
idleTimeout = "80s"
expire = "9h"
[hbase]
master = ""
meta = ""
dialTimeout = "1s"
readTimeout = "10s"
readsTimeout = "10s"
writeTimeout = "10s"
writesTimeout = "10s"
[hbase.zookeeper]
root = ""
addrs = ["172.18.33.75:2181" ]
timeout = "30s"
[Expect]
Top = 3
Count =2
closeCount = 1000
Rand = 1