You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
package export
import "sync"
type Option func ( e * BaseExport )
// UseHashMark 设置导出哈希标识
func UseHashMark ( hashMark string ) Option {
return func ( e * BaseExport ) {
e . hashMark = hashMark
}
}
// UseFile 使用自定义文件
func UseFile ( filename , filePath string ) Option {
return func ( e * BaseExport ) {
e . filename = filename
e . fullPath = filePath
e . customFile = true
}
}
type TaskOption func ( tp * BaseTask )
// UseFinishPart spn 分成的份数, fn 每完成一份的处理
//
// 使用完成一部分就通讯, 假如spn=50, 就是把总数分成50份进行步进更新,
// fn只会处理到倒数第二份的时候, 最后一份的逻辑, 需要完成的时候实现
func UseFinishPart ( spn int , fn PartDone ) TaskOption {
return func ( tp * BaseTask ) {
tp . fp = & FinishPart {
l : & sync . Mutex { } ,
spn : float64 ( spn ) ,
notifySp : make ( chan float64 ) ,
fn : fn ,
}
}
}
// UserProceed 使用断点续导出
//
// begin是当写入是第几条的时候才开始写入到文件
// filterNum是过滤的条数, 假如: 你是倒序查询, 在导出的时候查询只有100条数据, 但是续导的时候有101, 那就这个值就是 1; 当然, 如果你是正序的时候不用管, 或者直接让begin值+1
func UserProceed ( begin , filterNum int64 ) TaskOption {
return func ( tp * BaseTask ) {
tp . pe = & Proceed {
l : & sync . Mutex { } ,
filterNum : filterNum ,
begin : begin ,
}
}
}