Skip to content

Commit

Permalink
OK
Browse files Browse the repository at this point in the history
  • Loading branch information
xincao9 committed Jun 20, 2020
1 parent 9b87a36 commit 1952ba0
Show file tree
Hide file tree
Showing 23 changed files with 124 additions and 116 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@ build:

docker:build
docker build . -t dkv:latest

install:
go build -tags=jsoniter -o dkv main.go
mkdir -p /usr/local/dkv/conf
mkdir -p /usr/local/dkv/bin
cp ./resource/conf/* /usr/local/dkv/conf
cp dkv /usr/local/dkv/bin
16 changes: 8 additions & 8 deletions api/kv/kv.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package kv

import (
"dkv/component/cache"
"dkv/component/compress"
"dkv/component/constant"
"dkv/component/logger"
"dkv/component/metrics"
"dkv/store"
"github.com/gin-gonic/gin"
"net/http"
"dkv/component/cache"
"dkv/component/compress"
"dkv/component/constant"
"dkv/component/logger"
"dkv/component/metrics"
"dkv/store"
"github.com/gin-gonic/gin"
"net/http"
)

type KV struct {
Expand Down
16 changes: 8 additions & 8 deletions api/oss/oss.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package oss

import (
"crypto/md5"
"dkv/component/constant"
"dkv/component/logger"
"dkv/store"
"encoding/hex"
"github.com/gin-gonic/gin"
"io/ioutil"
"net/http"
"crypto/md5"
"dkv/component/constant"
"dkv/component/logger"
"dkv/store"
"encoding/hex"
"github.com/gin-gonic/gin"
"io/ioutil"
"net/http"
)

func Route(engine *gin.Engine) {
Expand Down
12 changes: 6 additions & 6 deletions api/redis/redis.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package redis

import (
"dkv/component/constant"
"dkv/component/logger"
"dkv/store"
"fmt"
"github.com/tidwall/redcon"
"strings"
"dkv/component/constant"
"dkv/component/logger"
"dkv/store"
"fmt"
"github.com/tidwall/redcon"
"strings"
)

func run() {
Expand Down
10 changes: 5 additions & 5 deletions benchmark/client/client.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package client

import (
"dkv/client/ms"
"log"
"math/rand"
"strconv"
"time"
"dkv/client/ms"
"log"
"math/rand"
"strconv"
"time"
)

const maxRequestCount = 1000000
Expand Down
4 changes: 2 additions & 2 deletions client/balancer/balancer_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package balancer

import (
"testing"
"testing"
)

func TestBalancer_Choose(t *testing.T) {
Expand All @@ -14,7 +14,7 @@ func TestBalancer_Choose(t *testing.T) {
nodes[node]++
B.Increment()
}
t.Logf("%v\n", nodes)
t.Logf("%v\n", nodes)
}

func BenchmarkBalancer_Choose(b *testing.B) {
Expand Down
2 changes: 1 addition & 1 deletion component/cache/cache_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cache

import (
"strconv"
"strconv"
"testing"
)

Expand Down
2 changes: 1 addition & 1 deletion component/compress/compress.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package compress

import (
"dkv/component/constant"
"dkv/component/constant"
"github.com/golang/snappy"
)

Expand Down
17 changes: 9 additions & 8 deletions component/config/config.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package config

import (
"flag"
"github.com/gin-gonic/gin"
"github.com/spf13/viper"
"log"
"net/http"
"strings"
"flag"
"github.com/gin-gonic/gin"
"github.com/spf13/viper"
"log"
"net/http"
"strings"
)

var (
Expand All @@ -24,9 +24,10 @@ func init() {
*c = string([]byte(*c)[:i-1])
}
}
C.SetConfigName(*c)
C.SetConfigName(*c)
C.SetConfigType("yaml")
C.AddConfigPath("/tmp/dkv/conf")
C.AddConfigPath("./resource/conf")
C.AddConfigPath("/usr/local/dkv/conf")
C.SetDefault("data.dir", "/tmp/dkv/data")
C.SetDefault("data.invalidIndex", false)
C.SetDefault("data.compress", false)
Expand Down
2 changes: 1 addition & 1 deletion component/constant/constant.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package constant

import (
"dkv/component/config"
"dkv/component/config"
"encoding/binary"
"errors"
)
Expand Down
2 changes: 1 addition & 1 deletion component/metrics/metrics.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package metrics

import (
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
"github.com/prometheus/client_golang/prometheus"
"github.com/zsais/go-gin-prometheus"
)
Expand Down
2 changes: 1 addition & 1 deletion component/pprof/pprof.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package pprof

import (
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
"net/http/pprof"
"strings"
)
Expand Down
32 changes: 16 additions & 16 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package main

import (
"dkv/api/kv"
"dkv/api/oss"
"dkv/api/redis"
"dkv/component/cache"
"dkv/component/config"
"dkv/component/logger"
"dkv/component/metrics"
"dkv/component/pprof"
"dkv/store"
_ "dkv/store/synchronous"
"flag"
"fmt"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
"os"
"os/exec"
"dkv/api/kv"
"dkv/api/oss"
"dkv/api/redis"
"dkv/component/cache"
"dkv/component/config"
"dkv/component/logger"
"dkv/component/metrics"
"dkv/component/pprof"
"dkv/store"
_ "dkv/store/synchronous"
"flag"
"fmt"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
"os"
"os/exec"
)

func init() {
Expand Down
14 changes: 7 additions & 7 deletions store/appendfile/appendfile.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package appendfile

import (
"dkv/component/constant"
"dkv/component/logger"
"fmt"
"os"
"path/filepath"
"strconv"
"sync"
"dkv/component/constant"
"dkv/component/logger"
"fmt"
"os"
"path/filepath"
"strconv"
"sync"
)

type appendFile struct {
Expand Down
2 changes: 1 addition & 1 deletion store/appendfile/appendfile_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package appendfile

import (
"dkv/component/constant"
"dkv/component/constant"
"os"
"testing"
)
Expand Down
26 changes: 13 additions & 13 deletions store/appendfile/appendfilemanager.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package appendfile

import (
"bytes"
"dkv/component/constant"
"dkv/component/logger"
"dkv/component/metrics"
"dkv/store/meta"
"fmt"
"io"
"os"
"path/filepath"
"sort"
"sync"
"sync/atomic"
"time"
"bytes"
"dkv/component/constant"
"dkv/component/logger"
"dkv/component/metrics"
"dkv/store/meta"
"fmt"
"io"
"os"
"path/filepath"
"sort"
"sync"
"sync/atomic"
"time"
)

type (
Expand Down
2 changes: 1 addition & 1 deletion store/appendfile/appendfilemanager_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package appendfile

import (
"dkv/component/constant"
"dkv/component/constant"
"os"
"strconv"
"testing"
Expand Down
2 changes: 1 addition & 1 deletion store/appendfile/keyvalue.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package appendfile

import (
"dkv/component/constant"
"dkv/component/constant"
"errors"
"hash/crc32"
"math"
Expand Down
14 changes: 7 additions & 7 deletions store/meta/meta.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package meta

import (
"dkv/component/constant"
"dkv/component/logger"
"encoding/json"
"io/ioutil"
"os"
"path/filepath"
"sort"
"dkv/component/constant"
"dkv/component/logger"
"encoding/json"
"io/ioutil"
"os"
"path/filepath"
"sort"
)

var M *meta
Expand Down
4 changes: 2 additions & 2 deletions store/meta/meta_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package meta

import (
"dkv/component/constant"
"os"
"dkv/component/constant"
"os"
"testing"
"time"
)
Expand Down
14 changes: 7 additions & 7 deletions store/store.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package store

import (
"crypto/md5"
"dkv/component/constant"
"dkv/component/logger"
"dkv/store/appendfile"
"encoding/hex"
"math"
"sync"
"crypto/md5"
"dkv/component/constant"
"dkv/component/logger"
"dkv/store/appendfile"
"encoding/hex"
"math"
"sync"
)

var (
Expand Down
8 changes: 4 additions & 4 deletions store/store_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package store

import (
"dkv/component/constant"
"os"
"strconv"
"testing"
"dkv/component/constant"
"os"
"strconv"
"testing"
)

var doc = make([]byte, 1024)
Expand Down
Loading

0 comments on commit 1952ba0

Please sign in to comment.