Skip to content

Commit

Permalink
raw data with mock meta path
Browse files Browse the repository at this point in the history
  • Loading branch information
李红 authored and 李红 committed Jul 13, 2018
1 parent 0ae8ee4 commit 0889b6b
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions mgr/dataflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ import (
"errors"
"fmt"
"io"
"os"
"path"
"strconv"
"strings"
"time"

"github.com/json-iterator/go"

"github.com/qiniu/log"
"github.com/qiniu/pandora-go-sdk/base/reqerr"

"github.com/qiniu/logkit/conf"
Expand All @@ -20,19 +25,31 @@ import (
. "github.com/qiniu/logkit/utils/models"
)

const DefaultTryTimes = 3
const (
DefaultTryTimes = 3
MetaTmp = "meta_tmp/"
)

// RawData 从 reader 模块中根据 type 获取字符串形式的样例日志
func RawData(readerConfig conf.MapConf) (string, error) {
if readerConfig == nil {
return "", fmt.Errorf("reader config cannot be empty")
}

runnerName, _ := readerConfig.GetString(GlobalKeyName)
configMetaPath := runnerName + "_" + Hash(strconv.FormatInt(time.Now().Unix(), 10))
metaPath := path.Join(MetaTmp, configMetaPath)
log.Debugf("Runner[%v] Using %s as default metaPath", runnerName, metaPath)
readerConfig[reader.KeyMetaPath] = metaPath

rd, err := reader.NewReader(readerConfig, true)
if err != nil {
return "", err
}
defer rd.Close()
defer func() {
rd.Close()
os.RemoveAll(metaPath)
}()

var rawData string

Expand Down

0 comments on commit 0889b6b

Please sign in to comment.