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,45 @@
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 = [
"article-job-test.toml",
"goconvey.toml",
],
importpath = "go-common/app/job/openplatform/article/cmd",
tags = ["automanaged"],
deps = [
"//app/job/openplatform/article/conf:go_default_library",
"//app/job/openplatform/article/http:go_default_library",
"//app/job/openplatform/article/service: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,264 @@
version = "1.0.0"
user = "nobody"
pid = "/tmp/article-job.pid"
env="dev" # dev or pro
dir = "./"
perf = "0.0.0.0:6740"
family = "article-job"
[xlog]
dir = "/data/log/article-job/"
[tracer]
proto = "udp"
addr = "172.18.21.30:5140"
tag = "platform/article-job"
[app]
key = "9cfc54570033cd61"
secret = "9d63835fa38fe58a62d9f49ef5da296f"
[SMS]
phone = "11111111111,11111111111"
token = "token"
[bm]
addr = "0.0.0.0:6741"
timeout = "1s"
[HTTPClient]
key = "9cfc54570033cd61"
secret = "9d63835fa38fe58a62d9f49ef5da296f"
dial = "50ms"
timeout = "1s"
keepAlive = "60s"
[HTTPClient.breaker]
window ="10s"
sleep ="10ms"
bucket = 10
ratio = 0.5
request = 100
[GameHTTPClient]
key = "9cfc54570033cd61"
secret = "9d63835fa38fe58a62d9f49ef5da296f"
dial = "50ms"
timeout = "1s"
keepAlive = "60s"
[GameHTTPClient.breaker]
window ="10s"
sleep ="10ms"
bucket = 10
ratio = 0.5
request = 100
[articleSub]
key = "0QEO9F8JuuIxZzNDvklH"
secret = "0QEO9F8JuuIxZzNDvklI"
group = "Article-Binlog-S"
topic = "Article-T"
action = "sub"
name = "article-job/article-sub"
proto = "tcp"
addr = "172.16.33.158:6205"
idle = 100
active = 100
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[articleStatSub]
key = "0QEO9F8JuuIxZzNDvklH"
secret = "0QEO9F8JuuIxZzNDvklI"
group = "ArticleStat-Article-S"
topic = "ArticleStat-T"
action = "sub"
name = "article-job/article-stat-sub"
proto = "tcp"
addr = "172.16.33.158:6205"
idle = 100
active = 100
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[LikeStatSub]
key = "9765cdac5894f2ba"
secret = "1448f5f2cd6029f6af6c5d438cd31edd"
group = "LikesBinlog-MainWebSvr-S"
topic = "LikesBinlog-T"
action = "sub"
name = "article-job/article-sub"
proto = "tcp"
addr = "172.16.33.158:6205"
idle = 100
active = 100
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[ReplyStatSub]
key = "9765cdac5894f2ba"
secret = "1448f5f2cd6029f6af6c5d438cd31edd"
group = "LikesBinlog-MainWebSvr-S"
topic = "LikesBinlog-T"
action = "sub"
name = "article-job/article-sub"
proto = "tcp"
addr = "172.16.33.158:6205"
idle = 100
active = 100
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[FavoriteStatSub]
key = "9765cdac5894f2ba"
secret = "1448f5f2cd6029f6af6c5d438cd31edd"
group = "LikesBinlog-MainWebSvr-S"
topic = "LikesBinlog-T"
action = "sub"
name = "article-job/article-sub"
proto = "tcp"
addr = "172.16.33.158:6205"
idle = 100
active = 100
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[CoinStatSub]
key = "9765cdac5894f2ba"
secret = "1448f5f2cd6029f6af6c5d438cd31edd"
group = "LikesBinlog-MainWebSvr-S"
topic = "LikesBinlog-T"
action = "sub"
name = "article-job/article-sub"
proto = "tcp"
addr = "172.16.33.158:6205"
idle = 100
active = 100
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[DynamicDbus]
key = "9765cdac5894f2ba"
secret = "1448f5f2cd6029f6af6c5d438cd31edd"
group= "CommTemplate-MainWebSvr-P"
topic= "CommTemplate-T"
action="pub"
name = "article/article-pub"
proto = "tcp"
addr = "172.16.33.158:6205"
idle = 100
active = 100
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[articleRPC]
pullInterval = "10s"
[articleRPC.client]
token = "123456"
proto = "tcp"
timeout = "1s"
timer = 1000
[articleRPC.client.breaker]
window ="10s"
sleep ="10ms"
bucket = 10
ratio = 0.5
request = 100
[articleRPC.zookeeper]
root = "/microservice/article-service/"
addrs = ["172.16.33.54:2181"]
timeout = "30s"
[tagRPC]
pullInterval = "10s"
[tagRPC.client]
proto = "tcp"
addr = "172.16.33.56:6099"
timeout = "1s"
timer = 1000
[tagRPC.client.breaker]
window ="10s"
sleep ="10ms"
bucket = 10
ratio = 0.5
request = 100
[tagRPC.zookeeper]
root = "/microservice/tag-service/"
addrs = ["172.16.33.54:2181"]
timeout = "30s"
[db]
name = "172.16.0.148:3306"
dsn = "test:test@tcp(172.16.33.54:3306)/bilibili_article?timeout=5s&readTimeout=5s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 5
idle = 2
idleTimeout ="4h"
queryTimeout = "100ms"
execTimeout = "100ms"
tranTimeout = "200ms"
[db.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[redis]
name = "article-job/views"
proto = "tcp"
addr = "172.16.33.54:6381"
active = 100
idle = 100
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "80s"
[artRedis]
name = "article-job/views"
proto = "tcp"
addr = "172.16.33.54:6381"
active = 100
idle = 100
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "80s"
[cheatInfoc]
taskID = "1"
proto = "tcp"
addr = "127.0.0.1:80"
chanSize = 10240
[ReadInfoc]
taskID = "1"
proto = "tcp"
addr = "127.0.0.1:80"
chanSize = 10240
[job]
viewCacheTTL = "30m"
dupViewCacheTTL = "30m"
updateDbInterval = "2m"
UpdateSortInterval = "1s"
GameCacheExpire = "5m"
ListReadCountInterval = "1h"
HotspotInterval = "1m"
HotspotForceInterval = "30m"
actLikeURL = "http://matsuri.bilibili.co/matsuri/api/article/like"
FlowURL = "http://uat-archive.api.bilibili.co/videoup/flow/entry/mid"
maxNewArtsNum = 1000
MaxSortArtsNum = 1000
ExpireSortArts = "24h"
TTLSortArts = "72h"
SortLimitTime = "504h"

View File

@@ -0,0 +1,5 @@
#!/bin/bash
command -v goconvey >/dev/null 2>&1 || { echo >&2 "required goconvey but it's not installed."; echo "Aborting."; echo "Please run commond: go get github.com/smartystreets/goconvey"; exit 1; }
goconvey -excludedDirs "vendor" -packages 1

View File

@@ -0,0 +1,197 @@
version = "1.0.0"
user = "nobody"
pid = "/tmp/article-job.pid"
env="dev" # dev or pro
dir = "./"
perf = "0.0.0.0:6413"
family = "article-job"
[xlog]
dir = "/data/log/article-job/"
[tracer]
proto = "udp"
addr = "172.18.21.30:5140"
tag = "platform/article-job"
[app]
key = "9cfc54570033cd61"
secret = "9d63835fa38fe58a62d9f49ef5da296f"
[SMS]
phone = "11111111111,11111111111"
token = "token"
[bm]
addr = "0.0.0.0:6741"
timeout = "1s"
[HTTPClient]
dial = "1s"
timeout = "3s"
keepAlive = "60s"
key = "9cfc54570033cd61"
secret = "9d63835fa38fe58a62d9f49ef5da296f"
[HTTPClient.breaker]
window ="10s"
sleep ="10ms"
bucket = 10
ratio = 0.5
request = 100
[GameHTTPClient]
key = "b336ebf10107c212"
secret = "ZadQSt7mCo9nwVu03SwKDEpgSlRBVtFc"
dial = "50ms"
timeout = "1s"
keepAlive = "60s"
[GameHTTPClient.breaker]
window ="10s"
sleep ="10ms"
bucket = 10
ratio = 0.5
request = 100
[articleSub]
key = "0QEO9F8JuuIxZzNDvklH"
secret = "0QEO9F8JuuIxZzNDvklI"
group = "Article-Binlog-S"
topic = "Article-T"
action = "sub"
name = "article-job/article-sub"
proto = "tcp"
addr = "172.16.33.158:6205"
idle = 100
active = 100
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[articleStatSub]
key = "0QEO9F8JuuIxZzNDvklH"
secret = "0QEO9F8JuuIxZzNDvklI"
group = "ArticleStat-Article-S"
topic = "ArticleStat-T"
action = "sub"
name = "article-job/article-stat-sub"
proto = "tcp"
addr = "172.16.33.158:6205"
idle = 100
active = 100
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[LikeStatSub]
key = "9765cdac5894f2ba"
secret = "1448f5f2cd6029f6af6c5d438cd31edd"
group = "LikesBinlog-MainWebSvr-S"
topic = "LikesBinlog-T"
action = "sub"
name = "article-job/article-sub"
proto = "tcp"
addr = "172.16.33.158:6205"
idle = 100
active = 100
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[DynamicDbus]
key = "9765cdac5894f2ba"
secret = "1448f5f2cd6029f6af6c5d438cd31edd"
group= "CommTemplate-MainWebSvr-P"
topic= "CommTemplate-T"
action="pub"
name = "article/article-pub"
proto = "tcp"
addr = "172.16.33.158:6205"
idle = 100
active = 100
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[articleRPC]
pullInterval = "10s"
[articleRPC.client]
token = "123456"
proto = "tcp"
timeout = "1s"
timer = 1000
[articleRPC.client.breaker]
window ="10s"
sleep ="10ms"
bucket = 10
ratio = 0.5
request = 100
[articleRPC.zookeeper]
root = "/microservice/article-service/"
addrs = ["172.16.33.54:2181"]
timeout = "30s"
[tagRPC]
pullInterval = "10s"
[tagRPC.client]
proto = "tcp"
addr = "172.16.33.56:6099"
timeout = "1s"
timer = 1000
[tagRPC.client.breaker]
window ="10s"
sleep ="10ms"
bucket = 10
ratio = 0.5
request = 100
[tagRPC.zookeeper]
root = "/microservice/tag-service/"
addrs = ["172.16.33.54:2181"]
timeout = "30s"
[db]
name = "172.16.0.148:3306"
dsn = "test:test@tcp(172.16.33.205:3308)/bilibili_article?timeout=5s&readTimeout=5s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 5
idle = 2
idleTimeout ="4h"
queryTimeout = "100ms"
execTimeout = "100ms"
tranTimeout = "200ms"
[db.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[redis]
name = "article-job/views"
proto = "tcp"
addr = "127.0.0.1:6379"
active = 10
idle = 2
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "80s"
[cheatInfoc]
taskID = "1"
proto = "tcp"
addr = "127.0.0.1:80"
chanSize = 10240
[job]
viewCacheTTL = "30m"
dupViewCacheTTL = "30m"
updateDbInterval = "2m"
GameCacheExpire = "5m"
UpdateSortInterval = "1s"
HotspotInterval = "1m"
HotspotForceInterval = "30m"
actLikeURL = "http://matsuri.bilibili.co/matsuri/api/article/like"
FlowURL = "http://uat-archive.api.bilibili.co/videoup/flow/entry/mid"

View File

@@ -0,0 +1,57 @@
package main
import (
"flag"
"os"
"os/signal"
"syscall"
"go-common/app/job/openplatform/article/conf"
"go-common/app/job/openplatform/article/http"
"go-common/app/job/openplatform/article/service"
"go-common/library/log"
"go-common/library/net/trace"
)
func main() {
flag.Parse()
initConf()
initLog()
defer log.Close()
log.Info("article-job start")
srv := service.New(conf.Conf)
http.Init(conf.Conf, srv)
initSignal(srv)
}
func initConf() {
if err := conf.Init(); err != nil {
panic(err)
}
}
func initLog() {
log.Init(conf.Conf.Xlog)
trace.Init(conf.Conf.Tracer)
defer trace.Close()
}
func initSignal(srv *service.Service) {
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
for {
s := <-c
log.Info("article-job get a signal: %s", s.String())
switch s {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
if err := srv.Close(); err != nil {
log.Error("srv close consumer error(%+v)", err)
}
return
case syscall.SIGHUP:
// TODO: reload
default:
return
}
}
}