This is an automated email from the ASF dual-hosted git repository.
littlecui 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 87189ee [feat]upgrade go-chassis (#254)
87189ee is described below
commit 87189ee9bf2577f7ffbc9c68e85360b47ffadbc7
Author: little-cui <[email protected]>
AuthorDate: Wed Aug 10 15:14:49 2022 +0800
[feat]upgrade go-chassis (#254)
---
.github/workflows/golangci-lint.yml | 4 ++--
go.mod | 8 ++++----
go.sum | 8 ++++++++
pkg/common/common.go | 8 ++++----
pkg/concurrency/semaphore.go | 6 +++---
pkg/iputil/ip_util.go | 2 +-
pkg/model/db_schema.go | 8 ++++----
pkg/model/kv.go | 22 ++++++++++----------
pkg/stringutil/string_util.go | 2 +-
pkg/util/util.go | 4 ++--
server/cache/long_polling.go | 6 +++---
server/config/config.go | 8 ++++----
server/config/struct.go | 6 +++---
server/config/tlsutil/tlsutil.go | 4 ++--
server/datasource/dao.go | 18 ++++++++--------
server/datasource/etcd/counter/revision.go | 6 +++---
server/datasource/etcd/history/history_dao.go | 12 +++++------
server/datasource/etcd/kv/kv_dao.go | 18 ++++++++--------
server/datasource/etcd/track/polling_detail_dao.go | 8 ++++----
server/datasource/mongo/counter/revision.go | 6 +++---
server/datasource/mongo/counter/struct.go | 2 +-
server/datasource/mongo/history/history_dao.go | 12 +++++------
server/datasource/mongo/kv/kv_dao.go | 24 +++++++++++-----------
.../datasource/mongo/track/polling_detail_dao.go | 8 ++++----
server/datasource/options.go | 24 +++++++++++-----------
server/handler/track_handler.go | 8 ++++----
server/plugin/qms/quota.go | 10 ++++-----
server/pubsub/bus.go | 12 +++++------
server/pubsub/event_handler.go | 4 ++--
server/pubsub/notifier/kv.go | 2 +-
server/pubsub/options.go | 2 +-
server/pubsub/struct.go | 20 +++++++++---------
server/rbac/rbac.go | 10 ++++-----
server/resource/v1/admin_resource.go | 4 ++--
server/resource/v1/common.go | 14 ++++++-------
server/resource/v1/doc_struct.go | 20 +++++++++---------
server/resource/v1/history_resource.go | 8 ++++----
server/resource/v1/kv_resource.go | 20 +++++++++---------
server/service/kv/kv_svc.go | 8 ++++----
39 files changed, 192 insertions(+), 184 deletions(-)
diff --git a/.github/workflows/golangci-lint.yml
b/.github/workflows/golangci-lint.yml
index 91e59ae..fea97e3 100644
--- a/.github/workflows/golangci-lint.yml
+++ b/.github/workflows/golangci-lint.yml
@@ -15,8 +15,8 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
- version: v1.45.2
- args: --enable gofmt,gocyclo,goimports,dupl,gosec
--skip-dirs=examples,test --skip-files=.*_test.go$
+ version: v1.48.0
+ args: --enable gofmt,gocyclo,goimports,dupl,gosec --timeout 5m
--skip-dirs=examples,test --skip-files=.*_test.go$
static-checks:
runs-on: ubuntu-latest
env:
diff --git a/go.mod b/go.mod
index 6096bcd..df8d377 100644
--- a/go.mod
+++ b/go.mod
@@ -2,11 +2,11 @@ module github.com/apache/servicecomb-kie
require (
github.com/apache/servicecomb-service-center/eventbase
v0.0.0-20220120070230-26997eb876ca
- github.com/emicklei/go-restful v2.12.0+incompatible
+ github.com/emicklei/go-restful
v2.15.1-0.20220703112237-d9c71e118c95+incompatible
github.com/go-chassis/cari v0.5.1-0.20220216075429-46c79de3311f
github.com/go-chassis/foundation v0.4.0
github.com/go-chassis/go-archaius v1.5.2-0.20210301074935-e4694f6b077b
- github.com/go-chassis/go-chassis/v2 v2.3.1-0.20211217084436-360a6a6a0ef3
+ github.com/go-chassis/go-chassis/v2 v2.5.2
github.com/go-chassis/openlog v1.1.3
github.com/go-chassis/seclog v1.3.1-0.20210917082355-52c40864f240
github.com/gofrs/uuid v4.0.0+incompatible
@@ -39,7 +39,7 @@ require (
github.com/fatih/color v1.9.0 // indirect
github.com/form3tech-oss/jwt-go v3.2.3+incompatible // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
- github.com/go-chassis/go-restful-swagger20 v1.0.3 // indirect
+ github.com/go-chassis/go-restful-swagger20
v1.0.4-0.20220704025524-9243cbee26b7 // indirect
github.com/go-chassis/kie-client v0.1.1-0.20210926011742-97eed4281056
// indirect
github.com/go-chassis/sc-client v0.6.1-0.20210918130508-2b9daad232da //
indirect
github.com/go-playground/locales v0.13.0 // indirect
@@ -125,7 +125,7 @@ require (
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40 // indirect
- golang.org/x/text v0.3.5 // indirect
+ golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba // indirect
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c //
indirect
google.golang.org/grpc v1.40.0 // indirect
diff --git a/go.sum b/go.sum
index 8686eb8..a24292e 100644
--- a/go.sum
+++ b/go.sum
@@ -119,6 +119,8 @@ github.com/elazarl/goproxy
v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkg
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod
h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
github.com/emicklei/go-restful v2.12.0+incompatible
h1:SIvoTSbsMEwuM3dzFirLwKc4BH6VXP5CNf+G1FfJVr4=
github.com/emicklei/go-restful v2.12.0+incompatible/go.mod
h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
+github.com/emicklei/go-restful
v2.15.1-0.20220703112237-d9c71e118c95+incompatible
h1:o87Jf90Yb9ZvrdJKy2jYAdzosa7MtC2H214tJxJx7As=
+github.com/emicklei/go-restful
v2.15.1-0.20220703112237-d9c71e118c95+incompatible/go.mod
h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod
h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane
v0.9.1-0.20191026205805-5f8ba28d4473/go.mod
h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod
h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
@@ -160,8 +162,12 @@ github.com/go-chassis/go-archaius
v1.5.2-0.20210301074935-e4694f6b077b/go.mod h1
github.com/go-chassis/go-chassis/v2 v2.3.0/go.mod
h1:iyJ2DWSkqfnCmad/0Il9nXWHaob7RcwPGlIDRNxccH0=
github.com/go-chassis/go-chassis/v2 v2.3.1-0.20211217084436-360a6a6a0ef3
h1:Ctxgyo/gc5sogcCJLoIvIKj9kEUzJOlbENpYO/nSPWA=
github.com/go-chassis/go-chassis/v2
v2.3.1-0.20211217084436-360a6a6a0ef3/go.mod
h1:oMnRaz2P+OPTtEfh2HEuiF9YzdYHQrNVPXdnbKzKO9w=
+github.com/go-chassis/go-chassis/v2 v2.5.2
h1:Au+rNk3ZYoYHp73HHWMVrI5FIIOBVlt12SyXZjDnC2Q=
+github.com/go-chassis/go-chassis/v2 v2.5.2/go.mod
h1:Ru3kB+ndcxxFZl3clnuihKVv+gOi7lOVR9Ghhtw8jaQ=
github.com/go-chassis/go-restful-swagger20 v1.0.3
h1:kWfeLwMwJZVkXP1zNyFpkmR41UZ55UTcOptTteXhvEs=
github.com/go-chassis/go-restful-swagger20 v1.0.3/go.mod
h1:eW62fYuzlNFDvIacB6AV8bhUDCTy4myfTCv0bT9Gbb0=
+github.com/go-chassis/go-restful-swagger20
v1.0.4-0.20220704025524-9243cbee26b7
h1:EOIGW+inOz52zh6vgr9EQHvvgL2w/VghAeCQIFOVUSE=
+github.com/go-chassis/go-restful-swagger20
v1.0.4-0.20220704025524-9243cbee26b7/go.mod
h1:pSGkT+ksxlMgytyJb4IAz8aZih6OLE1++d9CE6aO9Hg=
github.com/go-chassis/kie-client v0.0.0-20201210060018-938c7680a9ab/go.mod
h1:UTdbtyN5ge/v9DmQzdVRxQP7z51Q4z6hyl+W6ZpUHFM=
github.com/go-chassis/kie-client v0.1.0/go.mod
h1:UTdbtyN5ge/v9DmQzdVRxQP7z51Q4z6hyl+W6ZpUHFM=
github.com/go-chassis/kie-client v0.1.1-0.20210926011742-97eed4281056
h1:Y8CyErFNg4d1dPYXvNWxpyzzLQ/kuyuxJF2/7My7qLc=
@@ -764,6 +770,8 @@ golang.org/x/text v0.3.2/go.mod
h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
+golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod
h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod
h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod
h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
diff --git a/pkg/common/common.go b/pkg/common/common.go
index 205f2ef..5188d32 100644
--- a/pkg/common/common.go
+++ b/pkg/common/common.go
@@ -19,7 +19,7 @@ package common
import "time"
-//match mode
+// match mode
const (
QueryParamQ = "q"
QueryByLabelsCon = "&"
@@ -41,7 +41,7 @@ const (
QueryParamOverride = "override"
)
-//http headers
+// http headers
const (
HeaderDepth = "X-Depth"
HeaderRevision = "X-Kie-Revision"
@@ -49,14 +49,14 @@ const (
HeaderAccept = "Accept"
)
-//ContentType
+// ContentType
const (
ContentTypeText = "application/text"
ContentTypeJSON = "application/json"
ContentTypeYaml = "text/yaml"
)
-//const of server
+// const of server
const (
PatternExact = "exact"
StatusEnabled = "enabled"
diff --git a/pkg/concurrency/semaphore.go b/pkg/concurrency/semaphore.go
index 1dbf671..75445c8 100644
--- a/pkg/concurrency/semaphore.go
+++ b/pkg/concurrency/semaphore.go
@@ -7,12 +7,12 @@ const (
MaxConcurrency = math.MaxUint16
)
-//Semaphore ctl the max concurrency
+// Semaphore ctl the max concurrency
type Semaphore struct {
tickets chan bool
}
-//NewSemaphore accept concurrency number, not more than 65535
+// NewSemaphore accept concurrency number, not more than 65535
func NewSemaphore(concurrency int) *Semaphore {
if concurrency >= math.MaxUint16 {
concurrency = MaxConcurrency
@@ -29,7 +29,7 @@ func (b *Semaphore) Acquire() {
<-b.tickets
}
-//Release return back signal
+// Release return back signal
func (b *Semaphore) Release() {
b.tickets <- true
}
diff --git a/pkg/iputil/ip_util.go b/pkg/iputil/ip_util.go
index 7e21854..06ba60d 100644
--- a/pkg/iputil/ip_util.go
+++ b/pkg/iputil/ip_util.go
@@ -6,7 +6,7 @@ import (
"strings"
)
-//ClientIP try to get ip from http header
+// ClientIP try to get ip from http header
func ClientIP(r *http.Request) string {
xForwardedFor := r.Header.Get("X-Forwarded-For")
ip := strings.TrimSpace(strings.Split(xForwardedFor, ",")[0])
diff --git a/pkg/model/db_schema.go b/pkg/model/db_schema.go
index 3298634..7e4be22 100644
--- a/pkg/model/db_schema.go
+++ b/pkg/model/db_schema.go
@@ -19,7 +19,7 @@ package model
import "time"
-//LabelDoc is database struct to store labels
+// LabelDoc is database struct to store labels
type LabelDoc struct {
ID string `json:"id,omitempty" bson:"id,omitempty"
yaml:"id,omitempty" swag:"string"`
Labels map[string]string `json:"labels,omitempty"
yaml:"labels,omitempty"`
@@ -29,7 +29,7 @@ type LabelDoc struct {
Alias string `json:"alias,omitempty"
yaml:"alias,omitempty"`
}
-//KVDoc is database struct to store kv
+// KVDoc is database struct to store kv
type KVDoc struct {
ID string `json:"id,omitempty" bson:"id,omitempty"
yaml:"id,omitempty" swag:"string"`
LabelFormat string `json:"label_format,omitempty"
bson:"label_format,omitempty" yaml:"label_format,omitempty"`
@@ -48,7 +48,7 @@ type KVDoc struct {
Domain string `json:"domain,omitempty"
yaml:"domain,omitempty" validate:"min=1,max=256,commonName"`
//redundant
}
-//ViewDoc is db struct, it saves user's custom view name and criteria
+// ViewDoc is db struct, it saves user's custom view name and criteria
type ViewDoc struct {
ID string `json:"id,omitempty" bson:"id,omitempty"
yaml:"id,omitempty" swag:"string"`
Display string `json:"display,omitempty" yaml:"display,omitempty"`
@@ -57,7 +57,7 @@ type ViewDoc struct {
Criteria string `json:"criteria,omitempty" yaml:"criteria,omitempty"`
}
-//PollingDetail is db struct, it record operation history
+// PollingDetail is db struct, it record operation history
type PollingDetail struct {
ID string `json:"id,omitempty"
yaml:"id,omitempty"`
SessionID string `json:"session_id,omitempty"
bson:"session_id," yaml:"session_id,omitempty"`
diff --git a/pkg/model/kv.go b/pkg/model/kv.go
index f29186b..c7e3c00 100644
--- a/pkg/model/kv.go
+++ b/pkg/model/kv.go
@@ -17,7 +17,7 @@
package model
-//KVRequest is http request body
+// KVRequest is http request body
type KVRequest struct {
Key string `json:"key" yaml:"key"`
Value string `json:"value,omitempty"
yaml:"value,omitempty"`
@@ -26,31 +26,31 @@ type KVRequest struct {
Labels map[string]string `json:"labels,omitempty"
yaml:"labels,omitempty"` //redundant
}
-//KVResponse represents the key value list
+// KVResponse represents the key value list
type KVResponse struct {
Total int `json:"total"`
Data []*KVDoc `json:"data"`
}
-//LabelDocResponse is label struct
+// LabelDocResponse is label struct
type LabelDocResponse struct {
Labels map[string]string `json:"labels,omitempty"`
}
-//LabelHistoryResponse is label history revision struct
+// LabelHistoryResponse is label history revision struct
type LabelHistoryResponse struct {
Labels map[string]string `json:"labels,omitempty"`
KVs []*KVDoc `json:"data,omitempty"`
Revision int `json:"revision"`
}
-//ViewResponse represents the view list
+// ViewResponse represents the view list
type ViewResponse struct {
Total int `json:"total,omitempty"`
Data []*ViewDoc `json:"data,omitempty"`
}
-//DocResponseSingleKey is response doc
+// DocResponseSingleKey is response doc
type DocResponseSingleKey struct {
CreateRevision int64 `json:"create_revision"`
CreateTime string `json:"create_time"`
@@ -64,19 +64,19 @@ type DocResponseSingleKey struct {
ValueType string `json:"value_type"`
}
-//DocResponseGetKey is response doc
+// DocResponseGetKey is response doc
type DocResponseGetKey struct {
Data []*DocResponseSingleKey `json:"data"`
Total int64 `json:"total"`
}
-//DocRespOfUpload is response doc
+// DocRespOfUpload is response doc
type DocRespOfUpload struct {
Success []*KVDoc `json:"success"`
Failure []*DocFailedOfUpload `json:"failure"`
}
-//DocFailedOfUpload is reponse doc
+// DocFailedOfUpload is reponse doc
type DocFailedOfUpload struct {
Key string `json:"key"`
Labels map[string]string `json:"labels"`
@@ -84,13 +84,13 @@ type DocFailedOfUpload struct {
ErrMsg string `json:"error_message"`
}
-//PollingDataResponse is response doc
+// PollingDataResponse is response doc
type PollingDataResponse struct {
Data []*PollingDetail `json:"data"`
Total int `json:"total"`
}
-//DocHealthCheck is response doc
+// DocHealthCheck is response doc
type DocHealthCheck struct {
Version string `json:"version"`
Revision string `json:"revision"`
diff --git a/pkg/stringutil/string_util.go b/pkg/stringutil/string_util.go
index 0e0ab86..3ed0789 100644
--- a/pkg/stringutil/string_util.go
+++ b/pkg/stringutil/string_util.go
@@ -27,7 +27,7 @@ const (
LabelNone = "none"
)
-//FormatMap format map to string
+// FormatMap format map to string
func FormatMap(m map[string]string) string {
if len(m) == 0 {
return LabelNone
diff --git a/pkg/util/util.go b/pkg/util/util.go
index bd83a89..fba4f51 100644
--- a/pkg/util/util.go
+++ b/pkg/util/util.go
@@ -19,8 +19,8 @@ package util
import "reflect"
-//IsEquivalentLabel compares whether two labels are equal.
-//In particular, if one is nil and another is an empty map, it return true
+// IsEquivalentLabel compares whether two labels are equal.
+// In particular, if one is nil and another is an empty map, it return true
func IsEquivalentLabel(x, y map[string]string) bool {
if len(x) == 0 && len(y) == 0 {
return true
diff --git a/server/cache/long_polling.go b/server/cache/long_polling.go
index b1162ce..2032478 100644
--- a/server/cache/long_polling.go
+++ b/server/cache/long_polling.go
@@ -9,7 +9,7 @@ import (
var pollingCache = &LongPollingCache{}
-//LongPollingCache exchange space for time
+// LongPollingCache exchange space for time
type LongPollingCache struct {
m sync.Map
}
@@ -23,8 +23,8 @@ func CachedKV() *LongPollingCache {
return pollingCache
}
-//Read reads the cached query result
-//only need to filter by labels if match pattern is exact
+// Read reads the cached query result
+// only need to filter by labels if match pattern is exact
func (c *LongPollingCache) Read(topic string) (int64, *model.KVResponse,
*errsvc.Error) {
value, ok := c.m.Load(topic)
if !ok {
diff --git a/server/config/config.go b/server/config/config.go
index 3fc852c..cb8db17 100644
--- a/server/config/config.go
+++ b/server/config/config.go
@@ -25,10 +25,10 @@ import (
"gopkg.in/yaml.v2"
)
-//Configurations is kie config items
+// Configurations is kie config items
var Configurations = &Config{}
-//Init initiate config files
+// Init initiate config files
func Init() error {
if err := archaius.AddFile(Configurations.ConfigFile,
archaius.WithFileHandler(util.UseFileNameAsKeyContentAsValue)); err != nil {
return err
@@ -38,12 +38,12 @@ func Init() error {
return yaml.Unmarshal([]byte(content), Configurations)
}
-//GetDB return db configs
+// GetDB return db configs
func GetDB() DB {
return Configurations.DB
}
-//GetRBAC return rbac config
+// GetRBAC return rbac config
func GetRBAC() RBAC {
return Configurations.RBAC
}
diff --git a/server/config/struct.go b/server/config/struct.go
index 6cc4e74..8526030 100644
--- a/server/config/struct.go
+++ b/server/config/struct.go
@@ -17,7 +17,7 @@
package config
-//Config is yaml file struct
+// Config is yaml file struct
type Config struct {
DB DB `yaml:"db"`
RBAC RBAC `yaml:"rbac"`
@@ -39,7 +39,7 @@ type TLS struct {
VerifyPeer bool `yaml:"verifyPeer"`
}
-//DB is yaml file struct to set persistent config
+// DB is yaml file struct to set persistent config
type DB struct {
TLS `yaml:",inline" json:",inline"`
URI string `yaml:"uri" json:"uri,omitempty"`
@@ -48,7 +48,7 @@ type DB struct {
Timeout string `yaml:"timeout" json:"timeout,omitempty"`
}
-//RBAC is rbac config
+// RBAC is rbac config
type RBAC struct {
Enabled bool `yaml:"enabled"`
PubKeyFile string `yaml:"rsaPublicKeyFile"`
diff --git a/server/config/tlsutil/tlsutil.go b/server/config/tlsutil/tlsutil.go
index 059336a..662c923 100644
--- a/server/config/tlsutil/tlsutil.go
+++ b/server/config/tlsutil/tlsutil.go
@@ -20,7 +20,7 @@ package tlsutil
import (
"crypto/tls"
"errors"
- "io/ioutil"
+ "os"
"github.com/apache/servicecomb-kie/pkg/cipherutil"
"github.com/apache/servicecomb-kie/server/config"
@@ -34,7 +34,7 @@ var ErrRootCAMissing = errors.New("rootCAFile is empty in
config file")
func Config(c *config.TLS) (*tls.Config, error) {
var password string
if c.CertPwdFile != "" {
- pwdBytes, err := ioutil.ReadFile(c.CertPwdFile)
+ pwdBytes, err := os.ReadFile(c.CertPwdFile)
if err != nil {
openlog.Error("read cert password file failed: " +
err.Error())
return nil, err
diff --git a/server/datasource/dao.go b/server/datasource/dao.go
index ffd5510..7a4870e 100644
--- a/server/datasource/dao.go
+++ b/server/datasource/dao.go
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-//package dao supply pure persistence layer access
+// package dao supply pure persistence layer access
package datasource
import (
@@ -48,14 +48,14 @@ const (
ConfigResource = "config"
)
-//New init db session
+// New init db session
type New func(c *Config) (Broker, error)
func RegisterPlugin(name string, f New) {
plugins[name] = f
}
-//Broker avoid directly depend on one kind of persistence solution
+// Broker avoid directly depend on one kind of persistence solution
type Broker interface {
GetRevisionDao() RevisionDao
GetHistoryDao() HistoryDao
@@ -67,7 +67,7 @@ func GetBroker() Broker {
return b
}
-//KVDao provide api of KV entity
+// KVDao provide api of KV entity
type KVDao interface {
// Create Update List are usually for admin console
Create(ctx context.Context, kv *model.KVDoc, options ...WriteOption)
(*model.KVDoc, error)
@@ -85,26 +85,26 @@ type KVDao interface {
Total(ctx context.Context, project, domain string) (int64, error)
}
-//HistoryDao provide api of History entity
+// HistoryDao provide api of History entity
type HistoryDao interface {
AddHistory(ctx context.Context, kv *model.KVDoc) error
GetHistory(ctx context.Context, keyID, project, domain string, options
...FindOption) (*model.KVResponse, error)
DelayDeletionTime(ctx context.Context, kvIDs []string, project, domain
string) error
}
-//TrackDao provide api of Track entity
+// TrackDao provide api of Track entity
type TrackDao interface {
CreateOrUpdate(ctx context.Context, detail *model.PollingDetail)
(*model.PollingDetail, error)
GetPollingDetail(ctx context.Context, detail *model.PollingDetail)
([]*model.PollingDetail, error)
}
-//RevisionDao is global revision number management
+// RevisionDao is global revision number management
type RevisionDao interface {
GetRevision(ctx context.Context, domain string) (int64, error)
ApplyRevision(ctx context.Context, domain string) (int64, error)
}
-//ViewDao create update and get view data
+// ViewDao create update and get view data
type ViewDao interface {
Create(ctx context.Context, viewDoc *model.ViewDoc, options
...FindOption) error
Update(ctx context.Context, viewDoc *model.ViewDoc) error
@@ -128,7 +128,7 @@ func Init(kind string) error {
return nil
}
-//ClearPart remove domain and project of kv
+// ClearPart remove domain and project of kv
func ClearPart(kv *model.KVDoc) {
kv.Domain = ""
kv.Project = ""
diff --git a/server/datasource/etcd/counter/revision.go
b/server/datasource/etcd/counter/revision.go
index d1471cc..6788da4 100644
--- a/server/datasource/etcd/counter/revision.go
+++ b/server/datasource/etcd/counter/revision.go
@@ -28,11 +28,11 @@ import (
const revision = "revision_counter"
-//Dao is the implementation
+// Dao is the implementation
type Dao struct {
}
-//GetRevision return current revision number
+// GetRevision return current revision number
func (s *Dao) GetRevision(ctx context.Context, domain string) (int64, error) {
kv, err := etcdadpt.Get(ctx, key.Counter(revision, domain))
if err != nil {
@@ -45,7 +45,7 @@ func (s *Dao) GetRevision(ctx context.Context, domain string)
(int64, error) {
return kv.Version, nil
}
-//ApplyRevision increase revision number and return modified value
+// ApplyRevision increase revision number and return modified value
func (s *Dao) ApplyRevision(ctx context.Context, domain string) (int64, error)
{
resp, err := etcdadpt.PutBytesAndGet(ctx, key.Counter(revision,
domain), nil)
if err != nil {
diff --git a/server/datasource/etcd/history/history_dao.go
b/server/datasource/etcd/history/history_dao.go
index feec630..4139684 100644
--- a/server/datasource/etcd/history/history_dao.go
+++ b/server/datasource/etcd/history/history_dao.go
@@ -29,11 +29,11 @@ import (
"github.com/apache/servicecomb-kie/server/datasource/etcd/key"
)
-//Dao is the implementation
+// Dao is the implementation
type Dao struct {
}
-//GetHistory get all history by label id
+// GetHistory get all history by label id
func (s *Dao) GetHistory(ctx context.Context, kvID, project, domain string,
options ...datasource.FindOption) (*model.KVResponse, error) {
opts := datasource.FindOptions{}
for _, o := range options {
@@ -78,7 +78,7 @@ func pagingResult(histories []*model.KVDoc, offset, limit
int64) []*model.KVDoc
return histories[offset:end]
}
-//AddHistory add kv history
+// AddHistory add kv history
func (s *Dao) AddHistory(ctx context.Context, kv *model.KVDoc) error {
bytes, err := json.Marshal(kv)
if err != nil {
@@ -98,8 +98,8 @@ func (s *Dao) AddHistory(ctx context.Context, kv
*model.KVDoc) error {
return nil
}
-//DelayDeletionTime add delete time to all revisions of the kv,
-//thus these revisions will be automatically deleted by TTL index.
+// DelayDeletionTime add delete time to all revisions of the kv,
+// thus these revisions will be automatically deleted by TTL index.
// TODO support delay deletion
func (s *Dao) DelayDeletionTime(ctx context.Context, kvIDs []string, project,
domain string) error {
var opts []etcdadpt.OpOptions
@@ -114,7 +114,7 @@ func (s *Dao) DelayDeletionTime(ctx context.Context, kvIDs
[]string, project, do
return nil
}
-//historyRotate delete historical versions for a key that exceeds the limited
number
+// historyRotate delete historical versions for a key that exceeds the limited
number
func (s *Dao) historyRotate(ctx context.Context, kvID, project, domain string)
error {
resp, err := s.GetHistory(ctx, kvID, project, domain)
if err != nil {
diff --git a/server/datasource/etcd/kv/kv_dao.go
b/server/datasource/etcd/kv/kv_dao.go
index d7e317a..93cfc39 100644
--- a/server/datasource/etcd/kv/kv_dao.go
+++ b/server/datasource/etcd/kv/kv_dao.go
@@ -33,7 +33,7 @@ import (
"github.com/apache/servicecomb-kie/server/datasource/etcd/key"
)
-//Dao operate data in mongodb
+// Dao operate data in mongodb
type Dao struct {
}
@@ -99,7 +99,7 @@ func txnCreate(ctx context.Context, kv *model.KVDoc) (bool,
error) {
return resp.Succeeded, nil
}
-//Update update key value
+// Update update key value
func (s *Dao) Update(ctx context.Context, kv *model.KVDoc, options
...datasource.WriteOption) error {
keyKV := key.KV(kv.Domain, kv.Project, kv.ID)
resp, err := etcdadpt.Get(ctx, keyKV)
@@ -169,14 +169,14 @@ func update(ctx context.Context, kv *model.KVDoc, options
...datasource.WriteOpt
return etcdadpt.PutBytes(ctx, keyKV, kvBytes)
}
-//Extract key values
+// Extract key values
func getValue(str string) string {
rex := regexp.MustCompile(`\(([^)]+)\)`)
res := rex.FindStringSubmatch(str)
return res[len(res)-1]
}
-//Exist supports you query a key value by label map or labels id
+// Exist supports you query a key value by label map or labels id
func (s *Dao) Exist(ctx context.Context, key, project, domain string, options
...datasource.FindOption) (bool, error) {
opts := datasource.FindOptions{Key: key}
for _, o := range options {
@@ -200,8 +200,8 @@ func (s *Dao) Exist(ctx context.Context, key, project,
domain string, options ..
return true, nil
}
-//FindOneAndDelete deletes one kv by id and return the deleted kv as these
appeared before deletion
-//domain=tenant
+// FindOneAndDelete deletes one kv by id and return the deleted kv as these
appeared before deletion
+// domain=tenant
func (s *Dao) FindOneAndDelete(ctx context.Context, kvID, project, domain
string, options ...datasource.WriteOption) (*model.KVDoc, error) {
opts := datasource.NewWriteOptions(options...)
if opts.SyncEnable {
@@ -287,7 +287,7 @@ func getKVDoc(ctx context.Context, domain, project, kvID
string) (*model.KVDoc,
return curKV, nil
}
-//FindManyAndDelete deletes multiple kvs and return the deleted kv list as
these appeared before deletion
+// FindManyAndDelete deletes multiple kvs and return the deleted kv list as
these appeared before deletion
func (s *Dao) FindManyAndDelete(ctx context.Context, kvIDs []string, project,
domain string, options ...datasource.WriteOption) ([]*model.KVDoc, int64,
error) {
opts := datasource.NewWriteOptions(options...)
if opts.SyncEnable {
@@ -395,7 +395,7 @@ func txnFindManyAndDelete(ctx context.Context, kvIDs
[]string, project, domain s
return docs, int64(successKVNum), nil
}
-//Get get kv by kv id
+// Get get kv by kv id
func (s *Dao) Get(ctx context.Context, req *model.GetKVRequest) (*model.KVDoc,
error) {
resp, err := etcdadpt.Get(ctx, key.KV(req.Domain, req.Project, req.ID))
if err != nil {
@@ -423,7 +423,7 @@ func (s *Dao) Total(ctx context.Context, project, domain
string) (int64, error)
return total, err
}
-//List get kv list by key and criteria
+// List get kv list by key and criteria
func (s *Dao) List(ctx context.Context, project, domain string, options
...datasource.FindOption) (*model.KVResponse, error) {
opts := datasource.NewDefaultFindOpts()
for _, o := range options {
diff --git a/server/datasource/etcd/track/polling_detail_dao.go
b/server/datasource/etcd/track/polling_detail_dao.go
index 8e29083..58bd183 100644
--- a/server/datasource/etcd/track/polling_detail_dao.go
+++ b/server/datasource/etcd/track/polling_detail_dao.go
@@ -28,12 +28,12 @@ import (
"github.com/little-cui/etcdadpt"
)
-//Dao is the implementation
+// Dao is the implementation
type Dao struct {
}
-//CreateOrUpdate create a record or update exist record
-//If revision and session_id exists then update else insert
+// CreateOrUpdate create a record or update exist record
+// If revision and session_id exists then update else insert
func (s *Dao) CreateOrUpdate(ctx context.Context, detail *model.PollingDetail)
(*model.PollingDetail, error) {
bytes, err := json.Marshal(detail)
if err != nil {
@@ -48,7 +48,7 @@ func (s *Dao) CreateOrUpdate(ctx context.Context, detail
*model.PollingDetail) (
return detail, nil
}
-//GetPollingDetail is to get a track data
+// GetPollingDetail is to get a track data
func (s *Dao) GetPollingDetail(ctx context.Context, detail
*model.PollingDetail) ([]*model.PollingDetail, error) {
kvs, n, err := etcdadpt.List(ctx, key.TrackList(detail.Domain,
detail.Project))
if err != nil {
diff --git a/server/datasource/mongo/counter/revision.go
b/server/datasource/mongo/counter/revision.go
index 1fb42bb..1a2c9e8 100644
--- a/server/datasource/mongo/counter/revision.go
+++ b/server/datasource/mongo/counter/revision.go
@@ -31,11 +31,11 @@ import (
const revision = "revision_counter"
-//Dao is the implementation
+// Dao is the implementation
type Dao struct {
}
-//GetRevision return current revision number
+// GetRevision return current revision number
func (s *Dao) GetRevision(ctx context.Context, domain string) (int64, error) {
collection :=
mongo.GetClient().GetDB().Collection(model.CollectionCounter)
filter := bson.M{"name": revision, "domain": domain}
@@ -59,7 +59,7 @@ func (s *Dao) GetRevision(ctx context.Context, domain string)
(int64, error) {
return c.Count, nil
}
-//ApplyRevision increase revision number and return modified value
+// ApplyRevision increase revision number and return modified value
func (s *Dao) ApplyRevision(ctx context.Context, domain string) (int64, error)
{
collection :=
mongo.GetClient().GetDB().Collection(model.CollectionCounter)
filter := bson.M{"name": revision, "domain": domain}
diff --git a/server/datasource/mongo/counter/struct.go
b/server/datasource/mongo/counter/struct.go
index 07ed5bf..87f5505 100644
--- a/server/datasource/mongo/counter/struct.go
+++ b/server/datasource/mongo/counter/struct.go
@@ -17,7 +17,7 @@
package counter
-//Counter is db schema
+// Counter is db schema
type Counter struct {
Name string `bson:"name,omitempty"`
Count int64 `bson:"count,omitempty"`
diff --git a/server/datasource/mongo/history/history_dao.go
b/server/datasource/mongo/history/history_dao.go
index b8906f4..b8b3252 100644
--- a/server/datasource/mongo/history/history_dao.go
+++ b/server/datasource/mongo/history/history_dao.go
@@ -33,11 +33,11 @@ import (
mmodel "github.com/apache/servicecomb-kie/server/datasource/mongo/model"
)
-//Dao is the implementation
+// Dao is the implementation
type Dao struct {
}
-//GetHistory get all history by label id
+// GetHistory get all history by label id
func (s *Dao) GetHistory(ctx context.Context, kvID, project, domain string,
options ...datasource.FindOption) (*model.KVResponse, error) {
var filter primitive.M
opts := datasource.FindOptions{}
@@ -94,7 +94,7 @@ func getHistoryByKeyID(ctx context.Context, filter bson.M,
offset, limit int64)
return result, nil
}
-//AddHistory add kv history
+// AddHistory add kv history
func (s *Dao) AddHistory(ctx context.Context, kv *model.KVDoc) error {
collection :=
mongo.GetClient().GetDB().Collection(mmodel.CollectionKVRevision)
_, err := collection.InsertOne(ctx, kv)
@@ -110,8 +110,8 @@ func (s *Dao) AddHistory(ctx context.Context, kv
*model.KVDoc) error {
return nil
}
-//DelayDeletionTime add delete time to all revisions of the kv,
-//thus these revisions will be automatically deleted by TTL index.
+// DelayDeletionTime add delete time to all revisions of the kv,
+// thus these revisions will be automatically deleted by TTL index.
func (s *Dao) DelayDeletionTime(ctx context.Context, kvIDs []string, project,
domain string) error {
collection :=
mongo.GetClient().GetDB().Collection(mmodel.CollectionKVRevision)
now := time.Now()
@@ -132,7 +132,7 @@ func (s *Dao) DelayDeletionTime(ctx context.Context, kvIDs
[]string, project, do
return nil
}
-//historyRotate delete historical versions for a key that exceeds the limited
number
+// historyRotate delete historical versions for a key that exceeds the limited
number
func historyRotate(ctx context.Context, kvID, project, domain string) error {
filter := bson.M{"id": kvID, "domain": domain, "project": project}
collection :=
mongo.GetClient().GetDB().Collection(mmodel.CollectionKVRevision)
diff --git a/server/datasource/mongo/kv/kv_dao.go
b/server/datasource/mongo/kv/kv_dao.go
index 1338fae..5f70e51 100644
--- a/server/datasource/mongo/kv/kv_dao.go
+++ b/server/datasource/mongo/kv/kv_dao.go
@@ -41,7 +41,7 @@ const (
FmtErrFindKvFailed = "can not find kv in %s"
)
-//Dao operate data in mongodb
+// Dao operate data in mongodb
type Dao struct {
}
@@ -133,7 +133,7 @@ func txnCreate(ctx context.Context, kv *model.KVDoc)
(*model.KVDoc, error) {
return kv, nil
}
-//Update update key value
+// Update update key value
func (s *Dao) Update(ctx context.Context, kv *model.KVDoc, options
...datasource.WriteOption) error {
opts := datasource.NewWriteOptions(options...)
// if syncEnable is true, will create kv with task
@@ -246,7 +246,7 @@ func txnUpdate(ctx context.Context, kv *model.KVDoc) error {
return nil
}
-//Extract key values
+// Extract key values
func getValue(str string) string {
rex := regexp.MustCompile(`\(([^)]+)\)`)
res := rex.FindStringSubmatch(str)
@@ -326,7 +326,7 @@ func findOneKey(ctx context.Context, filter bson.M)
([]*model.KVDoc, error) {
return []*model.KVDoc{curKV}, nil
}
-//Exist supports you query a key value by label map or labels id
+// Exist supports you query a key value by label map or labels id
func (s *Dao) Exist(ctx context.Context, key, project, domain string, options
...datasource.FindOption) (bool, error) {
opts := datasource.FindOptions{}
for _, o := range options {
@@ -359,8 +359,8 @@ func (s *Dao) Exist(ctx context.Context, key, project,
domain string, options ..
}
-//FindOneAndDelete deletes one kv by id and return the deleted kv as these
appeared before deletion
-//domain=tenant
+// FindOneAndDelete deletes one kv by id and return the deleted kv as these
appeared before deletion
+// domain=tenant
func (s *Dao) FindOneAndDelete(ctx context.Context, kvID, project, domain
string, options ...datasource.WriteOption) (*model.KVDoc, error) {
opts := datasource.NewWriteOptions(options...)
if opts.SyncEnable {
@@ -486,7 +486,7 @@ func txnFindOneAndDelete(ctx context.Context, kvID,
project, domain string) (*mo
return curKV, nil
}
-//FindManyAndDelete deletes multiple kvs and return the deleted kv list as
these appeared before deletion
+// FindManyAndDelete deletes multiple kvs and return the deleted kv list as
these appeared before deletion
func (s *Dao) FindManyAndDelete(ctx context.Context, kvIDs []string, project,
domain string, options ...datasource.WriteOption) ([]*model.KVDoc, int64,
error) {
opts := datasource.NewWriteOptions(options...)
if opts.SyncEnable {
@@ -642,9 +642,9 @@ func findKeys(ctx context.Context, filter interface{},
withoutLabel bool) ([]*mo
return kvs, nil
}
-//findKVByLabel get kvs by key and label
-//key can be empty, then it will return all key values
-//if key is given, will return 0-1 key value
+// findKVByLabel get kvs by key and label
+// key can be empty, then it will return all key values
+// if key is given, will return 0-1 key value
func findKVByLabel(ctx context.Context, domain, labelFormat, key string,
project string) ([]*model.KVDoc, error) {
filter := bson.M{"label_format": labelFormat, "domain": domain,
"project": project}
if key != "" {
@@ -655,7 +655,7 @@ func findKVByLabel(ctx context.Context, domain,
labelFormat, key string, project
}
-//Get get kv by kv id
+// Get get kv by kv id
func (s *Dao) Get(ctx context.Context, req *model.GetKVRequest) (*model.KVDoc,
error) {
filter := bson.M{"id": req.ID, "domain": req.Domain, "project":
req.Project}
kvs, err := findOneKey(ctx, filter)
@@ -677,7 +677,7 @@ func (s *Dao) Total(ctx context.Context, project, domain
string) (int64, error)
return total, err
}
-//List get kv list by key and criteria
+// List get kv list by key and criteria
func (s *Dao) List(ctx context.Context, project, domain string, options
...datasource.FindOption) (*model.KVResponse, error) {
opts := datasource.NewDefaultFindOpts()
for _, o := range options {
diff --git a/server/datasource/mongo/track/polling_detail_dao.go
b/server/datasource/mongo/track/polling_detail_dao.go
index 27ceae8..1deadce 100644
--- a/server/datasource/mongo/track/polling_detail_dao.go
+++ b/server/datasource/mongo/track/polling_detail_dao.go
@@ -31,12 +31,12 @@ import (
mmodel "github.com/apache/servicecomb-kie/server/datasource/mongo/model"
)
-//Dao is the implementation
+// Dao is the implementation
type Dao struct {
}
-//CreateOrUpdate create a record or update exist record
-//If revision and session_id exists then update else insert
+// CreateOrUpdate create a record or update exist record
+// If revision and session_id exists then update else insert
func (s *Dao) CreateOrUpdate(ctx context.Context, detail *model.PollingDetail)
(*model.PollingDetail, error) {
collection :=
dmongo.GetClient().GetDB().Collection(mmodel.CollectionPollingDetail)
queryFilter := bson.M{"revision": detail.Revision, "domain":
detail.Domain, "session_id": detail.SessionID}
@@ -63,7 +63,7 @@ func (s *Dao) CreateOrUpdate(ctx context.Context, detail
*model.PollingDetail) (
return detail, nil
}
-//Get is to get a track data
+// Get is to get a track data
func (s *Dao) GetPollingDetail(ctx context.Context, detail
*model.PollingDetail) ([]*model.PollingDetail, error) {
collection :=
dmongo.GetClient().GetDB().Collection(mmodel.CollectionPollingDetail)
queryFilter := bson.M{"domain": detail.Domain}
diff --git a/server/datasource/options.go b/server/datasource/options.go
index 5d80af0..086dd01 100644
--- a/server/datasource/options.go
+++ b/server/datasource/options.go
@@ -26,7 +26,7 @@ const DefaultTimeout = 60 * time.Second
type Config struct {
}
-//NewDefaultFindOpts return default options
+// NewDefaultFindOpts return default options
func NewDefaultFindOpts() FindOptions {
return FindOptions{
Timeout: DefaultTimeout,
@@ -56,7 +56,7 @@ type WriteOptions struct {
SyncEnable bool
}
-//FindOptions is option to find key value
+// FindOptions is option to find key value
type FindOptions struct {
ExactLabels bool
Status string
@@ -76,7 +76,7 @@ type FindOptions struct {
// WriteOption is functional option to create, update and delete kv
type WriteOption func(*WriteOptions)
-//FindOption is functional option to find key value
+// FindOption is functional option to find key value
type FindOption func(*FindOptions)
// WithSync indicates that the synchronization function is on
@@ -86,63 +86,63 @@ func WithSync(enabled bool) WriteOption {
}
}
-//WithExactLabels tell model service to return only one kv matches the labels
+// WithExactLabels tell model service to return only one kv matches the labels
func WithExactLabels() FindOption {
return func(o *FindOptions) {
o.ExactLabels = true
}
}
-//WithID find by kvID
+// WithID find by kvID
func WithID(id string) FindOption {
return func(o *FindOptions) {
o.ID = id
}
}
-//WithKey find by key
+// WithKey find by key
func WithKey(key string) FindOption {
return func(o *FindOptions) {
o.Key = key
}
}
-//WithStatus enabled/disabled
+// WithStatus enabled/disabled
func WithStatus(status string) FindOption {
return func(o *FindOptions) {
o.Status = status
}
}
-//WithTimeout will return err if execution take too long
+// WithTimeout will return err if execution take too long
func WithTimeout(d time.Duration) FindOption {
return func(o *FindOptions) {
o.Timeout = d
}
}
-//WithLabels find kv by labels
+// WithLabels find kv by labels
func WithLabels(labels map[string]string) FindOption {
return func(o *FindOptions) {
o.Labels = labels
}
}
-//WithLabelFormat find kv by label string
+// WithLabelFormat find kv by label string
func WithLabelFormat(label string) FindOption {
return func(o *FindOptions) {
o.LabelFormat = label
}
}
-//WithLimit tells service paging limit
+// WithLimit tells service paging limit
func WithLimit(l int64) FindOption {
return func(o *FindOptions) {
o.Limit = l
}
}
-//WithOffset tells service paging offset
+// WithOffset tells service paging offset
func WithOffset(os int64) FindOption {
return func(o *FindOptions) {
o.Offset = os
diff --git a/server/handler/track_handler.go b/server/handler/track_handler.go
index 30e2f8a..29328e1 100644
--- a/server/handler/track_handler.go
+++ b/server/handler/track_handler.go
@@ -34,15 +34,15 @@ import (
"github.com/go-chassis/openlog"
)
-//const of noop auth handler
+// const of noop auth handler
const (
TrackHandlerName = "track-handler"
)
-//TrackHandler tracks polling data
+// TrackHandler tracks polling data
type TrackHandler struct{}
-//Handle set local attribute to http request
+// Handle set local attribute to http request
func (h *TrackHandler) Handle(chain *handler.Chain, inv
*invocation.Invocation, cb invocation.ResponseCallBack) {
req, ok := inv.Args.(*restful.Request)
if !ok {
@@ -105,7 +105,7 @@ func newTrackHandler() handler.Handler {
return &TrackHandler{}
}
-//Name is handler name
+// Name is handler name
func (h *TrackHandler) Name() string {
return TrackHandlerName
}
diff --git a/server/plugin/qms/quota.go b/server/plugin/qms/quota.go
index 14aff5b..303775f 100644
--- a/server/plugin/qms/quota.go
+++ b/server/plugin/qms/quota.go
@@ -26,13 +26,13 @@ import (
"github.com/go-chassis/openlog"
)
-//const
+// const
const (
DefaultQuota = 10000
QuotaConfigKey = "QUOTA_CONFIG"
)
-//BuildInManager read env config to max config item number, and db total usage
+// BuildInManager read env config to max config item number, and db total usage
// it is not a centralized QMS.
type BuildInManager struct {
}
@@ -45,7 +45,7 @@ func (m *BuildInManager) GetQuota(domain, project, resource
string) (*quota.Quot
panic("implement me")
}
-//GetQuotas get usage and quota
+// GetQuotas get usage and quota
func (m *BuildInManager) GetQuotas(domain, project string) ([]*quota.Quota,
error) {
max := archaius.GetInt64(QuotaConfigKey, DefaultQuota)
total, err := datasource.GetBroker().GetKVDao().Total(context.TODO(),
project, domain)
@@ -59,12 +59,12 @@ func (m *BuildInManager) GetQuotas(domain, project string)
([]*quota.Quota, erro
}}, nil
}
-//IncreaseUsed no use
+// IncreaseUsed no use
func (m *BuildInManager) IncreaseUsed(domain, project, resource string, used
int64) error {
return nil
}
-//DecreaseUsed no use
+// DecreaseUsed no use
func (m *BuildInManager) DecreaseUsed(domain, project, resource string, used
int64) error {
return nil
}
diff --git a/server/pubsub/bus.go b/server/pubsub/bus.go
index 45a3118..7210369 100644
--- a/server/pubsub/bus.go
+++ b/server/pubsub/bus.go
@@ -34,7 +34,7 @@ import (
var once sync.Once
var bus *Bus
-//const
+// const
const (
EventKVChange = "kv-chg"
DefaultEventBatchSize = 5000
@@ -47,12 +47,12 @@ func Topics() *sync.Map {
return &topics
}
-//Bus is message bug
+// Bus is message bug
type Bus struct {
agent *agent.Agent
}
-//Init create serf agent
+// Init create serf agent
func Init() {
once.Do(func() {
ac := agent.DefaultConfig()
@@ -98,7 +98,7 @@ func splitHostPort(advertiseAddr string, defaultHost string,
defaultPort int) (s
return host, p
}
-//Start start serf agent
+// Start start serf agent
func Start() {
err := bus.agent.Start()
if err != nil {
@@ -125,7 +125,7 @@ func join(addresses []string) error {
return nil
}
-//Publish send event
+// Publish send event
func Publish(event *KVChangeEvent) error {
b, err := json.Marshal(event)
if err != nil {
@@ -135,7 +135,7 @@ func Publish(event *KVChangeEvent) error {
}
-//AddObserver observe key changes by (key or labels) or (key and labels)
+// AddObserver observe key changes by (key or labels) or (key and labels)
func AddObserver(o *Observer, topic *Topic) (string, error) {
t, err := topic.Encode()
if err != nil {
diff --git a/server/pubsub/event_handler.go b/server/pubsub/event_handler.go
index e6ecdb7..afa95fe 100644
--- a/server/pubsub/event_handler.go
+++ b/server/pubsub/event_handler.go
@@ -32,11 +32,11 @@ func RegisterHandler(typ string, h agent.EventHandler) {
openlog.Info("register handler for:" + typ)
}
-//ClusterEventHandler handler serf custom event, it is singleton
+// ClusterEventHandler handler serf custom event, it is singleton
type ClusterEventHandler struct {
}
-//HandleEvent send event to subscribers
+// HandleEvent send event to subscribers
func (h *ClusterEventHandler) HandleEvent(e serf.Event) {
openlog.Debug("receive event:" + e.EventType().String())
switch e.EventType().String() {
diff --git a/server/pubsub/notifier/kv.go b/server/pubsub/notifier/kv.go
index 634f1c3..889941d 100644
--- a/server/pubsub/notifier/kv.go
+++ b/server/pubsub/notifier/kv.go
@@ -13,7 +13,7 @@ import (
"github.com/hashicorp/serf/serf"
)
-//KVHandler handler serf custom event, it is singleton
+// KVHandler handler serf custom event, it is singleton
type KVHandler struct {
BatchSize int
BatchInterval time.Duration
diff --git a/server/pubsub/options.go b/server/pubsub/options.go
index 87e7757..14e2541 100644
--- a/server/pubsub/options.go
+++ b/server/pubsub/options.go
@@ -17,7 +17,7 @@
package pubsub
-//Options is serf options
+// Options is serf options
type Options struct {
BindAddr string
AdvertiseAddr string
diff --git a/server/pubsub/struct.go b/server/pubsub/struct.go
index 5ec65cd..d4ed789 100644
--- a/server/pubsub/struct.go
+++ b/server/pubsub/struct.go
@@ -33,7 +33,7 @@ const (
ActionDelete = "del"
)
-//KVChangeEvent is event between kie nodes, and broadcast by serf
+// KVChangeEvent is event between kie nodes, and broadcast by serf
type KVChangeEvent struct {
Key string
Action string //include: put,delete
@@ -46,14 +46,14 @@ func (e *KVChangeEvent) String() string {
return strings.Join([]string{e.Key, e.Action,
stringutil.FormatMap(e.Labels), e.DomainID, e.Project}, ";;")
}
-//NewKVChangeEvent create a struct base on event payload
+// NewKVChangeEvent create a struct base on event payload
func NewKVChangeEvent(payload []byte) (*KVChangeEvent, error) {
ke := &KVChangeEvent{}
err := json.Unmarshal(payload, ke)
return ke, err
}
-//Topic can be subscribe
+// Topic can be subscribe
type Topic struct {
Labels map[string]string `json:"-"`
LabelsFormat string `json:"labels,omitempty"`
@@ -71,7 +71,7 @@ func (t *Topic) Encode() (string, error) {
return string(b), nil
}
-//ParseTopic parse topic string to topic struct
+// ParseTopic parse topic string to topic struct
func ParseTopic(s string) (*Topic, error) {
t := &Topic{
Labels: make(map[string]string),
@@ -96,12 +96,12 @@ func ParseTopic(s string) (*Topic, error) {
return t, err
}
-//Match compare event with topic
-//If the match type is set to exact in long pulling request, only update
request with exactly
-//the same label of pulling request will match the request and will trigger an
immediate return.
+// Match compare event with topic
+// If the match type is set to exact in long pulling request, only update
request with exactly
+// the same label of pulling request will match the request and will trigger
an immediate return.
//
-//If the match type is not set, it will be matched when pulling request labels
is equal to
-//update request labels or a subset of it.
+// If the match type is not set, it will be matched when pulling request
labels is equal to
+// update request labels or a subset of it.
func (t *Topic) Match(event *KVChangeEvent) bool {
match := false
if t.MatchType == common.PatternExact {
@@ -121,7 +121,7 @@ func (t *Topic) Match(event *KVChangeEvent) bool {
return match
}
-//Observer represents a client polling request
+// Observer represents a client polling request
type Observer struct {
UUID string
Event chan *KVChangeEvent
diff --git a/server/rbac/rbac.go b/server/rbac/rbac.go
index 659cfd9..b7614fa 100644
--- a/server/rbac/rbac.go
+++ b/server/rbac/rbac.go
@@ -18,8 +18,8 @@
package rbac
import (
- "io/ioutil"
"net/http"
+ "os"
"path/filepath"
"strings"
@@ -36,7 +36,7 @@ const (
pubContentKey = "rbac.publicKey"
)
-//Init initialize the rbac module
+// Init initialize the rbac module
func Init() {
if !config.GetRBAC().Enabled {
openlog.Info("rbac is disabled")
@@ -74,10 +74,10 @@ func Init() {
openlog.Info("rbac is enabled")
}
-//loadPublicKey read key to memory
+// loadPublicKey read key to memory
func loadPublicKey() {
pf := config.GetRBAC().PubKeyFile
- content, err := ioutil.ReadFile(filepath.Clean(pf))
+ content, err := os.ReadFile(filepath.Clean(pf))
if err != nil {
openlog.Fatal(err.Error())
return
@@ -88,7 +88,7 @@ func loadPublicKey() {
}
}
-//PublicKey get public key to verify a token
+// PublicKey get public key to verify a token
func PublicKey() string {
return archaius.GetString(pubContentKey, "")
}
diff --git a/server/resource/v1/admin_resource.go
b/server/resource/v1/admin_resource.go
index 0edb732..4d79eb1 100644
--- a/server/resource/v1/admin_resource.go
+++ b/server/resource/v1/admin_resource.go
@@ -34,7 +34,7 @@ import (
type AdminResource struct {
}
-//URLPatterns defined config operations
+// URLPatterns defined config operations
func (r *AdminResource) URLPatterns() []restful.Route {
return []restful.Route{
{
@@ -55,7 +55,7 @@ func (r *AdminResource) URLPatterns() []restful.Route {
}
}
-//HealthCheck provider version info and time info
+// HealthCheck provider version info and time info
func (r *AdminResource) HealthCheck(context *restful.Context) {
domain := ReadDomain(context.Ctx)
resp := &model.DocHealthCheck{}
diff --git a/server/resource/v1/common.go b/server/resource/v1/common.go
index 4baff07..2f19140 100644
--- a/server/resource/v1/common.go
+++ b/server/resource/v1/common.go
@@ -43,7 +43,7 @@ import (
"gopkg.in/yaml.v2"
)
-//const of server
+// const of server
const (
HeaderUserAgent = "User-Agent"
HeaderSessionID = "X-Session-Id"
@@ -65,7 +65,7 @@ func NewObserver() (*pubsub.Observer, error) {
}, nil
}
-//err
+// err
var (
ErrInvalidRev = errors.New(common.MsgInvalidRev)
@@ -74,7 +74,7 @@ var (
ErrIDIsNil = errors.New("id is empty")
)
-//ReadClaims get auth info
+// ReadClaims get auth info
func ReadClaims(ctx context.Context) map[string]interface{} {
c, err := rbac.FromContext(ctx)
if err != nil {
@@ -83,7 +83,7 @@ func ReadClaims(ctx context.Context) map[string]interface{} {
return c
}
-//ReadDomain get domain info
+// ReadDomain get domain info
func ReadDomain(ctx context.Context) string {
c := ReadClaims(ctx)
if c != nil {
@@ -92,8 +92,8 @@ func ReadDomain(ctx context.Context) string {
return "default"
}
-//ReadLabelCombinations get query combination from url
-//q=app:default+service:payment&q=app:default
+// ReadLabelCombinations get query combination from url
+// q=app:default+service:payment&q=app:default
func ReadLabelCombinations(req *goRestful.Request) ([]map[string]string,
error) {
queryCombinations := req.QueryParameters(common.QueryParamQ)
labelCombinations := make([]map[string]string, 0)
@@ -119,7 +119,7 @@ func ReadLabelCombinations(req *goRestful.Request)
([]map[string]string, error)
return labelCombinations, nil
}
-//WriteErrResponse write error message to client
+// WriteErrResponse write error message to client
func WriteErrResponse(context *restful.Context, code int32, msg string) {
configErr := config.NewError(code, msg)
context.Resp.Header().Set(goRestful.HEADER_ContentType,
goRestful.MIME_JSON)
diff --git a/server/resource/v1/doc_struct.go b/server/resource/v1/doc_struct.go
index 8a3ddac..6241738 100644
--- a/server/resource/v1/doc_struct.go
+++ b/server/resource/v1/doc_struct.go
@@ -25,7 +25,7 @@ import (
"github.com/go-chassis/go-chassis/v2/server/restful"
)
-//swagger doc request header params
+// swagger doc request header params
var (
DocHeaderDepth = &restful.Parameters{
DataType: "string",
@@ -49,7 +49,7 @@ var (
}
)
-//swagger doc response header params
+// swagger doc response header params
var (
DocHeaderRevision = goRestful.Header{
Items: &goRestful.Items{
@@ -59,7 +59,7 @@ var (
}
)
-//swagger doc query params
+// swagger doc query params
var (
DocQueryCombination = &restful.Parameters{
DataType: "string",
@@ -154,7 +154,7 @@ var (
}
)
-//swagger doc path params
+// swagger doc path params
var (
DocPathProject = &restful.Parameters{
DataType: "string",
@@ -170,7 +170,7 @@ var (
}
)
-//KVCreateBody is open api doc
+// KVCreateBody is open api doc
type KVCreateBody struct {
Key string `json:"key"`
Labels map[string]string `json:"labels"`
@@ -179,13 +179,13 @@ type KVCreateBody struct {
ValueType string `json:"value_type"`
}
-//KVUploadBody is open api doc
+// KVUploadBody is open api doc
type KVUploadBody struct {
MetaData MetaData `json:"metadata"`
Data []*model.KVDoc `json:"data"`
}
-//MetaData is extra info
+// MetaData is extra info
type MetaData struct {
Version string `json:"version"`
Annotations Annotations `json:"annotations"`
@@ -194,18 +194,18 @@ type MetaData struct {
type Annotations struct {
}
-//KVUpdateBody is open api doc
+// KVUpdateBody is open api doc
type KVUpdateBody struct {
Status string `json:"status"`
Value string `json:"value"`
}
-//DeleteBody is the request body struct of delete multiple kvs interface
+// DeleteBody is the request body struct of delete multiple kvs interface
type DeleteBody struct {
IDs []string `json:"ids"`
}
-//ErrorMsg is open api doc
+// ErrorMsg is open api doc
type ErrorMsg struct {
Msg string `json:"error_msg"`
}
diff --git a/server/resource/v1/history_resource.go
b/server/resource/v1/history_resource.go
index 3a4b016..09cd019 100644
--- a/server/resource/v1/history_resource.go
+++ b/server/resource/v1/history_resource.go
@@ -30,11 +30,11 @@ import (
"github.com/go-chassis/openlog"
)
-//HistoryResource TODO
+// HistoryResource TODO
type HistoryResource struct {
}
-//GetRevisions search key only by label
+// GetRevisions search key only by label
func (r *HistoryResource) GetRevisions(context *restful.Context) {
var err error
kvID := context.ReadPathParameter(common.PathParamKVID)
@@ -69,7 +69,7 @@ func (r *HistoryResource) GetRevisions(context
*restful.Context) {
}
}
-//GetPollingData get the record of the get or list history
+// GetPollingData get the record of the get or list history
func (r *HistoryResource) GetPollingData(context *restful.Context) {
query := &model.PollingDetail{}
sessionID := context.ReadQueryParameter(common.QueryParamSessionID)
@@ -121,7 +121,7 @@ func (r *HistoryResource) GetPollingData(context
*restful.Context) {
}
}
-//URLPatterns defined config operations
+// URLPatterns defined config operations
func (r *HistoryResource) URLPatterns() []restful.Route {
return []restful.Route{
{
diff --git a/server/resource/v1/kv_resource.go
b/server/resource/v1/kv_resource.go
index a017022..1fc087a 100644
--- a/server/resource/v1/kv_resource.go
+++ b/server/resource/v1/kv_resource.go
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-//Package v1 hold http rest v1 API
+// Package v1 hold http rest v1 API
package v1
import (
@@ -38,11 +38,11 @@ import (
kvsvc "github.com/apache/servicecomb-kie/server/service/kv"
)
-//KVResource has API about kv operations
+// KVResource has API about kv operations
type KVResource struct {
}
-//Upload upload kvs
+// Upload upload kvs
func (r *KVResource) Upload(rctx *restful.Context) {
if rctx.ReadQueryParameter(common.QueryParamOverride) == "" {
WriteErrResponse(rctx, config.ErrInvalidParams, "Query
parameter 'override' is required")
@@ -66,7 +66,7 @@ func (r *KVResource) Upload(rctx *restful.Context) {
}
}
-//Post create a kv
+// Post create a kv
func (r *KVResource) Post(rctx *restful.Context) {
var err error
kv := new(model.KVDoc)
@@ -88,7 +88,7 @@ func (r *KVResource) Post(rctx *restful.Context) {
}
}
-//Put update a kv
+// Put update a kv
func (r *KVResource) Put(rctx *restful.Context) {
var err error
kvID := rctx.ReadPathParameter(common.PathParamKVID)
@@ -136,7 +136,7 @@ func (r *KVResource) Put(rctx *restful.Context) {
}
-//Get search key by kv id
+// Get search key by kv id
func (r *KVResource) Get(rctx *restful.Context) {
request := &model.GetKVRequest{
Project: rctx.ReadPathParameter(common.PathParameterProject),
@@ -166,7 +166,7 @@ func (r *KVResource) Get(rctx *restful.Context) {
}
}
-//List response kv list
+// List response kv list
func (r *KVResource) List(rctx *restful.Context) {
var err error
request := &model.ListKVRequest{
@@ -277,7 +277,7 @@ func watch(rctx *restful.Context, request
*model.ListKVRequest, wait string) boo
return false
}
-//Delete deletes one kv by id
+// Delete deletes one kv by id
func (r *KVResource) Delete(rctx *restful.Context) {
project := rctx.ReadPathParameter(common.PathParameterProject)
domain := ReadDomain(rctx.Ctx)
@@ -313,7 +313,7 @@ func (r *KVResource) Delete(rctx *restful.Context) {
rctx.WriteHeader(http.StatusNoContent)
}
-//DeleteList deletes multiple kvs by ids
+// DeleteList deletes multiple kvs by ids
func (r *KVResource) DeleteList(rctx *restful.Context) {
project := rctx.ReadPathParameter(common.PathParameterProject)
domain := ReadDomain(rctx.Ctx)
@@ -355,7 +355,7 @@ func (r *KVResource) DeleteList(rctx *restful.Context) {
rctx.WriteHeader(http.StatusNoContent)
}
-//URLPatterns defined config operations
+// URLPatterns defined config operations
func (r *KVResource) URLPatterns() []restful.Route {
return []restful.Route{
{
diff --git a/server/service/kv/kv_svc.go b/server/service/kv/kv_svc.go
index 57c6f41..ec49ea2 100644
--- a/server/service/kv/kv_svc.go
+++ b/server/service/kv/kv_svc.go
@@ -66,9 +66,9 @@ func ListKV(ctx context.Context, request
*model.ListKVRequest) (int64, *model.KV
return rev, kv, nil
}
-//Create get latest revision from history
-//and increase revision of label
-//and insert key
+// Create get latest revision from history
+// and increase revision of label
+// and insert key
func Create(ctx context.Context, kv *model.KVDoc) (*model.KVDoc,
*errsvc.Error) {
if kv.Status == "" {
kv.Status = common.StatusDisabled
@@ -209,7 +209,7 @@ func Publish(kv *model.KVDoc) {
openlog.Info(fmt.Sprintf("post [%s] success", kv.ID))
}
-//Update update key value and add new revision
+// Update update key value and add new revision
func Update(ctx context.Context, kv *model.UpdateKVRequest) (*model.KVDoc,
error) {
oldKV, err := datasource.GetBroker().GetKVDao().Get(ctx,
&model.GetKVRequest{
Domain: kv.Domain,