Repository navigation
http reader support multiple prefix - #678
Conversation
531a518 to
d05b58f
Compare
| "senders": senders, | ||
| } | ||
|
|
||
| go func() { |
| wg.Add(1) | ||
| go func() { | ||
| got, err := httpReader.ReadLine() | ||
| assert.NoError(t, err) |
There was a problem hiding this comment.
goroutine里面用到的变量,如果没有当作参数传进去,就会出现并发错误,此处要把httpReader和t当作参数传入函数。
| } | ||
| log.Debugf("Runner[%v] %q daemon is stopping", r.meta.RunnerName, r.Name()) | ||
|
|
||
| close(r.readChan) |
There was a problem hiding this comment.
这里在http 仍然在serve的时候就close channel,可能会导致panic, send on closed channel
88df7d1 to
150500c
Compare
|
|
||
| r.server.Shutdown(context.Background()) | ||
| err := r.bufQueue.Close() | ||
| close(r.readChan) |
There was a problem hiding this comment.
这里要确认一下,如果http server在shutdown的之前,postData函数被阻塞了,比如数据来不及读导致channel传不进去数据,那么这里close会导致panic吗
150500c to
3768624
Compare
| Content: line, | ||
| Path: path, | ||
| } | ||
| } |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
尝试实际运行起来,然后用大量的请求去请求这个http reader,然后请求不要停,紧接着logkit关掉,看看现象 |
| "github.com/qiniu/logkit/queue" | ||
| "github.com/qiniu/logkit/reader" | ||
| . "github.com/qiniu/logkit/utils/models" | ||
| "sync" |
| 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
| 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.
这里直接错误返回吧,不用Warn,反正是初始配置的时候
6336754 to
87c42d4
Compare
| 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.
你这样写如果val是空就panic了,先trimeSpace,空的continue,然后检查 strings.HasPrefix()
87c42d4 to
2a94417
Compare
| path, _ := conf.GetStringOr(reader.KeyHTTPServicePath, reader.DefaultHTTPServicePath) | ||
| paths := strings.Split(path, ",") | ||
| for _, val := range paths { | ||
| if !strings.HasPrefix(val, "/") { |
|
文档也对应更新一下 mars上 |
2a94417 to
488b480
Compare
|
|
||
| r.server.Shutdown(context.Background()) | ||
| err := r.bufQueue.Close() | ||
| //Note:确保不会往已关闭的channel中写入message |
There was a problem hiding this comment.
这里描述不对吧,应该是和 wg.Done 一个作用,因为是 wait 完才 close 的 channel
|
LGTM |
488b480 to
2462fc8
Compare
|
LGTM |
文档:https://developer.qiniu.io/insight/manual/4771/http-reader?version=5b6a6cc393b8cf242ec5d94e