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,46 @@
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 = [
"convey-test.toml",
"feed-service-test.toml",
],
importpath = "go-common/app/service/main/feed/cmd",
tags = ["automanaged"],
deps = [
"//app/service/main/feed/conf:go_default_library",
"//app/service/main/feed/http:go_default_library",
"//app/service/main/feed/rpc/server:go_default_library",
"//app/service/main/feed/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,83 @@
# convey 测试用 注意每次会重置redis/memcache里的数据
[xlog]
dir = "/data/log/feed-service/"
[xlog.syslog]
proto = "udp"
addr = "172.18.19.22:9999"
project = "web-interface"
chanSize = 10240
[bm]
addr = "0.0.0.0:6362"
timeout = "1s"
[rpcServer]
proto = "tcp"
addr = "127.0.0.1:6361"
[accountRPC]
[archiveRPC]
[articleRPC]
[multiRedis]
maxArcsNum = 50 # 对每个up主回源时候 一次最多拿多少个稿件 也是每个up主稿件缓存的限制量
TTLUpper = "480h"
expireUpper = "480h"
expireFeed = "16h"
[multiRedis.Cache]
name = "feed-service"
proto = "tcp"
addr = "127.0.0.1:6379"
idle = 10
active = 10
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "10s"
[memcache]
name = "feed-service"
proto = "tcp"
addr = "127.0.0.1:11211"
idle = 10
active = 10
dialTimeout = "2s"
readTimeout = "2s"
writeTimeout = "2s"
idleTimeout = "7h"
expire = "15m"
bangumiExpire = "15m"
[httpClient]
key = "e7482d29be4a95b8"
secret = "9e803791cdef756e75faee68e12b7442"
dial = "500ms"
timeout = "2s"
keepAlive = "60s"
timer = 10
[httpClient.breaker]
window ="10s"
sleep ="10ms"
bucket = 10
ratio = 0.5
request = 100
[app]
key = "e7482d29be4a95b8"
secret = "9e803791cdef756e75faee68e12b7442"
[feed]
appLength = 200
webLength = 400
archiveFeedLength = 200
archiveFeedExpire = "5m"
bangumiFeedExpire = "5m"
appPullInterval = "5m"
webPullInterval = "15s"
bulkSize = 500
minUpCnt = 10
maxTotalCnt = 100

View File

@@ -0,0 +1,71 @@
# This is a TOML document. Boom.
[bm]
addr = "0.0.0.0:6362"
timeout = "1s"
[rpcServer]
proto = "tcp"
addr = "0.0.0.0:6361"
[accountRPC]
[archiveRPC]
[articleRPC]
[multiRedis]
maxArcsNum = 50 # 对每个up主回源时候 一次最多拿多少个稿件 也是每个up主稿件缓存的限制量
TTLUpper = "480h"
expireUpper = "480h"
expireFeed = "16h"
[multiRedis.Cache]
name = "feed-service"
proto = "tcp"
addr = "172.18.33.60:6891"
idle = 10
active = 10
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "10s"
[memcache]
name = "feed-service"
proto = "tcp"
addr = "172.18.33.61:11230"
idle = 10
active = 10
dialTimeout = "2s"
readTimeout = "2s"
writeTimeout = "2s"
idleTimeout = "7h"
expire = "15m"
bangumiExpire = "15m"
[httpClient]
key = "e7482d29be4a95b8"
secret = "9e803791cdef756e75faee68e12b7442"
dial = "500ms"
timeout = "2s"
keepAlive = "60s"
timer = 10
[httpClient.breaker]
window ="10s"
sleep ="10ms"
bucket = 10
ratio = 0.5
request = 100
[feed]
appLength = 200
webLength = 400
archiveFeedLength = 200
archiveFeedExpire = "5m"
bangumiFeedExpire = "5m"
appPullInterval = "5m"
webPullInterval = "15s"
bulkSize = 500
minUpCnt = 10
maxTotalCnt = 100

View File

@@ -0,0 +1,51 @@
package main
import (
"flag"
"os"
"os/signal"
"syscall"
"time"
"go-common/app/service/main/feed/conf"
"go-common/app/service/main/feed/http"
rpc "go-common/app/service/main/feed/rpc/server"
"go-common/app/service/main/feed/service"
"go-common/library/log"
"go-common/library/net/trace"
)
func main() {
flag.Parse()
// init conf,log,trace,stat,perf.
if err := conf.Init(); err != nil {
panic(err)
}
log.Init(conf.Conf.Xlog)
defer log.Close()
trace.Init(conf.Conf.Tracer)
defer trace.Close()
// service init
svr := service.New(conf.Conf)
http.Init(conf.Conf, svr)
rpcSvr := rpc.New(conf.Conf, svr)
// signal handler
log.Info("feed-service start")
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
for {
s := <-c
log.Info("feed-service get a signal %s", s.String())
switch s {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
log.Info("feed-service exit")
rpcSvr.Close()
time.Sleep(time.Second * 2)
return
case syscall.SIGHUP:
// TODO reload
default:
return
}
}
}

View File

@@ -0,0 +1,6 @@
#!/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; }
cd ../
goconvey -excludedDirs "vendor,node_modules,rpc" -packages 1