mirror of
https://github.com/go-micro/go-micro.git
synced 2025-11-29 21:47:44 +02:00
Add grpc,memory,quic transport automatically discover (#2237)
* Add grpc,memory,quic transport automatically discover * Add grpc,memory,quic transport automatically discover
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
|||||||
maddr "github.com/asim/go-micro/v3/util/addr"
|
maddr "github.com/asim/go-micro/v3/util/addr"
|
||||||
mnet "github.com/asim/go-micro/v3/util/net"
|
mnet "github.com/asim/go-micro/v3/util/net"
|
||||||
mls "github.com/asim/go-micro/v3/util/tls"
|
mls "github.com/asim/go-micro/v3/util/tls"
|
||||||
|
"github.com/asim/go-micro/v3/cmd"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/credentials"
|
"google.golang.org/grpc/credentials"
|
||||||
|
|
||||||
@@ -27,6 +27,10 @@ type grpcTransportListener struct {
|
|||||||
tls *tls.Config
|
tls *tls.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmd.DefaultTransports["grpc"] = NewTransport
|
||||||
|
}
|
||||||
|
|
||||||
func getTLSConfig(addr string) (*tls.Config, error) {
|
func getTLSConfig(addr string) (*tls.Config, error) {
|
||||||
hosts := []string{addr}
|
hosts := []string{addr}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import (
|
|||||||
"github.com/asim/go-micro/v3/transport"
|
"github.com/asim/go-micro/v3/transport"
|
||||||
maddr "github.com/asim/go-micro/v3/util/addr"
|
maddr "github.com/asim/go-micro/v3/util/addr"
|
||||||
mnet "github.com/asim/go-micro/v3/util/net"
|
mnet "github.com/asim/go-micro/v3/util/net"
|
||||||
|
"github.com/asim/go-micro/v3/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
type memorySocket struct {
|
type memorySocket struct {
|
||||||
@@ -53,6 +54,10 @@ type memoryTransport struct {
|
|||||||
listeners map[string]*memoryListener
|
listeners map[string]*memoryListener
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmd.DefaultTransports["memory"] = NewTransport
|
||||||
|
}
|
||||||
|
|
||||||
func (ms *memorySocket) Recv(m *transport.Message) error {
|
func (ms *memorySocket) Recv(m *transport.Message) error {
|
||||||
ms.RLock()
|
ms.RLock()
|
||||||
defer ms.RUnlock()
|
defer ms.RUnlock()
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"encoding/gob"
|
"encoding/gob"
|
||||||
|
"github.com/asim/go-micro/v3/cmd"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/asim/go-micro/v3/transport"
|
"github.com/asim/go-micro/v3/transport"
|
||||||
@@ -34,6 +35,10 @@ type quicListener struct {
|
|||||||
opts transport.ListenOptions
|
opts transport.ListenOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmd.DefaultTransports["quic"] = NewTransport
|
||||||
|
}
|
||||||
|
|
||||||
func (q *quicClient) Close() error {
|
func (q *quicClient) Close() error {
|
||||||
return q.quicSocket.st.Close()
|
return q.quicSocket.st.Close()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user