1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-03-03 15:22:30 +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:
simon 2021-09-03 01:10:24 +08:00 committed by GitHub
parent 993e2f55bd
commit a159598f36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 1 deletions

View File

@ -10,7 +10,7 @@ import (
maddr "github.com/asim/go-micro/v3/util/addr"
mnet "github.com/asim/go-micro/v3/util/net"
mls "github.com/asim/go-micro/v3/util/tls"
"github.com/asim/go-micro/v3/cmd"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
@ -27,6 +27,10 @@ type grpcTransportListener struct {
tls *tls.Config
}
func init() {
cmd.DefaultTransports["grpc"] = NewTransport
}
func getTLSConfig(addr string) (*tls.Config, error) {
hosts := []string{addr}

View File

@ -13,6 +13,7 @@ import (
"github.com/asim/go-micro/v3/transport"
maddr "github.com/asim/go-micro/v3/util/addr"
mnet "github.com/asim/go-micro/v3/util/net"
"github.com/asim/go-micro/v3/cmd"
)
type memorySocket struct {
@ -53,6 +54,10 @@ type memoryTransport struct {
listeners map[string]*memoryListener
}
func init() {
cmd.DefaultTransports["memory"] = NewTransport
}
func (ms *memorySocket) Recv(m *transport.Message) error {
ms.RLock()
defer ms.RUnlock()

View File

@ -4,6 +4,7 @@ import (
"context"
"crypto/tls"
"encoding/gob"
"github.com/asim/go-micro/v3/cmd"
"time"
"github.com/asim/go-micro/v3/transport"
@ -34,6 +35,10 @@ type quicListener struct {
opts transport.ListenOptions
}
func init() {
cmd.DefaultTransports["quic"] = NewTransport
}
func (q *quicClient) Close() error {
return q.quicSocket.st.Close()
}