正在显示
11 个修改的文件
包含
197 行增加
和
48 行删除
@@ -3,7 +3,7 @@ FROM golang:1.13 as builder | @@ -3,7 +3,7 @@ FROM golang:1.13 as builder | ||
3 | ENV GOPROXY https://goproxy.cn | 3 | ENV GOPROXY https://goproxy.cn |
4 | ENV GO111MODULE on | 4 | ENV GO111MODULE on |
5 | 5 | ||
6 | -RUN git clone http://gitlab.fjmaimaimai.com/mmm-go/gocomm.git /app/gocomm | 6 | +#RUN git clone http://github.com/tiptok/gocomm.git /app/gocomm |
7 | 7 | ||
8 | WORKDIR /app/ab | 8 | WORKDIR /app/ab |
9 | 9 |
@@ -2,9 +2,9 @@ package controllers | @@ -2,9 +2,9 @@ package controllers | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "github.com/astaxie/beego" | 4 | "github.com/astaxie/beego" |
5 | + "github.com/tiptok/gocomm/pkg/mybeego" | ||
5 | "gitlab.fjmaimaimai.com/mmm-go/ab/protocol" | 6 | "gitlab.fjmaimaimai.com/mmm-go/ab/protocol" |
6 | "gitlab.fjmaimaimai.com/mmm-go/ab/services/ab" | 7 | "gitlab.fjmaimaimai.com/mmm-go/ab/services/ab" |
7 | - "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/mybeego" | ||
8 | ) | 8 | ) |
9 | 9 | ||
10 | type ABController struct { | 10 | type ABController struct { |
@@ -2,9 +2,9 @@ package controllers | @@ -2,9 +2,9 @@ package controllers | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "github.com/astaxie/beego/validation" | 4 | "github.com/astaxie/beego/validation" |
5 | - "gitlab.fjmaimaimai.com/mmm-go/gocomm/common" | ||
6 | - "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | ||
7 | - "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/mybeego" | 5 | + "github.com/tiptok/gocomm/common" |
6 | + "github.com/tiptok/gocomm/pkg/log" | ||
7 | + "github.com/tiptok/gocomm/pkg/mybeego" | ||
8 | ) | 8 | ) |
9 | 9 | ||
10 | type BaseController struct { | 10 | type BaseController struct { |
@@ -12,16 +12,16 @@ type BaseController struct { | @@ -12,16 +12,16 @@ type BaseController struct { | ||
12 | } | 12 | } |
13 | 13 | ||
14 | //Valid valid struct | 14 | //Valid valid struct |
15 | -func (this *BaseController)Valid(obj interface{})(result bool ,msg *mybeego.Message){ | 15 | +func (this *BaseController) Valid(obj interface{}) (result bool, msg *mybeego.Message) { |
16 | /*校验*/ | 16 | /*校验*/ |
17 | var err error | 17 | var err error |
18 | - valid :=validation.Validation{} | ||
19 | - result,err= valid.Valid(obj) | ||
20 | - if err!=nil{ | 18 | + valid := validation.Validation{} |
19 | + result, err = valid.Valid(obj) | ||
20 | + if err != nil { | ||
21 | msg = mybeego.NewMessage(1) | 21 | msg = mybeego.NewMessage(1) |
22 | return | 22 | return |
23 | } | 23 | } |
24 | - if !result{ | 24 | + if !result { |
25 | for _, err := range valid.Errors { | 25 | for _, err := range valid.Errors { |
26 | log.Error(err.Key, err.Message) | 26 | log.Error(err.Key, err.Message) |
27 | } | 27 | } |
@@ -32,14 +32,14 @@ func (this *BaseController)Valid(obj interface{})(result bool ,msg *mybeego.Mess | @@ -32,14 +32,14 @@ func (this *BaseController)Valid(obj interface{})(result bool ,msg *mybeego.Mess | ||
32 | } | 32 | } |
33 | 33 | ||
34 | //GenMessage genarate a response message | 34 | //GenMessage genarate a response message |
35 | -func (this *BaseController)GenMessage(rsp interface{},err error)*mybeego.Message{ | 35 | +func (this *BaseController) GenMessage(rsp interface{}, err error) *mybeego.Message { |
36 | var msg *mybeego.Message | 36 | var msg *mybeego.Message |
37 | - if err==nil{ | 37 | + if err == nil { |
38 | msg = mybeego.NewMessage(0) | 38 | msg = mybeego.NewMessage(0) |
39 | msg.Data = rsp | 39 | msg.Data = rsp |
40 | return msg | 40 | return msg |
41 | } | 41 | } |
42 | - if e,ok :=err.(common.Error);ok{ | 42 | + if e, ok := err.(common.Error); ok { |
43 | msg = mybeego.NewMessage(e.Code) | 43 | msg = mybeego.NewMessage(e.Code) |
44 | msg.Data = rsp | 44 | msg.Data = rsp |
45 | return msg | 45 | return msg |
@@ -2,10 +2,10 @@ package controllers | @@ -2,10 +2,10 @@ package controllers | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "encoding/json" | 4 | "encoding/json" |
5 | + "github.com/tiptok/gocomm/pkg/log" | ||
6 | + "github.com/tiptok/gocomm/pkg/mybeego" | ||
5 | "gitlab.fjmaimaimai.com/mmm-go/ab/protocol" | 7 | "gitlab.fjmaimaimai.com/mmm-go/ab/protocol" |
6 | "gitlab.fjmaimaimai.com/mmm-go/ab/services/history" | 8 | "gitlab.fjmaimaimai.com/mmm-go/ab/services/history" |
7 | - "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/mybeego" | ||
8 | - "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | ||
9 | ) | 9 | ) |
10 | 10 | ||
11 | type HistoryController struct { | 11 | type HistoryController struct { |
@@ -13,18 +13,18 @@ type HistoryController struct { | @@ -13,18 +13,18 @@ type HistoryController struct { | ||
13 | } | 13 | } |
14 | 14 | ||
15 | //SuccessList | 15 | //SuccessList |
16 | -func(this *HistoryController)SuccessList(){ | 16 | +func (this *HistoryController) SuccessList() { |
17 | var msg *mybeego.Message | 17 | var msg *mybeego.Message |
18 | - defer func(){ | 18 | + defer func() { |
19 | this.Resp(msg) | 19 | this.Resp(msg) |
20 | }() | 20 | }() |
21 | var request *protocol.SuccessListRequest | 21 | var request *protocol.SuccessListRequest |
22 | - if err:=json.Unmarshal(this.ByteBody,&request);err!=nil{ | 22 | + if err := json.Unmarshal(this.ByteBody, &request); err != nil { |
23 | log.Error(err) | 23 | log.Error(err) |
24 | msg = mybeego.NewMessage(1) | 24 | msg = mybeego.NewMessage(1) |
25 | return | 25 | return |
26 | } | 26 | } |
27 | - if b,m :=this.Valid(request);!b{ | 27 | + if b, m := this.Valid(request); !b { |
28 | msg = m | 28 | msg = m |
29 | return | 29 | return |
30 | } | 30 | } |
@@ -32,18 +32,18 @@ func(this *HistoryController)SuccessList(){ | @@ -32,18 +32,18 @@ func(this *HistoryController)SuccessList(){ | ||
32 | } | 32 | } |
33 | 33 | ||
34 | //GetRequest | 34 | //GetRequest |
35 | -func(this *HistoryController)GetRequest(){ | 35 | +func (this *HistoryController) GetRequest() { |
36 | var msg *mybeego.Message | 36 | var msg *mybeego.Message |
37 | - defer func(){ | 37 | + defer func() { |
38 | this.Resp(msg) | 38 | this.Resp(msg) |
39 | }() | 39 | }() |
40 | var request *protocol.GetRequestRequest | 40 | var request *protocol.GetRequestRequest |
41 | - if err:=json.Unmarshal(this.ByteBody,&request);err!=nil{ | 41 | + if err := json.Unmarshal(this.ByteBody, &request); err != nil { |
42 | log.Error(err) | 42 | log.Error(err) |
43 | msg = mybeego.NewMessage(1) | 43 | msg = mybeego.NewMessage(1) |
44 | return | 44 | return |
45 | } | 45 | } |
46 | - if b,m :=this.Valid(request);!b{ | 46 | + if b, m := this.Valid(request); !b { |
47 | msg = m | 47 | msg = m |
48 | return | 48 | return |
49 | } | 49 | } |
@@ -51,18 +51,18 @@ func(this *HistoryController)GetRequest(){ | @@ -51,18 +51,18 @@ func(this *HistoryController)GetRequest(){ | ||
51 | } | 51 | } |
52 | 52 | ||
53 | //Retry | 53 | //Retry |
54 | -func(this *HistoryController)Retry(){ | 54 | +func (this *HistoryController) Retry() { |
55 | var msg *mybeego.Message | 55 | var msg *mybeego.Message |
56 | - defer func(){ | 56 | + defer func() { |
57 | this.Resp(msg) | 57 | this.Resp(msg) |
58 | }() | 58 | }() |
59 | var request *protocol.RetryRequest | 59 | var request *protocol.RetryRequest |
60 | - if err:=json.Unmarshal(this.ByteBody,&request);err!=nil{ | 60 | + if err := json.Unmarshal(this.ByteBody, &request); err != nil { |
61 | log.Error(err) | 61 | log.Error(err) |
62 | msg = mybeego.NewMessage(1) | 62 | msg = mybeego.NewMessage(1) |
63 | return | 63 | return |
64 | } | 64 | } |
65 | - if b,m :=this.Valid(request);!b{ | 65 | + if b, m := this.Valid(request); !b { |
66 | msg = m | 66 | msg = m |
67 | return | 67 | return |
68 | } | 68 | } |
@@ -70,18 +70,18 @@ func(this *HistoryController)Retry(){ | @@ -70,18 +70,18 @@ func(this *HistoryController)Retry(){ | ||
70 | } | 70 | } |
71 | 71 | ||
72 | //DeleteHistory | 72 | //DeleteHistory |
73 | -func(this *HistoryController)DeleteHistory(){ | 73 | +func (this *HistoryController) DeleteHistory() { |
74 | var msg *mybeego.Message | 74 | var msg *mybeego.Message |
75 | - defer func(){ | 75 | + defer func() { |
76 | this.Resp(msg) | 76 | this.Resp(msg) |
77 | }() | 77 | }() |
78 | var request *protocol.DeleteHistoryRequest | 78 | var request *protocol.DeleteHistoryRequest |
79 | - if err:=json.Unmarshal(this.ByteBody,&request);err!=nil{ | 79 | + if err := json.Unmarshal(this.ByteBody, &request); err != nil { |
80 | log.Error(err) | 80 | log.Error(err) |
81 | msg = mybeego.NewMessage(1) | 81 | msg = mybeego.NewMessage(1) |
82 | return | 82 | return |
83 | } | 83 | } |
84 | - if b,m :=this.Valid(request);!b{ | 84 | + if b, m := this.Valid(request); !b { |
85 | msg = m | 85 | msg = m |
86 | return | 86 | return |
87 | } | 87 | } |
deploy/k8s/dev/install.sh
0 → 100644
1 | +#!/bin/bash | ||
2 | +export PATH=/root/local/bin:$PATH | ||
3 | +kubectl -n mmm-suplus-dev get pods | grep -q ab | ||
4 | +if [ "$?" == "1" ];then | ||
5 | + kubectl create -f /tmp/dev/ab/opp.yaml --record | ||
6 | + kubectl -n mmm-suplus-dev get svc | grep -q ab | ||
7 | + if [ "$?" == "0" ];then | ||
8 | + echo "ab service install success!" | ||
9 | + else | ||
10 | + echo "ab service install fail!" | ||
11 | + fi | ||
12 | + kubectl -n mmm-suplus-dev get pods | grep -q ab | ||
13 | + if [ "$?" == "0" ];then | ||
14 | + echo "ab deployment install success!" | ||
15 | + else | ||
16 | + echo "ab deployment install fail!" | ||
17 | + fi | ||
18 | +else | ||
19 | + kubectl delete -f /tmp/dev/ab/opp.yaml | ||
20 | + kubectl -n mmm-suplus-dev get svc | grep -q ab | ||
21 | + while [ "$?" == "0" ] | ||
22 | + do | ||
23 | + kubectl -n mmm-suplus-dev get svc | grep -q ab | ||
24 | + done | ||
25 | + kubectl -n mmm-suplus-dev get pods | grep -q ab | ||
26 | + while [ "$?" == "0" ] | ||
27 | + do | ||
28 | + kubectl -n mmm-suplus-dev get pods | grep -q ab | ||
29 | + done | ||
30 | + kubectl create -f /tmp/dev/ab/opp.yaml --record | ||
31 | + kubectl -n mmm-suplus-dev get svc | grep -q ab | ||
32 | + if [ "$?" == "0" ];then | ||
33 | + echo "ab service update success!" | ||
34 | + else | ||
35 | + echo "opp service update fail!" | ||
36 | + fi | ||
37 | + kubectl -n mmm-suplus-dev get pods | grep -q opp | ||
38 | + if [ "$?" == "0" ];then | ||
39 | + echo "opp deployment update success!" | ||
40 | + else | ||
41 | + echo "opp deployment update fail!" | ||
42 | + fi | ||
43 | +fi |
deploy/k8s/dev/opp.yaml
0 → 100644
1 | +apiVersion: v1 | ||
2 | +kind: Service | ||
3 | +metadata: | ||
4 | + name: ab | ||
5 | + namespace: mmm-suplus-dev | ||
6 | + labels: | ||
7 | + k8s-app: ab | ||
8 | +spec: | ||
9 | + ports: | ||
10 | + - name: "http" | ||
11 | + port: 80 | ||
12 | + targetPort: 8080 | ||
13 | + selector: | ||
14 | + k8s-app: ab | ||
15 | +--- | ||
16 | +apiVersion: extensions/v1beta1 | ||
17 | +kind: Deployment | ||
18 | +metadata: | ||
19 | + name: ab | ||
20 | + namespace: mmm-suplus-dev | ||
21 | + labels: | ||
22 | + k8s-app: ab | ||
23 | +spec: | ||
24 | + replicas: 1 | ||
25 | + template: | ||
26 | + metadata: | ||
27 | + labels: | ||
28 | + k8s-app: ab | ||
29 | + spec: | ||
30 | +# affinity: | ||
31 | +# nodeAffinity: | ||
32 | +# preferredDuringSchedulingIgnoredDuringExecution: | ||
33 | +# - preference: {} | ||
34 | +# weight: 100 | ||
35 | +# requiredDuringSchedulingIgnoredDuringExecution: | ||
36 | +# nodeSelectorTerms: | ||
37 | +# - matchExpressions: | ||
38 | +# - key: kubernetes.io/hostname | ||
39 | +# operator: In | ||
40 | +# values: | ||
41 | +# - cn-hangzhou.i-bp1djh1xn7taumbue1ze | ||
42 | +# - cn-hangzhou.i-bp1djh1xn7taumbue1zd | ||
43 | +# - cn-hangzhou.i-bp1euf5u1ph9kbhtndhb | ||
44 | +# - cn-hangzhou.i-bp1hyp5oips9cdwxxgxy | ||
45 | + containers: | ||
46 | + - name: ab | ||
47 | + image: hub.docker.com/dk1992/ab:dev | ||
48 | + imagePullPolicy: Always | ||
49 | +# volumeMounts: | ||
50 | +# - mountPath: /opt/logs | ||
51 | +# name: accesslogs | ||
52 | +# - mountPath: /var/www/opp/file | ||
53 | +# name: mmmjihuitest-pvc1 | ||
54 | + ports: | ||
55 | + - containerPort: 8080 | ||
56 | + env: | ||
57 | + - name: MYSQL_HOST | ||
58 | + valueFrom: | ||
59 | + configMapKeyRef: | ||
60 | + name: suplus-config | ||
61 | + key: mysql.host | ||
62 | + - name: MYSQL_PORT | ||
63 | + valueFrom: | ||
64 | + configMapKeyRef: | ||
65 | + name: suplus-config | ||
66 | + key: mysql.port | ||
67 | + - name: REDIS_HOST | ||
68 | + valueFrom: | ||
69 | + configMapKeyRef: | ||
70 | + name: suplus-config | ||
71 | + key: redis.ip | ||
72 | + - name: REDIS_PORT | ||
73 | + valueFrom: | ||
74 | + configMapKeyRef: | ||
75 | + name: suplus-config | ||
76 | + key: redis.port | ||
77 | + - name: MYSQL_USER | ||
78 | + valueFrom: | ||
79 | + configMapKeyRef: | ||
80 | + name: suplus-config | ||
81 | + key: mysql.user | ||
82 | + - name: MYSQL_PASSWORD | ||
83 | + valueFrom: | ||
84 | + configMapKeyRef: | ||
85 | + name: suplus-config | ||
86 | + key: mysql.password | ||
87 | +# - name: MYSQL_DB_NAME | ||
88 | +# value: "opportunity_dev" | ||
89 | + - name: RUN_MODE | ||
90 | + value: "dev-online" | ||
91 | + - name: LOG_LEVEL | ||
92 | + value: "debug" | ||
93 | + - name: aliyun_logs_suplusfile | ||
94 | + value: "stdout" | ||
95 | + - name: aliyun_logs_access | ||
96 | + value: " /opt/logs/app.log" | ||
97 | + - name: BUSINESS_ADMIN_SERVICE_HOST | ||
98 | + valueFrom: | ||
99 | + configMapKeyRef: | ||
100 | + name: suplus-config | ||
101 | + key: service.businessadmin | ||
102 | +# volumes: | ||
103 | +# - name: accesslogs | ||
104 | +# emptyDir: {} | ||
105 | +# - name: mmmjihuitest-pvc1 | ||
106 | +# persistentVolumeClaim: | ||
107 | +# claimName: mmmjihuitest-pvc |
@@ -4,8 +4,8 @@ go 1.13 | @@ -4,8 +4,8 @@ go 1.13 | ||
4 | 4 | ||
5 | require ( | 5 | require ( |
6 | github.com/astaxie/beego v1.10.0 | 6 | github.com/astaxie/beego v1.10.0 |
7 | - github.com/prometheus/common v0.4.0 | ||
8 | - gitlab.fjmaimaimai.com/mmm-go/gocomm v0.0.1 | 7 | + github.com/prometheus/common v0.9.1 |
8 | + github.com/tiptok/gocomm v1.0.6 | ||
9 | ) | 9 | ) |
10 | 10 | ||
11 | -replace gitlab.fjmaimaimai.com/mmm-go/gocomm => ../gocomm | 11 | +// replace github.com/tiptok/gocomm => ../gocomm |
@@ -2,20 +2,19 @@ package main | @@ -2,20 +2,19 @@ package main | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "github.com/astaxie/beego" | 4 | "github.com/astaxie/beego" |
5 | + "github.com/tiptok/gocomm/config" | ||
6 | + "github.com/tiptok/gocomm/pkg/log" | ||
7 | + "github.com/tiptok/gocomm/pkg/redis" | ||
5 | _ "gitlab.fjmaimaimai.com/mmm-go/ab/routers" | 8 | _ "gitlab.fjmaimaimai.com/mmm-go/ab/routers" |
6 | - "gitlab.fjmaimaimai.com/mmm-go/gocomm/config" | ||
7 | - "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | ||
8 | - "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/redis" | ||
9 | ) | 9 | ) |
10 | 10 | ||
11 | - | ||
12 | -func init(){ | 11 | +func init() { |
13 | log.InitLog(config.Logger{ | 12 | log.InitLog(config.Logger{ |
14 | - Filename:"app.log", | ||
15 | - Level:"7", | 13 | + Filename: "app.log", |
14 | + Level: "7", | ||
16 | }) | 15 | }) |
17 | - err:= redis.InitWithDb(100,beego.AppConfig.String("redis_add_port"),beego.AppConfig.String("redis_auth"),"0") | ||
18 | - if err!=nil{ | 16 | + err := redis.InitWithDb(100, beego.AppConfig.String("redis_add_port"), beego.AppConfig.String("redis_auth"), "0") |
17 | + if err != nil { | ||
19 | log.Fatal(err) | 18 | log.Fatal(err) |
20 | } | 19 | } |
21 | //orm.NewBeeormEngine(config.Mysql{ | 20 | //orm.NewBeeormEngine(config.Mysql{ |
@@ -26,10 +25,10 @@ func init(){ | @@ -26,10 +25,10 @@ func init(){ | ||
26 | } | 25 | } |
27 | 26 | ||
28 | func main() { | 27 | func main() { |
29 | - defer func(){ | 28 | + defer func() { |
30 | log.Info("app on stop!") | 29 | log.Info("app on stop!") |
31 | }() | 30 | }() |
32 | log.Info("app on start!") | 31 | log.Info("app on start!") |
33 | - log.Info("Beego Run Mode:",beego.BConfig.RunMode) | 32 | + log.Info("Beego Run Mode:", beego.BConfig.RunMode) |
34 | beego.Run() | 33 | beego.Run() |
35 | } | 34 | } |
@@ -5,8 +5,8 @@ import ( | @@ -5,8 +5,8 @@ import ( | ||
5 | "fmt" | 5 | "fmt" |
6 | "github.com/astaxie/beego" | 6 | "github.com/astaxie/beego" |
7 | "github.com/astaxie/beego/httplib" | 7 | "github.com/astaxie/beego/httplib" |
8 | + "github.com/tiptok/gocomm/pkg/log" | ||
8 | "gitlab.fjmaimaimai.com/mmm-go/ab/protocol" | 9 | "gitlab.fjmaimaimai.com/mmm-go/ab/protocol" |
9 | - "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | ||
10 | "io/ioutil" | 10 | "io/ioutil" |
11 | "net/http" | 11 | "net/http" |
12 | "reflect" | 12 | "reflect" |
-
请 注册 或 登录 后发表评论