Skip to content

Commit

Permalink
Merge pull request #43 from humingcheng/master
Browse files Browse the repository at this point in the history
Edit the NOTICE
  • Loading branch information
tianxiaoliang committed Jan 30, 2018
2 parents f1facdc + 6d9624a commit 27fa4a9
Show file tree
Hide file tree
Showing 23 changed files with 476 additions and 899 deletions.
1 change: 1 addition & 0 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ github.com/opentracing/opentracing-go
github.com/openzipkin/zipkin-go-opentracing
github.com/patrickmn/go-cache
github.com/spf13/cast
github.com/uber-go/ratelimit

================================================================
The BSD Licenses
Expand Down
3 changes: 2 additions & 1 deletion chassis.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ import (
// aes package handles security related plugins
_ "github.com/ServiceComb/go-chassis/security/plugins/aes"
_ "github.com/ServiceComb/go-chassis/security/plugins/plain"
_ "github.com/ServiceComb/go-chassis/server/highway"
_ "github.com/ServiceComb/go-chassis/server/restful"
serverOption "github.com/ServiceComb/go-chassis/third_party/forked/go-micro/server"
// highway package register the highway server plugin
_ "github.com/ServiceComb/go-chassis/third_party/forked/go-micro/server/highway"
// tcp package handles transport related things
_ "github.com/ServiceComb/go-chassis/third_party/forked/go-micro/transport/tcp"
)
Expand Down
2 changes: 1 addition & 1 deletion client/highway/highway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import (
"github.com/ServiceComb/go-chassis/core/server"
"github.com/ServiceComb/go-chassis/examples/schemas"
"github.com/ServiceComb/go-chassis/examples/schemas/helloworld"
_ "github.com/ServiceComb/go-chassis/server/highway"
clientOption "github.com/ServiceComb/go-chassis/third_party/forked/go-micro/client"
serverOption "github.com/ServiceComb/go-chassis/third_party/forked/go-micro/server"
_ "github.com/ServiceComb/go-chassis/third_party/forked/go-micro/server/highway"
"github.com/ServiceComb/go-chassis/third_party/forked/go-micro/transport/tcp"
"github.com/stretchr/testify/assert"
"golang.org/x/net/context"
Expand Down
9 changes: 5 additions & 4 deletions client/highway/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ package tcp
import (
"errors"
"fmt"
"strconv"
"sync"
"time"

"github.com/ServiceComb/go-chassis/client/highway/pb"
"github.com/ServiceComb/go-chassis/core/lager"
"github.com/ServiceComb/go-chassis/core/util/metadata"
"github.com/ServiceComb/go-chassis/third_party/forked/go-micro/client"
"github.com/ServiceComb/go-chassis/third_party/forked/go-micro/metadata"
"github.com/ServiceComb/go-chassis/third_party/forked/go-micro/transport"
"github.com/golang/protobuf/proto"
"golang.org/x/net/context"
"strconv"
"sync"
"time"
)

//TODO 1. configurable
Expand Down
6 changes: 3 additions & 3 deletions core/core_test.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package core_test

import (
//"fmt"
"testing"

"github.com/ServiceComb/go-chassis/client/rest"
"github.com/ServiceComb/go-chassis/core"
"github.com/ServiceComb/go-chassis/core/config"
_ "github.com/ServiceComb/go-chassis/core/config"
"github.com/ServiceComb/go-chassis/core/config/model"
"github.com/ServiceComb/go-chassis/core/lager"
"github.com/ServiceComb/go-chassis/core/util/metadata"
"github.com/ServiceComb/go-chassis/examples/schemas/helloworld"
"github.com/ServiceComb/go-chassis/third_party/forked/go-micro/metadata"
"github.com/stretchr/testify/assert"
"golang.org/x/net/context"
"testing"
)

func initenv() {
Expand Down
2 changes: 1 addition & 1 deletion core/handler/router_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/ServiceComb/go-chassis/core/invocation"
"github.com/ServiceComb/go-chassis/core/registry"
"github.com/ServiceComb/go-chassis/core/route"
"github.com/ServiceComb/go-chassis/core/util/metadata"
"github.com/ServiceComb/go-chassis/third_party/forked/go-micro/metadata"
)

// RouterHandler router handler
Expand Down
2 changes: 1 addition & 1 deletion core/handler/tracing_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/ServiceComb/go-chassis/core/invocation"
"github.com/ServiceComb/go-chassis/core/lager"
"github.com/ServiceComb/go-chassis/core/tracing"
"github.com/ServiceComb/go-chassis/core/util/metadata"
"github.com/ServiceComb/go-chassis/third_party/forked/go-micro/metadata"
"github.com/ServiceComb/go-chassis/third_party/forked/valyala/fasthttp"
"github.com/ServiceComb/go-chassis/util/iputil"
"github.com/emicklei/go-restful"
Expand Down
2 changes: 1 addition & 1 deletion core/handler/transport_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
"github.com/ServiceComb/go-chassis/core/invocation"
"github.com/ServiceComb/go-chassis/core/lager"
"github.com/ServiceComb/go-chassis/core/server"
"github.com/ServiceComb/go-chassis/core/util/metadata"
"github.com/ServiceComb/go-chassis/examples/schemas"
"github.com/ServiceComb/go-chassis/examples/schemas/helloworld"
"github.com/ServiceComb/go-chassis/third_party/forked/go-micro/metadata"
serverOption "github.com/ServiceComb/go-chassis/third_party/forked/go-micro/server"
"github.com/ServiceComb/go-chassis/third_party/forked/go-micro/transport"
"github.com/ServiceComb/go-chassis/third_party/forked/go-micro/transport/tcp"
Expand Down
12 changes: 7 additions & 5 deletions core/qpslimiter/qps_limiter.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package qpslimiter

import (
"github.com/ServiceComb/go-chassis/core/archaius"
"github.com/ServiceComb/go-chassis/core/lager"
"strconv"
"sync"

"github.com/ServiceComb/go-chassis/core/archaius"
"github.com/ServiceComb/go-chassis/core/lager"
"github.com/ServiceComb/go-chassis/third_party/forked/uber-go/ratelimit"
)

// constant qps default rate
Expand All @@ -14,7 +16,7 @@ const (

// QPSLimiterMap qps limiter map struct
type QPSLimiterMap struct {
KeyMap map[string]Limiter
KeyMap map[string]ratelimit.Limiter
sync.RWMutex
}

Expand All @@ -28,7 +30,7 @@ var (
func GetQPSTrafficLimiter() *QPSLimiterMap {
initializeMap := func() {
qpsLimiter = &QPSLimiterMap{}
qpsLimiter.KeyMap = make(map[string]Limiter)
qpsLimiter.KeyMap = make(map[string]ratelimit.Limiter)
}

once.Do(initializeMap)
Expand Down Expand Up @@ -67,7 +69,7 @@ func (qpsL *QPSLimiterMap) ProcessDefaultRateRpsTokenReq(key string, qpsRate int

qpsL.Lock()
// Create a new bucket for the new operation
r := New(bucketSize)
r := ratelimit.New(bucketSize)
qpsL.KeyMap[key] = r
qpsL.Unlock()

Expand Down
12 changes: 7 additions & 5 deletions core/qpslimiter/qps_limiter_test.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package qpslimiter_test

import (
"log"
"os"
"path/filepath"
"testing"

"github.com/ServiceComb/go-chassis/core/archaius"
"github.com/ServiceComb/go-chassis/core/config"
"github.com/ServiceComb/go-chassis/core/invocation"
"github.com/ServiceComb/go-chassis/core/lager"
"github.com/ServiceComb/go-chassis/core/qpslimiter"
"github.com/ServiceComb/go-chassis/examples/schemas/helloworld"
"github.com/ServiceComb/go-chassis/third_party/forked/uber-go/ratelimit"
"github.com/stretchr/testify/assert"
"log"
"os"
"path/filepath"
"testing"
)

func initialize() {
Expand All @@ -25,7 +27,7 @@ func initialize() {
func TestProcessQpsTokenReq(t *testing.T) {
lager.Initialize("", "INFO", "", "size", true, 1, 10, 7)
bucketsize := 100
r := qpslimiter.New(bucketsize)
r := ratelimit.New(bucketsize)
qps := qpslimiter.GetQPSTrafficLimiter()
qps.KeyMap["serviceName"] = r

Expand Down
2 changes: 1 addition & 1 deletion core/rpc_invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/ServiceComb/go-chassis/core/handler"
"github.com/ServiceComb/go-chassis/core/invocation"
"github.com/ServiceComb/go-chassis/core/lager"
"github.com/ServiceComb/go-chassis/core/util/metadata"
"github.com/ServiceComb/go-chassis/third_party/forked/go-micro/metadata"
"golang.org/x/net/context"
"sync"
)
Expand Down
Loading

0 comments on commit 27fa4a9

Please sign in to comment.