You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ti...@apache.org on 2020/06/16 10:05:47 UTC
[servicecomb-kie] branch master updated: fix bug: can not track
polling response (#143)
This is an automated email from the ASF dual-hosted git repository.
tianxiaoliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git
The following commit(s) were added to refs/heads/master by this push:
new 45a4764 fix bug: can not track polling response (#143)
45a4764 is described below
commit 45a47644ba7e9cb5e8d8f5d2894b1a6aab93f787
Author: Shawn <xi...@gmail.com>
AuthorDate: Tue Jun 16 18:05:39 2020 +0800
fix bug: can not track polling response (#143)
---
.github/workflows/static_check.yml | 42 +++++++++++++++++++++++++++++++
.travis.yml | 32 -----------------------
cmd/kieserver/main.go | 3 +--
pkg/model/db_schema.go | 4 +--
scripts/{travis => ci}/formatChecker.sh | 0
scripts/{travis => ci}/goCycloChecker.sh | 0
scripts/{travis => ci}/goLintChecker.sh | 0
scripts/{travis => ci}/goSecureChecker.sh | 0
scripts/{travis => ci}/misspellChecker.sh | 0
scripts/travis/deadCodeChecker.sh | 24 ------------------
scripts/travis/goConstChecker.sh | 24 ------------------
scripts/travis/goVetChecker.sh | 25 ------------------
server/handler/track_handler.go | 9 +++----
server/resource/v1/common.go | 2 +-
server/resource/v1/kv_resource.go | 2 --
15 files changed, 50 insertions(+), 117 deletions(-)
diff --git a/.github/workflows/static_check.yml b/.github/workflows/static_check.yml
new file mode 100644
index 0000000..61406aa
--- /dev/null
+++ b/.github/workflows/static_check.yml
@@ -0,0 +1,42 @@
+name: Merge check
+on: [push, pull_request]
+jobs:
+ build:
+ name: Merge check
+ runs-on: ubuntu-latest
+ steps:
+
+ - name: Set up Go 1.13
+ uses: actions/setup-go@v1
+ with:
+ go-version: 1.13
+ id: go
+
+ - name: Check out code into the Go module directory
+ uses: actions/checkout@v1
+
+ - name: Build
+ run: go build -v .
+
+ - name: Fmt
+ run: |
+ bash scripts/ci/formatChecker.sh
+ - name: Misspell
+ run: |
+ go get -u github.com/client9/misspell/cmd/misspell
+ bash scripts/ci/formatChecker.sh
+ - name: Lint
+ run: |
+ go get -u golang.org/x/lint/golint
+ bash scripts/ci/goLintChecker.sh
+ - name: Cyclo
+ run: |
+ go get github.com/fzipp/gocyclo
+ bash scripts/ci/goCycloChecker.sh
+ - name: secure
+ run: |
+ go get github.com/securego/gosec/cmd/gosec
+ bash -x scripts/travis/goSecureChecker.sh
+ - name: UT
+ run: |
+ go test $(go list ./... | grep -v third_party | grep -v examples) -cover -covermode atomic -coverprofile coverage.out
diff --git a/.travis.yml b/.travis.yml
index 3f4489b..8e82967 100755
--- a/.travis.yml
+++ b/.travis.yml
@@ -19,47 +19,15 @@ go:
- 1.13
install: true
-before_script:
- - mkdir -p $HOME/gopath/src/github.com/apache/servicecomb-kie
- - rsync -az ${TRAVIS_BUILD_DIR}/ $HOME/gopath/src/github.com/apache/servicecomb-kie/
- - export TRAVIS_BUILD_DIR=$HOME/gopath/src/github.com/apache/servicecomb-kie
- - cd $HOME/gopath/src/github.com/apache/servicecomb-kie
jobs:
include:
- - stage: Format Checker
- script: bash scripts/travis/formatChecker.sh
- - stage: DeadCode Checker
- script:
- - go get -u github.com/tsenart/deadcode
- - bash scripts/travis/deadCodeChecker.sh
- - stage: Misspell Checker
- script:
- - go get -u github.com/client9/misspell
- - bash scripts/travis/misspellChecker.sh
- - stage: GoConst Checker
- script:
- - go get -u github.com/jgautheron/goconst/cmd/goconst
- - bash scripts/travis/goConstChecker.sh
- - stage: GoLint Checker
- script:
- - go get -u golang.org/x/lint/golint
- - bash scripts/travis/goLintChecker.sh
- - stage: GoCyclo Checker
- script:
- - go get github.com/fzipp/gocyclo
- - bash scripts/travis/goCycloChecker.sh
- - stage: GoSecure Checker
- script:
- - go get github.com/securego/gosec/cmd/gosec
- - bash -x scripts/travis/goSecureChecker.sh
- stage: Unit Test
script:
- export GOPROXY=https://goproxy.io
- GO111MODULE=on go mod download
- GO111MODULE=on go mod vendor
- bash scripts/travis/start_deps.sh
- - cd $HOME/gopath/src/github.com/apache/servicecomb-kie
- go get github.com/mattn/goveralls
- go get golang.org/x/tools/cmd/cover
- sleep 30
diff --git a/cmd/kieserver/main.go b/cmd/kieserver/main.go
index e8b0911..dc69f85 100644
--- a/cmd/kieserver/main.go
+++ b/cmd/kieserver/main.go
@@ -23,9 +23,8 @@ import (
"github.com/apache/servicecomb-kie/pkg/validate"
"github.com/apache/servicecomb-kie/server/config"
"github.com/apache/servicecomb-kie/server/pubsub"
- v1 "github.com/apache/servicecomb-kie/server/resource/v1"
+ "github.com/apache/servicecomb-kie/server/resource/v1"
"github.com/apache/servicecomb-kie/server/service"
-
"github.com/go-chassis/go-chassis"
"github.com/go-chassis/go-chassis/core/common"
"github.com/go-mesh/openlogging"
diff --git a/pkg/model/db_schema.go b/pkg/model/db_schema.go
index 4abf22b..caae854 100644
--- a/pkg/model/db_schema.go
+++ b/pkg/model/db_schema.go
@@ -60,11 +60,11 @@ type PollingDetail struct {
ID string `json:"id,omitempty" yaml:"id,omitempty"`
SessionID string `json:"session_id,omitempty" bson:"session_id," yaml:"session_id,omitempty"`
Domain string `json:"domain,omitempty" yaml:"domain,omitempty"`
- PollingData map[string]interface{} `json:"params,omitempty" yaml:"params,omitempty"`
+ PollingData map[string]interface{} `json:"polling_data,omitempty" yaml:"polling_data,omitempty"`
IP string `json:"ip,omitempty" yaml:"ip,omitempty"`
UserAgent string `json:"user_agent,omitempty" bson:"user_agent," yaml:"user_agent,omitempty"`
URLPath string `json:"url_path,omitempty" bson:"url_path," yaml:"url_path,omitempty"`
- ResponseBody interface{} `json:"response_body,omitempty" bson:"response_body," yaml:"response_body,omitempty"`
+ ResponseBody []*KVDoc `json:"kv,omitempty" bson:"kv," yaml:"kv,omitempty"`
ResponseHeader map[string][]string `json:"response_header,omitempty" bson:"response_header," yaml:"response_header,omitempty"`
ResponseCode int `json:"response_code,omitempty" bson:"response_code," yaml:"response_code,omitempty"`
}
diff --git a/scripts/travis/formatChecker.sh b/scripts/ci/formatChecker.sh
similarity index 100%
rename from scripts/travis/formatChecker.sh
rename to scripts/ci/formatChecker.sh
diff --git a/scripts/travis/goCycloChecker.sh b/scripts/ci/goCycloChecker.sh
similarity index 100%
rename from scripts/travis/goCycloChecker.sh
rename to scripts/ci/goCycloChecker.sh
diff --git a/scripts/travis/goLintChecker.sh b/scripts/ci/goLintChecker.sh
similarity index 100%
rename from scripts/travis/goLintChecker.sh
rename to scripts/ci/goLintChecker.sh
diff --git a/scripts/travis/goSecureChecker.sh b/scripts/ci/goSecureChecker.sh
similarity index 100%
rename from scripts/travis/goSecureChecker.sh
rename to scripts/ci/goSecureChecker.sh
diff --git a/scripts/travis/misspellChecker.sh b/scripts/ci/misspellChecker.sh
similarity index 100%
rename from scripts/travis/misspellChecker.sh
rename to scripts/ci/misspellChecker.sh
diff --git a/scripts/travis/deadCodeChecker.sh b/scripts/travis/deadCodeChecker.sh
deleted file mode 100755
index 70f9879..0000000
--- a/scripts/travis/deadCodeChecker.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/usr/bin/env bash
-
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-diff -u <(echo -n) <(find . -type d -not -path "./vendor/*" | xargs deadcode)
-if [ $? == 0 ]; then
- echo "Hurray....all code's are reachable and utilised..."
- exit 0
-else
- echo "There are some deadcode in the project...please remove the unused code"
- exit 1
-fi
diff --git a/scripts/travis/goConstChecker.sh b/scripts/travis/goConstChecker.sh
deleted file mode 100755
index ae9d86e..0000000
--- a/scripts/travis/goConstChecker.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/usr/bin/env bash
-
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-diff -u <(echo -n) <(goconst ./... | grep -v vendor | grep -v third_party)
-if [ $? == 0 ]; then
- echo "No goConst problem"
- exit 0
-else
- echo "Has goConst Problem"
- exit 1
-fi
diff --git a/scripts/travis/goVetChecker.sh b/scripts/travis/goVetChecker.sh
deleted file mode 100755
index 7a7384f..0000000
--- a/scripts/travis/goVetChecker.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin/env bash
-
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-diff -u <(echo -n) <(find . -type d -not -path "./vendor/*" -not -path "./third_party/*"| xargs go vet )
-if [ $? == 0 ]; then
- echo "Hurray....all OKAY..."
- exit 0
-else
- echo "There are some static issues in the project...please run go vet"
- exit 1
-fi
diff --git a/server/handler/track_handler.go b/server/handler/track_handler.go
index 88028d7..d02a829 100644
--- a/server/handler/track_handler.go
+++ b/server/handler/track_handler.go
@@ -69,16 +69,15 @@ func (h *TrackHandler) Handle(chain *handler.Chain, inv *invocation.Invocation,
data.UserAgent = req.HeaderParameter(v1.HeaderUserAgent)
data.Domain = inv.Metadata[v1.AttributeDomainKey].(string)
data.IP = iputil.ClientIP(req.Request)
- data.ResponseBody = inv.Ctx.Value(common.RespBodyContextKey)
+ data.ResponseBody = req.Attribute(common.RespBodyContextKey).([]*model.KVDoc)
data.ResponseCode = ir.Status
if resp != nil {
data.ResponseHeader = resp.Header()
}
data.PollingData = map[string]interface{}{
- "revStr": revStr,
- "wait": wait,
- "project": req.HeaderParameter(common.PathParameterProject),
- "labels": req.QueryParameter("label"),
+ "revision": revStr,
+ "wait": wait,
+ "labels": req.QueryParameter("label"),
}
_, err := track.CreateOrUpdate(inv.Ctx, data)
if err != nil {
diff --git a/server/resource/v1/common.go b/server/resource/v1/common.go
index d9d3530..ac4d4e2 100644
--- a/server/resource/v1/common.go
+++ b/server/resource/v1/common.go
@@ -263,7 +263,7 @@ func queryAndResponse(rctx *restful.Context, request *model.ListKVRequest) {
}
rctx.ReadResponseWriter().Header().Set(common.HeaderRevision, strconv.FormatInt(rev, 10))
err = writeResponse(rctx, kv)
- rctx.Ctx = context.WithValue(rctx.Ctx, common.RespBodyContextKey, kv)
+ rctx.ReadRestfulRequest().SetAttribute(common.RespBodyContextKey, kv.Data)
if err != nil {
openlogging.Error(err.Error())
}
diff --git a/server/resource/v1/kv_resource.go b/server/resource/v1/kv_resource.go
index cbe335c..4925906 100644
--- a/server/resource/v1/kv_resource.go
+++ b/server/resource/v1/kv_resource.go
@@ -19,7 +19,6 @@
package v1
import (
- "context"
"encoding/json"
"fmt"
"net/http"
@@ -170,7 +169,6 @@ func (r *KVResource) Get(rctx *restful.Context) {
kv.Domain = ""
kv.Project = ""
err = writeResponse(rctx, kv)
- rctx.Ctx = context.WithValue(rctx.Ctx, common.RespBodyContextKey, kv)
if err != nil {
openlogging.Error(err.Error())
}