Skip to content

sender/file: support custom time to render magic variables - #634

Merged
wonderflow merged 1 commit into
qiniu:masterfrom
unknwon:file-sender-timestamp
Jul 24, 2018
Merged

wonderflow merged 1 commit into
qiniu:masterfrom
unknwon:file-sender-timestamp

Conversation

@unknwon

@unknwon unknwon commented Jul 24, 2018 •

Copy link
Copy Markdown
Contributor
  1. 添加选项支持通过数据中的某个key来作为时间渲染文件名中的魔法变量,默认使用当前时间
  2. 维护一个文件池,保证最终同时打开的文件数和设定的一致
  3. 同个 Send 调用,写入到同个文件的内容会写在一行

@wonderflow

Copy link
Copy Markdown
Contributor

写文档

Comment thread sender/file/writer.go

const defaultFileWriterPoolSize = 10

type writer struct {

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.

最好针对这个writer库来点测试

Comment thread sender/file/file.go Outdated
if ok {
t, err := time.Parse(time.RFC3339Nano, key)
if err != nil {
return reqerr.NewSendError(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

直接return不太好

Comment thread sender/file/file.go
fmt.Sprintf("%s write data to file failed: %v", s.Name(), err),
sender.ConvertDatasBack(datas),
reqerr.TypeDefault,
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

同上

@wonderflow

Copy link
Copy Markdown
Contributor

LGTM 把文档加一下

@wonderflow
wonderflow merged commit b846af8 into qiniu:master Jul 24, 2018
@unknwon
unknwon deleted the file-sender-timestamp branch July 25, 2018 01:50
@unknwon

unknwon commented Jul 25, 2018

Copy link
Copy Markdown
Contributor Author

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.

3 participants

⌂ 换网址