Skip to content
Permalink
Browse files
Merge branch 'feature/grpc_v2' of github.com:PhilYue/dubbo-go-pixiu i…
…nto feature/grpc_v2
  • Loading branch information
PhilYue committed Dec 18, 2021
2 parents 126b31a + bb5915b commit 90cf947ed36f7089a85d5708f8dfba88f2d28358
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 180 deletions.
4 go.mod
@@ -4,7 +4,7 @@ go 1.15

require (
dubbo.apache.org/dubbo-go/v3 v3.0.0-rc4-1
github.com/MicahParks/keyfunc v0.10.0
github.com/MicahParks/keyfunc v1.0.0
github.com/Shopify/sarama v1.19.0
github.com/alibaba/sentinel-golang v1.0.2
github.com/apache/dubbo-go v1.5.7
@@ -53,4 +53,4 @@ require (

replace github.com/envoyproxy/go-control-plane => github.com/envoyproxy/go-control-plane v0.8.0

replace github.com/go-co-op/gocron => github.com/go-co-op/gocron v0.1.1
replace github.com/go-co-op/gocron => github.com/go-co-op/gocron v0.1.1
4 go.sum
@@ -64,8 +64,8 @@ github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/Julusian/godocdown v0.0.0-20170816220326-6d19f8ff2df8/go.mod h1:INZr5t32rG59/5xeltqoCJoNY7e5x/3xoY9WSWVWg74=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/MicahParks/keyfunc v0.10.0 h1:jWNhUVtMchsdYVl714lrZL8On+SKPEvPKC+CpIN7HwE=
github.com/MicahParks/keyfunc v0.10.0/go.mod h1:R8RZa27qn+5cHTfYLJ9/+7aSb5JIdz7cl0XFo0o4muo=
github.com/MicahParks/keyfunc v1.0.0 h1:O9VAkG6q/LqX4eS+HuIsW9KfC/Luh2NBQr9v4NiwHU0=
github.com/MicahParks/keyfunc v1.0.0/go.mod h1:R8RZa27qn+5cHTfYLJ9/+7aSb5JIdz7cl0XFo0o4muo=
github.com/Microsoft/go-winio v0.4.3/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA=
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
github.com/NYTimes/gziphandler v1.0.1/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
@@ -67,7 +67,6 @@ func (hcm *HttpConnectionManager) OnData(hc *pch.HttpContext) error {
func (hcm *HttpConnectionManager) handleHTTPRequest(c *pch.HttpContext) {
if len(c.Filters) > 0 {
c.Next()
c.WriteHeaderNow()
return
}
// TODO redirect
@@ -60,9 +60,8 @@ type HttpContext struct {
Route *model.RouteAction
Api *router.API

Request *http.Request
writermem responseWriter
Writer ResponseWriter
Request *http.Request
Writer http.ResponseWriter
}

type (
@@ -89,7 +88,6 @@ func (hc *HttpContext) Next() {

// Reset reset http context
func (hc *HttpContext) Reset() {
hc.Writer = &hc.writermem
hc.Ctx = nil
hc.Index = -1
hc.Filters = []FilterFunc{}
@@ -116,21 +114,11 @@ func (hc *HttpContext) GetRouteEntry() *model.RouteAction {
return hc.Route
}

// StatusCode get header status code
func (hc *HttpContext) StatusCode() int {
return hc.Writer.Status()
}

// Write write body data
func (hc *HttpContext) Write(b []byte) (int, error) {
return hc.Writer.Write(b)
}

// WriteHeaderNow write header now
func (hc *HttpContext) WriteHeaderNow() {
hc.writermem.WriteHeaderNow()
}

// WriteWithStatus status must set first
func (hc *HttpContext) WriteWithStatus(code int, b []byte) (int, error) {
hc.Writer.WriteHeader(code)
@@ -245,11 +233,6 @@ func (hc *HttpContext) doWrite(h map[string]string, code int, d interface{}) {
}
}

// ResetWritermen reset writermen
func (hc *HttpContext) ResetWritermen(w http.ResponseWriter) {
hc.writermem.reset(w)
}

// API sets the API to http context
func (hc *HttpContext) API(api router.API) {
hc.Timeout = api.Timeout

This file was deleted.

@@ -36,7 +36,7 @@ func GetMockHTTPContext(r *http.Request, fc ...filter.HttpFilter) *contexthttp.H
}

w := mockWriter{header: map[string][]string{}}
result.ResetWritermen(&w)
result.Writer = &w
result.Reset()
result.Ctx = context.Background()
for i := range fc {
@@ -69,7 +69,7 @@ type (
)

type Provider struct {
jwk *keyfunc.JWKs
jwk *keyfunc.JWKS
issuer string
forwardPayloadHeader string
headers FromHeaders
@@ -92,7 +92,8 @@ func (f *Filter) Handle(c *http.HttpContext) {
atomic.AddInt64(&totalElapsed, latency.Nanoseconds())
atomic.AddInt64(&totalCount, 1)

logger.Infof("[dubbo go server] [UPSTREAM] receive request | %d | %s | %s | %s | ", c.StatusCode(), latency, c.GetMethod(), c.GetUrl())
//todo status code
logger.Infof("[dubbo go server] [UPSTREAM] receive request | %d | %s | %s | %s | ", nil, latency, c.GetMethod(), c.GetUrl())
}

func registerOtelMetric() {
@@ -157,7 +157,7 @@ func (s *DefaultHttpWorker) ServeHTTP(w http.ResponseWriter, r *http.Request) {
defer s.pool.Put(hc)

hc.Request = r
hc.ResetWritermen(w)
hc.Writer = w
hc.Reset()

// now only one filter http_connection_manager, so just get it and call
@@ -17,10 +17,6 @@

package server

import (
"net/http/httptest"
)

import (
ctxHttp "github.com/apache/dubbo-go-pixiu/pkg/context/http"
"github.com/apache/dubbo-go-pixiu/pkg/model"
@@ -45,7 +41,6 @@ func getTestContext() *ctxHttp.HttpContext {
Listener: l.cfg,
Filters: []ctxHttp.FilterFunc{},
}
hc.ResetWritermen(httptest.NewRecorder())
hc.Reset()
return hc
}

0 comments on commit 90cf947

Please sign in to comment.