-
Notifications
You must be signed in to change notification settings - Fork 255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
http reader support multiple prefix #678
Conversation
531a518
to
d05b58f
Compare
mgr/dataflow_test.go
Outdated
@@ -319,19 +319,21 @@ func Test_SendData(t *testing.T) { | |||
"senders": senders, | |||
} | |||
|
|||
go func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
下面没等这个进程跑起来就会结束
reader/http/http_test.go
Outdated
wg.Add(1) | ||
go func() { | ||
got, err := httpReader.ReadLine() | ||
assert.NoError(t, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
goroutine里面用到的变量,如果没有当作参数传进去,就会出现并发错误,此处要把httpReader和t当作参数传入函数。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
下同
reader/http/http.go
Outdated
@@ -136,11 +142,10 @@ func (r *Reader) Close() error { | |||
return nil | |||
} | |||
log.Debugf("Runner[%v] %q daemon is stopping", r.meta.RunnerName, r.Name()) | |||
|
|||
close(r.readChan) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里在http 仍然在serve的时候就close channel,可能会导致panic, send on closed channel
88df7d1
to
150500c
Compare
reader/http/http.go
Outdated
r.server.Shutdown(context.Background()) | ||
err := r.bufQueue.Close() | ||
close(r.readChan) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里要确认一下,如果http server在shutdown的之前,postData函数被阻塞了,比如数据来不及读导致channel传不进去数据,那么这里close会导致panic吗
150500c
to
3768624
Compare
r.readChan <- Details{ | ||
Content: line, | ||
Path: path, | ||
} | ||
} |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
尝试实际运行起来,然后用大量的请求去请求这个http reader,然后请求不要停,紧接着logkit关掉,看看现象 |
reader/http/http.go
Outdated
"github.com/qiniu/logkit/reader" | ||
. "github.com/qiniu/logkit/utils/models" | ||
"sync" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
移到最上面的分组
|
||
server *http.Server | ||
} | ||
|
||
func NewReader(meta *reader.Meta, conf conf.MapConf) (reader.Reader, error) { | ||
address, _ := conf.GetStringOr(reader.KeyHTTPServiceAddress, reader.DefaultHTTPServiceAddress) | ||
path, _ := conf.GetStringOr(reader.KeyHTTPServicePath, reader.DefaultHTTPServicePath) | ||
paths := strings.Split(path, ",") |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
3768624
to
6336754
Compare
reader/http/http.go
Outdated
if val[0] == '/' { | ||
validPaths = append(validPaths, val) | ||
} else { | ||
log.Warnf("path[%v] not begin with '/',this path ignored", val) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里直接错误返回吧,不用Warn,反正是初始配置的时候
6336754
to
87c42d4
Compare
reader/http/http.go
Outdated
|
||
server *http.Server | ||
} | ||
|
||
func NewReader(meta *reader.Meta, conf conf.MapConf) (reader.Reader, error) { | ||
address, _ := conf.GetStringOr(reader.KeyHTTPServiceAddress, reader.DefaultHTTPServiceAddress) | ||
path, _ := conf.GetStringOr(reader.KeyHTTPServicePath, reader.DefaultHTTPServicePath) | ||
paths := strings.Split(path, ",") | ||
for _, val := range paths { | ||
if val[0] != '/' { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
你这样写如果val是空就panic了,先trimeSpace,空的continue,然后检查 strings.HasPrefix()
87c42d4
to
2a94417
Compare
reader/http/http.go
Outdated
|
||
server *http.Server | ||
} | ||
|
||
func NewReader(meta *reader.Meta, conf conf.MapConf) (reader.Reader, error) { | ||
address, _ := conf.GetStringOr(reader.KeyHTTPServiceAddress, reader.DefaultHTTPServiceAddress) | ||
path, _ := conf.GetStringOr(reader.KeyHTTPServicePath, reader.DefaultHTTPServicePath) | ||
paths := strings.Split(path, ",") | ||
for _, val := range paths { | ||
if !strings.HasPrefix(val, "/") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
空的过滤一下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
考虑: /api,/ap2,,
文档也对应更新一下 mars上 |
2a94417
to
488b480
Compare
reader/http/http.go
Outdated
r.server.Shutdown(context.Background()) | ||
err := r.bufQueue.Close() | ||
//Note:确保不会往已关闭的channel中写入message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里描述不对吧,应该是和 wg.Done 一个作用,因为是 wait 完才 close 的 channel
LGTM |
488b480
to
2462fc8
Compare
LGTM |
文档:https://developer.qiniu.io/insight/manual/4771/http-reader?version=5b6a6cc393b8cf242ec5d94e