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 = ["relation-service-example.toml"],
importpath = "go-common/app/service/main/relation/cmd",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/main/relation/conf:go_default_library",
"//app/service/main/relation/http:go_default_library",
"//app/service/main/relation/rpc/server:go_default_library",
"//app/service/main/relation/server/grpc:go_default_library",
"//app/service/main/relation/service:go_default_library",
"//library/log:go_default_library",
"//library/net/trace:go_default_library",
"//library/queue/databus/report: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,58 @@
package main
import (
"flag"
"os"
"os/signal"
"syscall"
"time"
"context"
"go-common/app/service/main/relation/conf"
"go-common/app/service/main/relation/http"
"go-common/app/service/main/relation/rpc/server"
"go-common/app/service/main/relation/server/grpc"
"go-common/app/service/main/relation/service"
"go-common/library/log"
"go-common/library/net/trace"
"go-common/library/queue/databus/report"
)
func main() {
flag.Parse()
// init conf,log,trace,stat,perf.
if err := conf.Init(); err != nil {
panic(err)
}
log.Init(conf.Conf.Log)
defer log.Close()
trace.Init(conf.Conf.Tracer)
defer trace.Close()
// report
report.InitUser(conf.Conf.Report)
// service init WardenServer *warden.ServerConfig
svr := service.New(conf.Conf)
rpcSvr := rpc.New(conf.Conf, svr)
//start grpc
ws := grpc.New(conf.Conf, svr)
http.Init(conf.Conf, svr)
// signal handler
log.Info("relation-service start")
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
for {
s := <-c
log.Info("relation-service get a signal %s", s.String())
switch s {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
ws.Shutdown(context.Background())
rpcSvr.Close()
time.Sleep(time.Second * 2)
log.Info("relation-service exit")
return
case syscall.SIGHUP:
default:
return
}
}
}

View File

@@ -0,0 +1,163 @@
[log]
stdout = true
[host]
passport = "http://uat-passport.bilibili.co"
[RPCClient2]
[RPCClient2.member]
timeout = "1s"
[bm]
addr = "0.0.0.0:6331"
maxListen = 1000
timeout = "10s"
[mysql]
addr = "172.16.33.205:3306"
dsn = "account:wx2U1MwXRyWEuURw@tcp(172.16.33.205:3306)/relation?timeout=15s&readTimeout=15s&writeTimeout=15s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 5
idle = 2
idleTimeout ="4h"
queryTimeout = "100ms"
execTimeout = "100ms"
tranTimeout = "200ms"
[memcache]
name = "relation-job"
proto = "tcp"
addr = "172.18.33.61:11212"
idle = 5
active = 10
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "10s"
expire = "24h"
[redis]
name = "relation-service"
proto = "tcp"
addr = "172.18.33.60:6969"
idle = 100
active = 100
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "10s"
expire = "720h"
[rpcServer]
token="1234"
proto = "tcp"
addr = "0.0.0.0:6339"
weight = 10
[verify]
openServiceHost= "http://open.bilibili.co"
[verify.httpClient]
dial = "3000ms"
timeout = "3000ms"
keepAlive = "60s"
key = "53e2fa226f5ad348"
secret = "3cf6bd1b0ff671021da5f424fea4b04a"
[clearPath]
following = "http://api.bilibili.co/x/internal/relation/cache/following/update"
follower = "http://api.bilibili.co/x/internal/relation/cache/follower/del"
stat = "http://api.bilibili.co/x/internal/relation/cache/stat/del"
[apiPath]
followersNotify = "http://message.bilibili.co/api/notify/send.user.notify.do"
[httpClient]
key = "e7482d29be4a95b8"
secret = "9e803791cdef756e75faee68e12b7442"
dial = "100ms"
timeout = "1s"
keepAlive = "60s"
timer = 128
[httpClient.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[app]
key = "e7482d29be4a95b8"
secret = "9e803791cdef756e75faee68e12b7442"
[databus]
key = "0QBAaL5f8hupBjLQydZt"
secret = "0QBAaL5f8hupBjLQydZu"
group = "Relation-Friends-S"
topic = "Relation-T"
action = "sub"
offset = "old"
buffer = 2048
name = "go-common/app/job/main/relation/databus"
proto = "tcp"
addr = "172.16.33.158:6205"
idle = 100
active = 100
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[sms]
phone="15121003430,13601914616"
token="460d52f1-dafe-44a2-911a-9f308968309a"
[relation]
maxFollowingCached = 1000
maxFollowerCached = 1000
maxWhisperCached = 1000
maxFollowingLimit = 1000
mediumFollowingLimit = 5
minFollowingLimit = 3
maxBlackLimit = 200
monitor = false
followersUnread = "168h"
achievekey="VELvdAga7rbzL1O8"
Period="1s"
[statcache]
size=4096
expire="10s"
leastFollower=10000
[infoc]
taskID = "000072"
proto = "tcp"
addr = "172.19.100.20:5401"
chanSize = 10240
[antispam]
on=true
second=2
n=1
hour=12
m=500
[antispam.redis]
name = "relation/relation-service"
proto = "unix"
addr = "/tmp/uat-relation-redis.sock"
idle = 100
active = 100
dialTimeout = "500ms"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "80s"
expire = "10m"
[rate]
[rate.apps]
"relationappkey" = {limit = 10000.0, burst = 10000}
[rate.urls]
"/x/internal/relation/following/add" = {limit = 30000.0, burst = 10000}
[wardenServer]
addr = "0.0.0.0:9000"
timeout = "1s"