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,44 @@
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 = ["captcha-test.toml"],
importpath = "go-common/app/interface/main/captcha/cmd",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/interface/main/captcha/conf:go_default_library",
"//app/interface/main/captcha/http:go_default_library",
"//app/interface/main/captcha/service:go_default_library",
"//library/ecode/tip:go_default_library",
"//library/log:go_default_library",
"//library/net/trace: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"],
)

View File

@@ -0,0 +1,140 @@
# This is a TOML document. Boom.
version = "1.0.0"
user = "nobody"
pid = "/tmp/captcha.pid"
dir = "./"
perf = "127.0.0.1:6240"
family = "captcha"
[xlog]
dir = "/data/log/captcha/"
[ecode]
domain = "172.16.33.248:6401"
all = "1h"
diff = "10m"
[ecode.clientconfig]
dial = "2000ms"
timeout = "2s"
keepAlive = "10s"
timer = 128
key = "test"
secret = "e6c4c252dc7e3d8a90805eecd7c73396"
[ecode.clientconfig.breaker]
window ="3s"
sleep ="100ms"
bucket = 10
ratio = 0.5
request = 100
[bm]
[bm.outer]
addr = "0.0.0.0:6241"
maxListen = 1000
timeout = "100ms"
[identify]
whiteAccessKey = ""
whiteMid = 0
[identify.app]
key = "f022126a8a365e20"
secret = "b7b86838145d634b487e67b811b8fab2"
[identify.memcache]
name = "go-business/identify"
proto = "tcp"
addr = "172.16.33.54:11211"
active = 5
idle = 10
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "80s"
[identify.host]
auth = "http://passport.bilibili.com"
secret = "http://open.bilibili.com"
[identify.httpClient]
key = "f022126a8a365e20"
secret = "b7b86838145d634b487e67b811b8fab2"
dial = "30ms"
timeout = "100ms"
keepAlive = "60s"
[identify.httpClient.breaker]
window = "10s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[identify.httpClient.url]
"http://passport.bilibili.co/intranet/auth/tokenInfo" = {timeout = "100ms"}
"http://passport.bilibili.co/intranet/auth/cookieInfo" = {timeout = "100ms"}
"http://open.bilibili.co/api/getsecret" = {timeout = "500ms"}
[rate]
[rate.apps]
"reply" = {limit = 10000.0, burst = 10000}
"live" = {limit = 30000.0, burst = 10000}
[rate.urls]
"/x/internal/v1/captcha/token" = {limit = 30000.0, burst = 10000}
"/x/internal/v1/captcha/verify" = {limit = 30000.0, burst = 10000}
"/x/v1/captcha/get" = {limit = 30000.0, burst = 10000}
[memcache]
proto = "tcp"
addr = "172.16.33.54:11211"
idle = 10
active = 10
dialTimeout = "2s"
readTimeout = "2s"
writeTimeout = "2s"
idleTimeout = "7h"
[captcha]
outerHost = "http://api.bilibili.com"
capacity = 1000
interval = "5m"
disturbLevel = 16
ext = "jpeg"
fonts = ["./fonts/comic.ttf"]
[[captcha.bkgColors]]
r = 255
g = 0
b = 0
a = 255
[[captcha.bkgColors]]
r = 0
g = 0
b = 255
a = 255
[[captcha.bkgColors]]
r = 0
g = 153
b = 0
a = 255
[[captcha.frontColors]]
r = 255
g = 255
b = 255
a = 255
[[business]]
businessID = "default"
lenStart = 4
lenEnd = 4
width = 100
length =50
ttl = "120s"
[[business]]
businessID = "account"
lenStart = 4
lenEnd = 5
width = 100
length =50
ttl = "120s"
[[business]]
businessID = "101"
lenStart = 4
lenEnd = 5
width = 100
length =50
ttl = "5m"

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,51 @@
package main
import (
"flag"
"math/rand"
"os"
"os/signal"
"syscall"
"time"
"go-common/app/interface/main/captcha/conf"
"go-common/app/interface/main/captcha/http"
"go-common/app/interface/main/captcha/service"
ecode "go-common/library/ecode/tip"
"go-common/library/log"
"go-common/library/net/trace"
)
func main() {
rand.Seed(time.Now().Unix())
flag.Parse()
if err := conf.Init(); err != nil {
log.Error("conf.Init() error(%v)", err)
panic(err)
}
log.Init(conf.Conf.XLog)
defer log.Close()
log.Info("captcha-service start")
trace.Init(conf.Conf.Tracer)
defer trace.Close()
svr := service.New(conf.Conf)
ecode.Init(conf.Conf.Ecode)
http.Init(conf.Conf, svr)
// signal
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
for {
s := <-c
log.Info("captcha-service get a signal %s", s.String())
switch s {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
// svr.Close()
log.Info("captcha-service exit")
return
case syscall.SIGHUP:
// TODO reload
default:
return
}
}
}