Skip to content

Commit f9a82e5

Browse files
committed
ci: release v1.8.7
1 parent 5c4cc76 commit f9a82e5

File tree

9 files changed

+38
-35
lines changed

9 files changed

+38
-35
lines changed

.docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM registry:5000/gobase:1.12.1-alpine3.9 AS gobuild
1+
FROM registry:5000/gobase:1.12.5-alpine3.9 AS gobuild
22

33
ENV GO111MODULE=on
44
WORKDIR /go-fluentd

.docker/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ go mod download
1717
go mod vendor
1818

1919
# build base image
20-
docker build . -f ./.docker/gobase.Dockerfile -t registry:5000/gobase:1.12.1-alpine3.9
21-
docker push registry:5000/gobase:1.12.1-alpine3.9
20+
docker build . -f ./.docker/gobase.Dockerfile -t registry:5000/gobase:1.12.5-alpine3.9
21+
docker push registry:5000/gobase:1.12.5-alpine3.9
2222

2323
# build image
2424
docker build . -f ./.docker/Dockerfile -t registry:5000/go-fluentd:1.8.2
@@ -38,8 +38,8 @@ build on machine that should installed docker.
3838

3939
```sh
4040
# build golang-stretch
41-
docker build . -f ./.docker/golang-stretch.Dockerfile -t registry:5000/golang:1.12.1-stretch
42-
docker push registry:5000/golang:1.12.1-stretch
41+
docker build . -f ./.docker/golang-stretch.Dockerfile -t registry:5000/golang:1.12.5-stretch
42+
docker push registry:5000/golang:1.12.5-stretch
4343

4444
# build mfs-stretch
4545
docker build . -f ./.docker/mfs-stretch.Dockerfile -t registry:5000/mfs-stretch:20190116

.docker/forward.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# docker run -it --rm --cap-add SYS_ADMIN --device /dev/fuse -e MFS_MASTER=mfs-master.sit.ptcloud.t.home -e TZ=Asia/Shanghai -v /opt/configs/go-fluentd/forward:/forward registry:5000/go-fluentd-forward:666 /bin/sh
33
# sh startApp.sh
44
# cp /forward/settings.yml /data/Sit/go-fluentd/settings/.
5-
FROM registry:5000/golang:1.12.1-stretch AS gobin
5+
FROM registry:5000/golang:1.12.5-stretch AS gobin
66

77
ENV GO111MODULE=on
88

.docker/gobase.Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# docker build . -f ./.docker/gobase.Dockerfile -t registry:5000/gobase:1.12.1-alpine3.9
2-
# docker push registry:5000/gobase:1.12.1-alpine3.9
3-
FROM golang:1.12.1-alpine3.9
1+
# docker build . -f ./.docker/gobase.Dockerfile -t registry:5000/gobase:1.12.5-alpine3.9
2+
# docker push registry:5000/gobase:1.12.5-alpine3.9
3+
FROM golang:1.12.5-alpine3.9
44

55
# http proxy
66
ENV HTTP_PROXY=http://172.16.4.26:17777

.docker/golang-stretch.Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# docker build . -f ./.docker/golang-stretch.Dockerfile -t registry:5000/golang:1.12.1-stretch
2-
# docker push registry:5000/golang:1.12.1-stretch
3-
FROM golang:1.12.1-stretch
1+
# docker build . -f ./.docker/golang-stretch.Dockerfile -t registry:5000/golang:1.12.5-stretch
2+
# docker push registry:5000/golang:1.12.5-stretch
3+
FROM golang:1.12.5-stretch
44

55
# http proxy
66
ENV HTTP_PROXY=http://172.16.4.26:17777

.docker/test.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# docker build . -f ./.docker/test.Dockerfile -t registry:5000/go-fluentd-test:v1
22
# docker push registry:5000/go-fluentd-test:v1
3-
FROM registry:5000/gobase:1.12.1-alpine3.9
3+
FROM registry:5000/gobase:1.12.5-alpine3.9
44

55
# http proxy
66
ENV HTTP_PROXY=http://172.16.4.26:17777

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ test:run:
4646
- public
4747
image: registry:5000/docker:latest
4848
script:
49-
- docker pull registry:5000/gobase:1.12.1-alpine3.9 # pull latest image
49+
- docker pull registry:5000/gobase:1.12.5-alpine3.9 # pull latest image
5050
- docker build . -f ./.docker/test.Dockerfile -t go-fluentd-test:$DOCKER_TAG
5151
- docker run -i --rm go-fluentd-test:$DOCKER_TAG
5252
retry: 1

senders/elasticsearch.go

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,12 @@ func (s *ElasticSearchSender) GetName() string {
7171
return s.Name
7272
}
7373

74-
type BulkOpCtx struct {
75-
body []byte
74+
type bulkOpCtx struct {
7675
buf *bytes.Buffer
7776
gzWriter *gzip.Writer
77+
cnt []byte
78+
starting []byte
79+
msg *libs.FluentMsg
7880
}
7981

8082
func (s *ElasticSearchSender) getMsgStarting(msg *libs.FluentMsg) ([]byte, error) {
@@ -90,32 +92,30 @@ func (s *ElasticSearchSender) getMsgStarting(msg *libs.FluentMsg) ([]byte, error
9092
return []byte("{\"index\": {\"_index\": \"" + index + "\", \"_type\": \"logs\"}}\n"), nil
9193
}
9294

93-
func (s *ElasticSearchSender) SendBulkMsgs(ctx *BulkOpCtx, msgs []*libs.FluentMsg) (err error) {
94-
cnt := []byte{}
95-
var starting []byte
96-
for _, m := range msgs {
97-
if starting, err = s.getMsgStarting(m); err != nil {
95+
func (s *ElasticSearchSender) SendBulkMsgs(ctx *bulkOpCtx, msgs []*libs.FluentMsg) (err error) {
96+
ctx.cnt = ctx.cnt[:0]
97+
for _, ctx.msg = range msgs {
98+
if ctx.starting, err = s.getMsgStarting(ctx.msg); err != nil {
9899
utils.Logger.Warn("try to generate bulk index got error", zap.Error(err))
99100
continue
100101
}
101102

102-
b, err := json.Marshal(m.Message)
103+
b, err := json.Marshal(ctx.msg.Message)
103104
if err != nil {
104105
return errors.Wrap(err, "try to marshal messages got error")
105106
}
106107

107108
utils.Logger.Debug("prepare bulk content send to es",
108-
zap.ByteString("starting", starting),
109+
zap.ByteString("starting", ctx.starting),
109110
zap.ByteString("body", b))
110-
cnt = append(cnt, starting...)
111-
cnt = append(cnt, b...)
112-
cnt = append(cnt, '\n')
111+
ctx.cnt = append(ctx.cnt, ctx.starting...)
112+
ctx.cnt = append(ctx.cnt, b...)
113+
ctx.cnt = append(ctx.cnt, '\n')
113114
}
114115

115116
ctx.buf.Reset()
116117
ctx.gzWriter.Reset(ctx.buf)
117-
// ctx.gzWriter = gzip.NewWriter(ctx.buf)
118-
if _, err = ctx.gzWriter.Write(cnt); err != nil {
118+
if _, err = ctx.gzWriter.Write(ctx.cnt); err != nil {
119119
return errors.Wrap(err, "try to compress messages got error")
120120
}
121121

@@ -205,8 +205,10 @@ func (s *ElasticSearchSender) Spawn(tag string) chan<- *libs.FluentMsg {
205205
iBatch = 0
206206
lastT = time.Unix(0, 0)
207207
err error
208-
ctx = &BulkOpCtx{}
209-
nRetry, j int
208+
ctx = &bulkOpCtx{
209+
cnt: []byte{},
210+
}
211+
nRetry, j int
210212
)
211213

212214
ctx.buf = &bytes.Buffer{}
@@ -244,12 +246,13 @@ func (s *ElasticSearchSender) Spawn(tag string) chan<- *libs.FluentMsg {
244246
if err = s.SendBulkMsgs(ctx, msgBatchDelivery); err != nil {
245247
nRetry++
246248
if nRetry > maxRetry {
247-
utils.Logger.Error("try send message got error", zap.Error(err), zap.String("tag", tag))
248-
utils.Logger.Error("discard msg since of sender err", zap.String("tag", msg.Tag), zap.Int("num", len(msgBatchDelivery)))
249+
utils.Logger.Error("try send message got error",
250+
zap.Error(err),
251+
zap.String("tag", tag),
252+
zap.Int("num", len(msgBatchDelivery)))
249253
for _, msg = range msgBatchDelivery {
250254
s.discardWithoutCommitChan <- msg
251255
}
252-
253256
continue
254257
}
255258
goto SEND_MSG

senders/httpforward.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func (s *HTTPSender) Spawn(tag string) chan<- *libs.FluentMsg {
7373
msgBatchDelivery []*libs.FluentMsg
7474
iBatch = 0
7575
lastT = time.Unix(0, 0)
76-
ctx = &BulkOpCtx{}
76+
ctx = &bulkOpCtx{}
7777
err error
7878
)
7979

@@ -136,7 +136,7 @@ func (s *HTTPSender) Spawn(tag string) chan<- *libs.FluentMsg {
136136
return inChan
137137
}
138138

139-
func (s *HTTPSender) SendBulkMsgs(ctx *BulkOpCtx, msgs []*libs.FluentMsg) (err error) {
139+
func (s *HTTPSender) SendBulkMsgs(ctx *bulkOpCtx, msgs []*libs.FluentMsg) (err error) {
140140
msgCnts := make([]map[string]interface{}, len(msgs))
141141
for i, m := range msgs {
142142
msgCnts[i] = m.Message

0 commit comments

Comments
 (0)