Skip to content

add socket reader json format - #728

Merged
wonderflow merged 1 commit into
qiniu:masterfrom
redHJ:pdr-6670
Aug 28, 2018
Merged

wonderflow merged 1 commit into
qiniu:masterfrom
redHJ:pdr-6670

Conversation

@redHJ

@redHJ redHJ commented Aug 27, 2018

Copy link
Copy Markdown
Collaborator

Comment thread reader/rest_reader_models.go Outdated
const (
SocketRulePacket = "按包获取"
SocketRuleJson = "按json获取"
SocketRuleLine = "按行获取"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

按原始包读取
按json格式读取
按换行符读取

Comment thread reader/rest_reader_models.go Outdated
Default: "false",
Advance: true,
Description: "获取方式(socket_rule)",
ToolTip: "默认对socket内容按包获取",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

json仅对tcp有效,json的选项放在最后面

Comment thread reader/socket/socket.go
return err
}

func tryDecodeReader(decoder *json.Decoder) bool {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个函数名字不是很清晰,改为 isDecodeReaderExpired 是不是更好?

Comment thread reader/socket/socket.go

if err != nil {
log.Errorf("decode buffered read error: %v", err)
return true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

出了error还是true吗,单测里可以测到这种case是什么情况吗

Comment thread reader/socket/socket.go Outdated
if !tryDecodeReader(decoder) {
decoder = json.NewDecoder(bufioReader)
}
log.Debugf("net error %v", netErr)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个debug日志要么改成warn吧,写的规范一些,其他日志也是,标明 runner是什么,reader是什么

@redHJ
redHJ force-pushed the pdr-6670 branch 2 times, most recently from b4b0e4b to ab26641 Compare August 27, 2018 08:12
Comment thread reader/socket/socket.go Outdated
if ssr.netproto == "tcp" || ssr.netproto == "tcp4" || ssr.netproto == "tcp6" {
if err := ssr.setKeepAlive(c); err != nil {
log.Error(fmt.Errorf("unable to configure keep alive (%s): %s", ssr.ServiceAddress, err))
log.Error(fmt.Errorf("runner[%v] Reader %q unable to configure keep alive (%s): %s", ssr.meta.RunnerName, ssr.Name(), ssr.ServiceAddress, err))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么不用log.Errorf

Comment thread reader/socket/socket.go Outdated
if !tryDecodeReader(decoder) {
decoder = json.NewDecoder(bufioReader)
}
log.Warnf("runner[%v] Reader %q net error %v", ssr.meta.RunnerName, ssr.Name(), netErr)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这行错误要不考虑删掉

Comment thread reader/socket/socket.go Outdated
if err != nil {
log.Errorf("runner[%v] Reader %q read decoder buffered error: %v")
} else {
log.Errorf("runner[%v] Reader %q read streaming message: %v", ssr.meta.RunnerName, ssr.Name(), string(readBytes))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2048

@redHJ
redHJ force-pushed the pdr-6670 branch 2 times, most recently from 620acc6 to c5f5cac Compare August 27, 2018 13:23
socket reader tcp json/packet/line
@wonderflow wonderflow changed the title socket json add socket reader json format Aug 28, 2018
@wonderflow

Copy link
Copy Markdown
Contributor

LGTM

@wonderflow
wonderflow merged commit dd8f0ac into qiniu:master Aug 28, 2018
@redHJ
redHJ deleted the pdr-6670 branch January 24, 2019 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

⌂ 换网址