Compare commits
10 Commits
d07a0f5828
...
v4
| Author | SHA1 | Date | |
|---|---|---|---|
| aad55b589b | |||
| a2544434f5 | |||
| f253aacfa1 | |||
| 290f8a1f9a | |||
| 4c0469d1f0 | |||
| 356e20440b | |||
| 415b232977 | |||
| 060459f197 | |||
| 867401c907 | |||
| 0298d01384 |
94
.github/workflows/job_sync.yml
vendored
Normal file
94
.github/workflows/job_sync.yml
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
name: sync
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '*/5 * * * *'
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
sync:
|
||||
if: github.server_url != 'https://github.com'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: init
|
||||
run: |
|
||||
git config --global user.email "vtolstov <vtolstov@users.noreply.github.com>"
|
||||
git config --global user.name "github-actions[bot]"
|
||||
echo "machine git.unistack.org login vtolstov password ${{ secrets.TOKEN_GITEA }}" >> /root/.netrc
|
||||
echo "machine github.com login vtolstov password ${{ secrets.TOKEN_GITHUB }}" >> /root/.netrc
|
||||
|
||||
- name: check master
|
||||
id: check_master
|
||||
run: |
|
||||
src_hash=$(git ls-remote https://github.com/${GITHUB_REPOSITORY} refs/heads/master | cut -f1)
|
||||
dst_hash=$(git ls-remote ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} refs/heads/master | cut -f1)
|
||||
echo "src_hash=$src_hash"
|
||||
echo "dst_hash=$dst_hash"
|
||||
if [ "$src_hash" != "$dst_hash" -a "$src_hash" != "" -a "$dst_hash" != "" ]; then
|
||||
echo "sync_needed=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "sync_needed=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: sync master
|
||||
if: steps.check_master.outputs.sync_needed == 'true'
|
||||
run: |
|
||||
git clone --filter=blob:none --filter=tree:0 --branch master --single-branch ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} repo
|
||||
cd repo
|
||||
git remote add --no-tags --fetch --track master upstream https://github.com/${GITHUB_REPOSITORY}
|
||||
git pull --rebase upstream master
|
||||
git push upstream master --progress
|
||||
git push origin master --progress
|
||||
cd ../
|
||||
rm -rf repo
|
||||
|
||||
- name: check v3
|
||||
id: check_v3
|
||||
run: |
|
||||
src_hash=$(git ls-remote https://github.com/${GITHUB_REPOSITORY} refs/heads/v3 | cut -f1)
|
||||
dst_hash=$(git ls-remote ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} refs/heads/v3 | cut -f1)
|
||||
echo "src_hash=$src_hash"
|
||||
echo "dst_hash=$dst_hash"
|
||||
if [ "$src_hash" != "$dst_hash" ]; then
|
||||
echo "sync_needed=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "sync_needed=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: sync v3
|
||||
if: steps.check_v3.outputs.sync_needed == 'true'
|
||||
run: |
|
||||
git clone --filter=blob:none --filter=tree:0 --branch v3 --single-branch ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} repo
|
||||
cd repo
|
||||
git remote add --no-tags --fetch --track v3 upstream https://github.com/${GITHUB_REPOSITORY}
|
||||
git pull --rebase upstream v3
|
||||
git push upstream v3 --progress
|
||||
git push origin v3 --progress
|
||||
cd ../
|
||||
rm -rf repo
|
||||
|
||||
- name: check v4
|
||||
id: check_v4
|
||||
run: |
|
||||
src_hash=$(git ls-remote https://github.com/${GITHUB_REPOSITORY} refs/heads/v4 | cut -f1)
|
||||
dst_hash=$(git ls-remote ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} refs/heads/v4 | cut -f1)
|
||||
echo "src_hash=$src_hash"
|
||||
echo "dst_hash=$dst_hash"
|
||||
if [ "$src_hash" != "$dst_hash" ]; then
|
||||
echo "sync_needed=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "sync_needed=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: sync v4
|
||||
if: steps.check_v4.outputs.sync_needed == 'true'
|
||||
run: |
|
||||
git clone --filter=blob:none --filter=tree:0 --branch v4 --single-branch ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} repo
|
||||
cd repo
|
||||
git remote add --no-tags --fetch --track v4 upstream https://github.com/${GITHUB_REPOSITORY}
|
||||
git pull --rebase upstream v4
|
||||
git push upstream v4 --progress
|
||||
git push origin v4 --progress
|
||||
cd ../
|
||||
rm -rf repo
|
||||
39
.gitignore
vendored
Normal file
39
.gitignore
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
# Develop tools
|
||||
/.vscode/
|
||||
/.idea/
|
||||
.idea
|
||||
.vscode
|
||||
|
||||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
*.exe~
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Folders
|
||||
_obj
|
||||
_test
|
||||
_build
|
||||
.DS_Store
|
||||
|
||||
# Architecture specific extensions/prefixes
|
||||
*.[568vq]
|
||||
[568vq].out
|
||||
|
||||
*.cgo1.go
|
||||
*.cgo2.c
|
||||
_cgo_defun.c
|
||||
_cgo_gotypes.go
|
||||
_cgo_export.*
|
||||
|
||||
# Test binary, build with `go test -c`
|
||||
*.test
|
||||
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
|
||||
# vim temp files
|
||||
*~
|
||||
*.swp
|
||||
*.swo
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.unistack.org/micro/v3/register"
|
||||
"go.unistack.org/micro/v4/register"
|
||||
)
|
||||
|
||||
func TestStoreRegex(t *testing.T) {
|
||||
|
||||
@@ -14,25 +14,25 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
rpc "go.unistack.org/micro-api-handler-rpc/v3"
|
||||
rregister "go.unistack.org/micro-api-router-register/v3"
|
||||
rstatic "go.unistack.org/micro-api-router-static/v3"
|
||||
gcli "go.unistack.org/micro-client-grpc/v3"
|
||||
jsoncodec "go.unistack.org/micro-codec-json/v3"
|
||||
protocodec "go.unistack.org/micro-codec-proto/v3"
|
||||
regRouter "go.unistack.org/micro-router-register/v3"
|
||||
gsrv "go.unistack.org/micro-server-grpc/v3"
|
||||
rpc "go.unistack.org/micro-api-handler-rpc/v4"
|
||||
rregister "go.unistack.org/micro-api-router-register/v4"
|
||||
rstatic "go.unistack.org/micro-api-router-static/v4"
|
||||
gcli "go.unistack.org/micro-client-grpc/v4"
|
||||
jsoncodec "go.unistack.org/micro-codec-json/v4"
|
||||
protocodec "go.unistack.org/micro-codec-proto/v4"
|
||||
regRouter "go.unistack.org/micro-router-register/v4"
|
||||
gsrv "go.unistack.org/micro-server-grpc/v4"
|
||||
gpb "go.unistack.org/micro-tests/server/grpc/gproto"
|
||||
pb "go.unistack.org/micro-tests/server/grpc/proto"
|
||||
"go.unistack.org/micro/v3/api"
|
||||
"go.unistack.org/micro/v3/api/handler"
|
||||
"go.unistack.org/micro/v3/api/router"
|
||||
"go.unistack.org/micro/v3/broker"
|
||||
"go.unistack.org/micro/v3/client"
|
||||
"go.unistack.org/micro/v3/errors"
|
||||
"go.unistack.org/micro/v3/register"
|
||||
rt "go.unistack.org/micro/v3/router"
|
||||
"go.unistack.org/micro/v3/server"
|
||||
"go.unistack.org/micro/v4/api"
|
||||
"go.unistack.org/micro/v4/api/handler"
|
||||
"go.unistack.org/micro/v4/api/router"
|
||||
"go.unistack.org/micro/v4/broker"
|
||||
"go.unistack.org/micro/v4/client"
|
||||
"go.unistack.org/micro/v4/errors"
|
||||
"go.unistack.org/micro/v4/register"
|
||||
rt "go.unistack.org/micro/v4/router"
|
||||
"go.unistack.org/micro/v4/server"
|
||||
)
|
||||
|
||||
// server is used to implement helloworld.GreeterServer.
|
||||
|
||||
@@ -10,12 +10,12 @@ import (
|
||||
"time"
|
||||
|
||||
kg "github.com/twmb/franz-go/pkg/kgo"
|
||||
kgo "go.unistack.org/micro-broker-kgo/v3"
|
||||
jsoncodec "go.unistack.org/micro-codec-json/v3"
|
||||
"go.unistack.org/micro/v3/broker"
|
||||
"go.unistack.org/micro/v3/client"
|
||||
"go.unistack.org/micro/v3/logger"
|
||||
"go.unistack.org/micro/v3/metadata"
|
||||
kgo "go.unistack.org/micro-broker-kgo/v4"
|
||||
jsoncodec "go.unistack.org/micro-codec-json/v4"
|
||||
"go.unistack.org/micro/v4/broker"
|
||||
"go.unistack.org/micro/v4/client"
|
||||
"go.unistack.org/micro/v4/logger"
|
||||
"go.unistack.org/micro/v4/metadata"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -6,17 +6,17 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"go.unistack.org/micro/v3/broker"
|
||||
bmemory "go.unistack.org/micro/v3/broker/memory"
|
||||
"go.unistack.org/micro/v3/client"
|
||||
"go.unistack.org/micro/v3/client/grpc"
|
||||
tmemory "go.unistack.org/micro/v3/network/transport/memory"
|
||||
rmemory "go.unistack.org/micro/v3/register/memory"
|
||||
"go.unistack.org/micro/v3/router"
|
||||
rtreg "go.unistack.org/micro/v3/router/register"
|
||||
"go.unistack.org/micro/v3/server"
|
||||
grpcsrv "go.unistack.org/micro/v3/server/grpc"
|
||||
cw "go.unistack.org/micro/v3/util/client"
|
||||
"go.unistack.org/micro/v4/broker"
|
||||
bmemory "go.unistack.org/micro/v4/broker/memory"
|
||||
"go.unistack.org/micro/v4/client"
|
||||
"go.unistack.org/micro/v4/client/grpc"
|
||||
tmemory "go.unistack.org/micro/v4/network/transport/memory"
|
||||
rmemory "go.unistack.org/micro/v4/register/memory"
|
||||
"go.unistack.org/micro/v4/router"
|
||||
rtreg "go.unistack.org/micro/v4/router/register"
|
||||
"go.unistack.org/micro/v4/server"
|
||||
grpcsrv "go.unistack.org/micro/v4/server/grpc"
|
||||
cw "go.unistack.org/micro/v4/util/client"
|
||||
)
|
||||
|
||||
type TestFoo struct{}
|
||||
|
||||
@@ -8,10 +8,10 @@ import (
|
||||
"net"
|
||||
"testing"
|
||||
|
||||
drpc "go.unistack.org/micro-client-drpc/v3"
|
||||
protocodec "go.unistack.org/micro-codec-proto/v3"
|
||||
drpc "go.unistack.org/micro-client-drpc/v4"
|
||||
protocodec "go.unistack.org/micro-codec-proto/v4"
|
||||
pb "go.unistack.org/micro-tests/client/drpc/proto"
|
||||
"go.unistack.org/micro/v3/client"
|
||||
"go.unistack.org/micro/v4/client"
|
||||
"storj.io/drpc/drpcmux"
|
||||
"storj.io/drpc/drpcserver"
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.26.0
|
||||
// protoc v5.28.3
|
||||
// protoc v5.29.2
|
||||
// source: test.proto
|
||||
|
||||
package pb
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-micro v3.10.4
|
||||
// - protoc v5.28.3
|
||||
// - protoc v5.29.2
|
||||
// source: test.proto
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
client "go.unistack.org/micro/v4/client"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -6,8 +6,8 @@ package pb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
server "go.unistack.org/micro/v3/server"
|
||||
client "go.unistack.org/micro/v4/client"
|
||||
server "go.unistack.org/micro/v4/server"
|
||||
)
|
||||
|
||||
type testServiceClient struct {
|
||||
@@ -58,6 +58,5 @@ func RegisterTestServiceServer(s server.Server, sh TestServiceServer, opts ...se
|
||||
testService
|
||||
}
|
||||
h := &testServiceServer{sh}
|
||||
var nopts []server.HandlerOption
|
||||
return s.Handle(s.NewHandler(&TestService{h}, append(nopts, opts...)...))
|
||||
return s.Handle(s.NewHandler(&TestService{h}, opts...))
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-micro v3.10.4
|
||||
// - protoc v5.28.3
|
||||
// - protoc v5.29.2
|
||||
// source: test.proto
|
||||
|
||||
package helloworld
|
||||
@@ -9,8 +9,8 @@ package helloworld
|
||||
import (
|
||||
context "context"
|
||||
proto "go.unistack.org/micro-tests/client/grpc/proto"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
metadata "go.unistack.org/micro/v3/metadata"
|
||||
client "go.unistack.org/micro/v4/client"
|
||||
metadata "go.unistack.org/micro/v4/metadata"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -26,6 +26,8 @@ type Test_StreamClient interface {
|
||||
Context() context.Context
|
||||
SendMsg(msg interface{}) error
|
||||
RecvMsg(msg interface{}) error
|
||||
CloseAndRecv() (*proto.Response, error)
|
||||
CloseSend() error
|
||||
Close() error
|
||||
Header() metadata.Metadata
|
||||
Send(msg *proto.Request) error
|
||||
@@ -41,6 +43,7 @@ type Test_StreamStream interface {
|
||||
Context() context.Context
|
||||
SendMsg(msg interface{}) error
|
||||
RecvMsg(msg interface{}) error
|
||||
SendAndClose(msg *proto.Response) error
|
||||
Close() error
|
||||
Recv() (*proto.Request, error)
|
||||
Send(msg *proto.Response) error
|
||||
|
||||
@@ -7,9 +7,9 @@ package helloworld
|
||||
import (
|
||||
context "context"
|
||||
proto "go.unistack.org/micro-tests/client/grpc/proto"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
metadata "go.unistack.org/micro/v3/metadata"
|
||||
server "go.unistack.org/micro/v3/server"
|
||||
client "go.unistack.org/micro/v4/client"
|
||||
metadata "go.unistack.org/micro/v4/metadata"
|
||||
server "go.unistack.org/micro/v4/server"
|
||||
)
|
||||
|
||||
type testClient struct {
|
||||
@@ -17,7 +17,7 @@ type testClient struct {
|
||||
name string
|
||||
}
|
||||
|
||||
func NewTestClient(name string, c client.Client) proto.TestClient {
|
||||
func NewTestClient(name string, c client.Client) TestClient {
|
||||
return &testClient{c: c, name: name}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,18 @@ type testClientStream struct {
|
||||
stream client.Stream
|
||||
}
|
||||
|
||||
func (s *testClientStream) CloseAndRecv() (*proto.Response, error) {
|
||||
msg := &proto.Response{}
|
||||
err := s.RecvMsg(msg)
|
||||
if err == nil {
|
||||
err = s.Close()
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return msg, nil
|
||||
}
|
||||
|
||||
func (s *testClientStream) Close() error {
|
||||
return s.stream.Close()
|
||||
}
|
||||
@@ -79,7 +91,7 @@ func (s *testClientStream) Recv() (*proto.Response, error) {
|
||||
}
|
||||
|
||||
type testServer struct {
|
||||
proto.TestServer
|
||||
TestServer
|
||||
}
|
||||
|
||||
func (h *testServer) Call(ctx context.Context, req *proto.Request, rsp *proto.Response) error {
|
||||
@@ -94,6 +106,13 @@ type testStreamStream struct {
|
||||
stream server.Stream
|
||||
}
|
||||
|
||||
func (s *testStreamStream) SendAndClose(msg *proto.Response) error {
|
||||
err := s.SendMsg(msg)
|
||||
if err == nil {
|
||||
err = s.stream.Close()
|
||||
}
|
||||
return err
|
||||
}
|
||||
func (s *testStreamStream) Close() error {
|
||||
return s.stream.Close()
|
||||
}
|
||||
@@ -122,7 +141,7 @@ func (s *testStreamStream) Recv() (*proto.Request, error) {
|
||||
return msg, nil
|
||||
}
|
||||
|
||||
func RegisterTestServer(s server.Server, sh proto.TestServer, opts ...server.HandlerOption) error {
|
||||
func RegisterTestServer(s server.Server, sh TestServer, opts ...server.HandlerOption) error {
|
||||
type test interface {
|
||||
Call(ctx context.Context, req *proto.Request, rsp *proto.Response) error
|
||||
Stream(ctx context.Context, stream server.Stream) error
|
||||
@@ -131,6 +150,5 @@ func RegisterTestServer(s server.Server, sh proto.TestServer, opts ...server.Han
|
||||
test
|
||||
}
|
||||
h := &testServer{sh}
|
||||
var nopts []server.HandlerOption
|
||||
return s.Handle(s.NewHandler(&Test{h}, append(nopts, opts...)...))
|
||||
return s.Handle(s.NewHandler(&Test{h}, opts...))
|
||||
}
|
||||
|
||||
@@ -8,14 +8,15 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
grpc "go.unistack.org/micro-client-grpc/v3"
|
||||
protocodec "go.unistack.org/micro-codec-proto/v3"
|
||||
regRouter "go.unistack.org/micro-router-register/v3"
|
||||
grpc "go.unistack.org/micro-client-grpc/v4"
|
||||
protocodec "go.unistack.org/micro-codec-proto/v4"
|
||||
regRouter "go.unistack.org/micro-router-register/v4"
|
||||
pb "go.unistack.org/micro-tests/client/grpc/proto"
|
||||
"go.unistack.org/micro/v3/client"
|
||||
"go.unistack.org/micro/v3/errors"
|
||||
"go.unistack.org/micro/v3/register"
|
||||
"go.unistack.org/micro/v3/router"
|
||||
"go.unistack.org/micro/v4/client"
|
||||
"go.unistack.org/micro/v4/errors"
|
||||
"go.unistack.org/micro/v4/register"
|
||||
mregister "go.unistack.org/micro/v4/register/memory"
|
||||
"go.unistack.org/micro/v4/router"
|
||||
pgrpc "google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
@@ -71,7 +72,7 @@ func TestGRPCClient(t *testing.T) {
|
||||
defer s.Stop()
|
||||
|
||||
// create mock register
|
||||
r := register.NewRegister()
|
||||
r := mregister.NewRegister()
|
||||
|
||||
// register service
|
||||
if err := r.Register(ctx, ®ister.Service{
|
||||
@@ -81,9 +82,6 @@ func TestGRPCClient(t *testing.T) {
|
||||
{
|
||||
ID: "test-1",
|
||||
Address: l.Addr().String(),
|
||||
Metadata: map[string]string{
|
||||
"protocol": "grpc",
|
||||
},
|
||||
},
|
||||
},
|
||||
}); err != nil {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.26.0
|
||||
// protoc v5.28.3
|
||||
// protoc v5.29.2
|
||||
// source: test.proto
|
||||
|
||||
package helloworld
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc v5.28.3
|
||||
// - protoc v5.29.2
|
||||
// source: test.proto
|
||||
|
||||
package helloworld
|
||||
|
||||
@@ -11,14 +11,15 @@ import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
mhttp "go.unistack.org/micro-client-http/v3"
|
||||
jsoncodec "go.unistack.org/micro-codec-json/v3"
|
||||
rrouter "go.unistack.org/micro-router-register/v3"
|
||||
mhttp "go.unistack.org/micro-client-http/v4"
|
||||
jsoncodec "go.unistack.org/micro-codec-json/v4"
|
||||
rrouter "go.unistack.org/micro-router-register/v4"
|
||||
pb "go.unistack.org/micro-tests/client/http/proto"
|
||||
"go.unistack.org/micro/v3/client"
|
||||
"go.unistack.org/micro/v3/codec"
|
||||
"go.unistack.org/micro/v3/register"
|
||||
"go.unistack.org/micro/v3/router"
|
||||
"go.unistack.org/micro/v4/client"
|
||||
"go.unistack.org/micro/v4/codec"
|
||||
"go.unistack.org/micro/v4/register"
|
||||
mregister "go.unistack.org/micro/v4/register/memory"
|
||||
"go.unistack.org/micro/v4/router"
|
||||
"google.golang.org/protobuf/types/known/wrapperspb"
|
||||
)
|
||||
|
||||
@@ -89,7 +90,7 @@ func TestNativeWithoutPath(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHTTPClient(t *testing.T) {
|
||||
reg := register.NewRegister()
|
||||
reg := mregister.NewRegister()
|
||||
rtr := rrouter.NewRouter(router.Register(reg))
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
@@ -150,9 +151,6 @@ func TestHTTPClient(t *testing.T) {
|
||||
{
|
||||
ID: "test.service.1",
|
||||
Address: l.Addr().String(),
|
||||
Metadata: map[string]string{
|
||||
"protocol": "http",
|
||||
},
|
||||
},
|
||||
},
|
||||
}); err != nil {
|
||||
@@ -179,7 +177,7 @@ func TestHTTPClient(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHTTPClientStream(t *testing.T) {
|
||||
reg := register.NewRegister()
|
||||
reg := mregister.NewRegister()
|
||||
rtr := rrouter.NewRouter(router.Register(reg))
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
@@ -314,9 +312,6 @@ func TestHTTPClientStream(t *testing.T) {
|
||||
{
|
||||
ID: "test.service.1",
|
||||
Address: l.Addr().String(),
|
||||
Metadata: map[string]string{
|
||||
"protocol": "http",
|
||||
},
|
||||
},
|
||||
},
|
||||
}); err != nil {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.26.0
|
||||
// protoc v5.28.3
|
||||
// protoc v5.29.2
|
||||
// source: github.proto
|
||||
|
||||
package pb
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-micro v3.10.4
|
||||
// - protoc v5.28.3
|
||||
// - protoc v5.29.2
|
||||
// source: github.proto
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
client "go.unistack.org/micro/v4/client"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -6,10 +6,10 @@ package pb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
v31 "go.unistack.org/micro-client-http/v3"
|
||||
v3 "go.unistack.org/micro-server-http/v3"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
server "go.unistack.org/micro/v3/server"
|
||||
v31 "go.unistack.org/micro-client-http/v4"
|
||||
v3 "go.unistack.org/micro-server-http/v4"
|
||||
client "go.unistack.org/micro/v4/client"
|
||||
server "go.unistack.org/micro/v4/server"
|
||||
http "net/http"
|
||||
)
|
||||
|
||||
@@ -98,7 +98,6 @@ func RegisterGithubServer(s server.Server, sh GithubServer, opts ...server.Handl
|
||||
github
|
||||
}
|
||||
h := &githubServer{sh}
|
||||
var nopts []server.HandlerOption
|
||||
nopts = append(nopts, v3.HandlerEndpoints(GithubServerEndpoints))
|
||||
return s.Handle(s.NewHandler(&Github{h}, append(nopts, opts...)...))
|
||||
opts = append(opts, v3.HandlerEndpoints(GithubServerEndpoints))
|
||||
return s.Handle(s.NewHandler(&Github{h}, opts...))
|
||||
}
|
||||
|
||||
@@ -5,11 +5,11 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"go.unistack.org/micro-client-mock/v3"
|
||||
jsoncodec "go.unistack.org/micro-codec-json/v3"
|
||||
"go.unistack.org/micro-client-mock/v4"
|
||||
jsoncodec "go.unistack.org/micro-codec-json/v4"
|
||||
pb "go.unistack.org/micro-tests/client/mock/proto"
|
||||
"go.unistack.org/micro/v3/client"
|
||||
"go.unistack.org/micro/v3/errors"
|
||||
"go.unistack.org/micro/v4/client"
|
||||
"go.unistack.org/micro/v4/errors"
|
||||
)
|
||||
|
||||
func TestCallWithoutError(t *testing.T) {
|
||||
|
||||
@@ -3,8 +3,8 @@ package pb
|
||||
import (
|
||||
context "context"
|
||||
|
||||
v3 "go.unistack.org/micro-server-http/v3"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
v3 "go.unistack.org/micro-server-http/v4"
|
||||
client "go.unistack.org/micro/v4/client"
|
||||
)
|
||||
|
||||
var GithubName = "Github"
|
||||
|
||||
@@ -4,10 +4,10 @@ import (
|
||||
context "context"
|
||||
http "net/http"
|
||||
|
||||
v3 "go.unistack.org/micro-client-http/v3"
|
||||
v31 "go.unistack.org/micro-server-http/v3"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
server "go.unistack.org/micro/v3/server"
|
||||
v3 "go.unistack.org/micro-client-http/v4"
|
||||
v31 "go.unistack.org/micro-server-http/v4"
|
||||
client "go.unistack.org/micro/v4/client"
|
||||
server "go.unistack.org/micro/v4/server"
|
||||
)
|
||||
|
||||
type githubClient struct {
|
||||
|
||||
@@ -3,8 +3,8 @@ package codec
|
||||
import (
|
||||
"testing"
|
||||
|
||||
jsoncodec "go.unistack.org/micro-codec-json/v3"
|
||||
"go.unistack.org/micro/v3/codec"
|
||||
jsoncodec "go.unistack.org/micro-codec-json/v4"
|
||||
"go.unistack.org/micro/v4/codec"
|
||||
)
|
||||
|
||||
func TestFrame(t *testing.T) {
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
package codec
|
||||
|
||||
//go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro/v3) -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go_out=paths=source_relative:./proto --go-micro_out=components='micro|http',debug=true,paths=source_relative:./proto proto/test.proto"
|
||||
//go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro/v4) -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go_out=paths=source_relative:./proto --go-micro_out=components='micro|http',debug=true,paths=source_relative:./proto proto/test.proto"
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.26.0
|
||||
// protoc v5.28.3
|
||||
// protoc v5.29.2
|
||||
// source: test.proto
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
codec "go.unistack.org/micro/v3/codec"
|
||||
codec "go.unistack.org/micro/v4/codec"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-micro v3.10.4
|
||||
// - protoc v5.28.3
|
||||
// - protoc v5.29.2
|
||||
// source: test.proto
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
codec "go.unistack.org/micro/v3/codec"
|
||||
client "go.unistack.org/micro/v4/client"
|
||||
codec "go.unistack.org/micro/v4/codec"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -6,15 +6,10 @@ package pb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
_ "go.unistack.org/micro-client-http/v3"
|
||||
v3 "go.unistack.org/micro-server-http/v3"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
codec "go.unistack.org/micro/v3/codec"
|
||||
server "go.unistack.org/micro/v3/server"
|
||||
)
|
||||
|
||||
var (
|
||||
TestServerEndpoints = []v3.EndpointMetadata{}
|
||||
_ "go.unistack.org/micro-client-http/v4"
|
||||
client "go.unistack.org/micro/v4/client"
|
||||
codec "go.unistack.org/micro/v4/codec"
|
||||
server "go.unistack.org/micro/v4/server"
|
||||
)
|
||||
|
||||
type testClient struct {
|
||||
@@ -51,7 +46,5 @@ func RegisterTestServer(s server.Server, sh TestServer, opts ...server.HandlerOp
|
||||
test
|
||||
}
|
||||
h := &testServer{sh}
|
||||
var nopts []server.HandlerOption
|
||||
nopts = append(nopts, v3.HandlerEndpoints(TestServerEndpoints))
|
||||
return s.Handle(s.NewHandler(&Test{h}, append(nopts, opts...)...))
|
||||
return s.Handle(s.NewHandler(&Test{h}, opts...))
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
package grpc
|
||||
|
||||
//go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go_out=paths=source_relative:./proto --go-micro_out=components='micro|http',debug=true,paths=source_relative:./proto proto/test.proto"
|
||||
//go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go_out=paths=source_relative:./proto --go-micro_out=components='micro|grpc',debug=true,paths=source_relative:./proto proto/test.proto"
|
||||
|
||||
@@ -4,26 +4,22 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
gclient "go.unistack.org/micro-client-grpc/v3"
|
||||
// protocodec "go.unistack.org/micro-codec-proto/v3"
|
||||
protocodec "go.unistack.org/micro-codec-segmentio/v3/proto"
|
||||
regRouter "go.unistack.org/micro-router-register/v3"
|
||||
gserver "go.unistack.org/micro-server-grpc/v3"
|
||||
gpb "go.unistack.org/micro-tests/server/grpc/gproto"
|
||||
pb "go.unistack.org/micro-tests/server/grpc/proto"
|
||||
"go.unistack.org/micro/v3/broker"
|
||||
"go.unistack.org/micro/v3/client"
|
||||
"go.unistack.org/micro/v3/errors"
|
||||
"go.unistack.org/micro/v3/register"
|
||||
"go.unistack.org/micro/v3/router"
|
||||
"go.unistack.org/micro/v3/server"
|
||||
gclient "go.unistack.org/micro-client-grpc/v4"
|
||||
// protocodec "go.unistack.org/micro-codec-proto/v4"
|
||||
protocodec "go.unistack.org/micro-codec-segmentio/v4/proto"
|
||||
regRouter "go.unistack.org/micro-router-register/v4"
|
||||
gserver "go.unistack.org/micro-server-grpc/v4"
|
||||
gpb "go.unistack.org/micro-tests/codec/segmentio/proto"
|
||||
"go.unistack.org/micro/v4/client"
|
||||
"go.unistack.org/micro/v4/errors"
|
||||
mregister "go.unistack.org/micro/v4/register/memory"
|
||||
"go.unistack.org/micro/v4/router"
|
||||
"go.unistack.org/micro/v4/server"
|
||||
)
|
||||
|
||||
type testServer struct {
|
||||
pb.UnimplementedTestServer
|
||||
}
|
||||
type testServer struct{}
|
||||
|
||||
func (g *testServer) Call(ctx context.Context, req *pb.Request, rsp *pb.Response) error {
|
||||
func (g *testServer) Call(ctx context.Context, req *gpb.Request, rsp *gpb.Response) error {
|
||||
if req.Name == "Error" {
|
||||
return &errors.Error{ID: "id", Code: 99, Detail: "detail"}
|
||||
}
|
||||
@@ -34,15 +30,13 @@ func (g *testServer) Call(ctx context.Context, req *pb.Request, rsp *pb.Response
|
||||
func TestGRPCServer(t *testing.T) {
|
||||
var err error
|
||||
|
||||
r := register.NewRegister()
|
||||
b := broker.NewBroker(broker.Register(r))
|
||||
r := mregister.NewRegister()
|
||||
s := gserver.NewServer(
|
||||
server.Codec("application/grpc+proto", protocodec.NewCodec()),
|
||||
server.Codec("application/grpc", protocodec.NewCodec()),
|
||||
server.Address("127.0.0.1:0"),
|
||||
server.Register(r),
|
||||
server.Name("helloworld"),
|
||||
gserver.Reflection(true),
|
||||
)
|
||||
// create router
|
||||
rtr := regRouter.NewRouter(router.Register(r))
|
||||
@@ -73,7 +67,6 @@ func TestGRPCServer(t *testing.T) {
|
||||
client.Codec("application/grpc", protocodec.NewCodec()),
|
||||
client.Router(rtr),
|
||||
client.Register(r),
|
||||
client.Broker(b),
|
||||
)
|
||||
|
||||
testMethods := []string{
|
||||
@@ -81,13 +74,13 @@ func TestGRPCServer(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, method := range testMethods {
|
||||
req := c.NewRequest("helloworld", method, &pb.Request{
|
||||
req := c.NewRequest("helloworld", method, &gpb.Request{
|
||||
Name: "John",
|
||||
})
|
||||
|
||||
rsp := pb.Response{}
|
||||
rsp := &gpb.Response{}
|
||||
|
||||
err = c.Call(context.TODO(), req, &rsp)
|
||||
err = c.Call(context.TODO(), req, rsp)
|
||||
if err != nil {
|
||||
t.Fatalf("method: %s err: %v", method, err)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.26.0
|
||||
// protoc v5.28.3
|
||||
// protoc v5.29.2
|
||||
// source: test.proto
|
||||
|
||||
package pb
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-micro v3.10.4
|
||||
// - protoc v5.28.3
|
||||
// - protoc v5.29.2
|
||||
// source: test.proto
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
client "go.unistack.org/micro/v4/client"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -6,14 +6,8 @@ package pb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
_ "go.unistack.org/micro-client-http/v3"
|
||||
v3 "go.unistack.org/micro-server-http/v3"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
server "go.unistack.org/micro/v3/server"
|
||||
)
|
||||
|
||||
var (
|
||||
TestServerEndpoints = []v3.EndpointMetadata{}
|
||||
client "go.unistack.org/micro/v4/client"
|
||||
server "go.unistack.org/micro/v4/server"
|
||||
)
|
||||
|
||||
type testClient struct {
|
||||
@@ -50,7 +44,5 @@ func RegisterTestServer(s server.Server, sh TestServer, opts ...server.HandlerOp
|
||||
test
|
||||
}
|
||||
h := &testServer{sh}
|
||||
var nopts []server.HandlerOption
|
||||
nopts = append(nopts, v3.HandlerEndpoints(TestServerEndpoints))
|
||||
return s.Handle(s.NewHandler(&Test{h}, append(nopts, opts...)...))
|
||||
return s.Handle(s.NewHandler(&Test{h}, opts...))
|
||||
}
|
||||
@@ -7,9 +7,9 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
jsoncodec "go.unistack.org/micro-codec-json/v3"
|
||||
consul "go.unistack.org/micro-config-consul/v3"
|
||||
"go.unistack.org/micro/v3/config"
|
||||
jsoncodec "go.unistack.org/micro-codec-json/v4"
|
||||
consul "go.unistack.org/micro-config-consul/v4"
|
||||
"go.unistack.org/micro/v4/config"
|
||||
)
|
||||
|
||||
type Cfg struct {
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
envconfig "go.unistack.org/micro-config-env/v3"
|
||||
"go.unistack.org/micro/v3/config"
|
||||
envconfig "go.unistack.org/micro-config-env/v4"
|
||||
"go.unistack.org/micro/v4/config"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
jsoncodec "go.unistack.org/micro-codec-json/v3"
|
||||
vault "go.unistack.org/micro-config-vault/v3"
|
||||
"go.unistack.org/micro/v3/config"
|
||||
jsoncodec "go.unistack.org/micro-codec-json/v4"
|
||||
vault "go.unistack.org/micro-config-vault/v4"
|
||||
"go.unistack.org/micro/v4/config"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
|
||||
@@ -6,19 +6,19 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
httpcli "go.unistack.org/micro-client-http/v3"
|
||||
jsoncodec "go.unistack.org/micro-codec-json/v3"
|
||||
jsonpbcodec "go.unistack.org/micro-codec-jsonpb/v3"
|
||||
httpsrv "go.unistack.org/micro-server-http/v3"
|
||||
httpcli "go.unistack.org/micro-client-http/v4"
|
||||
jsoncodec "go.unistack.org/micro-codec-json/v4"
|
||||
jsonpbcodec "go.unistack.org/micro-codec-jsonpb/v4"
|
||||
httpsrv "go.unistack.org/micro-server-http/v4"
|
||||
pb "go.unistack.org/micro-tests/flow/proto"
|
||||
"go.unistack.org/micro/v3"
|
||||
"go.unistack.org/micro/v3/client"
|
||||
"go.unistack.org/micro/v3/flow"
|
||||
"go.unistack.org/micro/v3/logger"
|
||||
"go.unistack.org/micro/v3/meter"
|
||||
"go.unistack.org/micro/v3/server"
|
||||
"go.unistack.org/micro/v3/store"
|
||||
"go.unistack.org/micro/v3/tracer"
|
||||
"go.unistack.org/micro/v4"
|
||||
"go.unistack.org/micro/v4/client"
|
||||
"go.unistack.org/micro/v4/flow"
|
||||
"go.unistack.org/micro/v4/logger"
|
||||
"go.unistack.org/micro/v4/meter"
|
||||
"go.unistack.org/micro/v4/server"
|
||||
"go.unistack.org/micro/v4/store"
|
||||
"go.unistack.org/micro/v4/tracer"
|
||||
)
|
||||
|
||||
type handler struct{}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.26.0
|
||||
// protoc v5.28.3
|
||||
// protoc v5.29.2
|
||||
// source: test.proto
|
||||
|
||||
package pb
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-micro v3.10.4
|
||||
// - protoc v5.28.3
|
||||
// - protoc v5.29.2
|
||||
// source: test.proto
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
client "go.unistack.org/micro/v4/client"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -6,10 +6,10 @@ package pb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
v31 "go.unistack.org/micro-client-http/v3"
|
||||
v3 "go.unistack.org/micro-server-http/v3"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
server "go.unistack.org/micro/v3/server"
|
||||
v31 "go.unistack.org/micro-client-http/v4"
|
||||
v3 "go.unistack.org/micro-server-http/v4"
|
||||
client "go.unistack.org/micro/v4/client"
|
||||
server "go.unistack.org/micro/v4/server"
|
||||
http "net/http"
|
||||
time "time"
|
||||
)
|
||||
@@ -185,7 +185,6 @@ func RegisterTestServiceServer(s server.Server, sh TestServiceServer, opts ...se
|
||||
testService
|
||||
}
|
||||
h := &testServiceServer{sh}
|
||||
var nopts []server.HandlerOption
|
||||
nopts = append(nopts, v3.HandlerEndpoints(TestServiceServerEndpoints))
|
||||
return s.Handle(s.NewHandler(&TestService{h}, append(nopts, opts...)...))
|
||||
opts = append(opts, v3.HandlerEndpoints(TestServiceServerEndpoints))
|
||||
return s.Handle(s.NewHandler(&TestService{h}, opts...))
|
||||
}
|
||||
|
||||
131
go.mod
131
go.mod
@@ -1,120 +1,123 @@
|
||||
module go.unistack.org/micro-tests
|
||||
|
||||
go 1.23.4
|
||||
go 1.24.0
|
||||
|
||||
require (
|
||||
github.com/jmoiron/sqlx v1.4.0
|
||||
github.com/opentracing/opentracing-go v1.2.0
|
||||
github.com/stretchr/testify v1.10.0
|
||||
github.com/twmb/franz-go v1.18.0
|
||||
github.com/twmb/franz-go v1.18.1
|
||||
github.com/uber/jaeger-client-go v2.30.0+incompatible
|
||||
go.unistack.org/micro-broker-kgo/v3 v3.8.51
|
||||
go.unistack.org/micro-client-grpc/v3 v3.11.10
|
||||
go.unistack.org/micro-client-http/v3 v3.9.14
|
||||
go.unistack.org/micro-client-mock/v3 v3.0.1
|
||||
go.unistack.org/micro-codec-json/v3 v3.10.1
|
||||
go.unistack.org/micro-codec-jsonpb/v3 v3.10.3
|
||||
go.unistack.org/micro-codec-proto/v3 v3.10.2
|
||||
go.unistack.org/micro-codec-segmentio/v3 v3.10.4
|
||||
go.unistack.org/micro-codec-urlencode/v3 v3.10.2
|
||||
go.unistack.org/micro-codec-xml/v3 v3.10.1
|
||||
go.unistack.org/micro-config-consul/v3 v3.8.6
|
||||
go.unistack.org/micro-config-env/v3 v3.8.7
|
||||
go.unistack.org/micro-config-vault/v3 v3.8.9
|
||||
go.unistack.org/micro-meter-prometheus/v3 v3.8.17
|
||||
go.unistack.org/micro-meter-victoriametrics/v3 v3.8.9
|
||||
go.unistack.org/micro-broker-kgo/v4 v4.0.1
|
||||
go.unistack.org/micro-client-grpc/v4 v4.1.0
|
||||
go.unistack.org/micro-client-http/v4 v4.1.0
|
||||
go.unistack.org/micro-client-mock/v4 v4.1.0
|
||||
go.unistack.org/micro-codec-json/v4 v4.0.0
|
||||
go.unistack.org/micro-codec-jsonpb/v4 v4.0.1
|
||||
go.unistack.org/micro-codec-proto/v4 v4.0.0
|
||||
go.unistack.org/micro-codec-segmentio/v4 v4.1.0
|
||||
go.unistack.org/micro-codec-urlencode/v4 v4.0.0
|
||||
go.unistack.org/micro-codec-xml/v4 v4.0.0
|
||||
go.unistack.org/micro-config-consul/v4 v4.0.4
|
||||
go.unistack.org/micro-config-env/v4 v4.0.3
|
||||
go.unistack.org/micro-config-vault/v4 v4.0.4
|
||||
go.unistack.org/micro-meter-prometheus/v4 v4.1.0
|
||||
go.unistack.org/micro-meter-victoriametrics/v4 v4.1.0
|
||||
go.unistack.org/micro-proto/v3 v3.4.1
|
||||
go.unistack.org/micro-router-register/v3 v3.9.0
|
||||
go.unistack.org/micro-server-grpc/v3 v3.10.26
|
||||
go.unistack.org/micro-server-http/v3 v3.11.37
|
||||
go.unistack.org/micro-server-tcp/v3 v3.10.1
|
||||
go.unistack.org/micro-tracer-opentracing/v3 v3.10.23
|
||||
go.unistack.org/micro-wrapper-recovery/v3 v3.9.0
|
||||
go.unistack.org/micro-wrapper-sql/v3 v3.10.15
|
||||
go.unistack.org/micro/v3 v3.11.14
|
||||
golang.org/x/net v0.32.0
|
||||
google.golang.org/grpc v1.68.1
|
||||
google.golang.org/protobuf v1.35.2
|
||||
go.unistack.org/micro-router-register/v4 v4.1.0
|
||||
go.unistack.org/micro-server-grpc/v4 v4.1.2
|
||||
go.unistack.org/micro-server-http/v3 v3.11.38
|
||||
go.unistack.org/micro-server-http/v4 v4.1.2
|
||||
go.unistack.org/micro-server-tcp/v4 v4.1.0
|
||||
go.unistack.org/micro-tracer-opentracing/v4 v4.0.8
|
||||
go.unistack.org/micro-wrapper-recovery/v4 v4.1.0
|
||||
go.unistack.org/micro-wrapper-sql/v4 v4.1.0
|
||||
go.unistack.org/micro/v4 v4.1.13
|
||||
golang.org/x/net v0.40.0
|
||||
google.golang.org/grpc v1.72.0
|
||||
google.golang.org/protobuf v1.36.6
|
||||
modernc.org/sqlite v1.34.2
|
||||
storj.io/drpc v0.0.34
|
||||
)
|
||||
|
||||
require (
|
||||
dario.cat/mergo v1.0.1 // indirect
|
||||
dario.cat/mergo v1.0.2 // indirect
|
||||
github.com/HdrHistogram/hdrhistogram-go v1.1.2 // indirect
|
||||
github.com/KimMachineGun/automemlimit v0.6.1 // indirect
|
||||
github.com/KimMachineGun/automemlimit v0.7.2 // indirect
|
||||
github.com/VictoriaMetrics/metrics v1.35.2 // indirect
|
||||
github.com/armon/go-metrics v0.4.1 // indirect
|
||||
github.com/ash3in/uuidv8 v1.2.0 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/cilium/ebpf v0.9.1 // indirect
|
||||
github.com/containerd/cgroups/v3 v3.0.1 // indirect
|
||||
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/docker/go-units v0.4.0 // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/fatih/color v1.16.0 // indirect
|
||||
github.com/go-jose/go-jose/v4 v4.0.4 // indirect
|
||||
github.com/godbus/dbus/v5 v5.0.4 // indirect
|
||||
github.com/fatih/color v1.18.0 // indirect
|
||||
github.com/fatih/structtag v1.2.0 // indirect
|
||||
github.com/go-jose/go-jose/v4 v4.0.5 // indirect
|
||||
github.com/goccy/go-yaml v1.17.1 // indirect
|
||||
github.com/google/gnostic v0.7.0 // indirect
|
||||
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
|
||||
github.com/google/gnostic-models v0.6.9 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/hashicorp/consul/api v1.26.1 // indirect
|
||||
github.com/hashicorp/consul/api v1.31.2 // indirect
|
||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
||||
github.com/hashicorp/go-hclog v1.6.3 // indirect
|
||||
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
|
||||
github.com/hashicorp/go-metrics v0.5.4 // indirect
|
||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
|
||||
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
|
||||
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.8 // indirect
|
||||
github.com/hashicorp/go-secure-stdlib/parseutil v0.2.0 // indirect
|
||||
github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 // indirect
|
||||
github.com/hashicorp/go-sockaddr v1.0.7 // indirect
|
||||
github.com/hashicorp/golang-lru v0.5.4 // indirect
|
||||
github.com/hashicorp/golang-lru v1.0.2 // indirect
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/hashicorp/serf v0.10.1 // indirect
|
||||
github.com/hashicorp/vault/api v1.15.0 // indirect
|
||||
github.com/imdario/mergo v0.3.16 // indirect
|
||||
github.com/klauspost/compress v1.17.11 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/hashicorp/serf v0.10.2 // indirect
|
||||
github.com/hashicorp/vault/api v1.16.0 // indirect
|
||||
github.com/klauspost/compress v1.18.0 // indirect
|
||||
github.com/matoous/go-nanoid v1.5.1 // indirect
|
||||
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/ncruces/go-strftime v0.1.9 // indirect
|
||||
github.com/opencontainers/runtime-spec v1.0.2 // indirect
|
||||
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
|
||||
github.com/pierrec/lz4/v4 v4.1.21 // indirect
|
||||
github.com/pierrec/lz4/v4 v4.1.22 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/prometheus/client_golang v1.20.4 // indirect
|
||||
github.com/prometheus/client_golang v1.21.1 // indirect
|
||||
github.com/prometheus/client_model v0.6.1 // indirect
|
||||
github.com/prometheus/common v0.59.1 // indirect
|
||||
github.com/prometheus/common v0.62.0 // indirect
|
||||
github.com/prometheus/procfs v0.15.1 // indirect
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||
github.com/ryanuber/go-glob v1.0.0 // indirect
|
||||
github.com/segmentio/asm v1.2.0 // indirect
|
||||
github.com/segmentio/encoding v0.4.0 // indirect
|
||||
github.com/silas/dag v0.0.0-20220518035006-a7e85ada93c5 // indirect
|
||||
github.com/sirupsen/logrus v1.8.1 // indirect
|
||||
github.com/twmb/franz-go/pkg/kadm v1.14.0 // indirect
|
||||
github.com/segmentio/encoding v0.4.1 // indirect
|
||||
github.com/spf13/cast v1.8.0 // indirect
|
||||
github.com/twmb/franz-go/pkg/kmsg v1.9.0 // indirect
|
||||
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
|
||||
github.com/valyala/fastrand v1.1.0 // indirect
|
||||
github.com/valyala/histogram v1.2.0 // indirect
|
||||
github.com/zeebo/errs v1.2.2 // indirect
|
||||
go.opentelemetry.io/otel v1.32.0 // indirect
|
||||
github.com/zeebo/errs v1.4.0 // indirect
|
||||
go.uber.org/atomic v1.11.0 // indirect
|
||||
go.uber.org/automaxprocs v1.6.0 // indirect
|
||||
go.unistack.org/metrics v0.0.1 // indirect
|
||||
go.unistack.org/micro-wrapper-requestid/v3 v3.9.3 // indirect
|
||||
golang.org/x/crypto v0.30.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20231108232855-2478ac86f678 // indirect
|
||||
golang.org/x/sys v0.28.0 // indirect
|
||||
golang.org/x/text v0.21.0 // indirect
|
||||
golang.org/x/time v0.7.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576 // indirect
|
||||
go.unistack.org/micro-client-http/v3 v3.9.15 // indirect
|
||||
go.unistack.org/micro-proto/v4 v4.1.0 // indirect
|
||||
go.unistack.org/micro-wrapper-requestid/v4 v4.1.0 // indirect
|
||||
go.unistack.org/micro/v3 v3.11.38 // indirect
|
||||
go.unistack.org/protoc-gen-go-micro/v4 v4.0.15 // indirect
|
||||
golang.org/x/crypto v0.38.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect
|
||||
golang.org/x/mod v0.24.0 // indirect
|
||||
golang.org/x/sync v0.14.0 // indirect
|
||||
golang.org/x/sys v0.33.0 // indirect
|
||||
golang.org/x/text v0.25.0 // indirect
|
||||
golang.org/x/time v0.11.0 // indirect
|
||||
golang.org/x/tools v0.33.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250512202823-5a2f75b736a9 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect
|
||||
modernc.org/libc v1.55.3 // indirect
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"testing"
|
||||
|
||||
pb "go.unistack.org/micro-tests/client/grpc/proto"
|
||||
"go.unistack.org/micro/v3/logger/unwrap"
|
||||
"go.unistack.org/micro/v4/logger/unwrap"
|
||||
"google.golang.org/protobuf/types/known/wrapperspb"
|
||||
)
|
||||
|
||||
|
||||
@@ -5,13 +5,14 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
prometheus "go.unistack.org/micro-meter-prometheus/v3"
|
||||
"go.unistack.org/micro/v3/client"
|
||||
"go.unistack.org/micro/v3/codec"
|
||||
"go.unistack.org/micro/v3/meter"
|
||||
prometheus "go.unistack.org/micro-meter-prometheus/v4"
|
||||
"go.unistack.org/micro/v4/client"
|
||||
"go.unistack.org/micro/v4/codec"
|
||||
"go.unistack.org/micro/v4/meter"
|
||||
)
|
||||
|
||||
func TestWrapper(t *testing.T) {
|
||||
t.Skip()
|
||||
m := prometheus.NewMeter() // meter.Labels("test_key", "test_val"))
|
||||
_ = m.Init()
|
||||
|
||||
|
||||
@@ -5,13 +5,14 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
victoriametrics "go.unistack.org/micro-meter-victoriametrics/v3"
|
||||
"go.unistack.org/micro/v3/client"
|
||||
"go.unistack.org/micro/v3/codec"
|
||||
"go.unistack.org/micro/v3/meter"
|
||||
victoriametrics "go.unistack.org/micro-meter-victoriametrics/v4"
|
||||
"go.unistack.org/micro/v4/client"
|
||||
"go.unistack.org/micro/v4/codec"
|
||||
"go.unistack.org/micro/v4/meter"
|
||||
)
|
||||
|
||||
func TestWrapper(t *testing.T) {
|
||||
t.Skip()
|
||||
m := victoriametrics.NewMeter() // meter.Labels("test_key", "test_val"))
|
||||
_ = m.Init()
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.26.0
|
||||
// protoc v5.28.3
|
||||
// protoc v5.29.2
|
||||
// source: test.proto
|
||||
|
||||
package pb
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package pb
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
cp "go.unistack.org/micro-codec-proto/v3"
|
||||
cp "go.unistack.org/micro-codec-proto/v4"
|
||||
)
|
||||
|
||||
func TestMarshalUnmarshal(t *testing.T) {
|
||||
@@ -20,7 +19,9 @@ func TestMarshalUnmarshal(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, item := range msg1.Items {
|
||||
fmt.Printf("item %#+v\n", item)
|
||||
}
|
||||
/*
|
||||
for _, item := range msg1.Items {
|
||||
fmt.Printf("item %#+v\n", item)
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh -e
|
||||
|
||||
INC=$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3)
|
||||
INC_CODEC=$(go list -f '{{ .Dir }}' -m go.unistack.org/micro/v3)
|
||||
INC=$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v4)
|
||||
INC_CODEC=$(go list -f '{{ .Dir }}' -m go.unistack.org/micro/v4)
|
||||
ARGS="-I${INC}"
|
||||
CODEC_ARGS="-I${INC_CODEC}"
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.26.0
|
||||
// protoc v5.28.3
|
||||
// protoc v5.29.2
|
||||
// source: test.proto
|
||||
|
||||
package pb
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-micro v3.10.4
|
||||
// - protoc v5.28.3
|
||||
// - protoc v5.29.2
|
||||
// source: test.proto
|
||||
|
||||
package pb
|
||||
@@ -9,7 +9,7 @@ package pb
|
||||
import (
|
||||
context "context"
|
||||
codec "go.unistack.org/micro-proto/v3/codec"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
client "go.unistack.org/micro/v4/client"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -6,11 +6,11 @@ package pb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
v31 "go.unistack.org/micro-client-http/v3"
|
||||
v31 "go.unistack.org/micro-client-http/v4"
|
||||
codec "go.unistack.org/micro-proto/v3/codec"
|
||||
v3 "go.unistack.org/micro-server-http/v3"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
server "go.unistack.org/micro/v3/server"
|
||||
v3 "go.unistack.org/micro-server-http/v4"
|
||||
client "go.unistack.org/micro/v4/client"
|
||||
server "go.unistack.org/micro/v4/server"
|
||||
http "net/http"
|
||||
)
|
||||
|
||||
@@ -198,7 +198,6 @@ func RegisterTestServiceServer(s server.Server, sh TestServiceServer, opts ...se
|
||||
testService
|
||||
}
|
||||
h := &testServiceServer{sh}
|
||||
var nopts []server.HandlerOption
|
||||
nopts = append(nopts, v3.HandlerEndpoints(TestServiceServerEndpoints))
|
||||
return s.Handle(s.NewHandler(&TestService{h}, append(nopts, opts...)...))
|
||||
opts = append(opts, v3.HandlerEndpoints(TestServiceServerEndpoints))
|
||||
return s.Handle(s.NewHandler(&TestService{h}, opts...))
|
||||
}
|
||||
|
||||
@@ -13,12 +13,12 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
// drpccli "go.unistack.org/micro-client-drpc/v3"
|
||||
grpccli "go.unistack.org/micro-client-grpc/v3"
|
||||
httpcli "go.unistack.org/micro-client-http/v3"
|
||||
jsonpbcodec "go.unistack.org/micro-codec-jsonpb/v3"
|
||||
protocodec "go.unistack.org/micro-codec-proto/v3"
|
||||
httpsrv "go.unistack.org/micro-server-http/v3"
|
||||
// drpccli "go.unistack.org/micro-client-drpc/v4"
|
||||
grpccli "go.unistack.org/micro-client-grpc/v4"
|
||||
httpcli "go.unistack.org/micro-client-http/v4"
|
||||
jsonpbcodec "go.unistack.org/micro-codec-jsonpb/v4"
|
||||
protocodec "go.unistack.org/micro-codec-proto/v4"
|
||||
httpsrv "go.unistack.org/micro-server-http/v4"
|
||||
// mdpb "go.unistack.org/micro-tests/server/combo/mdpb"
|
||||
mgpb "go.unistack.org/micro-tests/server/combo/mgpb"
|
||||
mhpb "go.unistack.org/micro-tests/server/combo/mhpb"
|
||||
@@ -26,12 +26,12 @@ import (
|
||||
// ndpb "go.unistack.org/micro-tests/server/combo/ndpb"
|
||||
ngpb "go.unistack.org/micro-tests/server/combo/ngpb"
|
||||
pb "go.unistack.org/micro-tests/server/combo/proto"
|
||||
"go.unistack.org/micro/v3/client"
|
||||
"go.unistack.org/micro/v3/codec"
|
||||
"go.unistack.org/micro/v3/logger"
|
||||
"go.unistack.org/micro/v3/metadata"
|
||||
"go.unistack.org/micro/v3/register"
|
||||
"go.unistack.org/micro/v3/server"
|
||||
"go.unistack.org/micro/v4/client"
|
||||
"go.unistack.org/micro/v4/codec"
|
||||
"go.unistack.org/micro/v4/logger"
|
||||
"go.unistack.org/micro/v4/metadata"
|
||||
"go.unistack.org/micro/v4/register"
|
||||
"go.unistack.org/micro/v4/server"
|
||||
"golang.org/x/net/http2"
|
||||
"golang.org/x/net/http2/h2c"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
@@ -10,20 +10,20 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
grpccli "go.unistack.org/micro-client-grpc/v3"
|
||||
httpcli "go.unistack.org/micro-client-http/v3"
|
||||
jsonpbcodec "go.unistack.org/micro-codec-jsonpb/v3"
|
||||
protocodec "go.unistack.org/micro-codec-proto/v3"
|
||||
grpcsrv "go.unistack.org/micro-server-grpc/v3"
|
||||
httpsrv "go.unistack.org/micro-server-http/v3"
|
||||
grpccli "go.unistack.org/micro-client-grpc/v4"
|
||||
httpcli "go.unistack.org/micro-client-http/v4"
|
||||
jsonpbcodec "go.unistack.org/micro-codec-jsonpb/v4"
|
||||
protocodec "go.unistack.org/micro-codec-proto/v4"
|
||||
grpcsrv "go.unistack.org/micro-server-grpc/v4"
|
||||
httpsrv "go.unistack.org/micro-server-http/v4"
|
||||
mgpb "go.unistack.org/micro-tests/server/combo/mgpb"
|
||||
mhpb "go.unistack.org/micro-tests/server/combo/mhpb"
|
||||
ngpb "go.unistack.org/micro-tests/server/combo/ngpb"
|
||||
pb "go.unistack.org/micro-tests/server/combo/proto"
|
||||
"go.unistack.org/micro/v3/client"
|
||||
"go.unistack.org/micro/v3/logger"
|
||||
"go.unistack.org/micro/v3/register"
|
||||
"go.unistack.org/micro/v3/server"
|
||||
"go.unistack.org/micro/v4/client"
|
||||
"go.unistack.org/micro/v4/logger"
|
||||
mregister "go.unistack.org/micro/v4/register/memory"
|
||||
"go.unistack.org/micro/v4/server"
|
||||
"golang.org/x/net/http2"
|
||||
"golang.org/x/net/http2/h2c"
|
||||
"google.golang.org/grpc"
|
||||
@@ -70,7 +70,7 @@ func (h *Handler) Call(ctx context.Context, req *pb.CallReq, rsp *pb.CallRsp) er
|
||||
}
|
||||
|
||||
func TestComboServer(t *testing.T) {
|
||||
reg := register.NewRegister()
|
||||
reg := mregister.NewRegister()
|
||||
ctx := context.Background()
|
||||
|
||||
h := &Handler{t: t}
|
||||
@@ -111,7 +111,7 @@ func TestComboServer(t *testing.T) {
|
||||
hs := &http.Server{Handler: h2c.NewHandler(newComboMux(hsrv, gsrv.GRPCServer(), nil), &http2.Server{})}
|
||||
|
||||
// init http server
|
||||
if err := hsrv.Init(httpsrv.Server(hs)); err != nil {
|
||||
if err := hsrv.Init(httpsrv.HTTPServer(hs)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,11 @@ package combo
|
||||
|
||||
//go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go_out=paths=source_relative:./proto proto/proto.proto"
|
||||
|
||||
//go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go-micro_out=components='micro|grpc',standalone=true,debug=true,paths=source_relative:./mgpb proto/proto.proto"
|
||||
//go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go-micro_out=components='micro',standalone=false,debug=true,paths=source_relative:./proto proto/proto.proto"
|
||||
|
||||
//go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go-micro_out=components='micro|http',standalone=true,debug=true,paths=source_relative:./mhpb proto/proto.proto"
|
||||
//go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go-micro_out=components='grpc',standalone=true,debug=true,paths=source_relative:./mgpb proto/proto.proto"
|
||||
|
||||
//go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go-micro_out=components='http',standalone=true,debug=true,paths=source_relative:./mhpb proto/proto.proto"
|
||||
|
||||
//go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go-micro_out=components='openapiv3',openapi_file=./apidocs.swagger.yaml,standalone=true,debug=true,paths=source_relative:./proto proto/proto.proto"
|
||||
|
||||
@@ -14,8 +16,6 @@ package combo
|
||||
////go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go_out=paths=source_relative:./ndpb proto/proto.proto"
|
||||
////go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go-drpc_out=json=false,paths=source_relative:./ndpb proto/proto.proto"
|
||||
|
||||
////go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go-micro_out=components='micro|http',standalone=true,debug=true,paths=source_relative:./mhpb proto/proto.proto"
|
||||
|
||||
////go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go-micro_out=components='micro|drpc',standalone=true,debug=true,paths=source_relative:./mdpb proto/proto.proto"
|
||||
|
||||
//go:generate sh -c "mkdir -p swagger-ui && cp proto/apidocs.swagger.yaml swagger-ui/swagger.yaml && curl -L https://github.com/swagger-api/swagger-ui/archive/refs/tags/v4.17.0.tar.gz -o v4.17.0.tar.gz && tar -C swagger-ui --strip-components=2 -zxvf v4.17.0.tar.gz swagger-ui-4.17.0/dist && rm -f v4.17.0.tar.gz && sed -i '' 's|https://petstore.swagger.io/v2/swagger.json|./swagger.yaml|g' swagger-ui/index.html swagger-ui/swagger-initializer.js && sed -i '' 's|deepLinking: true,|deepLinking: true, displayOperationId: true, tryItOutEnabled: true,|g' swagger-ui/swagger-initializer.js "
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-micro v3.10.4
|
||||
// - protoc v5.28.3
|
||||
// - protoc v5.29.2
|
||||
// source: proto.proto
|
||||
|
||||
package pb
|
||||
@@ -9,7 +9,7 @@ package pb
|
||||
import (
|
||||
context "context"
|
||||
proto "go.unistack.org/micro-tests/server/combo/proto"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
client "go.unistack.org/micro/v4/client"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -7,8 +7,8 @@ package pb
|
||||
import (
|
||||
context "context"
|
||||
proto "go.unistack.org/micro-tests/server/combo/proto"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
server "go.unistack.org/micro/v3/server"
|
||||
client "go.unistack.org/micro/v4/client"
|
||||
server "go.unistack.org/micro/v4/server"
|
||||
)
|
||||
|
||||
type testClient struct {
|
||||
@@ -45,6 +45,5 @@ func RegisterTestServer(s server.Server, sh proto.TestServer, opts ...server.Han
|
||||
test
|
||||
}
|
||||
h := &testServer{sh}
|
||||
var nopts []server.HandlerOption
|
||||
return s.Handle(s.NewHandler(&Test{h}, append(nopts, opts...)...))
|
||||
return s.Handle(s.NewHandler(&Test{h}, opts...))
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||
// protoc-gen-go-micro version: v3.10.4
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
protojson "google.golang.org/protobuf/encoding/protojson"
|
||||
)
|
||||
|
||||
var (
|
||||
marshaler = protojson.MarshalOptions{}
|
||||
)
|
||||
|
||||
func (m *Error) Error() string {
|
||||
buf, _ := marshaler.Marshal(m)
|
||||
return string(buf)
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-micro v3.10.4
|
||||
// - protoc v5.28.3
|
||||
// - protoc v5.29.2
|
||||
// source: proto.proto
|
||||
|
||||
package pb
|
||||
@@ -9,7 +9,7 @@ package pb
|
||||
import (
|
||||
context "context"
|
||||
proto "go.unistack.org/micro-tests/server/combo/proto"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
client "go.unistack.org/micro/v4/client"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -6,11 +6,11 @@ package pb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
v31 "go.unistack.org/micro-client-http/v3"
|
||||
v3 "go.unistack.org/micro-server-http/v3"
|
||||
v31 "go.unistack.org/micro-client-http/v4"
|
||||
v3 "go.unistack.org/micro-server-http/v4"
|
||||
proto "go.unistack.org/micro-tests/server/combo/proto"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
server "go.unistack.org/micro/v3/server"
|
||||
client "go.unistack.org/micro/v4/client"
|
||||
server "go.unistack.org/micro/v4/server"
|
||||
http "net/http"
|
||||
)
|
||||
|
||||
@@ -37,7 +37,7 @@ func NewTestClient(name string, c client.Client) proto.TestClient {
|
||||
|
||||
func (c *testClient) Call(ctx context.Context, req *proto.CallReq, opts ...client.CallOption) (*proto.CallRsp, error) {
|
||||
errmap := make(map[string]interface{}, 1)
|
||||
errmap["default"] = &proto.Error{}
|
||||
errmap["default"] = &proto.ErrorRsp{}
|
||||
opts = append(opts,
|
||||
v31.ErrorMap(errmap),
|
||||
)
|
||||
@@ -70,7 +70,6 @@ func RegisterTestServer(s server.Server, sh proto.TestServer, opts ...server.Han
|
||||
test
|
||||
}
|
||||
h := &testServer{sh}
|
||||
var nopts []server.HandlerOption
|
||||
nopts = append(nopts, v3.HandlerEndpoints(TestServerEndpoints))
|
||||
return s.Handle(s.NewHandler(&Test{h}, append(nopts, opts...)...))
|
||||
opts = append(opts, v3.HandlerEndpoints(TestServerEndpoints))
|
||||
return s.Handle(s.NewHandler(&Test{h}, opts...))
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.26.0
|
||||
// protoc v5.28.3
|
||||
// protoc v5.29.2
|
||||
// source: ngpb.proto
|
||||
|
||||
package pb
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc v5.28.3
|
||||
// - protoc v5.29.2
|
||||
// source: ngpb.proto
|
||||
|
||||
package pb
|
||||
|
||||
@@ -22,7 +22,7 @@ paths:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
$ref: '#/components/schemas/ErrorRsp'
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
@@ -41,7 +41,7 @@ components:
|
||||
properties:
|
||||
rsp:
|
||||
type: string
|
||||
Error:
|
||||
ErrorRsp:
|
||||
type: object
|
||||
properties:
|
||||
err:
|
||||
|
||||
@@ -11,7 +11,7 @@ var (
|
||||
marshaler = protojson.MarshalOptions{}
|
||||
)
|
||||
|
||||
func (m *Error) Error() string {
|
||||
func (m *ErrorRsp) Error() string {
|
||||
buf, _ := marshaler.Marshal(m)
|
||||
return string(buf)
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.26.0
|
||||
// protoc v5.28.3
|
||||
// protoc v5.29.2
|
||||
// source: proto.proto
|
||||
|
||||
package pb
|
||||
@@ -118,7 +118,7 @@ func (x *CallRsp) GetRsp() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
type Error struct {
|
||||
type ErrorRsp struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
@@ -126,8 +126,8 @@ type Error struct {
|
||||
Err string `protobuf:"bytes,1,opt,name=err,proto3" json:"err,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Error) Reset() {
|
||||
*x = Error{}
|
||||
func (x *ErrorRsp) Reset() {
|
||||
*x = ErrorRsp{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
@@ -135,13 +135,13 @@ func (x *Error) Reset() {
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Error) String() string {
|
||||
func (x *ErrorRsp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Error) ProtoMessage() {}
|
||||
func (*ErrorRsp) ProtoMessage() {}
|
||||
|
||||
func (x *Error) ProtoReflect() protoreflect.Message {
|
||||
func (x *ErrorRsp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
@@ -153,12 +153,12 @@ func (x *Error) ProtoReflect() protoreflect.Message {
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Error.ProtoReflect.Descriptor instead.
|
||||
func (*Error) Descriptor() ([]byte, []int) {
|
||||
// Deprecated: Use ErrorRsp.ProtoReflect.Descriptor instead.
|
||||
func (*ErrorRsp) Descriptor() ([]byte, []int) {
|
||||
return file_proto_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *Error) GetErr() string {
|
||||
func (x *ErrorRsp) GetErr() string {
|
||||
if x != nil {
|
||||
return x.Err
|
||||
}
|
||||
@@ -179,20 +179,20 @@ var file_proto_proto_rawDesc = []byte{
|
||||
0x1b, 0x0a, 0x07, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x72, 0x65,
|
||||
0x71, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x72, 0x65, 0x71, 0x22, 0x1b, 0x0a, 0x07,
|
||||
0x43, 0x61, 0x6c, 0x6c, 0x52, 0x73, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x72, 0x73, 0x70, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x72, 0x73, 0x70, 0x22, 0x19, 0x0a, 0x05, 0x45, 0x72, 0x72,
|
||||
0x6f, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x72, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x03, 0x65, 0x72, 0x72, 0x32, 0x77, 0x0a, 0x04, 0x54, 0x65, 0x73, 0x74, 0x12, 0x6f, 0x0a, 0x04,
|
||||
0x43, 0x61, 0x6c, 0x6c, 0x12, 0x16, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x16, 0x2e, 0x74,
|
||||
0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x61, 0x6c,
|
||||
0x6c, 0x52, 0x73, 0x70, 0x22, 0x37, 0xaa, 0x84, 0x9e, 0x03, 0x22, 0x2a, 0x04, 0x43, 0x61, 0x6c,
|
||||
0x6c, 0x42, 0x1a, 0x0a, 0x18, 0x12, 0x16, 0x0a, 0x14, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76,
|
||||
0x31, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0xb2, 0xea, 0xff,
|
||||
0xf9, 0x01, 0x0a, 0x22, 0x05, 0x2f, 0x43, 0x61, 0x6c, 0x6c, 0x3a, 0x01, 0x2a, 0x42, 0x33, 0x5a,
|
||||
0x31, 0x67, 0x6f, 0x2e, 0x75, 0x6e, 0x69, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x2e, 0x6f, 0x72, 0x67,
|
||||
0x2f, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2d, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x73, 0x65, 0x72,
|
||||
0x76, 0x65, 0x72, 0x2f, 0x63, 0x6f, 0x6d, 0x62, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b,
|
||||
0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x72, 0x73, 0x70, 0x22, 0x1c, 0x0a, 0x08, 0x45, 0x72, 0x72,
|
||||
0x6f, 0x72, 0x52, 0x73, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x72, 0x72, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x03, 0x65, 0x72, 0x72, 0x32, 0x7a, 0x0a, 0x04, 0x54, 0x65, 0x73, 0x74, 0x12,
|
||||
0x72, 0x0a, 0x04, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x16, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76,
|
||||
0x31, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x1a,
|
||||
0x16, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
|
||||
0x43, 0x61, 0x6c, 0x6c, 0x52, 0x73, 0x70, 0x22, 0x3a, 0xaa, 0x84, 0x9e, 0x03, 0x25, 0x2a, 0x04,
|
||||
0x43, 0x61, 0x6c, 0x6c, 0x42, 0x1d, 0x0a, 0x1b, 0x12, 0x19, 0x0a, 0x17, 0x2e, 0x74, 0x65, 0x73,
|
||||
0x74, 0x2e, 0x76, 0x31, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72,
|
||||
0x52, 0x73, 0x70, 0xb2, 0xea, 0xff, 0xf9, 0x01, 0x0a, 0x22, 0x05, 0x2f, 0x43, 0x61, 0x6c, 0x6c,
|
||||
0x3a, 0x01, 0x2a, 0x42, 0x33, 0x5a, 0x31, 0x67, 0x6f, 0x2e, 0x75, 0x6e, 0x69, 0x73, 0x74, 0x61,
|
||||
0x63, 0x6b, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2d, 0x74, 0x65, 0x73,
|
||||
0x74, 0x73, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x63, 0x6f, 0x6d, 0x62, 0x6f, 0x2f,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -209,9 +209,9 @@ func file_proto_proto_rawDescGZIP() []byte {
|
||||
|
||||
var file_proto_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||
var file_proto_proto_goTypes = []interface{}{
|
||||
(*CallReq)(nil), // 0: test.v1.proto.CallReq
|
||||
(*CallRsp)(nil), // 1: test.v1.proto.CallRsp
|
||||
(*Error)(nil), // 2: test.v1.proto.Error
|
||||
(*CallReq)(nil), // 0: test.v1.proto.CallReq
|
||||
(*CallRsp)(nil), // 1: test.v1.proto.CallRsp
|
||||
(*ErrorRsp)(nil), // 2: test.v1.proto.ErrorRsp
|
||||
}
|
||||
var file_proto_proto_depIdxs = []int32{
|
||||
0, // 0: test.v1.proto.Test.Call:input_type -> test.v1.proto.CallReq
|
||||
@@ -254,7 +254,7 @@ func file_proto_proto_init() {
|
||||
}
|
||||
}
|
||||
file_proto_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Error); i {
|
||||
switch v := v.(*ErrorRsp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
|
||||
@@ -16,7 +16,7 @@ service Test {
|
||||
responses: {
|
||||
default: {
|
||||
reference: {
|
||||
_ref: ".test.v1.proto.Error";
|
||||
_ref: ".test.v1.proto.ErrorRsp";
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -33,6 +33,6 @@ message CallRsp {
|
||||
string rsp = 1;
|
||||
};
|
||||
|
||||
message Error {
|
||||
message ErrorRsp {
|
||||
string err = 1;
|
||||
};
|
||||
|
||||
24
server/combo/proto/proto_micro.pb.go
Normal file
24
server/combo/proto/proto_micro.pb.go
Normal file
@@ -0,0 +1,24 @@
|
||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-micro v3.10.4
|
||||
// - protoc v5.29.2
|
||||
// source: proto.proto
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
client "go.unistack.org/micro/v4/client"
|
||||
)
|
||||
|
||||
var (
|
||||
TestName = "Test"
|
||||
)
|
||||
|
||||
type TestClient interface {
|
||||
Call(ctx context.Context, req *CallReq, opts ...client.CallOption) (*CallRsp, error)
|
||||
}
|
||||
|
||||
type TestServer interface {
|
||||
Call(ctx context.Context, req *CallReq, rsp *CallRsp) error
|
||||
}
|
||||
@@ -22,7 +22,7 @@ paths:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
$ref: '#/components/schemas/ErrorRsp'
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
@@ -41,7 +41,7 @@ components:
|
||||
properties:
|
||||
rsp:
|
||||
type: string
|
||||
Error:
|
||||
ErrorRsp:
|
||||
type: object
|
||||
properties:
|
||||
err:
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
package grpc
|
||||
|
||||
//go:generate go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
|
||||
//go:generate sh -c "protoc -I./proto -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) -I. --go-grpc_out=paths=source_relative:./proto --go_out=paths=source_relative:./proto --go-micro_out=components='micro|grpc',debug=true,standalone=true,paths=source_relative:./gproto proto/test.proto"
|
||||
//go:generate sh -c "protoc -I./proto -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) -I. --go-grpc_out=paths=source_relative:./proto --go_out=paths=source_relative:./proto proto/test.proto"
|
||||
//go:generate sh -c "protoc -I./proto -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) -I. --go-grpc_out=paths=source_relative:./proto --go_out=paths=source_relative:./proto --go-micro_out=components='micro',debug=true,standalone=true,paths=source_relative:./gproto proto/test.proto"
|
||||
//go:generate sh -c "protoc -I./proto -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) -I. --go-grpc_out=paths=source_relative:./proto --go_out=paths=source_relative:./proto --go-micro_out=components='grpc',debug=true,standalone=true,paths=source_relative:./gproto proto/test.proto"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-micro v3.10.4
|
||||
// - protoc v5.28.3
|
||||
// - protoc v5.29.2
|
||||
// source: test.proto
|
||||
|
||||
package helloworld
|
||||
@@ -9,8 +9,8 @@ package helloworld
|
||||
import (
|
||||
context "context"
|
||||
proto "go.unistack.org/micro-tests/server/grpc/proto"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
metadata "go.unistack.org/micro/v3/metadata"
|
||||
client "go.unistack.org/micro/v4/client"
|
||||
metadata "go.unistack.org/micro/v4/metadata"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -26,6 +26,8 @@ type Test_StreamCallClient interface {
|
||||
Context() context.Context
|
||||
SendMsg(msg interface{}) error
|
||||
RecvMsg(msg interface{}) error
|
||||
CloseAndRecv() (*proto.Response, error)
|
||||
CloseSend() error
|
||||
Close() error
|
||||
Header() metadata.Metadata
|
||||
Send(msg *proto.Request) error
|
||||
@@ -41,6 +43,7 @@ type Test_StreamCallStream interface {
|
||||
Context() context.Context
|
||||
SendMsg(msg interface{}) error
|
||||
RecvMsg(msg interface{}) error
|
||||
SendAndClose(msg *proto.Response) error
|
||||
Close() error
|
||||
Recv() (*proto.Request, error)
|
||||
Send(msg *proto.Response) error
|
||||
|
||||
@@ -7,9 +7,9 @@ package helloworld
|
||||
import (
|
||||
context "context"
|
||||
proto "go.unistack.org/micro-tests/server/grpc/proto"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
metadata "go.unistack.org/micro/v3/metadata"
|
||||
server "go.unistack.org/micro/v3/server"
|
||||
client "go.unistack.org/micro/v4/client"
|
||||
metadata "go.unistack.org/micro/v4/metadata"
|
||||
server "go.unistack.org/micro/v4/server"
|
||||
)
|
||||
|
||||
type testClient struct {
|
||||
@@ -17,7 +17,7 @@ type testClient struct {
|
||||
name string
|
||||
}
|
||||
|
||||
func NewTestClient(name string, c client.Client) proto.TestClient {
|
||||
func NewTestClient(name string, c client.Client) TestClient {
|
||||
return &testClient{c: c, name: name}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,18 @@ type testClientStreamCall struct {
|
||||
stream client.Stream
|
||||
}
|
||||
|
||||
func (s *testClientStreamCall) CloseAndRecv() (*proto.Response, error) {
|
||||
msg := &proto.Response{}
|
||||
err := s.RecvMsg(msg)
|
||||
if err == nil {
|
||||
err = s.Close()
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return msg, nil
|
||||
}
|
||||
|
||||
func (s *testClientStreamCall) Close() error {
|
||||
return s.stream.Close()
|
||||
}
|
||||
@@ -79,7 +91,7 @@ func (s *testClientStreamCall) Recv() (*proto.Response, error) {
|
||||
}
|
||||
|
||||
type testServer struct {
|
||||
proto.TestServer
|
||||
TestServer
|
||||
}
|
||||
|
||||
func (h *testServer) Call(ctx context.Context, req *proto.Request, rsp *proto.Response) error {
|
||||
@@ -94,6 +106,13 @@ type testStreamCallStream struct {
|
||||
stream server.Stream
|
||||
}
|
||||
|
||||
func (s *testStreamCallStream) SendAndClose(msg *proto.Response) error {
|
||||
err := s.SendMsg(msg)
|
||||
if err == nil {
|
||||
err = s.stream.Close()
|
||||
}
|
||||
return err
|
||||
}
|
||||
func (s *testStreamCallStream) Close() error {
|
||||
return s.stream.Close()
|
||||
}
|
||||
@@ -122,7 +141,7 @@ func (s *testStreamCallStream) Recv() (*proto.Request, error) {
|
||||
return msg, nil
|
||||
}
|
||||
|
||||
func RegisterTestServer(s server.Server, sh proto.TestServer, opts ...server.HandlerOption) error {
|
||||
func RegisterTestServer(s server.Server, sh TestServer, opts ...server.HandlerOption) error {
|
||||
type test interface {
|
||||
Call(ctx context.Context, req *proto.Request, rsp *proto.Response) error
|
||||
StreamCall(ctx context.Context, stream server.Stream) error
|
||||
@@ -131,6 +150,5 @@ func RegisterTestServer(s server.Server, sh proto.TestServer, opts ...server.Han
|
||||
test
|
||||
}
|
||||
h := &testServer{sh}
|
||||
var nopts []server.HandlerOption
|
||||
return s.Handle(s.NewHandler(&Test{h}, append(nopts, opts...)...))
|
||||
return s.Handle(s.NewHandler(&Test{h}, opts...))
|
||||
}
|
||||
|
||||
@@ -7,24 +7,23 @@ import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
gclient "go.unistack.org/micro-client-grpc/v3"
|
||||
jsonpbcodec "go.unistack.org/micro-codec-jsonpb/v3"
|
||||
protocodec "go.unistack.org/micro-codec-proto/v3"
|
||||
regRouter "go.unistack.org/micro-router-register/v3"
|
||||
gserver "go.unistack.org/micro-server-grpc/v3"
|
||||
httpsrv "go.unistack.org/micro-server-http/v3"
|
||||
gclient "go.unistack.org/micro-client-grpc/v4"
|
||||
jsonpbcodec "go.unistack.org/micro-codec-jsonpb/v4"
|
||||
protocodec "go.unistack.org/micro-codec-proto/v4"
|
||||
regRouter "go.unistack.org/micro-router-register/v4"
|
||||
gserver "go.unistack.org/micro-server-grpc/v4"
|
||||
health "go.unistack.org/micro-server-http/v3/handler/health"
|
||||
httpsrv "go.unistack.org/micro-server-http/v4"
|
||||
gpb "go.unistack.org/micro-tests/server/grpc/gproto"
|
||||
pb "go.unistack.org/micro-tests/server/grpc/proto"
|
||||
"go.unistack.org/micro/v3/broker"
|
||||
"go.unistack.org/micro/v3/client"
|
||||
"go.unistack.org/micro/v3/codec"
|
||||
"go.unistack.org/micro/v3/errors"
|
||||
"go.unistack.org/micro/v3/logger"
|
||||
"go.unistack.org/micro/v3/metadata"
|
||||
"go.unistack.org/micro/v3/register"
|
||||
"go.unistack.org/micro/v3/router"
|
||||
"go.unistack.org/micro/v3/server"
|
||||
"go.unistack.org/micro/v4/broker"
|
||||
"go.unistack.org/micro/v4/client"
|
||||
"go.unistack.org/micro/v4/errors"
|
||||
"go.unistack.org/micro/v4/logger"
|
||||
"go.unistack.org/micro/v4/metadata"
|
||||
mregister "go.unistack.org/micro/v4/register/memory"
|
||||
"go.unistack.org/micro/v4/router"
|
||||
"go.unistack.org/micro/v4/server"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/encoding/gzip"
|
||||
@@ -39,8 +38,8 @@ type testnServer struct {
|
||||
pb.UnimplementedTestServer
|
||||
}
|
||||
|
||||
func NewServerHandlerWrapper() server.HandlerWrapper {
|
||||
return func(fn server.HandlerFunc) server.HandlerFunc {
|
||||
func NewServerHandlerWrapper() server.HookHandler {
|
||||
return func(fn server.FuncHandler) server.FuncHandler {
|
||||
return func(ctx context.Context, req server.Request, rsp interface{}) error {
|
||||
// fmt.Printf("wrap ctx: %#+v req: %#+v\n", ctx, req)
|
||||
return fn(ctx, req, rsp)
|
||||
@@ -62,6 +61,10 @@ func (g *testServer) Call(ctx context.Context, req *pb.Request, rsp *pb.Response
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *testServer) StreamCall(ctx context.Context, stream gpb.Test_StreamCallStream) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *testnServer) Call(ctx context.Context, req *pb.Request) (*pb.Response, error) {
|
||||
_, ok := gmetadata.FromIncomingContext(ctx)
|
||||
if !ok {
|
||||
@@ -81,11 +84,10 @@ func (g *testnServer) Call(ctx context.Context, req *pb.Request) (*pb.Response,
|
||||
|
||||
func TestGRPCServer(t *testing.T) {
|
||||
var err error
|
||||
codec.DefaultMaxMsgSize = 8 * 1024 * 1024
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
_ = logger.DefaultLogger.Init(logger.WithLevel(logger.ErrorLevel))
|
||||
r := register.NewRegister()
|
||||
r := mregister.NewRegister()
|
||||
b := broker.NewBroker(broker.Register(r))
|
||||
s := gserver.NewServer(
|
||||
server.Codec("application/grpc+proto", protocodec.NewCodec()),
|
||||
@@ -93,8 +95,8 @@ func TestGRPCServer(t *testing.T) {
|
||||
server.Address("127.0.0.1:0"),
|
||||
server.Register(r),
|
||||
server.Name("helloworld"),
|
||||
gserver.Reflection(true),
|
||||
server.WrapHandler(NewServerHandlerWrapper()),
|
||||
// gserver.Reflection(true),
|
||||
server.Hooks(server.HookHandler(NewServerHandlerWrapper())),
|
||||
)
|
||||
// create router
|
||||
rtr := regRouter.NewRouter(router.Register(r))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.26.0
|
||||
// protoc v5.28.3
|
||||
// protoc v5.29.2
|
||||
// source: test.proto
|
||||
|
||||
package helloworld
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc v5.28.3
|
||||
// - protoc v5.29.2
|
||||
// source: test.proto
|
||||
|
||||
package helloworld
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
func TestTemplate(t *testing.T) {
|
||||
// t.Skip()
|
||||
t.Skip()
|
||||
h := http.NewServeMux()
|
||||
h.HandleFunc("/", swaggerui.Handler(""))
|
||||
if err := http.ListenAndServe(":8080", h); err != nil {
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
httpsrv "go.unistack.org/micro-server-http/v3"
|
||||
httpsrv "go.unistack.org/micro-server-http/v4"
|
||||
pb "go.unistack.org/micro-tests/client/http/proto"
|
||||
)
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package http_test
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
@@ -14,19 +15,19 @@ import (
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
httpcli "go.unistack.org/micro-client-http/v3"
|
||||
jsoncodec "go.unistack.org/micro-codec-json/v3"
|
||||
jsonpbcodec "go.unistack.org/micro-codec-jsonpb/v3"
|
||||
urlencodecodec "go.unistack.org/micro-codec-urlencode/v3"
|
||||
xmlcodec "go.unistack.org/micro-codec-xml/v3"
|
||||
vmeter "go.unistack.org/micro-meter-victoriametrics/v3"
|
||||
httpsrv "go.unistack.org/micro-server-http/v3"
|
||||
meterhandler "go.unistack.org/micro-server-http/v3/handler/meter"
|
||||
httpcli "go.unistack.org/micro-client-http/v4"
|
||||
jsoncodec "go.unistack.org/micro-codec-json/v4"
|
||||
jsonpbcodec "go.unistack.org/micro-codec-jsonpb/v4"
|
||||
urlencodecodec "go.unistack.org/micro-codec-urlencode/v4"
|
||||
xmlcodec "go.unistack.org/micro-codec-xml/v4"
|
||||
vmeter "go.unistack.org/micro-meter-victoriametrics/v4"
|
||||
httpsrv "go.unistack.org/micro-server-http/v4"
|
||||
meterhandler "go.unistack.org/micro-server-http/v4/handler/meter"
|
||||
pb "go.unistack.org/micro-tests/server/http/proto"
|
||||
"go.unistack.org/micro/v3/client"
|
||||
"go.unistack.org/micro/v3/metadata"
|
||||
"go.unistack.org/micro/v3/register"
|
||||
"go.unistack.org/micro/v3/server"
|
||||
"go.unistack.org/micro/v4/client"
|
||||
"go.unistack.org/micro/v4/metadata"
|
||||
mregister "go.unistack.org/micro/v4/register/memory"
|
||||
"go.unistack.org/micro/v4/server"
|
||||
wrapperspb "google.golang.org/protobuf/types/known/wrapperspb"
|
||||
)
|
||||
|
||||
@@ -82,7 +83,7 @@ func upload(client *http.Client, url string, values map[string]io.Reader) error
|
||||
}
|
||||
|
||||
func TestMultipart(t *testing.T) {
|
||||
reg := register.NewRegister()
|
||||
reg := mregister.NewRegister()
|
||||
ctx := context.Background()
|
||||
|
||||
// create server
|
||||
@@ -133,27 +134,28 @@ func TestMultipart(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func NewServerHandlerWrapper(t *testing.T) server.HandlerWrapper {
|
||||
return func(fn server.HandlerFunc) server.HandlerFunc {
|
||||
func NewServerHandlerWrapper(t *testing.T) server.HookHandler {
|
||||
return func(fn server.FuncHandler) server.FuncHandler {
|
||||
return func(ctx context.Context, req server.Request, rsp interface{}) error {
|
||||
md, ok := metadata.FromIncomingContext(ctx)
|
||||
// return fn(ctx, req, rsp)
|
||||
imd, ok := metadata.FromIncomingContext(ctx)
|
||||
if !ok {
|
||||
t.Fatal("metadata empty")
|
||||
return errors.New("missing metadata")
|
||||
}
|
||||
if v, ok := md.Get("Authorization"); ok && v == "test" {
|
||||
nmd := metadata.New(1)
|
||||
nmd, ok := metadata.FromOutgoingContext(ctx)
|
||||
if !ok {
|
||||
return errors.New("missing metadata")
|
||||
}
|
||||
if v, ok := imd.GetJoined("Authorization"); ok && v == "test" {
|
||||
nmd.Set("my-key", "my-val")
|
||||
nmd.Set("Content-Type", "text/xml")
|
||||
metadata.SetOutgoingContext(ctx, nmd)
|
||||
httpsrv.SetRspCode(ctx, http.StatusUnauthorized)
|
||||
return httpsrv.SetError(&pb.CallRsp{Rsp: "name_my_name"})
|
||||
}
|
||||
|
||||
if v, ok := md.Get("Test-Content-Type"); ok && v != "" {
|
||||
nmd := metadata.New(1)
|
||||
if v, ok := imd.GetJoined("Test-Content-Type"); ok && v != "" {
|
||||
nmd.Set("my-key", "my-val")
|
||||
nmd.Set("Content-Type", v)
|
||||
metadata.SetOutgoingContext(ctx, nmd)
|
||||
}
|
||||
|
||||
return fn(ctx, req, rsp)
|
||||
@@ -196,20 +198,29 @@ func (h *Handler) Call(ctx context.Context, req *pb.CallReq, rsp *pb.CallRsp) er
|
||||
if !ok {
|
||||
h.t.Fatalf("context without metadata")
|
||||
}
|
||||
omd, ok := metadata.FromOutgoingContext(ctx)
|
||||
if !ok {
|
||||
h.t.Fatalf("context without metadata")
|
||||
}
|
||||
if _, ok := md.Get("User-Agent"); !ok {
|
||||
h.t.Fatalf("context metadata does not have User-Agent header")
|
||||
}
|
||||
if req.Name != "my_name" {
|
||||
h.t.Fatalf("invalid req received: %#+v", req)
|
||||
}
|
||||
if req.Clientid != "1234567890" {
|
||||
h.t.Fatalf("invalid req recevided %#+v", req)
|
||||
if v, ok := md.GetJoined("Authorization"); ok && v == "test" {
|
||||
rsp.Rsp = "name_my_name"
|
||||
httpsrv.SetRspCode(ctx, http.StatusUnauthorized)
|
||||
omd.Set("my-key", "my-val")
|
||||
omd.Set("Content-Type", "text/xml")
|
||||
return httpsrv.SetError(&pb.CallRsp{Rsp: "name_my_name"})
|
||||
}
|
||||
|
||||
rsp.Rsp = "name_my_name"
|
||||
httpsrv.SetRspCode(ctx, http.StatusCreated)
|
||||
md = metadata.New(1)
|
||||
md.Set("my-key", "my-val")
|
||||
metadata.SetOutgoingContext(ctx, md)
|
||||
if omd, ok := metadata.FromOutgoingContext(ctx); ok {
|
||||
omd.Set("my-key", "my-val")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -225,7 +236,7 @@ func (h *Handler) CallError(ctx context.Context, req *pb.CallReq1, rsp *pb.CallR
|
||||
}
|
||||
|
||||
func TestNativeFormUrlencoded(t *testing.T) {
|
||||
reg := register.NewRegister()
|
||||
reg := mregister.NewRegister()
|
||||
ctx := context.Background()
|
||||
|
||||
// create server
|
||||
@@ -340,7 +351,7 @@ func TestNativeFormUrlencoded(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNativeClientServer(t *testing.T) {
|
||||
reg := register.NewRegister()
|
||||
reg := mregister.NewRegister()
|
||||
ctx := context.Background()
|
||||
|
||||
var mwfOk bool
|
||||
@@ -361,7 +372,7 @@ func TestNativeClientServer(t *testing.T) {
|
||||
server.Codec("application/json", jsonpbcodec.NewCodec()),
|
||||
server.Codec("application/x-www-form-urlencoded", urlencodecodec.NewCodec()),
|
||||
httpsrv.Middleware(mwf),
|
||||
server.WrapHandler(NewServerHandlerWrapper(t)),
|
||||
server.Hooks(server.HookHandler(NewServerHandlerWrapper(t))),
|
||||
)
|
||||
|
||||
h := &Handler{t: t}
|
||||
@@ -493,7 +504,7 @@ func TestNativeClientServer(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNativeServer(t *testing.T) {
|
||||
reg := register.NewRegister()
|
||||
reg := mregister.NewRegister()
|
||||
ctx := context.Background()
|
||||
|
||||
// create server
|
||||
@@ -504,7 +515,7 @@ func TestNativeServer(t *testing.T) {
|
||||
server.Codec("text/xml", xmlcodec.NewCodec()),
|
||||
server.Codec("application/json", jsoncodec.NewCodec()),
|
||||
server.Codec("application/x-www-form-urlencoded", urlencodecodec.NewCodec()),
|
||||
server.WrapHandler(NewServerHandlerWrapper(t)),
|
||||
// server.Hooks(server.HookHandler(NewServerHandlerWrapper(t))),
|
||||
)
|
||||
|
||||
h := &Handler{t: t}
|
||||
@@ -522,7 +533,7 @@ func TestNativeServer(t *testing.T) {
|
||||
}
|
||||
|
||||
// start server
|
||||
if err := srv.Start(); err != nil {
|
||||
if err = srv.Start(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -546,7 +557,7 @@ func TestNativeServer(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
req.Header.Set("Authorization", "test")
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Content-Type", "text/xml")
|
||||
rsp, err := http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -598,7 +609,7 @@ func TestNativeServer(t *testing.T) {
|
||||
}
|
||||
fn(rr, rq)
|
||||
if rr.Code != http.StatusBadRequest {
|
||||
t.Fatalf("invalid status received: %s\n", rr.Body.String())
|
||||
t.Fatalf("invalid status received: %#+v %s\n", rr.Header(), rr.Body.String())
|
||||
}
|
||||
if s := rr.Body.String(); s != `{"msg":"my_error_test"}` {
|
||||
t.Fatalf("Expected response %s, got %s", `{"msg":"my_error_test"}`, s)
|
||||
@@ -657,7 +668,7 @@ func TestNativeServer(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHTTPHandler(t *testing.T) {
|
||||
reg := register.NewRegister()
|
||||
reg := mregister.NewRegister()
|
||||
ctx := context.Background()
|
||||
|
||||
// create server
|
||||
@@ -736,7 +747,7 @@ func (h *handlerSwapper) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func TestHTTPServer(t *testing.T) {
|
||||
reg := register.NewRegister()
|
||||
reg := mregister.NewRegister()
|
||||
ctx := context.Background()
|
||||
|
||||
// create server mux
|
||||
@@ -754,7 +765,7 @@ func TestHTTPServer(t *testing.T) {
|
||||
srv := httpsrv.NewServer(
|
||||
server.Address("127.0.0.1:0"),
|
||||
server.Register(reg),
|
||||
httpsrv.Server(&http.Server{Handler: h}),
|
||||
httpsrv.HTTPServer(&http.Server{Handler: h}),
|
||||
server.Codec("application/json", jsoncodec.NewCodec()),
|
||||
)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.26.0
|
||||
// protoc v5.28.3
|
||||
// protoc v5.29.2
|
||||
// source: test.proto
|
||||
|
||||
package pb
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-micro v3.10.4
|
||||
// - protoc v5.28.3
|
||||
// - protoc v5.29.2
|
||||
// source: test.proto
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
client "go.unistack.org/micro/v4/client"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -6,10 +6,10 @@ package pb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
v31 "go.unistack.org/micro-client-http/v3"
|
||||
v3 "go.unistack.org/micro-server-http/v3"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
server "go.unistack.org/micro/v3/server"
|
||||
v31 "go.unistack.org/micro-client-http/v4"
|
||||
v3 "go.unistack.org/micro-server-http/v4"
|
||||
client "go.unistack.org/micro/v4/client"
|
||||
server "go.unistack.org/micro/v4/server"
|
||||
http "net/http"
|
||||
time "time"
|
||||
)
|
||||
@@ -76,9 +76,8 @@ func RegisterTestDoubleServer(s server.Server, sh TestDoubleServer, opts ...serv
|
||||
testDouble
|
||||
}
|
||||
h := &testDoubleServer{sh}
|
||||
var nopts []server.HandlerOption
|
||||
nopts = append(nopts, v3.HandlerEndpoints(TestDoubleServerEndpoints))
|
||||
return s.Handle(s.NewHandler(&TestDouble{h}, append(nopts, opts...)...))
|
||||
opts = append(opts, v3.HandlerEndpoints(TestDoubleServerEndpoints))
|
||||
return s.Handle(s.NewHandler(&TestDouble{h}, opts...))
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -256,7 +255,6 @@ func RegisterTestServer(s server.Server, sh TestServer, opts ...server.HandlerOp
|
||||
test
|
||||
}
|
||||
h := &testServer{sh}
|
||||
var nopts []server.HandlerOption
|
||||
nopts = append(nopts, v3.HandlerEndpoints(TestServerEndpoints))
|
||||
return s.Handle(s.NewHandler(&Test{h}, append(nopts, opts...)...))
|
||||
opts = append(opts, v3.HandlerEndpoints(TestServerEndpoints))
|
||||
return s.Handle(s.NewHandler(&Test{h}, opts...))
|
||||
}
|
||||
|
||||
@@ -8,10 +8,10 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
tcp "go.unistack.org/micro-server-tcp/v3"
|
||||
"go.unistack.org/micro/v3/broker"
|
||||
"go.unistack.org/micro/v3/register"
|
||||
"go.unistack.org/micro/v3/server"
|
||||
tcp "go.unistack.org/micro-server-tcp/v4"
|
||||
"go.unistack.org/micro/v4/broker"
|
||||
mregister "go.unistack.org/micro/v4/register/memory"
|
||||
"go.unistack.org/micro/v4/server"
|
||||
)
|
||||
|
||||
type testHandler struct {
|
||||
@@ -22,7 +22,7 @@ type testHandler struct {
|
||||
func TestTCPServer(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
reg := register.NewRegister()
|
||||
reg := mregister.NewRegister()
|
||||
if err := reg.Init(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@ package service
|
||||
import (
|
||||
"testing"
|
||||
|
||||
httpcli "go.unistack.org/micro-client-http/v3"
|
||||
httpsrv "go.unistack.org/micro-server-http/v3"
|
||||
"go.unistack.org/micro/v3"
|
||||
"go.unistack.org/micro/v3/server"
|
||||
httpcli "go.unistack.org/micro-client-http/v4"
|
||||
httpsrv "go.unistack.org/micro-server-http/v4"
|
||||
"go.unistack.org/micro/v4"
|
||||
"go.unistack.org/micro/v4/server"
|
||||
)
|
||||
|
||||
func TestHTTPService(t *testing.T) {
|
||||
|
||||
@@ -12,16 +12,16 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"go.unistack.org/micro/v3/store/cache"
|
||||
"go.unistack.org/micro/v4/store/cache"
|
||||
|
||||
"go.unistack.org/micro/v3/store/memory"
|
||||
"go.unistack.org/micro/v4/store/memory"
|
||||
|
||||
"github.com/kr/pretty"
|
||||
"go.unistack.org/micro/v3/store/cockroach"
|
||||
"go.unistack.org/micro/v4/store/cockroach"
|
||||
|
||||
"go.unistack.org/micro/v3/store"
|
||||
"go.unistack.org/micro/v4/store"
|
||||
|
||||
"go.unistack.org/micro/v3/store/file"
|
||||
"go.unistack.org/micro/v4/store/file"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
)
|
||||
|
||||
@@ -9,9 +9,9 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
sgrpc "go.unistack.org/micro-server-grpc/v3"
|
||||
"go.unistack.org/micro/v3"
|
||||
"go.unistack.org/micro/v3/server"
|
||||
sgrpc "go.unistack.org/micro-server-grpc/v4"
|
||||
"go.unistack.org/micro/v4"
|
||||
"go.unistack.org/micro/v4/server"
|
||||
grpc "google.golang.org/grpc"
|
||||
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
||||
)
|
||||
|
||||
@@ -12,18 +12,18 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/uber/jaeger-client-go"
|
||||
"github.com/uber/jaeger-client-go/config"
|
||||
cli "go.unistack.org/micro-client-grpc/v3"
|
||||
jsoncodec "go.unistack.org/micro-codec-json/v3"
|
||||
rrouter "go.unistack.org/micro-router-register/v3"
|
||||
srv "go.unistack.org/micro-server-grpc/v3"
|
||||
ot "go.unistack.org/micro-tracer-opentracing/v3"
|
||||
"go.unistack.org/micro/v3/broker"
|
||||
"go.unistack.org/micro/v3/client"
|
||||
"go.unistack.org/micro/v3/errors"
|
||||
"go.unistack.org/micro/v3/register"
|
||||
"go.unistack.org/micro/v3/router"
|
||||
"go.unistack.org/micro/v3/server"
|
||||
mt "go.unistack.org/micro/v3/tracer"
|
||||
cli "go.unistack.org/micro-client-grpc/v4"
|
||||
jsoncodec "go.unistack.org/micro-codec-json/v4"
|
||||
rrouter "go.unistack.org/micro-router-register/v4"
|
||||
srv "go.unistack.org/micro-server-grpc/v4"
|
||||
ot "go.unistack.org/micro-tracer-opentracing/v4"
|
||||
"go.unistack.org/micro/v4/broker"
|
||||
"go.unistack.org/micro/v4/client"
|
||||
"go.unistack.org/micro/v4/errors"
|
||||
mregister "go.unistack.org/micro/v4/register/memory"
|
||||
"go.unistack.org/micro/v4/router"
|
||||
"go.unistack.org/micro/v4/server"
|
||||
mt "go.unistack.org/micro/v4/tracer"
|
||||
)
|
||||
|
||||
type Test interface {
|
||||
@@ -104,7 +104,7 @@ func TestClient(t *testing.T) {
|
||||
defer cl.Close()
|
||||
opentracing.SetGlobalTracer(tr)
|
||||
|
||||
reg := register.NewRegister()
|
||||
reg := mregister.NewRegister()
|
||||
brk := broker.NewBroker(broker.Register(reg))
|
||||
|
||||
serverName := "service"
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2018-2021 Matous Dzivjak <matousdzivjak@gmail.com>
|
||||
Copyright (c) 2021 Unistack LLC <v.tolstov@unistack.org>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -1,42 +0,0 @@
|
||||
package id
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
mid "go.unistack.org/micro/v3/util/id"
|
||||
)
|
||||
|
||||
func TestHasNoCollisions(t *testing.T) {
|
||||
tries := 100_000
|
||||
used := make(map[string]bool, tries)
|
||||
for i := 0; i < tries; i++ {
|
||||
id := mid.Must()
|
||||
require.False(t, used[id], "shouldn't return colliding IDs")
|
||||
used[id] = true
|
||||
}
|
||||
}
|
||||
|
||||
func TestFlatDistribution(t *testing.T) {
|
||||
tries := 100_000
|
||||
alphabet := "abcdefghij"
|
||||
size := 10
|
||||
chars := make(map[rune]int)
|
||||
for i := 0; i < tries; i++ {
|
||||
id := mid.Must(mid.Alphabet(alphabet), mid.Size(size))
|
||||
for _, r := range id {
|
||||
chars[r]++
|
||||
}
|
||||
}
|
||||
|
||||
for _, count := range chars {
|
||||
require.InEpsilon(t, size*tries/len(alphabet), count, .01, "should have flat distribution")
|
||||
}
|
||||
}
|
||||
|
||||
// Benchmark id generator
|
||||
func BenchmarkNanoid(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
_, _ = mid.New()
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package id_test
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
id "go.unistack.org/micro/v3/util/id"
|
||||
)
|
||||
|
||||
func TestGenerate(t *testing.T) {
|
||||
t.Run("short alphabet", func(t *testing.T) {
|
||||
alphabet := ""
|
||||
_, err := id.New(id.Alphabet(alphabet), id.Size(32))
|
||||
assert.Error(t, err, "should return error if the alphabet is too small")
|
||||
})
|
||||
|
||||
t.Run("long alphabet", func(t *testing.T) {
|
||||
alphabet := strings.Repeat("a", 256)
|
||||
_, err := id.New(id.Alphabet(alphabet), id.Size(32))
|
||||
assert.Error(t, err, "should return error if the alphabet is too long")
|
||||
})
|
||||
|
||||
t.Run("negative ID length", func(t *testing.T) {
|
||||
_, err := id.New(id.Alphabet("abcdef"), id.Size(-1))
|
||||
assert.Error(t, err, "should return error if the requested ID length is invalid")
|
||||
})
|
||||
|
||||
t.Run("happy path", func(t *testing.T) {
|
||||
alphabet := "abcdef"
|
||||
id, err := id.New(id.Alphabet(alphabet), id.Size(6))
|
||||
assert.NoError(t, err, "shouldn't return error")
|
||||
assert.Len(t, id, 6, "should return ID of requested length")
|
||||
for _, r := range id {
|
||||
assert.True(t, strings.ContainsRune(alphabet, r), "should use given alphabet")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("works with unicode", func(t *testing.T) {
|
||||
alphabet := "🚀💩🦄🤖"
|
||||
id, err := id.New(id.Alphabet(alphabet), id.Size(6))
|
||||
assert.NoError(t, err, "shouldn't return error")
|
||||
assert.Equal(t, utf8.RuneCountInString(id), 6, "should return ID of requested length")
|
||||
for _, r := range id {
|
||||
assert.True(t, strings.ContainsRune(alphabet, r), "should use given alphabet")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestNew(t *testing.T) {
|
||||
t.Run("negative ID length", func(t *testing.T) {
|
||||
_, err := id.New(id.Size(-1))
|
||||
assert.Error(t, err, "should return error if the requested ID length is invalid")
|
||||
})
|
||||
|
||||
t.Run("happy path", func(t *testing.T) {
|
||||
nid, err := id.New()
|
||||
assert.NoError(t, err, "shouldn't return error")
|
||||
assert.Len(t, nid, id.DefaultSize, "should return ID of default length")
|
||||
})
|
||||
|
||||
t.Run("custom length", func(t *testing.T) {
|
||||
id, err := id.New(id.Size(6))
|
||||
assert.NoError(t, err, "shouldn't return error")
|
||||
assert.Len(t, id, 6, "should return ID of requested length")
|
||||
})
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.26.0
|
||||
// protoc v5.28.3
|
||||
// protoc v5.29.2
|
||||
// source: test.proto
|
||||
|
||||
package pb
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
pb "go.unistack.org/micro-tests/util/reflect/proto"
|
||||
rutil "go.unistack.org/micro/v3/util/reflect"
|
||||
rutil "go.unistack.org/micro/v4/util/reflect"
|
||||
)
|
||||
|
||||
func TestFieldName(t *testing.T) {
|
||||
|
||||
@@ -9,9 +9,9 @@ import (
|
||||
|
||||
"github.com/sony/gobreaker"
|
||||
"go.unistack.org/micro/register/memory"
|
||||
"go.unistack.org/micro/v3/client"
|
||||
"go.unistack.org/micro/v3/errors"
|
||||
"go.unistack.org/micro/v3/router"
|
||||
"go.unistack.org/micro/v4/client"
|
||||
"go.unistack.org/micro/v4/errors"
|
||||
"go.unistack.org/micro/v4/router"
|
||||
)
|
||||
|
||||
func TestBreaker(t *testing.T) {
|
||||
|
||||
@@ -8,10 +8,10 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/afex/hystrix-go/hystrix"
|
||||
rrouter "go.unistack.org/micro-router-register/v3"
|
||||
rrouter "go.unistack.org/micro-router-register/v4"
|
||||
"go.unistack.org/micro/register/memory"
|
||||
"go.unistack.org/micro/v3/client"
|
||||
"go.unistack.org/micro/v3/router"
|
||||
"go.unistack.org/micro/v4/client"
|
||||
"go.unistack.org/micro/v4/router"
|
||||
)
|
||||
|
||||
func TestBreaker(t *testing.T) {
|
||||
|
||||
@@ -10,17 +10,17 @@ import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
dto "github.com/prometheus/client_model/go"
|
||||
"github.com/stretchr/testify/assert"
|
||||
cli "go.unistack.org/micro-client-grpc/v3"
|
||||
jsoncodec "go.unistack.org/micro-codec-json/v3"
|
||||
promwrapper "go.unistack.org/micro-metrics-prometheus/v3"
|
||||
rrouter "go.unistack.org/micro-router-register/v3"
|
||||
srv "go.unistack.org/micro-server-grpc/v3"
|
||||
"go.unistack.org/micro/v3/broker"
|
||||
"go.unistack.org/micro/v3/client"
|
||||
"go.unistack.org/micro/v3/errors"
|
||||
"go.unistack.org/micro/v3/register"
|
||||
"go.unistack.org/micro/v3/router"
|
||||
"go.unistack.org/micro/v3/server"
|
||||
cli "go.unistack.org/micro-client-grpc/v4"
|
||||
jsoncodec "go.unistack.org/micro-codec-json/v4"
|
||||
promwrapper "go.unistack.org/micro-metrics-prometheus/v4"
|
||||
rrouter "go.unistack.org/micro-router-register/v4"
|
||||
srv "go.unistack.org/micro-server-grpc/v4"
|
||||
"go.unistack.org/micro/v4/broker"
|
||||
"go.unistack.org/micro/v4/client"
|
||||
"go.unistack.org/micro/v4/errors"
|
||||
"go.unistack.org/micro/v4/register"
|
||||
"go.unistack.org/micro/v4/router"
|
||||
"go.unistack.org/micro/v4/server"
|
||||
)
|
||||
|
||||
type Test interface {
|
||||
|
||||
@@ -10,14 +10,14 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/juju/ratelimit"
|
||||
rrouter "go.unistack.org/micro-router-register/v3"
|
||||
"go.unistack.org/micro/v3/broker"
|
||||
"go.unistack.org/micro/v3/client"
|
||||
"go.unistack.org/micro/v3/errors"
|
||||
"go.unistack.org/micro/v3/network/transport"
|
||||
"go.unistack.org/micro/v3/register"
|
||||
"go.unistack.org/micro/v3/router"
|
||||
"go.unistack.org/micro/v3/server"
|
||||
rrouter "go.unistack.org/micro-router-register/v4"
|
||||
"go.unistack.org/micro/v4/broker"
|
||||
"go.unistack.org/micro/v4/client"
|
||||
"go.unistack.org/micro/v4/errors"
|
||||
"go.unistack.org/micro/v4/network/transport"
|
||||
"go.unistack.org/micro/v4/register"
|
||||
"go.unistack.org/micro/v4/router"
|
||||
"go.unistack.org/micro/v4/server"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
@@ -2,20 +2,18 @@ package recovery_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
cli "go.unistack.org/micro-client-grpc/v3"
|
||||
jsoncodec "go.unistack.org/micro-codec-json/v3"
|
||||
rrouter "go.unistack.org/micro-router-register/v3"
|
||||
srv "go.unistack.org/micro-server-grpc/v3"
|
||||
recwrapper "go.unistack.org/micro-wrapper-recovery/v3"
|
||||
"go.unistack.org/micro/v3/broker"
|
||||
"go.unistack.org/micro/v3/client"
|
||||
"go.unistack.org/micro/v3/errors"
|
||||
"go.unistack.org/micro/v3/register"
|
||||
"go.unistack.org/micro/v3/router"
|
||||
"go.unistack.org/micro/v3/server"
|
||||
cli "go.unistack.org/micro-client-grpc/v4"
|
||||
jsoncodec "go.unistack.org/micro-codec-json/v4"
|
||||
rrouter "go.unistack.org/micro-router-register/v4"
|
||||
srv "go.unistack.org/micro-server-grpc/v4"
|
||||
recwrapper "go.unistack.org/micro-wrapper-recovery/v4"
|
||||
"go.unistack.org/micro/v4/client"
|
||||
"go.unistack.org/micro/v4/errors"
|
||||
mregister "go.unistack.org/micro/v4/register/memory"
|
||||
"go.unistack.org/micro/v4/router"
|
||||
"go.unistack.org/micro/v4/server"
|
||||
)
|
||||
|
||||
type Test interface {
|
||||
@@ -38,8 +36,7 @@ func (t *testHandler) Method(ctx context.Context, req *TestRequest, rsp *TestRes
|
||||
|
||||
func TestRecovery(t *testing.T) {
|
||||
// setup
|
||||
reg := register.NewRegister()
|
||||
brk := broker.NewBroker(broker.Register(reg))
|
||||
reg := mregister.NewRegister()
|
||||
|
||||
name := "test"
|
||||
id := "id-1234567890"
|
||||
@@ -63,9 +60,8 @@ func TestRecovery(t *testing.T) {
|
||||
server.Version(version),
|
||||
server.ID(id),
|
||||
server.Register(reg),
|
||||
server.Broker(brk),
|
||||
server.WrapHandler(
|
||||
recwrapper.NewServerHandlerWrapper(recwrapper.ServerHandlerFn(rfn)),
|
||||
server.Hooks(
|
||||
server.HookHandler(recwrapper.NewHook(recwrapper.ServerHandlerFunc(rfn)).ServerHandler),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -95,5 +91,5 @@ func TestRecovery(t *testing.T) {
|
||||
t.Fatalf("panic happens, but handler not return err")
|
||||
}
|
||||
|
||||
fmt.Printf("%v\n", err)
|
||||
// fmt.Printf("%v\n", err)
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user