mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-23 14:48:19 +08:00
Compare commits
35 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
077b6072fa | ||
|
|
0cafb1164b | ||
|
|
90afa08367 | ||
|
|
c92f788292 | ||
|
|
e94be9b302 | ||
|
|
e713d9013d | ||
|
|
24d6150073 | ||
|
|
44cddec5c3 | ||
|
|
47d13e5ef8 | ||
|
|
896e1a2abb | ||
|
|
075817a8dd | ||
|
|
29400f6814 | ||
|
|
34f536264f | ||
|
|
9d9c7e0fe0 | ||
|
|
e220d3a4cb | ||
|
|
193dcf90bc | ||
|
|
03756c9166 | ||
|
|
c1f12c5784 | ||
|
|
2883111af5 | ||
|
|
2758c4e842 | ||
|
|
4196ddb3e3 | ||
|
|
e24d797226 | ||
|
|
d4349fa958 | ||
|
|
da2c14d45f | ||
|
|
64e3aeda55 | ||
|
|
dedba17219 | ||
|
|
c6348b9855 | ||
|
|
8689a6247e | ||
|
|
ff6ee25d23 | ||
|
|
5213243bbb | ||
|
|
2588a36555 | ||
|
|
c2421beb25 | ||
|
|
dfe8a81c76 | ||
|
|
ee643a945e | ||
|
|
eeda6efae7 |
6
.github/workflows/go.yml
vendored
6
.github/workflows/go.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
|||||||
- name: Set up Go 1.x
|
- name: Set up Go 1.x
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.20'
|
go-version-file: go.mod
|
||||||
check-latest: true
|
check-latest: true
|
||||||
cache: true
|
cache: true
|
||||||
id: go
|
id: go
|
||||||
@@ -52,8 +52,8 @@ jobs:
|
|||||||
- name: Set up Go 1.x
|
- name: Set up Go 1.x
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
# use 1.20 to guarantee Go 1.20 compatibility
|
# make sure Go version compatible with go-zero
|
||||||
go-version: '1.20'
|
go-version-file: go.mod
|
||||||
check-latest: true
|
check-latest: true
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
|
|||||||
2
.github/workflows/release.yaml
vendored
2
.github/workflows/release.yaml
vendored
@@ -22,7 +22,7 @@ jobs:
|
|||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
goos: ${{ matrix.goos }}
|
goos: ${{ matrix.goos }}
|
||||||
goarch: ${{ matrix.goarch }}
|
goarch: ${{ matrix.goarch }}
|
||||||
goversion: "https://dl.google.com/go/go1.19.13.linux-amd64.tar.gz"
|
goversion: "https://dl.google.com/go/go1.20.14.linux-amd64.tar.gz"
|
||||||
project_path: "tools/goctl"
|
project_path: "tools/goctl"
|
||||||
binary_name: "goctl"
|
binary_name: "goctl"
|
||||||
extra_files: tools/goctl/readme.md tools/goctl/readme-cn.md
|
extra_files: tools/goctl/readme.md tools/goctl/readme-cn.md
|
||||||
200
core/configcenter/configurator.go
Normal file
200
core/configcenter/configurator.go
Normal file
@@ -0,0 +1,200 @@
|
|||||||
|
package configurator
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"reflect"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/configcenter/subscriber"
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
"github.com/zeromicro/go-zero/core/mapping"
|
||||||
|
"github.com/zeromicro/go-zero/core/threading"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
errEmptyConfig = errors.New("empty config value")
|
||||||
|
errMissingUnmarshalerType = errors.New("missing unmarshaler type")
|
||||||
|
)
|
||||||
|
|
||||||
|
// Configurator is the interface for configuration center.
|
||||||
|
type Configurator[T any] interface {
|
||||||
|
// GetConfig returns the subscription value.
|
||||||
|
GetConfig() (T, error)
|
||||||
|
// AddListener adds a listener to the subscriber.
|
||||||
|
AddListener(listener func())
|
||||||
|
}
|
||||||
|
|
||||||
|
type (
|
||||||
|
// Config is the configuration for Configurator.
|
||||||
|
Config struct {
|
||||||
|
// Type is the value type, yaml, json or toml.
|
||||||
|
Type string `json:",default=yaml,options=[yaml,json,toml]"`
|
||||||
|
// Log is the flag to control logging.
|
||||||
|
Log bool `json:",default=true"`
|
||||||
|
}
|
||||||
|
|
||||||
|
configCenter[T any] struct {
|
||||||
|
conf Config
|
||||||
|
unmarshaler LoaderFn
|
||||||
|
subscriber subscriber.Subscriber
|
||||||
|
listeners []func()
|
||||||
|
lock sync.Mutex
|
||||||
|
snapshot atomic.Value
|
||||||
|
}
|
||||||
|
|
||||||
|
value[T any] struct {
|
||||||
|
data string
|
||||||
|
marshalData T
|
||||||
|
err error
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Configurator is the interface for configuration center.
|
||||||
|
var _ Configurator[any] = (*configCenter[any])(nil)
|
||||||
|
|
||||||
|
// MustNewConfigCenter returns a Configurator, exits on errors.
|
||||||
|
func MustNewConfigCenter[T any](c Config, subscriber subscriber.Subscriber) Configurator[T] {
|
||||||
|
cc, err := NewConfigCenter[T](c, subscriber)
|
||||||
|
logx.Must(err)
|
||||||
|
return cc
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewConfigCenter returns a Configurator.
|
||||||
|
func NewConfigCenter[T any](c Config, subscriber subscriber.Subscriber) (Configurator[T], error) {
|
||||||
|
unmarshaler, ok := Unmarshaler(strings.ToLower(c.Type))
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("unknown format: %s", c.Type)
|
||||||
|
}
|
||||||
|
|
||||||
|
cc := &configCenter[T]{
|
||||||
|
conf: c,
|
||||||
|
unmarshaler: unmarshaler,
|
||||||
|
subscriber: subscriber,
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := cc.loadConfig(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := cc.subscriber.AddListener(cc.onChange); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := cc.GetConfig(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return cc, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddListener adds listener to s.
|
||||||
|
func (c *configCenter[T]) AddListener(listener func()) {
|
||||||
|
c.lock.Lock()
|
||||||
|
defer c.lock.Unlock()
|
||||||
|
c.listeners = append(c.listeners, listener)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetConfig return structured config.
|
||||||
|
func (c *configCenter[T]) GetConfig() (T, error) {
|
||||||
|
v := c.value()
|
||||||
|
if v == nil || len(v.data) == 0 {
|
||||||
|
var empty T
|
||||||
|
return empty, errEmptyConfig
|
||||||
|
}
|
||||||
|
|
||||||
|
return v.marshalData, v.err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Value returns the subscription value.
|
||||||
|
func (c *configCenter[T]) Value() string {
|
||||||
|
v := c.value()
|
||||||
|
if v == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return v.data
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *configCenter[T]) loadConfig() error {
|
||||||
|
v, err := c.subscriber.Value()
|
||||||
|
if err != nil {
|
||||||
|
if c.conf.Log {
|
||||||
|
logx.Errorf("ConfigCenter loads changed configuration, error: %v", err)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.conf.Log {
|
||||||
|
logx.Infof("ConfigCenter loads changed configuration, content [%s]", v)
|
||||||
|
}
|
||||||
|
|
||||||
|
c.snapshot.Store(c.genValue(v))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *configCenter[T]) onChange() {
|
||||||
|
if err := c.loadConfig(); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.lock.Lock()
|
||||||
|
listeners := make([]func(), len(c.listeners))
|
||||||
|
copy(listeners, c.listeners)
|
||||||
|
c.lock.Unlock()
|
||||||
|
|
||||||
|
for _, l := range listeners {
|
||||||
|
threading.GoSafe(l)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *configCenter[T]) value() *value[T] {
|
||||||
|
content := c.snapshot.Load()
|
||||||
|
if content == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return content.(*value[T])
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *configCenter[T]) genValue(data string) *value[T] {
|
||||||
|
v := &value[T]{
|
||||||
|
data: data,
|
||||||
|
}
|
||||||
|
if len(data) == 0 {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
t := reflect.TypeOf(v.marshalData)
|
||||||
|
// if the type is nil, it means that the user has not set the type of the configuration.
|
||||||
|
if t == nil {
|
||||||
|
v.err = errMissingUnmarshalerType
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
t = mapping.Deref(t)
|
||||||
|
switch t.Kind() {
|
||||||
|
case reflect.Struct, reflect.Array, reflect.Slice:
|
||||||
|
if err := c.unmarshaler([]byte(data), &v.marshalData); err != nil {
|
||||||
|
v.err = err
|
||||||
|
if c.conf.Log {
|
||||||
|
logx.Errorf("ConfigCenter unmarshal configuration failed, err: %+v, content [%s]",
|
||||||
|
err.Error(), data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case reflect.String:
|
||||||
|
if str, ok := any(data).(T); ok {
|
||||||
|
v.marshalData = str
|
||||||
|
} else {
|
||||||
|
v.err = errMissingUnmarshalerType
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
if c.conf.Log {
|
||||||
|
logx.Errorf("ConfigCenter unmarshal configuration missing unmarshaler for type: %s, content [%s]",
|
||||||
|
t.Kind(), data)
|
||||||
|
}
|
||||||
|
v.err = errMissingUnmarshalerType
|
||||||
|
}
|
||||||
|
|
||||||
|
return v
|
||||||
|
}
|
||||||
233
core/configcenter/configurator_test.go
Normal file
233
core/configcenter/configurator_test.go
Normal file
@@ -0,0 +1,233 @@
|
|||||||
|
package configurator
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"sync"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestNewConfigCenter(t *testing.T) {
|
||||||
|
_, err := NewConfigCenter[any](Config{
|
||||||
|
Log: true,
|
||||||
|
}, &mockSubscriber{})
|
||||||
|
assert.Error(t, err)
|
||||||
|
|
||||||
|
_, err = NewConfigCenter[any](Config{
|
||||||
|
Type: "json",
|
||||||
|
Log: true,
|
||||||
|
}, &mockSubscriber{})
|
||||||
|
assert.Error(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestConfigCenter_GetConfig(t *testing.T) {
|
||||||
|
mock := &mockSubscriber{}
|
||||||
|
type Data struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
mock.v = `{"name": "go-zero"}`
|
||||||
|
c1, err := NewConfigCenter[Data](Config{
|
||||||
|
Type: "json",
|
||||||
|
Log: true,
|
||||||
|
}, mock)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
data, err := c1.GetConfig()
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, "go-zero", data.Name)
|
||||||
|
|
||||||
|
mock.v = `{"name": "111"}`
|
||||||
|
c2, err := NewConfigCenter[Data](Config{Type: "json"}, mock)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
mock.v = `{}`
|
||||||
|
c3, err := NewConfigCenter[string](Config{
|
||||||
|
Type: "json",
|
||||||
|
Log: true,
|
||||||
|
}, mock)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
_, err = c3.GetConfig()
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
data, err = c2.GetConfig()
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
mock.lisErr = errors.New("mock error")
|
||||||
|
_, err = NewConfigCenter[Data](Config{
|
||||||
|
Type: "json",
|
||||||
|
Log: true,
|
||||||
|
}, mock)
|
||||||
|
assert.Error(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestConfigCenter_onChange(t *testing.T) {
|
||||||
|
mock := &mockSubscriber{}
|
||||||
|
type Data struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
mock.v = `{"name": "go-zero"}`
|
||||||
|
c1, err := NewConfigCenter[Data](Config{Type: "json", Log: true}, mock)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
data, err := c1.GetConfig()
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, "go-zero", data.Name)
|
||||||
|
|
||||||
|
mock.v = `{"name": "go-zero2"}`
|
||||||
|
mock.change()
|
||||||
|
|
||||||
|
data, err = c1.GetConfig()
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, "go-zero2", data.Name)
|
||||||
|
|
||||||
|
mock.valErr = errors.New("mock error")
|
||||||
|
_, err = NewConfigCenter[Data](Config{Type: "json", Log: false}, mock)
|
||||||
|
assert.Error(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestConfigCenter_Value(t *testing.T) {
|
||||||
|
mock := &mockSubscriber{}
|
||||||
|
mock.v = "1234"
|
||||||
|
|
||||||
|
c, err := NewConfigCenter[string](Config{
|
||||||
|
Type: "json",
|
||||||
|
Log: true,
|
||||||
|
}, mock)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
cc := c.(*configCenter[string])
|
||||||
|
|
||||||
|
assert.Equal(t, cc.Value(), "1234")
|
||||||
|
|
||||||
|
mock.valErr = errors.New("mock error")
|
||||||
|
|
||||||
|
_, err = NewConfigCenter[any](Config{
|
||||||
|
Type: "json",
|
||||||
|
Log: true,
|
||||||
|
}, mock)
|
||||||
|
assert.Error(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestConfigCenter_AddListener(t *testing.T) {
|
||||||
|
mock := &mockSubscriber{}
|
||||||
|
mock.v = "1234"
|
||||||
|
c, err := NewConfigCenter[string](Config{
|
||||||
|
Type: "json",
|
||||||
|
Log: true,
|
||||||
|
}, mock)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
cc := c.(*configCenter[string])
|
||||||
|
var a, b int
|
||||||
|
var mutex sync.Mutex
|
||||||
|
cc.AddListener(func() {
|
||||||
|
mutex.Lock()
|
||||||
|
a = 1
|
||||||
|
mutex.Unlock()
|
||||||
|
})
|
||||||
|
cc.AddListener(func() {
|
||||||
|
mutex.Lock()
|
||||||
|
b = 2
|
||||||
|
mutex.Unlock()
|
||||||
|
})
|
||||||
|
|
||||||
|
assert.Equal(t, 2, len(cc.listeners))
|
||||||
|
|
||||||
|
mock.change()
|
||||||
|
|
||||||
|
time.Sleep(time.Millisecond * 100)
|
||||||
|
|
||||||
|
mutex.Lock()
|
||||||
|
assert.Equal(t, 1, a)
|
||||||
|
assert.Equal(t, 2, b)
|
||||||
|
mutex.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestConfigCenter_genValue(t *testing.T) {
|
||||||
|
t.Run("data is empty", func(t *testing.T) {
|
||||||
|
c := &configCenter[string]{
|
||||||
|
unmarshaler: registry.unmarshalers["json"],
|
||||||
|
conf: Config{Log: true},
|
||||||
|
}
|
||||||
|
v := c.genValue("")
|
||||||
|
assert.Equal(t, "", v.data)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("invalid template type", func(t *testing.T) {
|
||||||
|
c := &configCenter[any]{
|
||||||
|
unmarshaler: registry.unmarshalers["json"],
|
||||||
|
conf: Config{Log: true},
|
||||||
|
}
|
||||||
|
v := c.genValue("xxxx")
|
||||||
|
assert.Equal(t, errMissingUnmarshalerType, v.err)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("unsupported template type", func(t *testing.T) {
|
||||||
|
c := &configCenter[int]{
|
||||||
|
unmarshaler: registry.unmarshalers["json"],
|
||||||
|
conf: Config{Log: true},
|
||||||
|
}
|
||||||
|
v := c.genValue("1")
|
||||||
|
assert.Equal(t, errMissingUnmarshalerType, v.err)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("supported template string type", func(t *testing.T) {
|
||||||
|
c := &configCenter[string]{
|
||||||
|
unmarshaler: registry.unmarshalers["json"],
|
||||||
|
conf: Config{Log: true},
|
||||||
|
}
|
||||||
|
v := c.genValue("12345")
|
||||||
|
assert.NoError(t, v.err)
|
||||||
|
assert.Equal(t, "12345", v.data)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("unmarshal fail", func(t *testing.T) {
|
||||||
|
c := &configCenter[struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
}]{
|
||||||
|
unmarshaler: registry.unmarshalers["json"],
|
||||||
|
conf: Config{Log: true},
|
||||||
|
}
|
||||||
|
v := c.genValue(`{"name":"new name}`)
|
||||||
|
assert.Equal(t, `{"name":"new name}`, v.data)
|
||||||
|
assert.Error(t, v.err)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("success", func(t *testing.T) {
|
||||||
|
c := &configCenter[struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
}]{
|
||||||
|
unmarshaler: registry.unmarshalers["json"],
|
||||||
|
conf: Config{Log: true},
|
||||||
|
}
|
||||||
|
v := c.genValue(`{"name":"new name"}`)
|
||||||
|
assert.Equal(t, `{"name":"new name"}`, v.data)
|
||||||
|
assert.Equal(t, "new name", v.marshalData.Name)
|
||||||
|
assert.NoError(t, v.err)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
type mockSubscriber struct {
|
||||||
|
v string
|
||||||
|
lisErr, valErr error
|
||||||
|
listener func()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *mockSubscriber) AddListener(listener func()) error {
|
||||||
|
m.listener = listener
|
||||||
|
return m.lisErr
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *mockSubscriber) Value() (string, error) {
|
||||||
|
return m.v, m.valErr
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *mockSubscriber) change() {
|
||||||
|
if m.listener != nil {
|
||||||
|
m.listener()
|
||||||
|
}
|
||||||
|
}
|
||||||
67
core/configcenter/subscriber/etcd.go
Normal file
67
core/configcenter/subscriber/etcd.go
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
package subscriber
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/zeromicro/go-zero/core/discov"
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
// etcdSubscriber is a subscriber that subscribes to etcd.
|
||||||
|
etcdSubscriber struct {
|
||||||
|
*discov.Subscriber
|
||||||
|
}
|
||||||
|
|
||||||
|
// EtcdConf is the configuration for etcd.
|
||||||
|
EtcdConf = discov.EtcdConf
|
||||||
|
)
|
||||||
|
|
||||||
|
// MustNewEtcdSubscriber returns an etcd Subscriber, exits on errors.
|
||||||
|
func MustNewEtcdSubscriber(conf EtcdConf) Subscriber {
|
||||||
|
s, err := NewEtcdSubscriber(conf)
|
||||||
|
logx.Must(err)
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewEtcdSubscriber returns an etcd Subscriber.
|
||||||
|
func NewEtcdSubscriber(conf EtcdConf) (Subscriber, error) {
|
||||||
|
opts := buildSubOptions(conf)
|
||||||
|
s, err := discov.NewSubscriber(conf.Hosts, conf.Key, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &etcdSubscriber{Subscriber: s}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// buildSubOptions constructs the options for creating a new etcd subscriber.
|
||||||
|
func buildSubOptions(conf EtcdConf) []discov.SubOption {
|
||||||
|
opts := []discov.SubOption{
|
||||||
|
discov.WithExactMatch(),
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(conf.User) > 0 {
|
||||||
|
opts = append(opts, discov.WithSubEtcdAccount(conf.User, conf.Pass))
|
||||||
|
}
|
||||||
|
if len(conf.CertFile) > 0 || len(conf.CertKeyFile) > 0 || len(conf.CACertFile) > 0 {
|
||||||
|
opts = append(opts, discov.WithSubEtcdTLS(conf.CertFile, conf.CertKeyFile,
|
||||||
|
conf.CACertFile, conf.InsecureSkipVerify))
|
||||||
|
}
|
||||||
|
|
||||||
|
return opts
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddListener adds a listener to the subscriber.
|
||||||
|
func (s *etcdSubscriber) AddListener(listener func()) error {
|
||||||
|
s.Subscriber.AddListener(listener)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Value returns the value of the subscriber.
|
||||||
|
func (s *etcdSubscriber) Value() (string, error) {
|
||||||
|
vs := s.Subscriber.Values()
|
||||||
|
if len(vs) > 0 {
|
||||||
|
return vs[len(vs)-1], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
9
core/configcenter/subscriber/subscriber.go
Normal file
9
core/configcenter/subscriber/subscriber.go
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package subscriber
|
||||||
|
|
||||||
|
// Subscriber is the interface for configcenter subscribers.
|
||||||
|
type Subscriber interface {
|
||||||
|
// AddListener adds a listener to the subscriber.
|
||||||
|
AddListener(listener func()) error
|
||||||
|
// Value returns the value of the subscriber.
|
||||||
|
Value() (string, error)
|
||||||
|
}
|
||||||
41
core/configcenter/unmarshaler.go
Normal file
41
core/configcenter/unmarshaler.go
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
package configurator
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/conf"
|
||||||
|
)
|
||||||
|
|
||||||
|
var registry = &unmarshalerRegistry{
|
||||||
|
unmarshalers: map[string]LoaderFn{
|
||||||
|
"json": conf.LoadFromJsonBytes,
|
||||||
|
"toml": conf.LoadFromTomlBytes,
|
||||||
|
"yaml": conf.LoadFromYamlBytes,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
type (
|
||||||
|
// LoaderFn is the function type for loading configuration.
|
||||||
|
LoaderFn func([]byte, any) error
|
||||||
|
|
||||||
|
// unmarshalerRegistry is the registry for unmarshalers.
|
||||||
|
unmarshalerRegistry struct {
|
||||||
|
unmarshalers map[string]LoaderFn
|
||||||
|
mu sync.RWMutex
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// RegisterUnmarshaler registers an unmarshaler.
|
||||||
|
func RegisterUnmarshaler(name string, fn LoaderFn) {
|
||||||
|
registry.mu.Lock()
|
||||||
|
defer registry.mu.Unlock()
|
||||||
|
registry.unmarshalers[name] = fn
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unmarshaler returns the unmarshaler by name.
|
||||||
|
func Unmarshaler(name string) (LoaderFn, bool) {
|
||||||
|
registry.mu.RLock()
|
||||||
|
defer registry.mu.RUnlock()
|
||||||
|
fn, ok := registry.unmarshalers[name]
|
||||||
|
return fn, ok
|
||||||
|
}
|
||||||
28
core/configcenter/unmarshaler_test.go
Normal file
28
core/configcenter/unmarshaler_test.go
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
package configurator
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestRegisterUnmarshaler(t *testing.T) {
|
||||||
|
RegisterUnmarshaler("test", func(data []byte, v interface{}) error {
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
|
_, ok := Unmarshaler("test")
|
||||||
|
assert.True(t, ok)
|
||||||
|
|
||||||
|
_, ok = Unmarshaler("test2")
|
||||||
|
assert.False(t, ok)
|
||||||
|
|
||||||
|
_, ok = Unmarshaler("json")
|
||||||
|
assert.True(t, ok)
|
||||||
|
|
||||||
|
_, ok = Unmarshaler("toml")
|
||||||
|
assert.True(t, ok)
|
||||||
|
|
||||||
|
_, ok = Unmarshaler("yaml")
|
||||||
|
assert.True(t, ok)
|
||||||
|
}
|
||||||
@@ -10,13 +10,14 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"go.etcd.io/etcd/api/v3/v3rpc/rpctypes"
|
||||||
|
clientv3 "go.etcd.io/etcd/client/v3"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/contextx"
|
"github.com/zeromicro/go-zero/core/contextx"
|
||||||
"github.com/zeromicro/go-zero/core/lang"
|
"github.com/zeromicro/go-zero/core/lang"
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
"github.com/zeromicro/go-zero/core/syncx"
|
"github.com/zeromicro/go-zero/core/syncx"
|
||||||
"github.com/zeromicro/go-zero/core/threading"
|
"github.com/zeromicro/go-zero/core/threading"
|
||||||
"go.etcd.io/etcd/api/v3/v3rpc/rpctypes"
|
|
||||||
clientv3 "go.etcd.io/etcd/client/v3"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -45,7 +46,7 @@ func (r *Registry) GetConn(endpoints []string) (EtcdClient, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Monitor monitors the key on given etcd endpoints, notify with the given UpdateListener.
|
// Monitor monitors the key on given etcd endpoints, notify with the given UpdateListener.
|
||||||
func (r *Registry) Monitor(endpoints []string, key string, l UpdateListener) error {
|
func (r *Registry) Monitor(endpoints []string, key string, l UpdateListener, exactMatch bool) error {
|
||||||
c, exists := r.getCluster(endpoints)
|
c, exists := r.getCluster(endpoints)
|
||||||
// if exists, the existing values should be updated to the listener.
|
// if exists, the existing values should be updated to the listener.
|
||||||
if exists {
|
if exists {
|
||||||
@@ -55,7 +56,7 @@ func (r *Registry) Monitor(endpoints []string, key string, l UpdateListener) err
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.monitor(key, l)
|
return c.monitor(key, l, exactMatch)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Registry) getCluster(endpoints []string) (c *cluster, exists bool) {
|
func (r *Registry) getCluster(endpoints []string) (c *cluster, exists bool) {
|
||||||
@@ -86,6 +87,7 @@ type cluster struct {
|
|||||||
watchGroup *threading.RoutineGroup
|
watchGroup *threading.RoutineGroup
|
||||||
done chan lang.PlaceholderType
|
done chan lang.PlaceholderType
|
||||||
lock sync.RWMutex
|
lock sync.RWMutex
|
||||||
|
exactMatch bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func newCluster(endpoints []string) *cluster {
|
func newCluster(endpoints []string) *cluster {
|
||||||
@@ -224,7 +226,12 @@ func (c *cluster) load(cli EtcdClient, key string) int64 {
|
|||||||
for {
|
for {
|
||||||
var err error
|
var err error
|
||||||
ctx, cancel := context.WithTimeout(c.context(cli), RequestTimeout)
|
ctx, cancel := context.WithTimeout(c.context(cli), RequestTimeout)
|
||||||
resp, err = cli.Get(ctx, makeKeyPrefix(key), clientv3.WithPrefix())
|
if c.exactMatch {
|
||||||
|
resp, err = cli.Get(ctx, key)
|
||||||
|
} else {
|
||||||
|
resp, err = cli.Get(ctx, makeKeyPrefix(key), clientv3.WithPrefix())
|
||||||
|
}
|
||||||
|
|
||||||
cancel()
|
cancel()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
break
|
break
|
||||||
@@ -247,9 +254,10 @@ func (c *cluster) load(cli EtcdClient, key string) int64 {
|
|||||||
return resp.Header.Revision
|
return resp.Header.Revision
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cluster) monitor(key string, l UpdateListener) error {
|
func (c *cluster) monitor(key string, l UpdateListener, exactMatch bool) error {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
c.listeners[key] = append(c.listeners[key], l)
|
c.listeners[key] = append(c.listeners[key], l)
|
||||||
|
c.exactMatch = exactMatch
|
||||||
c.lock.Unlock()
|
c.lock.Unlock()
|
||||||
|
|
||||||
cli, err := c.getClient()
|
cli, err := c.getClient()
|
||||||
@@ -315,14 +323,20 @@ func (c *cluster) watch(cli EtcdClient, key string, rev int64) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *cluster) watchStream(cli EtcdClient, key string, rev int64) error {
|
func (c *cluster) watchStream(cli EtcdClient, key string, rev int64) error {
|
||||||
var rch clientv3.WatchChan
|
var (
|
||||||
if rev != 0 {
|
rch clientv3.WatchChan
|
||||||
rch = cli.Watch(clientv3.WithRequireLeader(c.context(cli)), makeKeyPrefix(key),
|
ops []clientv3.OpOption
|
||||||
clientv3.WithPrefix(), clientv3.WithRev(rev+1))
|
watchKey = key
|
||||||
} else {
|
)
|
||||||
rch = cli.Watch(clientv3.WithRequireLeader(c.context(cli)), makeKeyPrefix(key),
|
if !c.exactMatch {
|
||||||
clientv3.WithPrefix())
|
watchKey = makeKeyPrefix(key)
|
||||||
|
ops = append(ops, clientv3.WithPrefix())
|
||||||
}
|
}
|
||||||
|
if rev != 0 {
|
||||||
|
ops = append(ops, clientv3.WithRev(rev+1))
|
||||||
|
}
|
||||||
|
|
||||||
|
rch = cli.Watch(clientv3.WithRequireLeader(c.context(cli)), watchKey, ops...)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ func TestRegistry_Monitor(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
GetRegistry().lock.Unlock()
|
GetRegistry().lock.Unlock()
|
||||||
assert.Error(t, GetRegistry().Monitor(endpoints, "foo", new(mockListener)))
|
assert.Error(t, GetRegistry().Monitor(endpoints, "foo", new(mockListener), false))
|
||||||
}
|
}
|
||||||
|
|
||||||
type mockListener struct {
|
type mockListener struct {
|
||||||
|
|||||||
@@ -15,9 +15,10 @@ type (
|
|||||||
|
|
||||||
// A Subscriber is used to subscribe the given key on an etcd cluster.
|
// A Subscriber is used to subscribe the given key on an etcd cluster.
|
||||||
Subscriber struct {
|
Subscriber struct {
|
||||||
endpoints []string
|
endpoints []string
|
||||||
exclusive bool
|
exclusive bool
|
||||||
items *container
|
exactMatch bool
|
||||||
|
items *container
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -34,7 +35,7 @@ func NewSubscriber(endpoints []string, key string, opts ...SubOption) (*Subscrib
|
|||||||
}
|
}
|
||||||
sub.items = newContainer(sub.exclusive)
|
sub.items = newContainer(sub.exclusive)
|
||||||
|
|
||||||
if err := internal.GetRegistry().Monitor(endpoints, key, sub.items); err != nil {
|
if err := internal.GetRegistry().Monitor(endpoints, key, sub.items, sub.exactMatch); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,6 +60,13 @@ func Exclusive() SubOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithExactMatch turn off querying using key prefixes.
|
||||||
|
func WithExactMatch() SubOption {
|
||||||
|
return func(sub *Subscriber) {
|
||||||
|
sub.exactMatch = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// WithSubEtcdAccount provides the etcd username/password.
|
// WithSubEtcdAccount provides the etcd username/password.
|
||||||
func WithSubEtcdAccount(user, pass string) SubOption {
|
func WithSubEtcdAccount(user, pass string) SubOption {
|
||||||
return func(sub *Subscriber) {
|
return func(sub *Subscriber) {
|
||||||
|
|||||||
@@ -1,21 +1,17 @@
|
|||||||
package errorx
|
package errorx
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"errors"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
// BatchError is an error that can hold multiple errors.
|
||||||
// A BatchError is an error that can hold multiple errors.
|
type BatchError struct {
|
||||||
BatchError struct {
|
errs []error
|
||||||
errs errorArray
|
lock sync.RWMutex
|
||||||
lock sync.Mutex
|
}
|
||||||
}
|
|
||||||
|
|
||||||
errorArray []error
|
// Add adds one or more non-nil errors to the BatchError instance.
|
||||||
)
|
|
||||||
|
|
||||||
// Add adds errs to be, nil errors are ignored.
|
|
||||||
func (be *BatchError) Add(errs ...error) {
|
func (be *BatchError) Add(errs ...error) {
|
||||||
be.lock.Lock()
|
be.lock.Lock()
|
||||||
defer be.lock.Unlock()
|
defer be.lock.Unlock()
|
||||||
@@ -27,39 +23,20 @@ func (be *BatchError) Add(errs ...error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Err returns an error that represents all errors.
|
// Err returns an error that represents all accumulated errors.
|
||||||
|
// It returns nil if there are no errors.
|
||||||
func (be *BatchError) Err() error {
|
func (be *BatchError) Err() error {
|
||||||
be.lock.Lock()
|
be.lock.RLock()
|
||||||
defer be.lock.Unlock()
|
defer be.lock.RUnlock()
|
||||||
|
|
||||||
switch len(be.errs) {
|
// If there are no non-nil errors, errors.Join(...) returns nil.
|
||||||
case 0:
|
return errors.Join(be.errs...)
|
||||||
return nil
|
|
||||||
case 1:
|
|
||||||
return be.errs[0]
|
|
||||||
default:
|
|
||||||
return be.errs
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NotNil checks if any error inside.
|
// NotNil checks if there is at least one error inside the BatchError.
|
||||||
func (be *BatchError) NotNil() bool {
|
func (be *BatchError) NotNil() bool {
|
||||||
be.lock.Lock()
|
be.lock.RLock()
|
||||||
defer be.lock.Unlock()
|
defer be.lock.RUnlock()
|
||||||
|
|
||||||
return len(be.errs) > 0
|
return len(be.errs) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error returns a string that represents inside errors.
|
|
||||||
func (ea errorArray) Error() string {
|
|
||||||
var buf bytes.Buffer
|
|
||||||
|
|
||||||
for i := range ea {
|
|
||||||
if i > 0 {
|
|
||||||
buf.WriteByte('\n')
|
|
||||||
}
|
|
||||||
buf.WriteString(ea[i].Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
return buf.String()
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -66,3 +66,82 @@ func TestBatchErrorConcurrentAdd(t *testing.T) {
|
|||||||
assert.Equal(t, count, len(batch.errs))
|
assert.Equal(t, count, len(batch.errs))
|
||||||
assert.True(t, batch.NotNil())
|
assert.True(t, batch.NotNil())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestBatchError_Unwrap(t *testing.T) {
|
||||||
|
t.Run("nil", func(t *testing.T) {
|
||||||
|
var be BatchError
|
||||||
|
assert.Nil(t, be.Err())
|
||||||
|
assert.True(t, errors.Is(be.Err(), nil))
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("one error", func(t *testing.T) {
|
||||||
|
var errFoo = errors.New("foo")
|
||||||
|
var errBar = errors.New("bar")
|
||||||
|
var be BatchError
|
||||||
|
be.Add(errFoo)
|
||||||
|
assert.True(t, errors.Is(be.Err(), errFoo))
|
||||||
|
assert.False(t, errors.Is(be.Err(), errBar))
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("two errors", func(t *testing.T) {
|
||||||
|
var errFoo = errors.New("foo")
|
||||||
|
var errBar = errors.New("bar")
|
||||||
|
var errBaz = errors.New("baz")
|
||||||
|
var be BatchError
|
||||||
|
be.Add(errFoo)
|
||||||
|
be.Add(errBar)
|
||||||
|
assert.True(t, errors.Is(be.Err(), errFoo))
|
||||||
|
assert.True(t, errors.Is(be.Err(), errBar))
|
||||||
|
assert.False(t, errors.Is(be.Err(), errBaz))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBatchError_Add(t *testing.T) {
|
||||||
|
var be BatchError
|
||||||
|
|
||||||
|
// Test adding nil errors
|
||||||
|
be.Add(nil, nil)
|
||||||
|
assert.False(t, be.NotNil(), "Expected BatchError to be empty after adding nil errors")
|
||||||
|
|
||||||
|
// Test adding non-nil errors
|
||||||
|
err1 := errors.New("error 1")
|
||||||
|
err2 := errors.New("error 2")
|
||||||
|
be.Add(err1, err2)
|
||||||
|
assert.True(t, be.NotNil(), "Expected BatchError to be non-empty after adding errors")
|
||||||
|
|
||||||
|
// Test adding a mix of nil and non-nil errors
|
||||||
|
err3 := errors.New("error 3")
|
||||||
|
be.Add(nil, err3, nil)
|
||||||
|
assert.True(t, be.NotNil(), "Expected BatchError to be non-empty after adding a mix of nil and non-nil errors")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBatchError_Err(t *testing.T) {
|
||||||
|
var be BatchError
|
||||||
|
|
||||||
|
// Test Err() on empty BatchError
|
||||||
|
assert.Nil(t, be.Err(), "Expected nil error for empty BatchError")
|
||||||
|
|
||||||
|
// Test Err() with multiple errors
|
||||||
|
err1 := errors.New("error 1")
|
||||||
|
err2 := errors.New("error 2")
|
||||||
|
be.Add(err1, err2)
|
||||||
|
|
||||||
|
combinedErr := be.Err()
|
||||||
|
assert.NotNil(t, combinedErr, "Expected nil error for BatchError with multiple errors")
|
||||||
|
|
||||||
|
// Check if the combined error contains both error messages
|
||||||
|
errString := combinedErr.Error()
|
||||||
|
assert.Truef(t, errors.Is(combinedErr, err1), "Combined error doesn't contain first error: %s", errString)
|
||||||
|
assert.Truef(t, errors.Is(combinedErr, err2), "Combined error doesn't contain second error: %s", errString)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBatchError_NotNil(t *testing.T) {
|
||||||
|
var be BatchError
|
||||||
|
|
||||||
|
// Test NotNil() on empty BatchError
|
||||||
|
assert.Nil(t, be.Err(), "Expected nil error for empty BatchError")
|
||||||
|
|
||||||
|
// Test NotNil() after adding an error
|
||||||
|
be.Add(errors.New("test error"))
|
||||||
|
assert.NotNil(t, be.Err(), "Expected non-nil error after adding an error")
|
||||||
|
}
|
||||||
|
|||||||
@@ -42,4 +42,6 @@ type LogConf struct {
|
|||||||
// daily: daily rotation.
|
// daily: daily rotation.
|
||||||
// size: size limited rotation.
|
// size: size limited rotation.
|
||||||
Rotation string `json:",default=daily,options=[daily,size]"`
|
Rotation string `json:",default=daily,options=[daily,size]"`
|
||||||
|
// FileTimeFormat represents the time format for file name, default is `2006-01-02T15:04:05.000Z07:00`.
|
||||||
|
FileTimeFormat string `json:",optional"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -294,6 +294,10 @@ func SetUp(c LogConf) (err error) {
|
|||||||
timeFormat = c.TimeFormat
|
timeFormat = c.TimeFormat
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(c.FileTimeFormat) > 0 {
|
||||||
|
fileTimeFormat = c.FileTimeFormat
|
||||||
|
}
|
||||||
|
|
||||||
atomic.StoreUint32(&maxContentLength, c.MaxContentLength)
|
atomic.StoreUint32(&maxContentLength, c.MaxContentLength)
|
||||||
|
|
||||||
switch c.Encoding {
|
switch c.Encoding {
|
||||||
|
|||||||
@@ -850,12 +850,13 @@ func doTestStructedLogConsole(t *testing.T, w *mockWriter, write func(...any)) {
|
|||||||
func testSetLevelTwiceWithMode(t *testing.T, mode string, w *mockWriter) {
|
func testSetLevelTwiceWithMode(t *testing.T, mode string, w *mockWriter) {
|
||||||
writer.Store(nil)
|
writer.Store(nil)
|
||||||
SetUp(LogConf{
|
SetUp(LogConf{
|
||||||
Mode: mode,
|
Mode: mode,
|
||||||
Level: "debug",
|
Level: "debug",
|
||||||
Path: "/dev/null",
|
Path: "/dev/null",
|
||||||
Encoding: plainEncoding,
|
Encoding: plainEncoding,
|
||||||
Stat: false,
|
Stat: false,
|
||||||
TimeFormat: time.RFC3339,
|
TimeFormat: time.RFC3339,
|
||||||
|
FileTimeFormat: time.DateTime,
|
||||||
})
|
})
|
||||||
SetUp(LogConf{
|
SetUp(LogConf{
|
||||||
Mode: mode,
|
Mode: mode,
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
dateFormat = "2006-01-02"
|
dateFormat = "2006-01-02"
|
||||||
fileTimeFormat = time.RFC3339
|
|
||||||
hoursPerDay = 24
|
hoursPerDay = 24
|
||||||
bufferSize = 100
|
bufferSize = 100
|
||||||
defaultDirMode = 0o755
|
defaultDirMode = 0o755
|
||||||
@@ -28,8 +27,12 @@ const (
|
|||||||
megaBytes = 1 << 20
|
megaBytes = 1 << 20
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrLogFileClosed is an error that indicates the log file is already closed.
|
var (
|
||||||
var ErrLogFileClosed = errors.New("error: log file closed")
|
// ErrLogFileClosed is an error that indicates the log file is already closed.
|
||||||
|
ErrLogFileClosed = errors.New("error: log file closed")
|
||||||
|
|
||||||
|
fileTimeFormat = time.RFC3339
|
||||||
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
// A RotateRule interface is used to define the log rotating rules.
|
// A RotateRule interface is used to define the log rotating rules.
|
||||||
|
|||||||
29
go.mod
29
go.mod
@@ -16,13 +16,13 @@ require (
|
|||||||
github.com/jhump/protoreflect v1.16.0
|
github.com/jhump/protoreflect v1.16.0
|
||||||
github.com/olekukonko/tablewriter v0.0.5
|
github.com/olekukonko/tablewriter v0.0.5
|
||||||
github.com/pelletier/go-toml/v2 v2.2.2
|
github.com/pelletier/go-toml/v2 v2.2.2
|
||||||
github.com/prometheus/client_golang v1.19.1
|
github.com/prometheus/client_golang v1.20.2
|
||||||
github.com/redis/go-redis/v9 v9.6.1
|
github.com/redis/go-redis/v9 v9.6.1
|
||||||
github.com/spaolacci/murmur3 v1.1.0
|
github.com/spaolacci/murmur3 v1.1.0
|
||||||
github.com/stretchr/testify v1.9.0
|
github.com/stretchr/testify v1.9.0
|
||||||
go.etcd.io/etcd/api/v3 v3.5.15
|
go.etcd.io/etcd/api/v3 v3.5.15
|
||||||
go.etcd.io/etcd/client/v3 v3.5.15
|
go.etcd.io/etcd/client/v3 v3.5.15
|
||||||
go.mongodb.org/mongo-driver v1.16.0
|
go.mongodb.org/mongo-driver v1.16.1
|
||||||
go.opentelemetry.io/otel v1.24.0
|
go.opentelemetry.io/otel v1.24.0
|
||||||
go.opentelemetry.io/otel/exporters/jaeger v1.17.0
|
go.opentelemetry.io/otel/exporters/jaeger v1.17.0
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0
|
||||||
@@ -33,9 +33,9 @@ require (
|
|||||||
go.opentelemetry.io/otel/trace v1.24.0
|
go.opentelemetry.io/otel/trace v1.24.0
|
||||||
go.uber.org/automaxprocs v1.5.3
|
go.uber.org/automaxprocs v1.5.3
|
||||||
go.uber.org/goleak v1.3.0
|
go.uber.org/goleak v1.3.0
|
||||||
golang.org/x/net v0.27.0
|
golang.org/x/net v0.28.0
|
||||||
golang.org/x/sys v0.22.0
|
golang.org/x/sys v0.24.0
|
||||||
golang.org/x/time v0.5.0
|
golang.org/x/time v0.6.0
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d
|
google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d
|
||||||
google.golang.org/grpc v1.65.0
|
google.golang.org/grpc v1.65.0
|
||||||
google.golang.org/protobuf v1.34.2
|
google.golang.org/protobuf v1.34.2
|
||||||
@@ -80,7 +80,8 @@ require (
|
|||||||
github.com/jackc/puddle/v2 v2.2.1 // indirect
|
github.com/jackc/puddle/v2 v2.2.1 // indirect
|
||||||
github.com/josharian/intern v1.0.0 // indirect
|
github.com/josharian/intern v1.0.0 // indirect
|
||||||
github.com/json-iterator/go v1.1.12 // indirect
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
github.com/klauspost/compress v1.17.8 // indirect
|
github.com/klauspost/compress v1.17.9 // indirect
|
||||||
|
github.com/kylelemons/godebug v1.1.0 // indirect
|
||||||
github.com/mailru/easyjson v0.7.7 // indirect
|
github.com/mailru/easyjson v0.7.7 // indirect
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
@@ -91,9 +92,9 @@ require (
|
|||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||||
github.com/openzipkin/zipkin-go v0.4.3 // indirect
|
github.com/openzipkin/zipkin-go v0.4.3 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/prometheus/client_model v0.5.0 // indirect
|
github.com/prometheus/client_model v0.6.1 // indirect
|
||||||
github.com/prometheus/common v0.48.0 // indirect
|
github.com/prometheus/common v0.55.0 // indirect
|
||||||
github.com/prometheus/procfs v0.12.0 // indirect
|
github.com/prometheus/procfs v0.15.1 // indirect
|
||||||
github.com/rivo/uniseg v0.2.0 // indirect
|
github.com/rivo/uniseg v0.2.0 // indirect
|
||||||
github.com/stretchr/objx v0.5.2 // indirect
|
github.com/stretchr/objx v0.5.2 // indirect
|
||||||
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
|
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
|
||||||
@@ -108,11 +109,11 @@ require (
|
|||||||
go.uber.org/atomic v1.10.0 // indirect
|
go.uber.org/atomic v1.10.0 // indirect
|
||||||
go.uber.org/multierr v1.9.0 // indirect
|
go.uber.org/multierr v1.9.0 // indirect
|
||||||
go.uber.org/zap v1.24.0 // indirect
|
go.uber.org/zap v1.24.0 // indirect
|
||||||
golang.org/x/crypto v0.25.0 // indirect
|
golang.org/x/crypto v0.26.0 // indirect
|
||||||
golang.org/x/oauth2 v0.20.0 // indirect
|
golang.org/x/oauth2 v0.21.0 // indirect
|
||||||
golang.org/x/sync v0.7.0 // indirect
|
golang.org/x/sync v0.8.0 // indirect
|
||||||
golang.org/x/term v0.22.0 // indirect
|
golang.org/x/term v0.23.0 // indirect
|
||||||
golang.org/x/text v0.16.0 // indirect
|
golang.org/x/text v0.17.0 // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
|
||||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
|
|||||||
58
go.sum
58
go.sum
@@ -98,14 +98,16 @@ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHm
|
|||||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
github.com/kisielk/sqlstruct v0.0.0-20201105191214-5f3e10d3ab46/go.mod h1:yyMNCyc/Ib3bDTKd379tNMpB/7/H5TjM2Y9QJ5THLbE=
|
github.com/kisielk/sqlstruct v0.0.0-20201105191214-5f3e10d3ab46/go.mod h1:yyMNCyc/Ib3bDTKd379tNMpB/7/H5TjM2Y9QJ5THLbE=
|
||||||
github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU=
|
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
|
||||||
github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
|
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
|
||||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
|
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||||
|
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||||
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
|
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
|
||||||
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
||||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||||
@@ -139,14 +141,14 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
|||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
|
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
|
||||||
github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE=
|
github.com/prometheus/client_golang v1.20.2 h1:5ctymQzZlyOON1666svgwn3s6IKWgfbjsejTMiXIyjg=
|
||||||
github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho=
|
github.com/prometheus/client_golang v1.20.2/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
|
||||||
github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw=
|
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
|
||||||
github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI=
|
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
|
||||||
github.com/prometheus/common v0.48.0 h1:QO8U2CdOzSn1BBsmXJXduaaW+dY/5QLjfB8svtSzKKE=
|
github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc=
|
||||||
github.com/prometheus/common v0.48.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc=
|
github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8=
|
||||||
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
|
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
||||||
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
|
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
||||||
github.com/redis/go-redis/v9 v9.6.1 h1:HHDteefn6ZkTtY5fGUE8tj8uy85AHk6zP7CpzIAM0y4=
|
github.com/redis/go-redis/v9 v9.6.1 h1:HHDteefn6ZkTtY5fGUE8tj8uy85AHk6zP7CpzIAM0y4=
|
||||||
github.com/redis/go-redis/v9 v9.6.1/go.mod h1:0C0c6ycQsdpVNQpxb1njEQIqkx5UcsM8FJCQLgE9+RA=
|
github.com/redis/go-redis/v9 v9.6.1/go.mod h1:0C0c6ycQsdpVNQpxb1njEQIqkx5UcsM8FJCQLgE9+RA=
|
||||||
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
|
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
|
||||||
@@ -188,8 +190,8 @@ go.etcd.io/etcd/client/pkg/v3 v3.5.15 h1:fo0HpWz/KlHGMCC+YejpiCmyWDEuIpnTDzpJLB5
|
|||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.15/go.mod h1:mXDI4NAOwEiszrHCb0aqfAYNCrZP4e9hRca3d1YK8EU=
|
go.etcd.io/etcd/client/pkg/v3 v3.5.15/go.mod h1:mXDI4NAOwEiszrHCb0aqfAYNCrZP4e9hRca3d1YK8EU=
|
||||||
go.etcd.io/etcd/client/v3 v3.5.15 h1:23M0eY4Fd/inNv1ZfU3AxrbbOdW79r9V9Rl62Nm6ip4=
|
go.etcd.io/etcd/client/v3 v3.5.15 h1:23M0eY4Fd/inNv1ZfU3AxrbbOdW79r9V9Rl62Nm6ip4=
|
||||||
go.etcd.io/etcd/client/v3 v3.5.15/go.mod h1:CLSJxrYjvLtHsrPKsy7LmZEE+DK2ktfd2bN4RhBMwlU=
|
go.etcd.io/etcd/client/v3 v3.5.15/go.mod h1:CLSJxrYjvLtHsrPKsy7LmZEE+DK2ktfd2bN4RhBMwlU=
|
||||||
go.mongodb.org/mongo-driver v1.16.0 h1:tpRsfBJMROVHKpdGyc1BBEzzjDUWjItxbVSZ8Ls4BQ4=
|
go.mongodb.org/mongo-driver v1.16.1 h1:rIVLL3q0IHM39dvE+z2ulZLp9ENZKThVfuvN/IiN4l8=
|
||||||
go.mongodb.org/mongo-driver v1.16.0/go.mod h1:oB6AhJQvFQL4LEHyXi6aJzQJtBiTQHiAd83l0GdFaiw=
|
go.mongodb.org/mongo-driver v1.16.1/go.mod h1:oB6AhJQvFQL4LEHyXi6aJzQJtBiTQHiAd83l0GdFaiw=
|
||||||
go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo=
|
go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo=
|
||||||
go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo=
|
go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo=
|
||||||
go.opentelemetry.io/otel/exporters/jaeger v1.17.0 h1:D7UpUy2Xc2wsi1Ras6V40q806WM07rqoCWzXu7Sqy+4=
|
go.opentelemetry.io/otel/exporters/jaeger v1.17.0 h1:D7UpUy2Xc2wsi1Ras6V40q806WM07rqoCWzXu7Sqy+4=
|
||||||
@@ -227,8 +229,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
|
|||||||
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
|
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
|
||||||
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
|
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
|
||||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
@@ -240,17 +242,17 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY
|
|||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
|
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
|
||||||
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
|
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
|
||||||
golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo=
|
golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs=
|
||||||
golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
|
golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
|
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
|
||||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
@@ -262,20 +264,20 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
|
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
|
||||||
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk=
|
golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU=
|
||||||
golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4=
|
golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
|
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
|
||||||
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
|
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
|
||||||
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
|
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
||||||
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
|
golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U=
|
||||||
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||||
|
|||||||
@@ -77,10 +77,12 @@ func (s *Server) StartAsync(c Config) {
|
|||||||
|
|
||||||
// StartAgent start inner http server by config.
|
// StartAgent start inner http server by config.
|
||||||
func StartAgent(c Config) {
|
func StartAgent(c Config) {
|
||||||
|
if !c.Enabled {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
once.Do(func() {
|
once.Do(func() {
|
||||||
if c.Enabled {
|
s := NewServer(c)
|
||||||
s := NewServer(c)
|
s.StartAsync(c)
|
||||||
s.StartAsync(c)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -298,6 +298,7 @@ go-zero 已被许多公司用于生产部署,接入场景如在线教育、电
|
|||||||
>99. 新华三技术有限公司
|
>99. 新华三技术有限公司
|
||||||
>100. 上海邑脉科技有限公司
|
>100. 上海邑脉科技有限公司
|
||||||
>101. 上海巨瓴科技有限公司
|
>101. 上海巨瓴科技有限公司
|
||||||
|
>102. 深圳市兴海物联科技有限公司
|
||||||
|
|
||||||
如果贵公司也已使用 go-zero,欢迎在 [登记地址](https://github.com/zeromicro/go-zero/issues/602) 登记,仅仅为了推广,不做其它用途。
|
如果贵公司也已使用 go-zero,欢迎在 [登记地址](https://github.com/zeromicro/go-zero/issues/602) 登记,仅仅为了推广,不做其它用途。
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ go-zero contains simple API description syntax and code generation tool called `
|
|||||||
|
|
||||||
## Backgrounds of go-zero
|
## Backgrounds of go-zero
|
||||||
|
|
||||||
At the beginning of 2018, we decided to re-design our system, from monolithic architecture with Java+MongoDB to microservice architecture. After research and comparison, we chose to:
|
|
||||||
In early 2018, we embarked on a transformative journey to redesign our system, transitioning from a monolithic architecture built with Java and MongoDB to a microservices architecture. After careful research and comparison, we made a deliberate choice to:
|
In early 2018, we embarked on a transformative journey to redesign our system, transitioning from a monolithic architecture built with Java and MongoDB to a microservices architecture. After careful research and comparison, we made a deliberate choice to:
|
||||||
|
|
||||||
* Go Beyond with Golang
|
* Go Beyond with Golang
|
||||||
@@ -251,7 +250,7 @@ go-zero enlisted in the [CNCF Cloud Native Landscape](https://landscape.cncf.io/
|
|||||||
|
|
||||||
## Give a Star! ⭐
|
## Give a Star! ⭐
|
||||||
|
|
||||||
If you like or are using this project to learn or start your solution, please give it a star. Thanks!
|
If you like this project or are using it to learn or start your own solution, give it a star to get updates on new releases. Your support matters!
|
||||||
|
|
||||||
## Buy me a coffee
|
## Buy me a coffee
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,11 @@ const (
|
|||||||
originHeader = "Origin"
|
originHeader = "Origin"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// AddAllowHeaders sets the allowed headers.
|
||||||
|
func AddAllowHeaders(header http.Header, headers ...string) {
|
||||||
|
header.Add(allowHeaders, strings.Join(headers, ", "))
|
||||||
|
}
|
||||||
|
|
||||||
// NotAllowedHandler handles cross domain not allowed requests.
|
// NotAllowedHandler handles cross domain not allowed requests.
|
||||||
// At most one origin can be specified, other origins are ignored if given, default to be *.
|
// At most one origin can be specified, other origins are ignored if given, default to be *.
|
||||||
func NotAllowedHandler(fn func(w http.ResponseWriter), origins ...string) http.Handler {
|
func NotAllowedHandler(fn func(w http.ResponseWriter), origins ...string) http.Handler {
|
||||||
|
|||||||
@@ -3,11 +3,80 @@ package cors
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestAddAllowHeaders(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
initial string
|
||||||
|
headers []string
|
||||||
|
expected string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "single header",
|
||||||
|
initial: "",
|
||||||
|
headers: []string{"Content-Type"},
|
||||||
|
expected: "Content-Type",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "multiple headers",
|
||||||
|
initial: "",
|
||||||
|
headers: []string{"Content-Type", "Authorization", "X-Requested-With"},
|
||||||
|
expected: "Content-Type, Authorization, X-Requested-With",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "add to existing headers",
|
||||||
|
initial: "Origin, Accept",
|
||||||
|
headers: []string{"Content-Type"},
|
||||||
|
expected: "Origin, Accept, Content-Type",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "no headers",
|
||||||
|
initial: "",
|
||||||
|
headers: []string{},
|
||||||
|
expected: "",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
header := http.Header{}
|
||||||
|
headers := make(map[string]struct{})
|
||||||
|
if tt.initial != "" {
|
||||||
|
header.Set(allowHeaders, tt.initial)
|
||||||
|
vals := strings.Split(tt.initial, ", ")
|
||||||
|
for _, v := range vals {
|
||||||
|
headers[v] = struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, h := range tt.headers {
|
||||||
|
headers[h] = struct{}{}
|
||||||
|
}
|
||||||
|
AddAllowHeaders(header, tt.headers...)
|
||||||
|
var actual []string
|
||||||
|
vals := header.Values(allowHeaders)
|
||||||
|
for _, v := range vals {
|
||||||
|
bunch := strings.Split(v, ", ")
|
||||||
|
for _, b := range bunch {
|
||||||
|
if len(b) > 0 {
|
||||||
|
actual = append(actual, b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var expect []string
|
||||||
|
for k := range headers {
|
||||||
|
expect = append(expect, k)
|
||||||
|
}
|
||||||
|
assert.ElementsMatch(t, expect, actual)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestCorsHandlerWithOrigins(t *testing.T) {
|
func TestCorsHandlerWithOrigins(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
|
|||||||
@@ -161,6 +161,18 @@ func WithCors(origin ...string) RunOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithCorsHeaders returns a RunOption to enable CORS with given headers.
|
||||||
|
func WithCorsHeaders(headers ...string) RunOption {
|
||||||
|
const allDomains = "*"
|
||||||
|
|
||||||
|
return func(server *Server) {
|
||||||
|
server.router.SetNotAllowedHandler(cors.NotAllowedHandler(nil, allDomains))
|
||||||
|
server.router = newCorsRouter(server.router, func(header http.Header) {
|
||||||
|
cors.AddAllowHeaders(header, headers...)
|
||||||
|
}, allDomains)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// WithCustomCors returns a func to enable CORS for given origin, or default to all origins (*),
|
// WithCustomCors returns a func to enable CORS for given origin, or default to all origins (*),
|
||||||
// fn lets caller customizing the response.
|
// fn lets caller customizing the response.
|
||||||
func WithCustomCors(middlewareFn func(header http.Header), notAllowedFn func(http.ResponseWriter),
|
func WithCustomCors(middlewareFn func(header http.Header), notAllowedFn func(http.ResponseWriter),
|
||||||
|
|||||||
@@ -420,6 +420,64 @@ Port: 54321
|
|||||||
opt(svr)
|
opt(svr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestWithCorsHeaders(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
headers []string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "single header",
|
||||||
|
headers: []string{"UserHeader"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "multiple headers",
|
||||||
|
headers: []string{"UserHeader", "X-Requested-With"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "no headers",
|
||||||
|
headers: []string{},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
const configYaml = `
|
||||||
|
Name: foo
|
||||||
|
Port: 54321
|
||||||
|
`
|
||||||
|
var cnf RestConf
|
||||||
|
assert.Nil(t, conf.LoadFromYamlBytes([]byte(configYaml), &cnf))
|
||||||
|
rt := router.NewRouter()
|
||||||
|
svr, err := NewServer(cnf, WithRouter(rt))
|
||||||
|
assert.Nil(t, err)
|
||||||
|
defer svr.Stop()
|
||||||
|
option := WithCorsHeaders(tt.headers...)
|
||||||
|
option(svr)
|
||||||
|
|
||||||
|
// Assuming newCorsRouter sets headers correctly,
|
||||||
|
// we would need to verify the behavior here. Since we don't have
|
||||||
|
// direct access to headers, we'll mock newCorsRouter to capture it.
|
||||||
|
w := httptest.NewRecorder()
|
||||||
|
svr.ServeHTTP(w, httptest.NewRequest(http.MethodOptions, "/", nil))
|
||||||
|
|
||||||
|
vals := w.Header().Values("Access-Control-Allow-Headers")
|
||||||
|
respHeaders := make(map[string]struct{})
|
||||||
|
for _, header := range vals {
|
||||||
|
headers := strings.Split(header, ", ")
|
||||||
|
for _, h := range headers {
|
||||||
|
if len(h) > 0 {
|
||||||
|
respHeaders[h] = struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, h := range tt.headers {
|
||||||
|
_, ok := respHeaders[h]
|
||||||
|
assert.Truef(t, ok, "expected header %s not found", h)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestServer_PrintRoutes(t *testing.T) {
|
func TestServer_PrintRoutes(t *testing.T) {
|
||||||
const (
|
const (
|
||||||
configYaml = `
|
configYaml = `
|
||||||
|
|||||||
@@ -157,8 +157,8 @@ func convertDataType(api *spec.ApiSpec, isLegacy bool) (error, *DartSpec) {
|
|||||||
defineStruct, ok := ty.(spec.DefineStruct)
|
defineStruct, ok := ty.(spec.DefineStruct)
|
||||||
if ok {
|
if ok {
|
||||||
for index, member := range defineStruct.Members {
|
for index, member := range defineStruct.Members {
|
||||||
structMember, ok := member.Type.(spec.DefineStruct)
|
structMember, ok := member.Type.(spec.NestedStruct)
|
||||||
if ok && structMember.IsNestedStruct() {
|
if ok {
|
||||||
defineStruct.Members[index].Type = spec.PrimitiveType{RawName: member.Name}
|
defineStruct.Members[index].Type = spec.PrimitiveType{RawName: member.Name}
|
||||||
t := template.New("dataTemplate")
|
t := template.New("dataTemplate")
|
||||||
t = t.Funcs(funcMap)
|
t = t.Funcs(funcMap)
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import (
|
|||||||
"github.com/zeromicro/go-zero/core/collection"
|
"github.com/zeromicro/go-zero/core/collection"
|
||||||
"github.com/zeromicro/go-zero/tools/goctl/api/spec"
|
"github.com/zeromicro/go-zero/tools/goctl/api/spec"
|
||||||
"github.com/zeromicro/go-zero/tools/goctl/config"
|
"github.com/zeromicro/go-zero/tools/goctl/config"
|
||||||
|
"github.com/zeromicro/go-zero/tools/goctl/internal/version"
|
||||||
"github.com/zeromicro/go-zero/tools/goctl/util/format"
|
"github.com/zeromicro/go-zero/tools/goctl/util/format"
|
||||||
"github.com/zeromicro/go-zero/tools/goctl/util/pathx"
|
"github.com/zeromicro/go-zero/tools/goctl/util/pathx"
|
||||||
"github.com/zeromicro/go-zero/tools/goctl/vars"
|
"github.com/zeromicro/go-zero/tools/goctl/vars"
|
||||||
@@ -22,6 +23,8 @@ const (
|
|||||||
jwtTransKey = "jwtTransition"
|
jwtTransKey = "jwtTransition"
|
||||||
routesFilename = "routes"
|
routesFilename = "routes"
|
||||||
routesTemplate = `// Code generated by goctl. DO NOT EDIT.
|
routesTemplate = `// Code generated by goctl. DO NOT EDIT.
|
||||||
|
// goctl {{.version}}
|
||||||
|
|
||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -203,6 +206,7 @@ rest.WithPrefix("%s"),`, g.prefix)
|
|||||||
"hasTimeout": hasTimeout,
|
"hasTimeout": hasTimeout,
|
||||||
"importPackages": genRouteImports(rootPkg, api),
|
"importPackages": genRouteImports(rootPkg, api),
|
||||||
"routesAdditions": strings.TrimSpace(builder.String()),
|
"routesAdditions": strings.TrimSpace(builder.String()),
|
||||||
|
"version": version.BuildVersion,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/zeromicro/go-zero/tools/goctl/api/spec"
|
"github.com/zeromicro/go-zero/tools/goctl/api/spec"
|
||||||
apiutil "github.com/zeromicro/go-zero/tools/goctl/api/util"
|
apiutil "github.com/zeromicro/go-zero/tools/goctl/api/util"
|
||||||
"github.com/zeromicro/go-zero/tools/goctl/config"
|
"github.com/zeromicro/go-zero/tools/goctl/config"
|
||||||
|
"github.com/zeromicro/go-zero/tools/goctl/internal/version"
|
||||||
"github.com/zeromicro/go-zero/tools/goctl/util"
|
"github.com/zeromicro/go-zero/tools/goctl/util"
|
||||||
"github.com/zeromicro/go-zero/tools/goctl/util/format"
|
"github.com/zeromicro/go-zero/tools/goctl/util/format"
|
||||||
)
|
)
|
||||||
@@ -64,6 +65,7 @@ func genTypes(dir string, cfg *config.Config, api *spec.ApiSpec) error {
|
|||||||
data: map[string]any{
|
data: map[string]any{
|
||||||
"types": val,
|
"types": val,
|
||||||
"containsTime": false,
|
"containsTime": false,
|
||||||
|
"version": version.BuildVersion,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
// Code generated by goctl. DO NOT EDIT.
|
// Code generated by goctl. DO NOT EDIT.
|
||||||
|
// goctl {{.version}}
|
||||||
|
|
||||||
package types{{if .containsTime}}
|
package types{{if .containsTime}}
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ func writeProperty(writer io.Writer, name, tag, comment string, tp spec.Type, in
|
|||||||
err error
|
err error
|
||||||
isNestedStruct bool
|
isNestedStruct bool
|
||||||
)
|
)
|
||||||
structType, ok := tp.(spec.DefineStruct)
|
structType, ok := tp.(spec.NestedStruct)
|
||||||
if ok && structType.IsNestedStruct() {
|
if ok {
|
||||||
isNestedStruct = true
|
isNestedStruct = true
|
||||||
}
|
}
|
||||||
if len(comment) > 0 {
|
if len(comment) > 0 {
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
// Code generated by goctl. DO NOT EDIT.
|
// Code generated by goctl. DO NOT EDIT.
|
||||||
|
// goctl {{.version}}
|
||||||
|
|
||||||
package com.xhb.logic.http.packet.{{.packet}}.model;
|
package com.xhb.logic.http.packet.{{.packet}}.model;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import (
|
|||||||
"github.com/zeromicro/go-zero/core/stringx"
|
"github.com/zeromicro/go-zero/core/stringx"
|
||||||
"github.com/zeromicro/go-zero/tools/goctl/api/spec"
|
"github.com/zeromicro/go-zero/tools/goctl/api/spec"
|
||||||
apiutil "github.com/zeromicro/go-zero/tools/goctl/api/util"
|
apiutil "github.com/zeromicro/go-zero/tools/goctl/api/util"
|
||||||
|
"github.com/zeromicro/go-zero/tools/goctl/internal/version"
|
||||||
"github.com/zeromicro/go-zero/tools/goctl/util"
|
"github.com/zeromicro/go-zero/tools/goctl/util"
|
||||||
"github.com/zeromicro/go-zero/tools/goctl/util/pathx"
|
"github.com/zeromicro/go-zero/tools/goctl/util/pathx"
|
||||||
)
|
)
|
||||||
@@ -131,6 +132,7 @@ func (c *componentsContext) createComponent(dir, packetName string, ty spec.Type
|
|||||||
"className": util.Title(defineStruct.Name()),
|
"className": util.Title(defineStruct.Name()),
|
||||||
"superClassName": superClassName,
|
"superClassName": superClassName,
|
||||||
"HasProperty": len(strings.TrimSpace(propertiesString)) > 0,
|
"HasProperty": len(strings.TrimSpace(propertiesString)) > 0,
|
||||||
|
"version": version.BuildVersion,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -30,9 +30,19 @@ func (t DefineStruct) Documents() []string {
|
|||||||
return t.Docs
|
return t.Docs
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsNestedStruct returns whether the structure is nested.
|
// Name returns a structure string, such as User
|
||||||
func (t DefineStruct) IsNestedStruct() bool {
|
func (t NestedStruct) Name() string {
|
||||||
return len(t.Members) > 0
|
return t.RawName
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comments returns the comments of struct
|
||||||
|
func (t NestedStruct) Comments() []string {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Documents returns the documents of struct
|
||||||
|
func (t NestedStruct) Documents() []string {
|
||||||
|
return t.Docs
|
||||||
}
|
}
|
||||||
|
|
||||||
// Name returns a map string, such as map[string]int
|
// Name returns a map string, such as map[string]int
|
||||||
|
|||||||
@@ -105,6 +105,13 @@ type (
|
|||||||
Docs Doc
|
Docs Doc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NestedStruct describes a structure nested in structure.
|
||||||
|
NestedStruct struct {
|
||||||
|
RawName string
|
||||||
|
Members []Member
|
||||||
|
Docs Doc
|
||||||
|
}
|
||||||
|
|
||||||
// PrimitiveType describes the basic golang type, such as bool,int32,int64, ...
|
// PrimitiveType describes the basic golang type, such as bool,int32,int64, ...
|
||||||
PrimitiveType struct {
|
PrimitiveType struct {
|
||||||
RawName string
|
RawName string
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
// Code generated by goctl. DO NOT EDIT.
|
// Code generated by goctl. DO NOT EDIT.
|
||||||
|
// goctl {{.version}}
|
||||||
|
|
||||||
{{.componentTypes}}
|
{{.componentTypes}}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
|
|
||||||
"github.com/zeromicro/go-zero/tools/goctl/api/spec"
|
"github.com/zeromicro/go-zero/tools/goctl/api/spec"
|
||||||
apiutil "github.com/zeromicro/go-zero/tools/goctl/api/util"
|
apiutil "github.com/zeromicro/go-zero/tools/goctl/api/util"
|
||||||
|
"github.com/zeromicro/go-zero/tools/goctl/internal/version"
|
||||||
"github.com/zeromicro/go-zero/tools/goctl/util/pathx"
|
"github.com/zeromicro/go-zero/tools/goctl/util/pathx"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -61,5 +62,6 @@ func genComponents(dir string, api *spec.ApiSpec) error {
|
|||||||
t := template.Must(template.New("componentsTemplate").Parse(componentsTemplate))
|
t := template.Must(template.New("componentsTemplate").Parse(componentsTemplate))
|
||||||
return t.Execute(fp, map[string]string{
|
return t.Execute(fp, map[string]string{
|
||||||
"componentTypes": val,
|
"componentTypes": val,
|
||||||
|
"version": version.BuildVersion,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ func writeIndent(writer io.Writer, indent int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func genTsType(m spec.Member, indent int) (ty string, err error) {
|
func genTsType(m spec.Member, indent int) (ty string, err error) {
|
||||||
v, ok := m.Type.(spec.DefineStruct)
|
v, ok := m.Type.(spec.NestedStruct)
|
||||||
if ok && v.IsNestedStruct() {
|
if ok {
|
||||||
writer := bytes.NewBuffer(nil)
|
writer := bytes.NewBuffer(nil)
|
||||||
_, err := fmt.Fprintf(writer, "{\n")
|
_, err := fmt.Fprintf(writer, "{\n")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
1
tools/goctl/compare/.gitignore
vendored
Normal file
1
tools/goctl/compare/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
build
|
||||||
151
tools/goctl/compare/api/test.api
Normal file
151
tools/goctl/compare/api/test.api
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
syntax = "v1"
|
||||||
|
|
||||||
|
@server (
|
||||||
|
group: base
|
||||||
|
)
|
||||||
|
service test {
|
||||||
|
@handler root
|
||||||
|
get /
|
||||||
|
|
||||||
|
@handler ping
|
||||||
|
get /ping
|
||||||
|
|
||||||
|
@handler postRoot
|
||||||
|
post /
|
||||||
|
|
||||||
|
@handler postPing
|
||||||
|
post /ping
|
||||||
|
}
|
||||||
|
|
||||||
|
type (
|
||||||
|
Subject {
|
||||||
|
Id int64 `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
Grade {
|
||||||
|
Id int64 `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
Class {
|
||||||
|
Id int64 `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
GradeId int64 `json:"gradeId"`
|
||||||
|
Teachers []*Teacher `json:"teachers"`
|
||||||
|
Master {
|
||||||
|
UserId int64 `json:"userId"`
|
||||||
|
Temp bool `json:"temp"`
|
||||||
|
} `json:"master"`
|
||||||
|
}
|
||||||
|
User {
|
||||||
|
Id int64 `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Gender int `json:"gender"`
|
||||||
|
Active bool `json:"active"`
|
||||||
|
Hobby []string `json:"hobby"`
|
||||||
|
}
|
||||||
|
Teacher {
|
||||||
|
UserId int64 `json:"userId"`
|
||||||
|
Id int64 `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
SubjectId int64 `json:"subjectId"`
|
||||||
|
Class map[int64]*Class `json:"class"`
|
||||||
|
}
|
||||||
|
Student {
|
||||||
|
UserId int64 `json:"userId"`
|
||||||
|
StudentId int64 `json:"studentId"`
|
||||||
|
Number string `json:"number"`
|
||||||
|
ClassId int64 `json:"classId"`
|
||||||
|
SubjectId []int64 `json:"subjectId"`
|
||||||
|
SubjectTop3 [3]int64 `json:"subjectTop3"`
|
||||||
|
Extra map[string]interface{} `json:"extra"`
|
||||||
|
}
|
||||||
|
Base {
|
||||||
|
Code int64 `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
LoginReq {
|
||||||
|
Username string `json:"username"`
|
||||||
|
Password string `json:"password"`
|
||||||
|
}
|
||||||
|
LoginResp {
|
||||||
|
Base
|
||||||
|
Data *User `json:"data"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
@server (
|
||||||
|
group: user
|
||||||
|
prefix: /user
|
||||||
|
)
|
||||||
|
service test {
|
||||||
|
@handler login
|
||||||
|
post /login (LoginReq) returns (LoginReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
type (
|
||||||
|
UserInfoReq {
|
||||||
|
Id int64 `path:"id"`
|
||||||
|
}
|
||||||
|
UserInfoResp {
|
||||||
|
Base
|
||||||
|
Data *User `json:"data"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
@server (
|
||||||
|
group: user
|
||||||
|
prefix: /user
|
||||||
|
jwt: JWT
|
||||||
|
middleware: Auth
|
||||||
|
)
|
||||||
|
service test {
|
||||||
|
@handler userInfo
|
||||||
|
post /info/:id (UserInfoReq) returns (UserInfoResp)
|
||||||
|
}
|
||||||
|
|
||||||
|
type (
|
||||||
|
StudentClassNameListReq {
|
||||||
|
Id int64 `string:"id"`
|
||||||
|
}
|
||||||
|
StudentInfoReq {
|
||||||
|
Id int64 `path:"id"`
|
||||||
|
}
|
||||||
|
SutdentInfoResp {
|
||||||
|
Base
|
||||||
|
Data *Student `json:"data"`
|
||||||
|
}
|
||||||
|
UpdateStudentInfoReq {
|
||||||
|
UserId int64 `form:"userId"`
|
||||||
|
StudentId int64 `form:"studentId"`
|
||||||
|
Number string `form:"number"`
|
||||||
|
ClassId int64 `form:"classId"`
|
||||||
|
SubjectId []int64 `form:"subjectId"`
|
||||||
|
SubjectTop3 [3]int64 `form:"subjectTop3"`
|
||||||
|
Extra map[string]interface{} `form:"extra"`
|
||||||
|
}
|
||||||
|
UpdateSutdentInfoResp {
|
||||||
|
Base
|
||||||
|
Data *Student `json:"data"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
@server (
|
||||||
|
group: student
|
||||||
|
prefix: /student
|
||||||
|
jwt: JWT
|
||||||
|
middleware: Auth
|
||||||
|
)
|
||||||
|
service test {
|
||||||
|
@handler studentInfo
|
||||||
|
get /info/:id (StudentInfoReq) returns (SutdentInfoResp)
|
||||||
|
|
||||||
|
@handler updateStudentInfo
|
||||||
|
post /info/update (UpdateStudentInfoReq) returns (UpdateSutdentInfoResp)
|
||||||
|
|
||||||
|
@handler studentClassNameList
|
||||||
|
post /class/name/list (StudentClassNameListReq) returns ([]string)
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package cmd
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"github.com/zeromicro/go-zero/tools/goctl/compare/testdata"
|
|
||||||
"github.com/zeromicro/go-zero/tools/goctl/util/console"
|
|
||||||
)
|
|
||||||
|
|
||||||
var rootCmd = &cobra.Command{
|
|
||||||
Use: "compare",
|
|
||||||
Short: "Compare the goctl commands generated results between urfave and cobra",
|
|
||||||
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),
|
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
|
||||||
dir := args[0]
|
|
||||||
testdata.MustRun(dir)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
func Execute() {
|
|
||||||
if err := rootCmd.Execute(); err != nil {
|
|
||||||
console.Error("%+v", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import "github.com/zeromicro/go-zero/tools/goctl/compare/cmd"
|
|
||||||
|
|
||||||
// EXPERIMENTAL: compare goctl generated code results between old and new, it will be removed in the feature.
|
|
||||||
// TODO: BEFORE RUNNING: export DSN=$datasource, the database must be gozero, and there has no limit for tables.
|
|
||||||
// TODO: AFTER RUNNING: diff --recursive old_fs new_fs
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
cmd.Execute()
|
|
||||||
}
|
|
||||||
97
tools/goctl/compare/compare.sh
Normal file
97
tools/goctl/compare/compare.sh
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# local compare test
|
||||||
|
# compare goctl between latest and newest version if exists different.
|
||||||
|
|
||||||
|
execute_command() {
|
||||||
|
local command="$1"
|
||||||
|
|
||||||
|
echo "=> $command"
|
||||||
|
eval "$command"
|
||||||
|
}
|
||||||
|
|
||||||
|
has_diff (){
|
||||||
|
local command="$1"
|
||||||
|
if $command &> /dev/null; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "=======================env init============================="
|
||||||
|
WD=$(readlink -f $(dirname $0))/build
|
||||||
|
BIN=$WD/bin
|
||||||
|
PROJECT_DIR=$WD/project
|
||||||
|
OLD_CODE=$PROJECT_DIR/old
|
||||||
|
NEW_CODE=$PROJECT_DIR/new
|
||||||
|
|
||||||
|
if [ -d $WD ]; then
|
||||||
|
execute_command "rm -rf $WD"
|
||||||
|
fi
|
||||||
|
|
||||||
|
execute_command "mkdir -p $BIN $PROJECT_DIR $OLD_CODE $NEW_CODE"
|
||||||
|
execute_command 'export GOPROXY="https://goproxy.cn,direct"'
|
||||||
|
execute_command "export GOBIN=$BIN"
|
||||||
|
|
||||||
|
echo "=======================install goctl============================="
|
||||||
|
# install latest goctl
|
||||||
|
execute_command "go install github.com/zeromicro/go-zero/tools/goctl@master"
|
||||||
|
execute_command "mv $BIN/goctl $BIN/goctl.old"
|
||||||
|
execute_command "$BIN/goctl.old env"
|
||||||
|
execute_command "$BIN/goctl.old env -w GOCTL_EXPERIMENTAL=on"
|
||||||
|
|
||||||
|
# install newest goctl
|
||||||
|
execute_command "cd .."
|
||||||
|
execute_command "go build -o goctl.new ."
|
||||||
|
execute_command "mv goctl.new $BIN/goctl.new"
|
||||||
|
execute_command "cd -"
|
||||||
|
execute_command "$BIN/goctl.new env"
|
||||||
|
execute_command "$BIN/goctl.new env -w GOCTL_EXPERIMENTAL=on"
|
||||||
|
|
||||||
|
echo "=======================go mod tidy============================="
|
||||||
|
# go mod init
|
||||||
|
execute_command "cd $OLD_CODE"
|
||||||
|
execute_command "go mod init demo"
|
||||||
|
execute_command "cd -"
|
||||||
|
|
||||||
|
execute_command "cd $NEW_CODE"
|
||||||
|
execute_command "go mod init demo"
|
||||||
|
execute_command "cd -"
|
||||||
|
|
||||||
|
echo "=======================generate api============================="
|
||||||
|
execute_command "cd api"
|
||||||
|
# generate api by goctl.old
|
||||||
|
execute_command "$BIN/goctl.old api go --api test.api --dir $OLD_CODE/api"
|
||||||
|
# generate api by goctl.new
|
||||||
|
execute_command "$BIN/goctl.new api go --api test.api --dir $NEW_CODE/api"
|
||||||
|
execute_command "cd -"
|
||||||
|
|
||||||
|
echo "=======================generate rpc============================="
|
||||||
|
execute_command "cd rpc"
|
||||||
|
# generate rpc by goctl.old
|
||||||
|
execute_command "$BIN/goctl.old rpc protoc test.proto --go_out=$OLD_CODE/rpc --go-grpc_out=$OLD_CODE/rpc --zrpc_out=$OLD_CODE/rpc"
|
||||||
|
# generate rpc by goctl.new
|
||||||
|
execute_command "$BIN/goctl.new rpc protoc test.proto --go_out=$NEW_CODE/rpc --go-grpc_out=$NEW_CODE/rpc --zrpc_out=$NEW_CODE/rpc"
|
||||||
|
execute_command "cd -"
|
||||||
|
|
||||||
|
echo "=======================generate model============================="
|
||||||
|
execute_command "cd model"
|
||||||
|
# generate model by goctl.old
|
||||||
|
execute_command "$BIN/goctl.old model mysql ddl --src user.sql --dir $OLD_CODE/cache -c"
|
||||||
|
execute_command "$BIN/goctl.old model mysql ddl --src user.sql --dir $OLD_CODE/nocache"
|
||||||
|
# generate model by goctl.new
|
||||||
|
execute_command "$BIN/goctl.new model mysql ddl --src user.sql --dir $NEW_CODE/cache -c"
|
||||||
|
execute_command "$BIN/goctl.new model mysql ddl --src user.sql --dir $NEW_CODE/nocache"
|
||||||
|
execute_command "cd -"
|
||||||
|
|
||||||
|
echo "=======================diff compare============================="
|
||||||
|
# compare and diff
|
||||||
|
if has_diff "diff -rq $OLD_CODE $NEW_CODE"; then
|
||||||
|
echo "no diff"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "a diff found"
|
||||||
|
execute_command "diff -r $OLD_CODE $NEW_CODE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
wd=`dirname $0`
|
|
||||||
GOBIN="$GOPATH/bin"
|
|
||||||
EXE=goctl-compare
|
|
||||||
go build -o $EXE $wd
|
|
||||||
mv $EXE $GOBIN
|
|
||||||
@@ -4,11 +4,12 @@ CREATE TABLE `user`
|
|||||||
`id` bigint(10) NOT NULL AUTO_INCREMENT,
|
`id` bigint(10) NOT NULL AUTO_INCREMENT,
|
||||||
`user` varchar(50) NOT NULL DEFAULT '' COMMENT '用户',
|
`user` varchar(50) NOT NULL DEFAULT '' COMMENT '用户',
|
||||||
`name` varchar(255) COLLATE utf8mb4_general_ci NULL COMMENT '用户\t名称',
|
`name` varchar(255) COLLATE utf8mb4_general_ci NULL COMMENT '用户\t名称',
|
||||||
|
`age` tinyint(3) unsigned NOT NULL DEFAULT 0 COMMENT '年龄',
|
||||||
`password` varchar(255) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '用户\n密码',
|
`password` varchar(255) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '用户\n密码',
|
||||||
`mobile` varchar(255) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '手机号',
|
`mobile` varchar(255) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '手机号',
|
||||||
`gender` char(5) COLLATE utf8mb4_general_ci NOT NULL COMMENT '男|女|未公\r开',
|
`gender` char(5) COLLATE utf8mb4_general_ci NOT NULL COMMENT '男|女|未公\r开',
|
||||||
`nickname` varchar(255) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '用户昵称',
|
`nickname` varchar(255) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '用户昵称',
|
||||||
`type` tinyint(1) COLLATE utf8mb4_general_ci DEFAULT 0 COMMENT '用户类型',
|
`type` tinyint(1) COLLATE utf8mb4_general_ci DEFAULT 0 COMMENT '用户类型',
|
||||||
`create_time` timestamp NULL,
|
`create_time` timestamp NULL,
|
||||||
`update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
`update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
@@ -21,14 +22,15 @@ CREATE TABLE `user`
|
|||||||
|
|
||||||
CREATE TABLE `student`
|
CREATE TABLE `student`
|
||||||
(
|
(
|
||||||
`type` bigint NOT NULL,
|
`type` bigint NOT NULL,
|
||||||
`class` varchar(255) COLLATE utf8mb4_bin NOT NULL DEFAULT '',
|
`class` varchar(255) NOT NULL DEFAULT '',
|
||||||
`name` varchar(255) COLLATE utf8mb4_bin NOT NULL DEFAULT '',
|
`name` varchar(255) NOT NULL DEFAULT '',
|
||||||
`age` tinyint DEFAULT NULL,
|
`age` tinyint DEFAULT NULL,
|
||||||
`score` float(10, 0
|
`score` float(10, 0
|
||||||
) DEFAULT NULL,
|
) DEFAULT NULL,
|
||||||
|
`amount` decimal DEFAULT NULL,
|
||||||
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
`update_time` timestamp NULL DEFAULT NULL,
|
`update_time` timestamp NULL DEFAULT NULL,
|
||||||
PRIMARY KEY (`type`) USING BTREE,
|
`delete_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
|
||||||
UNIQUE KEY `class_name_index` (`class`,`name`)
|
PRIMARY KEY (`type`) USING BTREE
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
|
||||||
8
tools/goctl/compare/rpc/base/common.proto
Normal file
8
tools/goctl/compare/rpc/base/common.proto
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package common;
|
||||||
|
option go_package="./common";
|
||||||
|
|
||||||
|
message User {
|
||||||
|
string name = 1;
|
||||||
|
}
|
||||||
65
tools/goctl/compare/rpc/test.proto
Normal file
65
tools/goctl/compare/rpc/test.proto
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
// test proto
|
||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package test;
|
||||||
|
|
||||||
|
import "base/common.proto";
|
||||||
|
option go_package = "github.com/test";
|
||||||
|
|
||||||
|
message Req {
|
||||||
|
string in = 1;
|
||||||
|
common.User user = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Reply {
|
||||||
|
string out = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message snake_req {}
|
||||||
|
|
||||||
|
message snake_reply {}
|
||||||
|
|
||||||
|
message CamelReq{}
|
||||||
|
|
||||||
|
message CamelReply{}
|
||||||
|
|
||||||
|
message EnumMessage {
|
||||||
|
enum Enum {
|
||||||
|
unknown = 0;
|
||||||
|
male = 1;
|
||||||
|
female = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message CommonReply{}
|
||||||
|
|
||||||
|
message MapReq{
|
||||||
|
map<string, string> m = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message RepeatedReq{
|
||||||
|
repeated string id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
service Test_Service {
|
||||||
|
// service
|
||||||
|
rpc Service (Req) returns (Reply);
|
||||||
|
// greet service
|
||||||
|
rpc GreetService (Req) returns (Reply);
|
||||||
|
// case snake
|
||||||
|
rpc snake_service (snake_req) returns (snake_reply);
|
||||||
|
// case camel
|
||||||
|
rpc CamelService (CamelReq) returns (CamelReply);
|
||||||
|
// case enum
|
||||||
|
rpc EnumService (EnumMessage) returns (CommonReply);
|
||||||
|
// case map
|
||||||
|
rpc MapService (MapReq) returns (CommonReply);
|
||||||
|
// case repeated
|
||||||
|
rpc RepeatedService (RepeatedReq) returns (CommonReply);
|
||||||
|
// server stream
|
||||||
|
rpc ServerStream (Req) returns (stream Reply);
|
||||||
|
// client stream
|
||||||
|
rpc ClientStream (stream Req) returns (Reply);
|
||||||
|
// stream
|
||||||
|
rpc Stream(stream Req) returns (stream Reply);
|
||||||
|
}
|
||||||
17
tools/goctl/compare/testdata/kotlin.api
vendored
17
tools/goctl/compare/testdata/kotlin.api
vendored
@@ -1,17 +0,0 @@
|
|||||||
syntax = "v1"
|
|
||||||
|
|
||||||
info(
|
|
||||||
title: "type title here"
|
|
||||||
desc: "type desc here"
|
|
||||||
author: "type author here"
|
|
||||||
email: "type email here"
|
|
||||||
version: "type version here"
|
|
||||||
)
|
|
||||||
|
|
||||||
type req{}
|
|
||||||
type reply{}
|
|
||||||
|
|
||||||
service kotlin-api{
|
|
||||||
@handler ping
|
|
||||||
post /ping
|
|
||||||
}
|
|
||||||
470
tools/goctl/compare/testdata/testcase.go
vendored
470
tools/goctl/compare/testdata/testcase.go
vendored
@@ -1,470 +0,0 @@
|
|||||||
package testdata
|
|
||||||
|
|
||||||
import _ "embed"
|
|
||||||
|
|
||||||
var (
|
|
||||||
//go:embed unformat.api
|
|
||||||
unformatApi string
|
|
||||||
//go:embed kotlin.api
|
|
||||||
kotlinApi string
|
|
||||||
//go:embed user.sql
|
|
||||||
userSql string
|
|
||||||
|
|
||||||
list = Files{
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "version",
|
|
||||||
Cmd: "goctl --version",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/sample_file/local",
|
|
||||||
Cmd: "goctl api --o sample.api",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/sample_file/local/assign",
|
|
||||||
Cmd: "goctl api --o=sample.api",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/sample_file/local/assign/shorthand",
|
|
||||||
Cmd: "goctl api -o=sample.api",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/sample_file/remote",
|
|
||||||
Cmd: "goctl api --o sample.api --remote https://github.com/zeromicro/go-zero-template --branch main",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/sample_file/remote/shorthand",
|
|
||||||
Cmd: "goctl api -o sample.api -remote https://github.com/zeromicro/go-zero-template -branch main",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/sample_file/remote/assign",
|
|
||||||
Cmd: "goctl api --o=sample.api --remote https://github.com/zeromicro/go-zero-template --branch=main",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/sample_file/remote/assign/shorthand",
|
|
||||||
Cmd: "goctl api -o=sample.api -remote https://github.com/zeromicro/go-zero-template -branch=main",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/dart/legacy/true",
|
|
||||||
Cmd: "goctl api --o sample.api && goctl api dart --api sample.api --dir . --hostname 127.0.0.1 --legacy true",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/dart/legacy/true/shorthand",
|
|
||||||
Cmd: "goctl api -o sample.api && goctl api dart -api sample.api -dir . -hostname 127.0.0.1 -legacy true",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/dart/legacy/true/assign",
|
|
||||||
Cmd: "goctl api --o=sample.api && goctl api dart --api=sample.api --dir=. --hostname=127.0.0.1 --legacy=true",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/dart/legacy/true/assign/shorthand",
|
|
||||||
Cmd: "goctl api -o=sample.api && goctl api dart -api=sample.api -dir=. -hostname=127.0.0.1 -legacy=true",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/dart/legacy/false",
|
|
||||||
Cmd: "goctl api --o sample.api && goctl api dart --api sample.api --dir . --hostname 127.0.0.1 --legacy true",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/dart/legacy/false/shorthand",
|
|
||||||
Cmd: "goctl api -o sample.api && goctl api dart -api sample.api -dir . -hostname 127.0.0.1 -legacy true",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/dart/legacy/false/assign",
|
|
||||||
Cmd: "goctl api --o=sample.api && goctl api dart --api=sample.api --dir=. --hostname=127.0.0.1 --legacy=true",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/dart/legacy/false/assign/shorthand",
|
|
||||||
Cmd: "goctl api -o=sample.api && goctl api dart -api=sample.api -dir=. -hostname=127.0.0.1 -legacy=true",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/doc",
|
|
||||||
Cmd: "goctl api --o sample.api && goctl api doc --dir . --o .",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/doc/shorthand",
|
|
||||||
Cmd: "goctl api -o sample.api && goctl api doc -dir . -o .",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/doc/assign",
|
|
||||||
Cmd: "goctl api --o=sample.api && goctl api doc --dir=. --o=.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/doc/assign/shorthand",
|
|
||||||
Cmd: "goctl api -o=sample.api && goctl api doc -dir=. -o=.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Path: "api/format/unformat.api",
|
|
||||||
Content: unformatApi,
|
|
||||||
Cmd: "goctl api format --dir . --iu",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Path: "api/format/shorthand/unformat.api",
|
|
||||||
Content: unformatApi,
|
|
||||||
Cmd: "goctl api format -dir . -iu",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Path: "api/format/assign/unformat.api",
|
|
||||||
Content: unformatApi,
|
|
||||||
Cmd: "goctl api format --dir=. --iu",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Path: "api/format/assign/shorthand/unformat.api",
|
|
||||||
Content: unformatApi,
|
|
||||||
Cmd: "goctl api format -dir=. -iu",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/go/style/default",
|
|
||||||
Cmd: "goctl api --o sample.api && goctl api go --api sample.api --dir .",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/go/style/default/shorthand",
|
|
||||||
Cmd: "goctl api -o sample.api && goctl api go -api sample.api -dir .",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/go/style/assign/default",
|
|
||||||
Cmd: "goctl api --o=sample.api && goctl api go --api=sample.api --dir=.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/go/style/assign/default/shorthand",
|
|
||||||
Cmd: "goctl api -o=sample.api && goctl api go -api=sample.api -dir=.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/go/style/goZero",
|
|
||||||
Cmd: "goctl api --o sample.api && goctl api go --api sample.api --dir . --style goZero",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/go/style/goZero/shorthand",
|
|
||||||
Cmd: "goctl api -o sample.api && goctl api go -api sample.api -dir . -style goZero",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/go/style/goZero/assign",
|
|
||||||
Cmd: "goctl api --o=sample.api && goctl api go --api=sample.api --dir=. --style=goZero",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/go/style/goZero/assign/shorthand",
|
|
||||||
Cmd: "goctl api -o=sample.api && goctl api go -api=sample.api -dir=. -style=goZero",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/java",
|
|
||||||
Cmd: "goctl api --o sample.api && goctl api java --api sample.api --dir .",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/java/shorthand",
|
|
||||||
Cmd: "goctl api -o sample.api && goctl api java -api sample.api -dir .",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/java/assign",
|
|
||||||
Cmd: "goctl api --o=sample.api && goctl api java --api=sample.api --dir=.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/java/shorthand/assign",
|
|
||||||
Cmd: "goctl api -o=sample.api && goctl api java -api=sample.api -dir=.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/new/style/default",
|
|
||||||
Cmd: "goctl api new greet",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/new/style/goZero",
|
|
||||||
Cmd: "goctl api new greet --style goZero",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/new/style/goZero/assign",
|
|
||||||
Cmd: "goctl api new greet --style=goZero",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/new/style/goZero/shorthand",
|
|
||||||
Cmd: "goctl api new greet -style goZero",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/new/style/goZero/shorthand/assign",
|
|
||||||
Cmd: "goctl api new greet -style=goZero",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/ts",
|
|
||||||
Cmd: "goctl api --o sample.api && goctl api ts --api sample.api --dir . --unwrap --webapi .",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/ts/shorthand",
|
|
||||||
Cmd: "goctl api -o sample.api && goctl api ts -api sample.api -dir . -unwrap -webapi .",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/ts/assign",
|
|
||||||
Cmd: "goctl api --o=sample.api && goctl api ts --api=sample.api --dir=. --unwrap --webapi=.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/ts/shorthand/assign",
|
|
||||||
Cmd: "goctl api -o=sample.api && goctl api ts -api=sample.api -dir=. -unwrap -webapi=.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/validate",
|
|
||||||
Cmd: "goctl api --o sample.api && goctl api validate --api sample.api",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/validate/shorthand",
|
|
||||||
Cmd: "goctl api -o sample.api && goctl api validate -api sample.api",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/validate/assign",
|
|
||||||
Cmd: "goctl api --o=sample.api && goctl api validate --api=sample.api",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "api/validate/shorthand/assign",
|
|
||||||
Cmd: "goctl api -o=sample.api && goctl api validate -api=sample.api",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "env/show",
|
|
||||||
Cmd: "goctl env > env.txt",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "env/check",
|
|
||||||
Cmd: "goctl env check -f -v",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "env/install",
|
|
||||||
Cmd: "goctl env install -v",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "kube",
|
|
||||||
Cmd: "goctl kube deploy --image alpine --name foo --namespace foo --o foo.yaml --port 8888",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "kube/shorthand",
|
|
||||||
Cmd: "goctl kube deploy -image alpine -name foo -namespace foo -o foo.yaml -port 8888",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "kube/assign",
|
|
||||||
Cmd: "goctl kube deploy --image=alpine --name=foo --namespace=foo --o=foo.yaml --port=8888",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "kube/shorthand/assign",
|
|
||||||
Cmd: "goctl kube deploy -image=alpine -name=foo -namespace=foo -o=foo.yaml -port=8888",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "model/mongo/cache",
|
|
||||||
Cmd: "goctl model mongo --dir . --type user --style goZero -c",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "model/mongo/cache/shorthand",
|
|
||||||
Cmd: "goctl model mongo -dir . -type user -style goZero -c",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "model/mongo/cache/assign",
|
|
||||||
Cmd: "goctl model mongo --dir=. --type=user --style=goZero -c",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "model/mongo/cache/shorthand/assign",
|
|
||||||
Cmd: "goctl model mongo -dir=. -type=user -style=goZero -c",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "model/mongo/nocache",
|
|
||||||
Cmd: "goctl model mongo --dir . --type user",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "model/mongo/nocache/shorthand",
|
|
||||||
Cmd: "goctl model mongo -dir . -type user",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "model/mongo/nocache/assign",
|
|
||||||
Cmd: "goctl model mongo --dir=. --type=user",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "model/mongo/nocache/shorthand/assign",
|
|
||||||
Cmd: "goctl model mongo -dir=. -type=user",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Content: userSql,
|
|
||||||
Path: "model/mysql/ddl/user.sql",
|
|
||||||
Cmd: "goctl model mysql ddl --database user --dir cache --src user.sql -c",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Content: userSql,
|
|
||||||
Path: "model/mysql/ddl/shorthand/user.sql",
|
|
||||||
Cmd: "goctl model mysql ddl -database user -dir cache -src user.sql -c",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Content: userSql,
|
|
||||||
Path: "model/mysql/ddl/assign/user.sql",
|
|
||||||
Cmd: "goctl model mysql ddl --database=user --dir=cache --src=user.sql -c",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Content: userSql,
|
|
||||||
Path: "model/mysql/ddl/shorthand/assign/user.sql",
|
|
||||||
Cmd: "goctl model mysql ddl -database=user -dir=cache -src=user.sql -c",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Content: userSql,
|
|
||||||
Path: "model/mysql/ddl/user.sql",
|
|
||||||
Cmd: "goctl model mysql ddl --database user --dir nocache --src user.sql",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Content: userSql,
|
|
||||||
Path: "model/mysql/ddl/shorthand/user.sql",
|
|
||||||
Cmd: "goctl model mysql ddl -database user -dir nocache -src user.sql",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Content: userSql,
|
|
||||||
Path: "model/mysql/ddl/assign/user.sql",
|
|
||||||
Cmd: "goctl model mysql ddl --database=user --dir=nocache --src=user.sql",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Content: userSql,
|
|
||||||
Path: "model/mysql/ddl/shorthand/assign/user.sql",
|
|
||||||
Cmd: "goctl model mysql ddl -database=user -dir=nocache -src=user.sql",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "model/mysql/datasource",
|
|
||||||
Cmd: `goctl model mysql datasource --url $DSN --dir cache --table "*" -c`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "model/mysql/datasource/shorthand",
|
|
||||||
Cmd: `goctl model mysql datasource -url $DSN -dir cache -table "*" -c`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "model/mysql/datasource/shorthand2",
|
|
||||||
Cmd: `goctl model mysql datasource -url $DSN -dir cache -t "*" -c`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "model/mysql/datasource/assign",
|
|
||||||
Cmd: `goctl model mysql datasource --url=$DSN --dir=cache --table="*" -c`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "model/mysql/datasource/shorthand/assign",
|
|
||||||
Cmd: `goctl model mysql datasource -url=$DSN -dir=cache -table="*" -c`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "model/mysql/datasource/shorthand2/assign",
|
|
||||||
Cmd: `goctl model mysql datasource -url=$DSN -dir=cache -t="*" -c`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "model/mysql/datasource",
|
|
||||||
Cmd: `goctl model mysql datasource --url $DSN --dir nocache --table "*" -c`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "model/mysql/datasource/shorthand",
|
|
||||||
Cmd: `goctl model mysql datasource -url $DSN -dir nocache -table "*" -c`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "model/mysql/datasource/shorthand2",
|
|
||||||
Cmd: `goctl model mysql datasource -url $DSN -dir nocache -t "*" -c`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "model/mysql/datasource/assign",
|
|
||||||
Cmd: `goctl model mysql datasource --url=$DSN --dir=nocache --table="*" -c`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "model/mysql/datasource/shorthand/assign",
|
|
||||||
Cmd: `goctl model mysql datasource -url=$DSN -dir=nocache -table="*" -c`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "model/mysql/datasource/shorthand2/assign",
|
|
||||||
Cmd: `goctl model mysql datasource -url=$DSN -dir=nocache -t="*" -c`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "rpc/new",
|
|
||||||
Cmd: "goctl rpc new greet",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "rpc/template",
|
|
||||||
Cmd: "goctl rpc template --o greet.proto",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "rpc/template/shorthand",
|
|
||||||
Cmd: "goctl rpc template -o greet.proto",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "rpc/template/assign",
|
|
||||||
Cmd: "goctl rpc template --o=greet.proto",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "rpc/template/shorthand/assign",
|
|
||||||
Cmd: "goctl rpc template -o=greet.proto",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "rpc/protoc",
|
|
||||||
Cmd: "goctl rpc template --o greet.proto && goctl rpc protoc greet.proto --go_out . --go-grpc_out . --zrpc_out .",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
IsDir: true,
|
|
||||||
Path: "rpc/protoc/assign",
|
|
||||||
Cmd: "goctl rpc template --o=greet.proto && goctl rpc protoc greet.proto --go_out=. --go-grpc_out=. --zrpc_out=.",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
)
|
|
||||||
119
tools/goctl/compare/testdata/testdata.go
vendored
119
tools/goctl/compare/testdata/testdata.go
vendored
@@ -1,119 +0,0 @@
|
|||||||
package testdata
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
"os/exec"
|
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/gookit/color"
|
|
||||||
"github.com/zeromicro/go-zero/tools/goctl/util/pathx"
|
|
||||||
)
|
|
||||||
|
|
||||||
type (
|
|
||||||
File struct {
|
|
||||||
IsDir bool
|
|
||||||
Path string
|
|
||||||
AbsolutePath string
|
|
||||||
Content string
|
|
||||||
Cmd string
|
|
||||||
}
|
|
||||||
|
|
||||||
Files []File
|
|
||||||
)
|
|
||||||
|
|
||||||
func (f File) execute(goctl string) error {
|
|
||||||
printDir := f.Path
|
|
||||||
dir := f.AbsolutePath
|
|
||||||
if !f.IsDir {
|
|
||||||
printDir = filepath.Dir(printDir)
|
|
||||||
dir = filepath.Dir(dir)
|
|
||||||
}
|
|
||||||
printCommand := strings.ReplaceAll(fmt.Sprintf("cd %s && %s", printDir, f.Cmd), "goctl", filepath.Base(goctl))
|
|
||||||
command := strings.ReplaceAll(fmt.Sprintf("cd %s && %s", dir, f.Cmd), "goctl", goctl)
|
|
||||||
fmt.Println(color.LightGreen.Render(printCommand))
|
|
||||||
cmd := exec.Command("sh", "-c", command)
|
|
||||||
cmd.Env = os.Environ()
|
|
||||||
cmd.Stdout = os.Stdout
|
|
||||||
cmd.Stderr = os.Stderr
|
|
||||||
return cmd.Run()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (fs Files) execute(goctl string) error {
|
|
||||||
for _, f := range fs {
|
|
||||||
err := f.execute(goctl)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func mustGetTestData(baseDir string) (Files, Files) {
|
|
||||||
if len(baseDir) == 0 {
|
|
||||||
dir, err := os.Getwd()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalln(err)
|
|
||||||
}
|
|
||||||
baseDir = dir
|
|
||||||
}
|
|
||||||
baseDir, err := filepath.Abs(baseDir)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
createFile := func(baseDir string, data File) (File, error) {
|
|
||||||
fp := filepath.Join(baseDir, data.Path)
|
|
||||||
dir := filepath.Dir(fp)
|
|
||||||
if data.IsDir {
|
|
||||||
dir = fp
|
|
||||||
}
|
|
||||||
if err := pathx.MkdirIfNotExist(dir); err != nil {
|
|
||||||
return data, err
|
|
||||||
}
|
|
||||||
data.AbsolutePath = fp
|
|
||||||
if data.IsDir {
|
|
||||||
return data, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return data, os.WriteFile(fp, []byte(data.Content), os.ModePerm)
|
|
||||||
}
|
|
||||||
oldDir := filepath.Join(baseDir, "old_fs")
|
|
||||||
newDir := filepath.Join(baseDir, "new_fs")
|
|
||||||
os.RemoveAll(oldDir)
|
|
||||||
os.RemoveAll(newDir)
|
|
||||||
var oldFiles, newFiles []File
|
|
||||||
for _, data := range list {
|
|
||||||
od, err := createFile(oldDir, data)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalln(err)
|
|
||||||
}
|
|
||||||
oldFiles = append(oldFiles, od)
|
|
||||||
nd, err := createFile(newDir, data)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalln(err)
|
|
||||||
}
|
|
||||||
newFiles = append(newFiles, nd)
|
|
||||||
}
|
|
||||||
return oldFiles, newFiles
|
|
||||||
}
|
|
||||||
|
|
||||||
func MustRun(baseDir string) {
|
|
||||||
oldFiles, newFiles := mustGetTestData(baseDir)
|
|
||||||
goctlOld, err := exec.LookPath("goctl.old")
|
|
||||||
must(err)
|
|
||||||
goctlNew, err := exec.LookPath("goctl")
|
|
||||||
must(err)
|
|
||||||
fmt.Println(color.LightBlue.Render("========================goctl.old======================="))
|
|
||||||
must(oldFiles.execute(goctlOld))
|
|
||||||
fmt.Println()
|
|
||||||
fmt.Println(color.LightBlue.Render("========================goctl.new======================="))
|
|
||||||
must(newFiles.execute(goctlNew))
|
|
||||||
}
|
|
||||||
|
|
||||||
func must(err error) {
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalln(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
3
tools/goctl/compare/testdata/unformat.api
vendored
3
tools/goctl/compare/testdata/unformat.api
vendored
@@ -1,3 +0,0 @@
|
|||||||
syntax = "v1"
|
|
||||||
|
|
||||||
type Foo struct{}
|
|
||||||
@@ -15,8 +15,8 @@ require (
|
|||||||
github.com/withfig/autocomplete-tools/integrations/cobra v1.2.1
|
github.com/withfig/autocomplete-tools/integrations/cobra v1.2.1
|
||||||
github.com/zeromicro/antlr v0.0.1
|
github.com/zeromicro/antlr v0.0.1
|
||||||
github.com/zeromicro/ddl-parser v1.0.5
|
github.com/zeromicro/ddl-parser v1.0.5
|
||||||
github.com/zeromicro/go-zero v1.6.6
|
github.com/zeromicro/go-zero v1.7.1
|
||||||
golang.org/x/text v0.16.0
|
golang.org/x/text v0.17.0
|
||||||
google.golang.org/grpc v1.65.0
|
google.golang.org/grpc v1.65.0
|
||||||
google.golang.org/protobuf v1.34.2
|
google.golang.org/protobuf v1.34.2
|
||||||
gopkg.in/yaml.v2 v2.4.0
|
gopkg.in/yaml.v2 v2.4.0
|
||||||
@@ -28,7 +28,7 @@ require (
|
|||||||
github.com/alicebob/miniredis/v2 v2.33.0 // indirect
|
github.com/alicebob/miniredis/v2 v2.33.0 // indirect
|
||||||
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20210521184019-c5ad59b459ec // indirect
|
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20210521184019-c5ad59b459ec // indirect
|
||||||
github.com/beorn7/perks v1.0.1 // indirect
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
|
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||||
github.com/coreos/go-semver v0.3.1 // indirect
|
github.com/coreos/go-semver v0.3.1 // indirect
|
||||||
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
|
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
|
||||||
@@ -36,7 +36,7 @@ require (
|
|||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||||
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
|
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
|
||||||
github.com/fatih/color v1.17.0 // indirect
|
github.com/fatih/color v1.17.0 // indirect
|
||||||
github.com/go-logr/logr v1.3.0 // indirect
|
github.com/go-logr/logr v1.4.2 // indirect
|
||||||
github.com/go-logr/stdr v1.2.2 // indirect
|
github.com/go-logr/stdr v1.2.2 // indirect
|
||||||
github.com/go-openapi/jsonpointer v0.19.6 // indirect
|
github.com/go-openapi/jsonpointer v0.19.6 // indirect
|
||||||
github.com/go-openapi/jsonreference v0.20.2 // indirect
|
github.com/go-openapi/jsonreference v0.20.2 // indirect
|
||||||
@@ -48,59 +48,59 @@ require (
|
|||||||
github.com/google/go-cmp v0.6.0 // indirect
|
github.com/google/go-cmp v0.6.0 // indirect
|
||||||
github.com/google/gofuzz v1.2.0 // indirect
|
github.com/google/gofuzz v1.2.0 // indirect
|
||||||
github.com/google/uuid v1.6.0 // indirect
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 // indirect
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
|
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
||||||
github.com/jackc/pgx/v5 v5.5.5 // indirect
|
github.com/jackc/pgx/v5 v5.6.0 // indirect
|
||||||
github.com/jackc/puddle/v2 v2.2.1 // indirect
|
github.com/jackc/puddle/v2 v2.2.1 // indirect
|
||||||
github.com/josharian/intern v1.0.0 // indirect
|
github.com/josharian/intern v1.0.0 // indirect
|
||||||
github.com/json-iterator/go v1.1.12 // indirect
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
|
github.com/klauspost/compress v1.17.9 // indirect
|
||||||
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
|
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
|
||||||
github.com/mailru/easyjson v0.7.7 // indirect
|
github.com/mailru/easyjson v0.7.7 // indirect
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
|
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||||
github.com/openzipkin/zipkin-go v0.4.2 // indirect
|
github.com/openzipkin/zipkin-go v0.4.3 // indirect
|
||||||
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
|
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/prometheus/client_golang v1.18.0 // indirect
|
github.com/prometheus/client_golang v1.20.2 // indirect
|
||||||
github.com/prometheus/client_model v0.5.0 // indirect
|
github.com/prometheus/client_model v0.6.1 // indirect
|
||||||
github.com/prometheus/common v0.45.0 // indirect
|
github.com/prometheus/common v0.55.0 // indirect
|
||||||
github.com/prometheus/procfs v0.12.0 // indirect
|
github.com/prometheus/procfs v0.15.1 // indirect
|
||||||
github.com/redis/go-redis/v9 v9.5.3 // indirect
|
github.com/redis/go-redis/v9 v9.6.1 // indirect
|
||||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||||
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
|
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
|
||||||
github.com/yuin/gopher-lua v1.1.1 // indirect
|
github.com/yuin/gopher-lua v1.1.1 // indirect
|
||||||
go.etcd.io/etcd/api/v3 v3.5.14 // indirect
|
go.etcd.io/etcd/api/v3 v3.5.15 // indirect
|
||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.14 // indirect
|
go.etcd.io/etcd/client/pkg/v3 v3.5.15 // indirect
|
||||||
go.etcd.io/etcd/client/v3 v3.5.14 // indirect
|
go.etcd.io/etcd/client/v3 v3.5.15 // indirect
|
||||||
go.opentelemetry.io/otel v1.19.0 // indirect
|
go.opentelemetry.io/otel v1.24.0 // indirect
|
||||||
go.opentelemetry.io/otel/exporters/jaeger v1.17.0 // indirect
|
go.opentelemetry.io/otel/exporters/jaeger v1.17.0 // indirect
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 // indirect
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 // indirect
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0 // indirect
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 // indirect
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 // indirect
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 // indirect
|
||||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.19.0 // indirect
|
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0 // indirect
|
||||||
go.opentelemetry.io/otel/exporters/zipkin v1.19.0 // indirect
|
go.opentelemetry.io/otel/exporters/zipkin v1.24.0 // indirect
|
||||||
go.opentelemetry.io/otel/metric v1.19.0 // indirect
|
go.opentelemetry.io/otel/metric v1.24.0 // indirect
|
||||||
go.opentelemetry.io/otel/sdk v1.19.0 // indirect
|
go.opentelemetry.io/otel/sdk v1.24.0 // indirect
|
||||||
go.opentelemetry.io/otel/trace v1.19.0 // indirect
|
go.opentelemetry.io/otel/trace v1.24.0 // indirect
|
||||||
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
|
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
|
||||||
go.uber.org/atomic v1.10.0 // indirect
|
go.uber.org/atomic v1.10.0 // indirect
|
||||||
go.uber.org/automaxprocs v1.5.3 // indirect
|
go.uber.org/automaxprocs v1.5.3 // indirect
|
||||||
go.uber.org/multierr v1.9.0 // indirect
|
go.uber.org/multierr v1.9.0 // indirect
|
||||||
go.uber.org/zap v1.24.0 // indirect
|
go.uber.org/zap v1.24.0 // indirect
|
||||||
golang.org/x/crypto v0.25.0 // indirect
|
golang.org/x/crypto v0.26.0 // indirect
|
||||||
golang.org/x/net v0.27.0 // indirect
|
golang.org/x/net v0.28.0 // indirect
|
||||||
golang.org/x/oauth2 v0.20.0 // indirect
|
golang.org/x/oauth2 v0.21.0 // indirect
|
||||||
golang.org/x/sync v0.7.0 // indirect
|
golang.org/x/sync v0.8.0 // indirect
|
||||||
golang.org/x/sys v0.22.0 // indirect
|
golang.org/x/sys v0.24.0 // indirect
|
||||||
golang.org/x/term v0.22.0 // indirect
|
golang.org/x/term v0.23.0 // indirect
|
||||||
golang.org/x/time v0.5.0 // indirect
|
golang.org/x/time v0.6.0 // indirect
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
|
google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240711142825-46eb208f015d // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240711142825-46eb208f015d // indirect
|
||||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
@@ -109,7 +109,7 @@ require (
|
|||||||
k8s.io/client-go v0.29.3 // indirect
|
k8s.io/client-go v0.29.3 // indirect
|
||||||
k8s.io/klog/v2 v2.110.1 // indirect
|
k8s.io/klog/v2 v2.110.1 // indirect
|
||||||
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
|
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
|
||||||
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
|
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
|
||||||
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
|
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
|
||||||
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
|
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
|
||||||
sigs.k8s.io/yaml v1.3.0 // indirect
|
sigs.k8s.io/yaml v1.3.0 // indirect
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302 h1:uvdUDbHQHO
|
|||||||
github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
|
github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
|
||||||
github.com/alicebob/miniredis/v2 v2.33.0 h1:uvTF0EDeu9RLnUEG27Db5I68ESoIxTiXbNUiji6lZrA=
|
github.com/alicebob/miniredis/v2 v2.33.0 h1:uvTF0EDeu9RLnUEG27Db5I68ESoIxTiXbNUiji6lZrA=
|
||||||
github.com/alicebob/miniredis/v2 v2.33.0/go.mod h1:MhP4a3EU7aENRi9aO+tHfTBZicLqQevyi/DJpoj6mi0=
|
github.com/alicebob/miniredis/v2 v2.33.0/go.mod h1:MhP4a3EU7aENRi9aO+tHfTBZicLqQevyi/DJpoj6mi0=
|
||||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
|
||||||
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20210521184019-c5ad59b459ec h1:EEyRvzmpEUZ+I8WmD5cw/vY8EqhambkOqy5iFr0908A=
|
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20210521184019-c5ad59b459ec h1:EEyRvzmpEUZ+I8WmD5cw/vY8EqhambkOqy5iFr0908A=
|
||||||
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20210521184019-c5ad59b459ec/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY=
|
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20210521184019-c5ad59b459ec/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY=
|
||||||
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
|
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
|
||||||
@@ -14,13 +13,10 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
|||||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||||
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
||||||
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
||||||
github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM=
|
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
|
||||||
github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
|
||||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
|
||||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
|
||||||
github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4=
|
github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4=
|
||||||
github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec=
|
github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec=
|
||||||
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
|
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
|
||||||
@@ -40,10 +36,10 @@ github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
|
|||||||
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI=
|
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI=
|
||||||
github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4=
|
github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4=
|
||||||
github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94=
|
github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94=
|
||||||
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
|
|
||||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||||
github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY=
|
|
||||||
github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||||
|
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
||||||
|
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||||
github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE=
|
github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE=
|
||||||
@@ -59,8 +55,6 @@ github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEe
|
|||||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||||
github.com/golang/glog v1.2.1 h1:OptwRhECazUx5ix5TTWC3EZhsZEHWcYWY4FQHTIubm4=
|
|
||||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
|
||||||
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
|
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
|
||||||
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
|
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
|
||||||
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||||
@@ -74,14 +68,12 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/
|
|||||||
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
|
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
|
||||||
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec=
|
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec=
|
||||||
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
|
||||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0=
|
github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0=
|
||||||
github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w=
|
github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w=
|
||||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0=
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 h1:RtRsiaGvWxcwd8y3BiRZxsylPT8hLWZ5SPcfI+3IDNk=
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k=
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0/go.mod h1:TzP6duP4Py2pHLVPPQp42aoYI92+PCrVotyR5e8Vqlk=
|
|
||||||
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw=
|
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw=
|
||||||
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
|
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
|
||||||
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
|
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
|
||||||
@@ -89,27 +81,28 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2
|
|||||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||||
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
||||||
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
||||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
|
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
|
||||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
||||||
github.com/jackc/pgx/v5 v5.5.5 h1:amBjrZVmksIdNjxGW/IiIMzxMKZFelXbUoPNb+8sjQw=
|
github.com/jackc/pgx/v5 v5.6.0 h1:SWJzexBzPL5jb0GEsrPMLIsi/3jOo7RHlzTjcAeDrPY=
|
||||||
github.com/jackc/pgx/v5 v5.5.5/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A=
|
github.com/jackc/pgx/v5 v5.6.0/go.mod h1:DNZ/vlrUnhWCoFGxHAG8U2ljioxukquj7utPDgtQdTw=
|
||||||
github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk=
|
github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk=
|
||||||
github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
||||||
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
|
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
|
||||||
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
|
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
|
||||||
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
|
|
||||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
|
||||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
github.com/kisielk/sqlstruct v0.0.0-20201105191214-5f3e10d3ab46/go.mod h1:yyMNCyc/Ib3bDTKd379tNMpB/7/H5TjM2Y9QJ5THLbE=
|
github.com/kisielk/sqlstruct v0.0.0-20201105191214-5f3e10d3ab46/go.mod h1:yyMNCyc/Ib3bDTKd379tNMpB/7/H5TjM2Y9QJ5THLbE=
|
||||||
|
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
|
||||||
|
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
|
||||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
|
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||||
github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8=
|
github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8=
|
||||||
github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
|
github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
|
||||||
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
|
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
|
||||||
@@ -119,9 +112,6 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk
|
|||||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
|
||||||
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg=
|
|
||||||
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k=
|
|
||||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
@@ -129,29 +119,26 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
|
|||||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
|
||||||
github.com/onsi/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4=
|
github.com/onsi/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4=
|
||||||
github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg=
|
github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg=
|
||||||
github.com/openzipkin/zipkin-go v0.4.2 h1:zjqfqHjUpPmB3c1GlCvvgsM1G4LkvqQbBDueDOCg/jA=
|
github.com/openzipkin/zipkin-go v0.4.3 h1:9EGwpqkgnwdEIJ+Od7QVSEIH+ocmm5nPat0G7sjsSdg=
|
||||||
github.com/openzipkin/zipkin-go v0.4.2/go.mod h1:ZeVkFjuuBiSy13y8vpSDCjMi9GoI3hPpCJSBx/EYFhY=
|
github.com/openzipkin/zipkin-go v0.4.3/go.mod h1:M9wCJZFWCo2RiY+o1eBCEMe0Dp2S5LDHcMZmk3RmK7c=
|
||||||
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
|
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
|
||||||
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
|
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
|
||||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
|
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
|
||||||
github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk=
|
github.com/prometheus/client_golang v1.20.2 h1:5ctymQzZlyOON1666svgwn3s6IKWgfbjsejTMiXIyjg=
|
||||||
github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA=
|
github.com/prometheus/client_golang v1.20.2/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
|
||||||
github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw=
|
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
|
||||||
github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI=
|
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
|
||||||
github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lneoxM=
|
github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc=
|
||||||
github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY=
|
github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8=
|
||||||
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
|
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
||||||
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
|
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
||||||
github.com/redis/go-redis/v9 v9.5.3 h1:fOAp1/uJG+ZtcITgZOfYFmTKPE7n4Vclj1wZFgRciUU=
|
github.com/redis/go-redis/v9 v9.6.1 h1:HHDteefn6ZkTtY5fGUE8tj8uy85AHk6zP7CpzIAM0y4=
|
||||||
github.com/redis/go-redis/v9 v9.5.3/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M=
|
github.com/redis/go-redis/v9 v9.6.1/go.mod h1:0C0c6ycQsdpVNQpxb1njEQIqkx5UcsM8FJCQLgE9+RA=
|
||||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
|
||||||
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
||||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
|
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
|
||||||
@@ -184,45 +171,43 @@ github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M
|
|||||||
github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
|
github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
|
||||||
github.com/zeromicro/antlr v0.0.1 h1:CQpIn/dc0pUjgGQ81y98s/NGOm2Hfru2NNio2I9mQgk=
|
github.com/zeromicro/antlr v0.0.1 h1:CQpIn/dc0pUjgGQ81y98s/NGOm2Hfru2NNio2I9mQgk=
|
||||||
github.com/zeromicro/antlr v0.0.1/go.mod h1:nfpjEwFR6Q4xGDJMcZnCL9tEfQRgszMwu3rDz2Z+p5M=
|
github.com/zeromicro/antlr v0.0.1/go.mod h1:nfpjEwFR6Q4xGDJMcZnCL9tEfQRgszMwu3rDz2Z+p5M=
|
||||||
github.com/zeromicro/antlr v1.0.0 h1:XqOf69i6619D3FveNpToDbqkLckw06o9M0+6E1R3jVE=
|
|
||||||
github.com/zeromicro/antlr v1.0.0/go.mod h1:nfpjEwFR6Q4xGDJMcZnCL9tEfQRgszMwu3rDz2Z+p5M=
|
|
||||||
github.com/zeromicro/ddl-parser v1.0.5 h1:LaVqHdzMTjasua1yYpIYaksxKqRzFrEukj2Wi2EbWaQ=
|
github.com/zeromicro/ddl-parser v1.0.5 h1:LaVqHdzMTjasua1yYpIYaksxKqRzFrEukj2Wi2EbWaQ=
|
||||||
github.com/zeromicro/ddl-parser v1.0.5/go.mod h1:ISU/8NuPyEpl9pa17Py9TBPetMjtsiHrb9f5XGiYbo8=
|
github.com/zeromicro/ddl-parser v1.0.5/go.mod h1:ISU/8NuPyEpl9pa17Py9TBPetMjtsiHrb9f5XGiYbo8=
|
||||||
github.com/zeromicro/go-zero v1.6.6 h1:nZTVYObklHiBdYJ/nPoAZ8kGVAplWSDjT7DGE7ur0uk=
|
github.com/zeromicro/go-zero v1.7.1 h1:2JNWRg/C91SPvY6tugSkBo2IrsfCfnnNjqcVFj9tCtA=
|
||||||
github.com/zeromicro/go-zero v1.6.6/go.mod h1:olKf1/hELbSmuIgLgJeoeNVp3tCbLqj6UmO7ATSta4A=
|
github.com/zeromicro/go-zero v1.7.1/go.mod h1:WFXfF92Exw0O7WECifS6r99JSzv4KEN49x9RhAfgkMc=
|
||||||
go.etcd.io/etcd/api/v3 v3.5.14 h1:vHObSCxyB9zlF60w7qzAdTcGaglbJOpSj1Xj9+WGxq0=
|
go.etcd.io/etcd/api/v3 v3.5.15 h1:3KpLJir1ZEBrYuV2v+Twaa/e2MdDCEZ/70H+lzEiwsk=
|
||||||
go.etcd.io/etcd/api/v3 v3.5.14/go.mod h1:BmtWcRlQvwa1h3G2jvKYwIQy4PkHlDej5t7uLMUdJUU=
|
go.etcd.io/etcd/api/v3 v3.5.15/go.mod h1:N9EhGzXq58WuMllgH9ZvnEr7SI9pS0k0+DHZezGp7jM=
|
||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.14 h1:SaNH6Y+rVEdxfpA2Jr5wkEvN6Zykme5+YnbCkxvuWxQ=
|
go.etcd.io/etcd/client/pkg/v3 v3.5.15 h1:fo0HpWz/KlHGMCC+YejpiCmyWDEuIpnTDzpJLB5fWlA=
|
||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.14/go.mod h1:8uMgAokyG1czCtIdsq+AGyYQMvpIKnSvPjFMunkgeZI=
|
go.etcd.io/etcd/client/pkg/v3 v3.5.15/go.mod h1:mXDI4NAOwEiszrHCb0aqfAYNCrZP4e9hRca3d1YK8EU=
|
||||||
go.etcd.io/etcd/client/v3 v3.5.14 h1:CWfRs4FDaDoSz81giL7zPpZH2Z35tbOrAJkkjMqOupg=
|
go.etcd.io/etcd/client/v3 v3.5.15 h1:23M0eY4Fd/inNv1ZfU3AxrbbOdW79r9V9Rl62Nm6ip4=
|
||||||
go.etcd.io/etcd/client/v3 v3.5.14/go.mod h1:k3XfdV/VIHy/97rqWjoUzrj9tk7GgJGH9J8L4dNXmAk=
|
go.etcd.io/etcd/client/v3 v3.5.15/go.mod h1:CLSJxrYjvLtHsrPKsy7LmZEE+DK2ktfd2bN4RhBMwlU=
|
||||||
go.opentelemetry.io/otel v1.19.0 h1:MuS/TNf4/j4IXsZuJegVzI1cwut7Qc00344rgH7p8bs=
|
go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo=
|
||||||
go.opentelemetry.io/otel v1.19.0/go.mod h1:i0QyjOq3UPoTzff0PJB2N66fb4S0+rSbSB15/oyH9fY=
|
go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo=
|
||||||
go.opentelemetry.io/otel/exporters/jaeger v1.17.0 h1:D7UpUy2Xc2wsi1Ras6V40q806WM07rqoCWzXu7Sqy+4=
|
go.opentelemetry.io/otel/exporters/jaeger v1.17.0 h1:D7UpUy2Xc2wsi1Ras6V40q806WM07rqoCWzXu7Sqy+4=
|
||||||
go.opentelemetry.io/otel/exporters/jaeger v1.17.0/go.mod h1:nPCqOnEH9rNLKqH/+rrUjiMzHJdV1BlpKcTwRTyKkKI=
|
go.opentelemetry.io/otel/exporters/jaeger v1.17.0/go.mod h1:nPCqOnEH9rNLKqH/+rrUjiMzHJdV1BlpKcTwRTyKkKI=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 h1:Mne5On7VWdx7omSrSSZvM4Kw7cS7NQkOOmLcgscI51U=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 h1:t6wl9SPayj+c7lEIFgm4ooDBZVb01IhLB4InpomhRw8=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0/go.mod h1:IPtUMKL4O3tH5y+iXVyAXqpAwMuzC1IrxVS81rummfE=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0/go.mod h1:iSDOcsnSA5INXzZtwaBPrKp/lWu/V14Dd+llD0oI2EA=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0 h1:3d+S281UTjM+AbF31XSOYn1qXn3BgIdWl8HNEpx08Jk=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 h1:Mw5xcxMwlqoJd97vwPxA8isEaIoxsta9/Q51+TTJLGE=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0/go.mod h1:0+KuTDyKL4gjKCF75pHOX4wuzYDUZYfAQdSu43o+Z2I=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0/go.mod h1:CQNu9bj7o7mC6U7+CA/schKEYakYXWr79ucDHTMGhCM=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 h1:IeMeyr1aBvBiPVYihXIaeIZba6b8E1bYp7lbdxK8CQg=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 h1:Xw8U6u2f8DK2XAkGRFV7BBLENgnTGX9i4rQRxJf+/vs=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0/go.mod h1:oVdCUtjq9MK9BlS7TtucsQwUcXcymNiEDjgDD2jMtZU=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0/go.mod h1:6KW1Fm6R/s6Z3PGXwSJN2K4eT6wQB3vXX6CVnYX9NmM=
|
||||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.19.0 h1:Nw7Dv4lwvGrI68+wULbcq7su9K2cebeCUrDjVrUJHxM=
|
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0 h1:s0PHtIkN+3xrbDOpt2M8OTG92cWqUESvzh2MxiR5xY8=
|
||||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.19.0/go.mod h1:1MsF6Y7gTqosgoZvHlzcaaM8DIMNZgJh87ykokoNH7Y=
|
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0/go.mod h1:hZlFbDbRt++MMPCCfSJfmhkGIWnX1h3XjkfxZUjLrIA=
|
||||||
go.opentelemetry.io/otel/exporters/zipkin v1.19.0 h1:EGY0h5mGliP9o/nIkVuLI0vRiQqmsYOcbwCuotksO1o=
|
go.opentelemetry.io/otel/exporters/zipkin v1.24.0 h1:3evrL5poBuh1KF51D9gO/S+N/1msnm4DaBqs/rpXUqY=
|
||||||
go.opentelemetry.io/otel/exporters/zipkin v1.19.0/go.mod h1:JQgTGJP11yi3o4GHzIWYodhPisxANdqxF1eHwDSnJrI=
|
go.opentelemetry.io/otel/exporters/zipkin v1.24.0/go.mod h1:0EHgD8R0+8yRhUYJOGR8Hfg2dpiJQxDOszd5smVO9wM=
|
||||||
go.opentelemetry.io/otel/metric v1.19.0 h1:aTzpGtV0ar9wlV4Sna9sdJyII5jTVJEvKETPiOKwvpE=
|
go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI=
|
||||||
go.opentelemetry.io/otel/metric v1.19.0/go.mod h1:L5rUsV9kM1IxCj1MmSdS+JQAcVm319EUrDVLrt7jqt8=
|
go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco=
|
||||||
go.opentelemetry.io/otel/sdk v1.19.0 h1:6USY6zH+L8uMH8L3t1enZPR3WFEmSTADlqldyHtJi3o=
|
go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw=
|
||||||
go.opentelemetry.io/otel/sdk v1.19.0/go.mod h1:NedEbbS4w3C6zElbLdPJKOpJQOrGUJ+GfzpjUvI0v1A=
|
go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg=
|
||||||
go.opentelemetry.io/otel/trace v1.19.0 h1:DFVQmlVbfVeOuBRrwdtaehRrWiL1JoVs9CPIQ1Dzxpg=
|
go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI=
|
||||||
go.opentelemetry.io/otel/trace v1.19.0/go.mod h1:mfaSyvGyEJEI0nyV2I4qhNQnbBOUUmYZpYojqMnX2vo=
|
go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU=
|
||||||
go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I=
|
go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0=
|
||||||
go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM=
|
go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8=
|
||||||
go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ=
|
go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ=
|
||||||
go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
||||||
go.uber.org/automaxprocs v1.5.3 h1:kWazyxZUrS3Gs4qUpbwo5kEIMGe/DAvi5Z4tl2NW4j8=
|
go.uber.org/automaxprocs v1.5.3 h1:kWazyxZUrS3Gs4qUpbwo5kEIMGe/DAvi5Z4tl2NW4j8=
|
||||||
go.uber.org/automaxprocs v1.5.3/go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0=
|
go.uber.org/automaxprocs v1.5.3/go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0=
|
||||||
go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A=
|
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||||
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
|
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
|
||||||
go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ=
|
go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ=
|
||||||
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
|
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
|
||||||
@@ -230,8 +215,8 @@ go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
|
|||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
|
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
|
||||||
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
|
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
|
||||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
@@ -240,16 +225,16 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
|
|||||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||||
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
|
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
|
||||||
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
|
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
|
||||||
golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo=
|
golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs=
|
||||||
golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
|
golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
|
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
|
||||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
@@ -258,17 +243,17 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
|
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
|
||||||
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk=
|
golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU=
|
||||||
golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4=
|
golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
|
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
|
||||||
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
|
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
||||||
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
|
golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U=
|
||||||
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||||
@@ -279,8 +264,8 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
|
|||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 h1:7whR9kGa5LUwFtpLm2ArCEejtnxlGeLbAyjFY8sGNFw=
|
google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d h1:kHjw/5UfflP/L5EbledDrcG4C2597RtymmGRZvHiCuY=
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157/go.mod h1:99sLkeliLXfdj2J75X3Ho+rrVCaJze0uwN7zDDkjPVU=
|
google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d/go.mod h1:mw8MG/Qz5wfgYr6VqVCiZcHe/GJEfI+oGGDCohaVgB0=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240711142825-46eb208f015d h1:JU0iKnSg02Gmb5ZdV8nYsKEKsP6o/FGVWTrw4i1DA9A=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240711142825-46eb208f015d h1:JU0iKnSg02Gmb5ZdV8nYsKEKsP6o/FGVWTrw4i1DA9A=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240711142825-46eb208f015d/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240711142825-46eb208f015d/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
|
||||||
google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc=
|
google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc=
|
||||||
@@ -309,8 +294,8 @@ k8s.io/klog/v2 v2.110.1 h1:U/Af64HJf7FcwMcXyKm2RPM22WZzyR7OSpYj5tg3cL0=
|
|||||||
k8s.io/klog/v2 v2.110.1/go.mod h1:YGtd1984u+GgbuZ7e08/yBuAfKLSO0+uR1Fhi6ExXjo=
|
k8s.io/klog/v2 v2.110.1/go.mod h1:YGtd1984u+GgbuZ7e08/yBuAfKLSO0+uR1Fhi6ExXjo=
|
||||||
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/AuzbMm96cd3YHRTU83I780=
|
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/AuzbMm96cd3YHRTU83I780=
|
||||||
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA=
|
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA=
|
||||||
k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI=
|
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 h1:pUdcCO1Lk/tbT5ztQWOBi5HBgbBP1J8+AsQnQCKsi8A=
|
||||||
k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
|
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
|
||||||
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
|
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
|
||||||
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
|
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
|
||||||
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4=
|
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4=
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// BuildVersion is the version of goctl.
|
// BuildVersion is the version of goctl.
|
||||||
const BuildVersion = "1.7.0"
|
const BuildVersion = "1.7.1"
|
||||||
|
|
||||||
var tag = map[string]int{"pre-alpha": 0, "alpha": 1, "pre-bata": 2, "beta": 3, "released": 4, "": 5}
|
var tag = map[string]int{"pre-alpha": 0, "alpha": 1, "pre-bata": 2, "beta": 3, "released": 4, "": 5}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/tools/goctl/config"
|
"github.com/zeromicro/go-zero/tools/goctl/config"
|
||||||
|
"github.com/zeromicro/go-zero/tools/goctl/internal/version"
|
||||||
"github.com/zeromicro/go-zero/tools/goctl/model/mongo/template"
|
"github.com/zeromicro/go-zero/tools/goctl/model/mongo/template"
|
||||||
"github.com/zeromicro/go-zero/tools/goctl/util"
|
"github.com/zeromicro/go-zero/tools/goctl/util"
|
||||||
"github.com/zeromicro/go-zero/tools/goctl/util/format"
|
"github.com/zeromicro/go-zero/tools/goctl/util/format"
|
||||||
@@ -59,6 +60,7 @@ func generateModel(ctx *Context) error {
|
|||||||
"Type": stringx.From(t).Title(),
|
"Type": stringx.From(t).Title(),
|
||||||
"lowerType": stringx.From(t).Untitle(),
|
"lowerType": stringx.From(t).Untitle(),
|
||||||
"Cache": ctx.Cache,
|
"Cache": ctx.Cache,
|
||||||
|
"version": version.BuildVersion,
|
||||||
}, output, true); err != nil {
|
}, output, true); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
// Code generated by goctl. DO NOT EDIT.
|
// Code generated by goctl. DO NOT EDIT.
|
||||||
|
// goctl {{.version}}
|
||||||
|
|
||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
_ "embed"
|
_ "embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/tools/goctl/internal/version"
|
||||||
"github.com/zeromicro/go-zero/tools/goctl/util"
|
"github.com/zeromicro/go-zero/tools/goctl/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -44,6 +45,8 @@ var ModelCustom string
|
|||||||
|
|
||||||
// ModelGen defines a template for model
|
// ModelGen defines a template for model
|
||||||
var ModelGen = fmt.Sprintf(`%s
|
var ModelGen = fmt.Sprintf(`%s
|
||||||
|
// versions:
|
||||||
|
// goctl version: %s
|
||||||
|
|
||||||
package {{.pkg}}
|
package {{.pkg}}
|
||||||
{{.imports}}
|
{{.imports}}
|
||||||
@@ -57,7 +60,7 @@ package {{.pkg}}
|
|||||||
{{.extraMethod}}
|
{{.extraMethod}}
|
||||||
{{.tableName}}
|
{{.tableName}}
|
||||||
{{.customized}}
|
{{.customized}}
|
||||||
`, util.DoNotEditHead)
|
`, util.DoNotEditHead, version.BuildVersion)
|
||||||
|
|
||||||
// Insert defines a template for insert code in model
|
// Insert defines a template for insert code in model
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ func (a *Analyzer) astTypeToSpec(in ast.DataType) (spec.Type, error) {
|
|||||||
return nil, ast.SyntaxError(v.Pos(), "unsupported empty struct")
|
return nil, ast.SyntaxError(v.Pos(), "unsupported empty struct")
|
||||||
}
|
}
|
||||||
|
|
||||||
return spec.DefineStruct{
|
return spec.NestedStruct{
|
||||||
RawName: v.RawText(),
|
RawName: v.RawText(),
|
||||||
Members: members,
|
Members: members,
|
||||||
}, nil
|
}, nil
|
||||||
@@ -78,7 +78,7 @@ func (a *Analyzer) astTypeToSpec(in ast.DataType) (spec.Type, error) {
|
|||||||
|
|
||||||
return spec.MapType{
|
return spec.MapType{
|
||||||
RawName: v.RawText(),
|
RawName: v.RawText(),
|
||||||
Key: v.RawText(),
|
Key: v.Key.RawText(),
|
||||||
Value: value,
|
Value: value,
|
||||||
}, nil
|
}, nil
|
||||||
case *ast.PointerDataType:
|
case *ast.PointerDataType:
|
||||||
@@ -347,14 +347,12 @@ func (a *Analyzer) fillTypes() error {
|
|||||||
for _, member := range v.Members {
|
for _, member := range v.Members {
|
||||||
switch v := member.Type.(type) {
|
switch v := member.Type.(type) {
|
||||||
case spec.DefineStruct:
|
case spec.DefineStruct:
|
||||||
if !v.IsNestedStruct() {
|
tp, err := a.findDefinedType(v.RawName)
|
||||||
tp, err := a.findDefinedType(v.RawName)
|
if err != nil {
|
||||||
if err != nil {
|
return err
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
member.Type = tp
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
member.Type = tp
|
||||||
}
|
}
|
||||||
members = append(members, member)
|
members = append(members, member)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,12 +56,8 @@ func initProject() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.Must(pathx.MkdirIfNotExist(projectDir))
|
log.Must(pathx.MkdirIfNotExist(projectDir))
|
||||||
if hasGoMod, _ := ctx.IsGoMod(projectDir); hasGoMod {
|
_, err = ctx.Prepare(projectDir)
|
||||||
return
|
logx.Must(err)
|
||||||
}
|
|
||||||
if exitCode := execCommand(projectDir, "go mod init "+baseDir); exitCode != 0 {
|
|
||||||
log.Fatalln("Init process exit")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func run(_ *cobra.Command, _ []string) error {
|
func run(_ *cobra.Command, _ []string) error {
|
||||||
|
|||||||
@@ -62,4 +62,4 @@ service Test_Service {
|
|||||||
rpc ClientStream (stream Req) returns (Reply);
|
rpc ClientStream (stream Req) returns (Reply);
|
||||||
// stream
|
// stream
|
||||||
rpc Stream(stream Req) returns (stream Reply);
|
rpc Stream(stream Req) returns (stream Reply);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,13 +81,13 @@ func Test_getRealModule(t *testing.T) {
|
|||||||
"Path":"foo",
|
"Path":"foo",
|
||||||
"Dir":"/home/foo",
|
"Dir":"/home/foo",
|
||||||
"GoMod":"/home/foo/go.mod",
|
"GoMod":"/home/foo/go.mod",
|
||||||
"GoVersion":"go1.19"
|
"GoVersion":"go1.20"
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
"Path":"bar",
|
"Path":"bar",
|
||||||
"Dir":"/home/bar",
|
"Dir":"/home/bar",
|
||||||
"GoMod":"/home/bar/go.mod",
|
"GoMod":"/home/bar/go.mod",
|
||||||
"GoVersion":"go1.19"
|
"GoVersion":"go1.20"
|
||||||
}`, nil
|
}`, nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -95,7 +95,7 @@ func Test_getRealModule(t *testing.T) {
|
|||||||
Path: "bar",
|
Path: "bar",
|
||||||
Dir: "/home/bar",
|
Dir: "/home/bar",
|
||||||
GoMod: "/home/bar/go.mod",
|
GoMod: "/home/bar/go.mod",
|
||||||
GoVersion: "go1.19",
|
GoVersion: "go1.20",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -143,26 +143,26 @@ func TestDecodePackages(t *testing.T) {
|
|||||||
"Path":"foo",
|
"Path":"foo",
|
||||||
"Dir":"/home/foo",
|
"Dir":"/home/foo",
|
||||||
"GoMod":"/home/foo/go.mod",
|
"GoMod":"/home/foo/go.mod",
|
||||||
"GoVersion":"go1.19"
|
"GoVersion":"go1.20"
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
"Path":"bar",
|
"Path":"bar",
|
||||||
"Dir":"/home/bar",
|
"Dir":"/home/bar",
|
||||||
"GoMod":"/home/bar/go.mod",
|
"GoMod":"/home/bar/go.mod",
|
||||||
"GoVersion":"go1.19"
|
"GoVersion":"go1.20"
|
||||||
}`),
|
}`),
|
||||||
want: []Module{
|
want: []Module{
|
||||||
{
|
{
|
||||||
Path: "foo",
|
Path: "foo",
|
||||||
Dir: "/home/foo",
|
Dir: "/home/foo",
|
||||||
GoMod: "/home/foo/go.mod",
|
GoMod: "/home/foo/go.mod",
|
||||||
GoVersion: "go1.19",
|
GoVersion: "go1.20",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Path: "bar",
|
Path: "bar",
|
||||||
Dir: "/home/bar",
|
Dir: "/home/bar",
|
||||||
GoMod: "/home/bar/go.mod",
|
GoMod: "/home/bar/go.mod",
|
||||||
GoVersion: "go1.19",
|
GoVersion: "go1.20",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -173,14 +173,14 @@ func TestDecodePackages(t *testing.T) {
|
|||||||
"Path":"foo",
|
"Path":"foo",
|
||||||
"Dir":"/home/foo",
|
"Dir":"/home/foo",
|
||||||
"GoMod":"/home/foo/go.mod",
|
"GoMod":"/home/foo/go.mod",
|
||||||
"GoVersion":"go1.19"
|
"GoVersion":"go1.20"
|
||||||
}`),
|
}`),
|
||||||
want: []Module{
|
want: []Module{
|
||||||
{
|
{
|
||||||
Path: "foo",
|
Path: "foo",
|
||||||
Dir: "/home/foo",
|
Dir: "/home/foo",
|
||||||
GoMod: "/home/foo/go.mod",
|
GoMod: "/home/foo/go.mod",
|
||||||
GoVersion: "go1.19",
|
GoVersion: "go1.20",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,17 +1,21 @@
|
|||||||
package util
|
package util
|
||||||
|
|
||||||
|
import "github.com/zeromicro/go-zero/tools/goctl/internal/version"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// DoNotEditHead added to the beginning of a file to prompt the user not to edit
|
// DoNotEditHead added to the beginning of a file to prompt the user not to edit
|
||||||
DoNotEditHead = "// Code generated by goctl. DO NOT EDIT."
|
DoNotEditHead = "// Code generated by goctl. DO NOT EDIT."
|
||||||
|
|
||||||
headTemplate = DoNotEditHead + `
|
headTemplate = DoNotEditHead + `
|
||||||
|
// goctl {{.version}}
|
||||||
// Source: {{.source}}`
|
// Source: {{.source}}`
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetHead returns a code head string with source filename
|
// GetHead returns a code head string with source filename
|
||||||
func GetHead(source string) string {
|
func GetHead(source string) string {
|
||||||
buffer, _ := With("head").Parse(headTemplate).Execute(map[string]any{
|
buffer, _ := With("head").Parse(headTemplate).Execute(map[string]any{
|
||||||
"source": source,
|
"source": source,
|
||||||
|
"version": version.BuildVersion,
|
||||||
})
|
})
|
||||||
return buffer.String()
|
return buffer.String()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// NewRpcPubServer returns a Server.
|
// NewRpcPubServer returns a Server.
|
||||||
func NewRpcPubServer(etcd discov.EtcdConf, listenOn string, middlewares ServerMiddlewaresConf,
|
func NewRpcPubServer(etcd discov.EtcdConf, listenOn string,
|
||||||
opts ...ServerOption) (Server, error) {
|
opts ...ServerOption) (Server, error) {
|
||||||
registerEtcd := func() error {
|
registerEtcd := func() error {
|
||||||
pubListenOn := figureOutListenOn(listenOn)
|
pubListenOn := figureOutListenOn(listenOn)
|
||||||
@@ -34,7 +34,7 @@ func NewRpcPubServer(etcd discov.EtcdConf, listenOn string, middlewares ServerMi
|
|||||||
}
|
}
|
||||||
server := keepAliveServer{
|
server := keepAliveServer{
|
||||||
registerEtcd: registerEtcd,
|
registerEtcd: registerEtcd,
|
||||||
Server: NewRpcServer(listenOn, middlewares, opts...),
|
Server: NewRpcServer(listenOn, opts...),
|
||||||
}
|
}
|
||||||
|
|
||||||
return server, nil
|
return server, nil
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ func TestNewRpcPubServer(t *testing.T) {
|
|||||||
User: "user",
|
User: "user",
|
||||||
Pass: "pass",
|
Pass: "pass",
|
||||||
ID: 10,
|
ID: 10,
|
||||||
}, "", ServerMiddlewaresConf{})
|
}, "")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.NotPanics(t, func() {
|
assert.NotPanics(t, func() {
|
||||||
s.Start(nil)
|
s.Start(nil)
|
||||||
|
|||||||
@@ -5,9 +5,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/proc"
|
"github.com/zeromicro/go-zero/core/proc"
|
||||||
"github.com/zeromicro/go-zero/core/stat"
|
|
||||||
"github.com/zeromicro/go-zero/internal/health"
|
"github.com/zeromicro/go-zero/internal/health"
|
||||||
"github.com/zeromicro/go-zero/zrpc/internal/serverinterceptors"
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/health/grpc_health_v1"
|
"google.golang.org/grpc/health/grpc_health_v1"
|
||||||
)
|
)
|
||||||
@@ -19,38 +17,31 @@ type (
|
|||||||
ServerOption func(options *rpcServerOptions)
|
ServerOption func(options *rpcServerOptions)
|
||||||
|
|
||||||
rpcServerOptions struct {
|
rpcServerOptions struct {
|
||||||
metrics *stat.Metrics
|
health bool
|
||||||
health bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rpcServer struct {
|
rpcServer struct {
|
||||||
*baseRpcServer
|
*baseRpcServer
|
||||||
name string
|
name string
|
||||||
middlewares ServerMiddlewaresConf
|
|
||||||
healthManager health.Probe
|
healthManager health.Probe
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewRpcServer returns a Server.
|
// NewRpcServer returns a Server.
|
||||||
func NewRpcServer(addr string, middlewares ServerMiddlewaresConf, opts ...ServerOption) Server {
|
func NewRpcServer(addr string, opts ...ServerOption) Server {
|
||||||
var options rpcServerOptions
|
var options rpcServerOptions
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
opt(&options)
|
opt(&options)
|
||||||
}
|
}
|
||||||
if options.metrics == nil {
|
|
||||||
options.metrics = stat.NewMetrics(addr)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &rpcServer{
|
return &rpcServer{
|
||||||
baseRpcServer: newBaseRpcServer(addr, &options),
|
baseRpcServer: newBaseRpcServer(addr, &options),
|
||||||
middlewares: middlewares,
|
|
||||||
healthManager: health.NewHealthManager(fmt.Sprintf("%s-%s", probeNamePrefix, addr)),
|
healthManager: health.NewHealthManager(fmt.Sprintf("%s-%s", probeNamePrefix, addr)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *rpcServer) SetName(name string) {
|
func (s *rpcServer) SetName(name string) {
|
||||||
s.name = name
|
s.name = name
|
||||||
s.baseRpcServer.SetName(name)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *rpcServer) Start(register RegisterFn) error {
|
func (s *rpcServer) Start(register RegisterFn) error {
|
||||||
@@ -59,8 +50,8 @@ func (s *rpcServer) Start(register RegisterFn) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
unaryInterceptorOption := grpc.ChainUnaryInterceptor(s.buildUnaryInterceptors()...)
|
unaryInterceptorOption := grpc.ChainUnaryInterceptor(s.unaryInterceptors...)
|
||||||
streamInterceptorOption := grpc.ChainStreamInterceptor(s.buildStreamInterceptors()...)
|
streamInterceptorOption := grpc.ChainStreamInterceptor(s.streamInterceptors...)
|
||||||
|
|
||||||
options := append(s.options, unaryInterceptorOption, streamInterceptorOption)
|
options := append(s.options, unaryInterceptorOption, streamInterceptorOption)
|
||||||
server := grpc.NewServer(options...)
|
server := grpc.NewServer(options...)
|
||||||
@@ -87,52 +78,6 @@ func (s *rpcServer) Start(register RegisterFn) error {
|
|||||||
return server.Serve(lis)
|
return server.Serve(lis)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *rpcServer) buildStreamInterceptors() []grpc.StreamServerInterceptor {
|
|
||||||
var interceptors []grpc.StreamServerInterceptor
|
|
||||||
|
|
||||||
if s.middlewares.Trace {
|
|
||||||
interceptors = append(interceptors, serverinterceptors.StreamTracingInterceptor)
|
|
||||||
}
|
|
||||||
if s.middlewares.Recover {
|
|
||||||
interceptors = append(interceptors, serverinterceptors.StreamRecoverInterceptor)
|
|
||||||
}
|
|
||||||
if s.middlewares.Breaker {
|
|
||||||
interceptors = append(interceptors, serverinterceptors.StreamBreakerInterceptor)
|
|
||||||
}
|
|
||||||
|
|
||||||
return append(interceptors, s.streamInterceptors...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *rpcServer) buildUnaryInterceptors() []grpc.UnaryServerInterceptor {
|
|
||||||
var interceptors []grpc.UnaryServerInterceptor
|
|
||||||
|
|
||||||
if s.middlewares.Trace {
|
|
||||||
interceptors = append(interceptors, serverinterceptors.UnaryTracingInterceptor)
|
|
||||||
}
|
|
||||||
if s.middlewares.Recover {
|
|
||||||
interceptors = append(interceptors, serverinterceptors.UnaryRecoverInterceptor)
|
|
||||||
}
|
|
||||||
if s.middlewares.Stat {
|
|
||||||
interceptors = append(interceptors,
|
|
||||||
serverinterceptors.UnaryStatInterceptor(s.metrics, s.middlewares.StatConf))
|
|
||||||
}
|
|
||||||
if s.middlewares.Prometheus {
|
|
||||||
interceptors = append(interceptors, serverinterceptors.UnaryPrometheusInterceptor)
|
|
||||||
}
|
|
||||||
if s.middlewares.Breaker {
|
|
||||||
interceptors = append(interceptors, serverinterceptors.UnaryBreakerInterceptor)
|
|
||||||
}
|
|
||||||
|
|
||||||
return append(interceptors, s.unaryInterceptors...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// WithMetrics returns a func that sets metrics to a Server.
|
|
||||||
func WithMetrics(metrics *stat.Metrics) ServerOption {
|
|
||||||
return func(options *rpcServerOptions) {
|
|
||||||
options.metrics = metrics
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// WithRpcHealth returns a func that sets rpc health switch to a Server.
|
// WithRpcHealth returns a func that sets rpc health switch to a Server.
|
||||||
func WithRpcHealth(health bool) ServerOption {
|
func WithRpcHealth(health bool) ServerOption {
|
||||||
return func(options *rpcServerOptions) {
|
return func(options *rpcServerOptions) {
|
||||||
|
|||||||
@@ -1,27 +1,18 @@
|
|||||||
package internal
|
package internal
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/zeromicro/go-zero/core/proc"
|
"github.com/zeromicro/go-zero/core/proc"
|
||||||
"github.com/zeromicro/go-zero/core/stat"
|
|
||||||
"github.com/zeromicro/go-zero/internal/mock"
|
"github.com/zeromicro/go-zero/internal/mock"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestRpcServer(t *testing.T) {
|
func TestRpcServer(t *testing.T) {
|
||||||
metrics := stat.NewMetrics("foo")
|
server := NewRpcServer("localhost:54321", WithRpcHealth(true))
|
||||||
server := NewRpcServer("localhost:54321", ServerMiddlewaresConf{
|
|
||||||
Trace: true,
|
|
||||||
Recover: true,
|
|
||||||
Stat: true,
|
|
||||||
Prometheus: true,
|
|
||||||
Breaker: true,
|
|
||||||
}, WithMetrics(metrics), WithRpcHealth(true))
|
|
||||||
server.SetName("mock")
|
server.SetName("mock")
|
||||||
var wg, wgDone sync.WaitGroup
|
var wg, wgDone sync.WaitGroup
|
||||||
var grpcServer *grpc.Server
|
var grpcServer *grpc.Server
|
||||||
@@ -52,13 +43,7 @@ func TestRpcServer(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRpcServer_WithBadAddress(t *testing.T) {
|
func TestRpcServer_WithBadAddress(t *testing.T) {
|
||||||
server := NewRpcServer("localhost:111111", ServerMiddlewaresConf{
|
server := NewRpcServer("localhost:111111", WithRpcHealth(true))
|
||||||
Trace: true,
|
|
||||||
Recover: true,
|
|
||||||
Stat: true,
|
|
||||||
Prometheus: true,
|
|
||||||
Breaker: true,
|
|
||||||
}, WithRpcHealth(true))
|
|
||||||
server.SetName("mock")
|
server.SetName("mock")
|
||||||
err := server.Start(func(server *grpc.Server) {
|
err := server.Start(func(server *grpc.Server) {
|
||||||
mock.RegisterDepositServiceServer(server, new(mock.DepositServer))
|
mock.RegisterDepositServiceServer(server, new(mock.DepositServer))
|
||||||
@@ -67,115 +52,3 @@ func TestRpcServer_WithBadAddress(t *testing.T) {
|
|||||||
|
|
||||||
proc.WrapUp()
|
proc.WrapUp()
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRpcServer_buildUnaryInterceptor(t *testing.T) {
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
r *rpcServer
|
|
||||||
len int
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "empty",
|
|
||||||
r: &rpcServer{
|
|
||||||
baseRpcServer: &baseRpcServer{},
|
|
||||||
},
|
|
||||||
len: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "custom",
|
|
||||||
r: &rpcServer{
|
|
||||||
baseRpcServer: &baseRpcServer{
|
|
||||||
unaryInterceptors: []grpc.UnaryServerInterceptor{
|
|
||||||
func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo,
|
|
||||||
handler grpc.UnaryHandler) (interface{}, error) {
|
|
||||||
return nil, nil
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
len: 1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "middleware",
|
|
||||||
r: &rpcServer{
|
|
||||||
baseRpcServer: &baseRpcServer{
|
|
||||||
unaryInterceptors: []grpc.UnaryServerInterceptor{
|
|
||||||
func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo,
|
|
||||||
handler grpc.UnaryHandler) (interface{}, error) {
|
|
||||||
return nil, nil
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
middlewares: ServerMiddlewaresConf{
|
|
||||||
Trace: true,
|
|
||||||
Recover: true,
|
|
||||||
Stat: true,
|
|
||||||
Prometheus: true,
|
|
||||||
Breaker: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
len: 6,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, test := range tests {
|
|
||||||
t.Run(test.name, func(t *testing.T) {
|
|
||||||
assert.Equal(t, test.len, len(test.r.buildUnaryInterceptors()))
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRpcServer_buildStreamInterceptor(t *testing.T) {
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
r *rpcServer
|
|
||||||
len int
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "empty",
|
|
||||||
r: &rpcServer{
|
|
||||||
baseRpcServer: &baseRpcServer{},
|
|
||||||
},
|
|
||||||
len: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "custom",
|
|
||||||
r: &rpcServer{
|
|
||||||
baseRpcServer: &baseRpcServer{
|
|
||||||
streamInterceptors: []grpc.StreamServerInterceptor{
|
|
||||||
func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo,
|
|
||||||
handler grpc.StreamHandler) error {
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
len: 1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "middleware",
|
|
||||||
r: &rpcServer{
|
|
||||||
baseRpcServer: &baseRpcServer{
|
|
||||||
streamInterceptors: []grpc.StreamServerInterceptor{
|
|
||||||
func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo,
|
|
||||||
handler grpc.StreamHandler) error {
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
middlewares: ServerMiddlewaresConf{
|
|
||||||
Trace: true,
|
|
||||||
Recover: true,
|
|
||||||
Breaker: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
len: 4,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, test := range tests {
|
|
||||||
t.Run(test.name, func(t *testing.T) {
|
|
||||||
assert.Equal(t, test.len, len(test.r.buildStreamInterceptors()))
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package internal
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/stat"
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/health"
|
"google.golang.org/grpc/health"
|
||||||
"google.golang.org/grpc/keepalive"
|
"google.golang.org/grpc/keepalive"
|
||||||
@@ -27,7 +26,6 @@ type (
|
|||||||
baseRpcServer struct {
|
baseRpcServer struct {
|
||||||
address string
|
address string
|
||||||
health *health.Server
|
health *health.Server
|
||||||
metrics *stat.Metrics
|
|
||||||
options []grpc.ServerOption
|
options []grpc.ServerOption
|
||||||
streamInterceptors []grpc.StreamServerInterceptor
|
streamInterceptors []grpc.StreamServerInterceptor
|
||||||
unaryInterceptors []grpc.UnaryServerInterceptor
|
unaryInterceptors []grpc.UnaryServerInterceptor
|
||||||
@@ -42,7 +40,6 @@ func newBaseRpcServer(address string, rpcServerOpts *rpcServerOptions) *baseRpcS
|
|||||||
return &baseRpcServer{
|
return &baseRpcServer{
|
||||||
address: address,
|
address: address,
|
||||||
health: h,
|
health: h,
|
||||||
metrics: rpcServerOpts.metrics,
|
|
||||||
options: []grpc.ServerOption{grpc.KeepaliveParams(keepalive.ServerParameters{
|
options: []grpc.ServerOption{grpc.KeepaliveParams(keepalive.ServerParameters{
|
||||||
MaxConnectionIdle: defaultConnectionIdleDuration,
|
MaxConnectionIdle: defaultConnectionIdleDuration,
|
||||||
})},
|
})},
|
||||||
@@ -60,7 +57,3 @@ func (s *baseRpcServer) AddStreamInterceptors(interceptors ...grpc.StreamServerI
|
|||||||
func (s *baseRpcServer) AddUnaryInterceptors(interceptors ...grpc.UnaryServerInterceptor) {
|
func (s *baseRpcServer) AddUnaryInterceptors(interceptors ...grpc.UnaryServerInterceptor) {
|
||||||
s.unaryInterceptors = append(s.unaryInterceptors, interceptors...)
|
s.unaryInterceptors = append(s.unaryInterceptors, interceptors...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *baseRpcServer) SetName(name string) {
|
|
||||||
s.metrics.SetName(name)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -5,23 +5,18 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/zeromicro/go-zero/core/stat"
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestBaseRpcServer_AddOptions(t *testing.T) {
|
func TestBaseRpcServer_AddOptions(t *testing.T) {
|
||||||
metrics := stat.NewMetrics("foo")
|
server := newBaseRpcServer("foo", &rpcServerOptions{})
|
||||||
server := newBaseRpcServer("foo", &rpcServerOptions{metrics: metrics})
|
|
||||||
server.SetName("bar")
|
|
||||||
var opt grpc.EmptyServerOption
|
var opt grpc.EmptyServerOption
|
||||||
server.AddOptions(opt)
|
server.AddOptions(opt)
|
||||||
assert.Contains(t, server.options, opt)
|
assert.Contains(t, server.options, opt)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBaseRpcServer_AddStreamInterceptors(t *testing.T) {
|
func TestBaseRpcServer_AddStreamInterceptors(t *testing.T) {
|
||||||
metrics := stat.NewMetrics("foo")
|
server := newBaseRpcServer("foo", &rpcServerOptions{})
|
||||||
server := newBaseRpcServer("foo", &rpcServerOptions{metrics: metrics})
|
|
||||||
server.SetName("bar")
|
|
||||||
var vals []int
|
var vals []int
|
||||||
f := func(_ any, _ grpc.ServerStream, _ *grpc.StreamServerInfo, _ grpc.StreamHandler) error {
|
f := func(_ any, _ grpc.ServerStream, _ *grpc.StreamServerInfo, _ grpc.StreamHandler) error {
|
||||||
vals = append(vals, 1)
|
vals = append(vals, 1)
|
||||||
@@ -35,9 +30,7 @@ func TestBaseRpcServer_AddStreamInterceptors(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestBaseRpcServer_AddUnaryInterceptors(t *testing.T) {
|
func TestBaseRpcServer_AddUnaryInterceptors(t *testing.T) {
|
||||||
metrics := stat.NewMetrics("foo")
|
server := newBaseRpcServer("foo", &rpcServerOptions{})
|
||||||
server := newBaseRpcServer("foo", &rpcServerOptions{metrics: metrics})
|
|
||||||
server.SetName("bar")
|
|
||||||
var vals []int
|
var vals []int
|
||||||
f := func(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (
|
f := func(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (
|
||||||
resp any, err error) {
|
resp any, err error) {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
//go:build !no_k8s
|
||||||
|
|
||||||
package internal
|
package internal
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
8
zrpc/resolver/internal/register.go
Normal file
8
zrpc/resolver/internal/register.go
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
//go:build no_k8s
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
// RegisterResolver registers the direct, etcd and discov schemes to the resolver.
|
||||||
|
func RegisterResolver() {
|
||||||
|
register()
|
||||||
|
}
|
||||||
13
zrpc/resolver/internal/register_k8s.go
Normal file
13
zrpc/resolver/internal/register_k8s.go
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
//go:build !no_k8s
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import "google.golang.org/grpc/resolver"
|
||||||
|
|
||||||
|
var k8sResolverBuilder kubeBuilder
|
||||||
|
|
||||||
|
// RegisterResolver registers the direct, etcd, discov and k8s schemes to the resolver.
|
||||||
|
func RegisterResolver() {
|
||||||
|
register()
|
||||||
|
resolver.Register(&k8sResolverBuilder)
|
||||||
|
}
|
||||||
@@ -28,15 +28,12 @@ var (
|
|||||||
directResolverBuilder directBuilder
|
directResolverBuilder directBuilder
|
||||||
discovResolverBuilder discovBuilder
|
discovResolverBuilder discovBuilder
|
||||||
etcdResolverBuilder etcdBuilder
|
etcdResolverBuilder etcdBuilder
|
||||||
k8sResolverBuilder kubeBuilder
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// RegisterResolver registers the direct and discov schemes to the resolver.
|
func register() {
|
||||||
func RegisterResolver() {
|
|
||||||
resolver.Register(&directResolverBuilder)
|
resolver.Register(&directResolverBuilder)
|
||||||
resolver.Register(&discovResolverBuilder)
|
resolver.Register(&discovResolverBuilder)
|
||||||
resolver.Register(&etcdResolverBuilder)
|
resolver.Register(&etcdResolverBuilder)
|
||||||
resolver.Register(&k8sResolverBuilder)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type nopResolver struct {
|
type nopResolver struct {
|
||||||
|
|||||||
@@ -36,21 +36,23 @@ func NewServer(c RpcServerConf, register internal.RegisterFn) (*RpcServer, error
|
|||||||
var server internal.Server
|
var server internal.Server
|
||||||
metrics := stat.NewMetrics(c.ListenOn)
|
metrics := stat.NewMetrics(c.ListenOn)
|
||||||
serverOptions := []internal.ServerOption{
|
serverOptions := []internal.ServerOption{
|
||||||
internal.WithMetrics(metrics),
|
|
||||||
internal.WithRpcHealth(c.Health),
|
internal.WithRpcHealth(c.Health),
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.HasEtcd() {
|
if c.HasEtcd() {
|
||||||
server, err = internal.NewRpcPubServer(c.Etcd, c.ListenOn, c.Middlewares, serverOptions...)
|
server, err = internal.NewRpcPubServer(c.Etcd, c.ListenOn, serverOptions...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
server = internal.NewRpcServer(c.ListenOn, c.Middlewares, serverOptions...)
|
server = internal.NewRpcServer(c.ListenOn, serverOptions...)
|
||||||
}
|
}
|
||||||
|
|
||||||
server.SetName(c.Name)
|
server.SetName(c.Name)
|
||||||
if err = setupInterceptors(server, c, metrics); err != nil {
|
metrics.SetName(c.Name)
|
||||||
|
setupStreamInterceptors(server, c)
|
||||||
|
setupUnaryInterceptors(server, c, metrics)
|
||||||
|
if err = setupAuthInterceptors(server, c); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,6 +110,9 @@ func SetServerSlowThreshold(threshold time.Duration) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func setupAuthInterceptors(svr internal.Server, c RpcServerConf) error {
|
func setupAuthInterceptors(svr internal.Server, c RpcServerConf) error {
|
||||||
|
if !c.Auth {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
rds, err := redis.NewRedis(c.Redis.RedisConf)
|
rds, err := redis.NewRedis(c.Redis.RedisConf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -124,22 +129,40 @@ func setupAuthInterceptors(svr internal.Server, c RpcServerConf) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupInterceptors(svr internal.Server, c RpcServerConf, metrics *stat.Metrics) error {
|
func setupStreamInterceptors(svr internal.Server, c RpcServerConf) {
|
||||||
|
if c.Middlewares.Trace {
|
||||||
|
svr.AddStreamInterceptors(serverinterceptors.StreamTracingInterceptor)
|
||||||
|
}
|
||||||
|
if c.Middlewares.Recover {
|
||||||
|
svr.AddStreamInterceptors(serverinterceptors.StreamRecoverInterceptor)
|
||||||
|
}
|
||||||
|
if c.Middlewares.Breaker {
|
||||||
|
svr.AddStreamInterceptors(serverinterceptors.StreamBreakerInterceptor)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func setupUnaryInterceptors(svr internal.Server, c RpcServerConf, metrics *stat.Metrics) {
|
||||||
|
if c.Middlewares.Trace {
|
||||||
|
svr.AddUnaryInterceptors(serverinterceptors.UnaryTracingInterceptor)
|
||||||
|
}
|
||||||
|
if c.Middlewares.Recover {
|
||||||
|
svr.AddUnaryInterceptors(serverinterceptors.UnaryRecoverInterceptor)
|
||||||
|
}
|
||||||
|
if c.Middlewares.Stat {
|
||||||
|
svr.AddUnaryInterceptors(serverinterceptors.UnaryStatInterceptor(metrics, c.Middlewares.StatConf))
|
||||||
|
}
|
||||||
|
if c.Middlewares.Prometheus {
|
||||||
|
svr.AddUnaryInterceptors(serverinterceptors.UnaryPrometheusInterceptor)
|
||||||
|
}
|
||||||
|
if c.Middlewares.Breaker {
|
||||||
|
svr.AddUnaryInterceptors(serverinterceptors.UnaryBreakerInterceptor)
|
||||||
|
}
|
||||||
if c.CpuThreshold > 0 {
|
if c.CpuThreshold > 0 {
|
||||||
shedder := load.NewAdaptiveShedder(load.WithCpuThreshold(c.CpuThreshold))
|
shedder := load.NewAdaptiveShedder(load.WithCpuThreshold(c.CpuThreshold))
|
||||||
svr.AddUnaryInterceptors(serverinterceptors.UnarySheddingInterceptor(shedder, metrics))
|
svr.AddUnaryInterceptors(serverinterceptors.UnarySheddingInterceptor(shedder, metrics))
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.Timeout > 0 {
|
if c.Timeout > 0 {
|
||||||
svr.AddUnaryInterceptors(serverinterceptors.UnaryTimeoutInterceptor(
|
svr.AddUnaryInterceptors(serverinterceptors.UnaryTimeoutInterceptor(
|
||||||
time.Duration(c.Timeout)*time.Millisecond, c.MethodTimeouts...))
|
time.Duration(c.Timeout)*time.Millisecond, c.MethodTimeouts...))
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.Auth {
|
|
||||||
if err := setupAuthInterceptors(svr, c); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package zrpc
|
package zrpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -16,47 +17,6 @@ import (
|
|||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestServer_setupInterceptors(t *testing.T) {
|
|
||||||
rds, err := miniredis.Run()
|
|
||||||
assert.NoError(t, err)
|
|
||||||
defer rds.Close()
|
|
||||||
|
|
||||||
server := new(mockedServer)
|
|
||||||
conf := RpcServerConf{
|
|
||||||
Auth: true,
|
|
||||||
Redis: redis.RedisKeyConf{
|
|
||||||
RedisConf: redis.RedisConf{
|
|
||||||
Host: rds.Addr(),
|
|
||||||
Type: redis.NodeType,
|
|
||||||
},
|
|
||||||
Key: "foo",
|
|
||||||
},
|
|
||||||
CpuThreshold: 10,
|
|
||||||
Timeout: 100,
|
|
||||||
Middlewares: ServerMiddlewaresConf{
|
|
||||||
Trace: true,
|
|
||||||
Recover: true,
|
|
||||||
Stat: true,
|
|
||||||
Prometheus: true,
|
|
||||||
Breaker: true,
|
|
||||||
},
|
|
||||||
MethodTimeouts: []MethodTimeoutConf{
|
|
||||||
{
|
|
||||||
FullMethod: "/foo",
|
|
||||||
Timeout: 5 * time.Second,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
err = setupInterceptors(server, conf, new(stat.Metrics))
|
|
||||||
assert.Nil(t, err)
|
|
||||||
assert.Equal(t, 3, len(server.unaryInterceptors))
|
|
||||||
assert.Equal(t, 1, len(server.streamInterceptors))
|
|
||||||
|
|
||||||
rds.SetError("mock error")
|
|
||||||
err = setupInterceptors(server, conf, new(stat.Metrics))
|
|
||||||
assert.Error(t, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestServer(t *testing.T) {
|
func TestServer(t *testing.T) {
|
||||||
DontLogContentForMethod("foo")
|
DontLogContentForMethod("foo")
|
||||||
SetServerSlowThreshold(time.Second)
|
SetServerSlowThreshold(time.Second)
|
||||||
@@ -198,3 +158,153 @@ func (m *mockedServer) SetName(_ string) {
|
|||||||
func (m *mockedServer) Start(_ internal.RegisterFn) error {
|
func (m *mockedServer) Start(_ internal.RegisterFn) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_setupUnaryInterceptors(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
r *mockedServer
|
||||||
|
conf RpcServerConf
|
||||||
|
len int
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "empty",
|
||||||
|
r: &mockedServer{},
|
||||||
|
len: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "custom",
|
||||||
|
r: &mockedServer{
|
||||||
|
unaryInterceptors: []grpc.UnaryServerInterceptor{
|
||||||
|
func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo,
|
||||||
|
handler grpc.UnaryHandler) (interface{}, error) {
|
||||||
|
return nil, nil
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
len: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "middleware",
|
||||||
|
r: &mockedServer{},
|
||||||
|
conf: RpcServerConf{
|
||||||
|
Middlewares: ServerMiddlewaresConf{
|
||||||
|
Trace: true,
|
||||||
|
Recover: true,
|
||||||
|
Stat: true,
|
||||||
|
Prometheus: true,
|
||||||
|
Breaker: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
len: 5,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "internal middleware",
|
||||||
|
r: &mockedServer{},
|
||||||
|
conf: RpcServerConf{
|
||||||
|
CpuThreshold: 900,
|
||||||
|
Timeout: 100,
|
||||||
|
Middlewares: ServerMiddlewaresConf{
|
||||||
|
Trace: true,
|
||||||
|
Recover: true,
|
||||||
|
Stat: true,
|
||||||
|
Prometheus: true,
|
||||||
|
Breaker: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
len: 7,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
t.Run(test.name, func(t *testing.T) {
|
||||||
|
metrics := stat.NewMetrics("abc")
|
||||||
|
setupUnaryInterceptors(test.r, test.conf, metrics)
|
||||||
|
assert.Equal(t, test.len, len(test.r.unaryInterceptors))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_setupStreamInterceptors(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
r *mockedServer
|
||||||
|
conf RpcServerConf
|
||||||
|
len int
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "empty",
|
||||||
|
r: &mockedServer{},
|
||||||
|
len: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "custom",
|
||||||
|
r: &mockedServer{
|
||||||
|
streamInterceptors: []grpc.StreamServerInterceptor{
|
||||||
|
func(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
|
||||||
|
return handler(srv, ss)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
len: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "middleware",
|
||||||
|
r: &mockedServer{},
|
||||||
|
conf: RpcServerConf{
|
||||||
|
Middlewares: ServerMiddlewaresConf{
|
||||||
|
Trace: true,
|
||||||
|
Recover: true,
|
||||||
|
Stat: true,
|
||||||
|
Prometheus: true,
|
||||||
|
Breaker: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
len: 3,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
t.Run(test.name, func(t *testing.T) {
|
||||||
|
setupStreamInterceptors(test.r, test.conf)
|
||||||
|
assert.Equal(t, test.len, len(test.r.streamInterceptors))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_setupAuthInterceptors(t *testing.T) {
|
||||||
|
t.Run("no need set auth", func(t *testing.T) {
|
||||||
|
s := &mockedServer{}
|
||||||
|
err := setupAuthInterceptors(s, RpcServerConf{
|
||||||
|
Auth: false,
|
||||||
|
Redis: redis.RedisKeyConf{},
|
||||||
|
})
|
||||||
|
assert.NoError(t, err)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("redis error", func(t *testing.T) {
|
||||||
|
s := &mockedServer{}
|
||||||
|
err := setupAuthInterceptors(s, RpcServerConf{
|
||||||
|
Auth: true,
|
||||||
|
Redis: redis.RedisKeyConf{},
|
||||||
|
})
|
||||||
|
assert.Error(t, err)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("works", func(t *testing.T) {
|
||||||
|
rds := miniredis.RunT(t)
|
||||||
|
s := &mockedServer{}
|
||||||
|
err := setupAuthInterceptors(s, RpcServerConf{
|
||||||
|
Auth: true,
|
||||||
|
Redis: redis.RedisKeyConf{
|
||||||
|
RedisConf: redis.RedisConf{
|
||||||
|
Host: rds.Addr(),
|
||||||
|
Type: redis.NodeType,
|
||||||
|
},
|
||||||
|
Key: "foo",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, 1, len(s.unaryInterceptors))
|
||||||
|
assert.Equal(t, 1, len(s.streamInterceptors))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user