Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
language: go

matrix:
fast_finish: true
include:
- go: 1.11.x
env: GO111MODULE=on
- go: 1.12.x
env: GO111MODULE=on
- go: master
env: GO111MODULE=on

before_install:
- if [[ "${GO111MODULE}" = "on" ]]; then mkdir "${HOME}/go"; export GOPATH="${HOME}/go"; fi

install:
- if [[ "${GO111MODULE}" = "on" ]]; then go mod download; else go install; fi
- if [[ "${GO111MODULE}" = "on" ]]; then export PATH="${GOPATH}/bin:${GOROOT}/bin:${PATH}"; fi

script:
- make fmt
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SOURCE_FILE := `find . -name "*.go" | grep -v "vendor/*"`

fmt:
gofmt -s -w ${SOURCE_FILE} > /dev/null
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<h1 align="left">go-redis-parser</h1>
<img align="right" width="130px" src="https://raw.githubusercontent.com/8090Lambert/material/master/go-redis-parser.jpg">

This is a parser in Golang. Its characteristics are: make full use of
the coroutine language's coroutine, write at the same time as the file
is written, more efficient analysis.
A efficient and safe parser in Golang. Its characteristics are: make full use of
the language's `goroutine`, write at the same time as the file is written. This
important thing is that you can analyze without connecting to an online service.
<br>

```
Expand Down Expand Up @@ -34,17 +34,18 @@ Supports Redis from 2.8 to 5.0, all data types except module. Including:
- List
- Set
- SortedSed
- Stream
- **Stream(Redis 5.0 new data type)**

In addition to exporting all key/values, it also looks for all types of `Bigkeys` (like `redis-cli --bigkeys`).


### Installation
`go-redis-parser` is a standard package,you can use `git` or `go get` to install.
`go-redis-parser` will build a `binary file`,you can use `git` or `go get` to install.

#### via git
```
$ git clone https://github.com/8090Lambert/go-redis-parser.git
$ git clone https://github.com/8090Lambert/go-redis-parser.git && cd go-redis-parser
$ go install
```

#### via go
Expand All @@ -53,8 +54,9 @@ $ go get github.com/8090Lambert/go-redis-parser
```

### Using
Before using, you should set `export PATH=$PATH:$GOPATH/bin`
```
$ go run main.go -rdb <dump.rdb> -o <gen-file folder> -type <gen-file type, json or csv, default csv>
$ go-redis-parser -rdb <dump.rdb> -o <gen-file folder> -type <gen-file type, json or csv, default csv>
```

### Generate File
Expand Down
4 changes: 1 addition & 3 deletions boot/boot.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ func Boot() {
factory(file).Parse()
}

type Factory func(file string) protocol.Parser

func NewParserFactory(mod int) Factory {
func NewParserFactory(mod int) protocol.Factory {
if mod == constants.RDBMOD {
return rdb.NewRDB
} else {
Expand Down
2 changes: 2 additions & 0 deletions protocol/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ type TypeObject interface {
Type() string // Redis data type
ConcreteSize() uint64 // Data bytes size, except metadata
}

type Factory func(file string) Parser