mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-05-15 16:42:38 +08:00
monolithic
This commit is contained in:
parent
47e916aebe
commit
a060da5ec6
56
pkg/service/a_test.go
Normal file
56
pkg/service/a_test.go
Normal file
@ -0,0 +1,56 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"net"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestName1(t *testing.T) {
|
||||
|
||||
tls.Client(&testConn{}, &tls.Config{}).Handshake()
|
||||
|
||||
time.Sleep(time.Hour)
|
||||
}
|
||||
|
||||
type testConn struct {
|
||||
}
|
||||
|
||||
func (testConn) Read(b []byte) (n int, err error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (testConn) Write(b []byte) (n int, err error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (testConn) Close() error {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (testConn) LocalAddr() net.Addr {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (testConn) RemoteAddr() net.Addr {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (testConn) SetDeadline(t time.Time) error {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (testConn) SetReadDeadline(t time.Time) error {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (testConn) SetWriteDeadline(t time.Time) error {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
67
pkg/service/registry.go
Normal file
67
pkg/service/registry.go
Normal file
@ -0,0 +1,67 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type Conn interface {
|
||||
GetConns(ctx context.Context, serviceName string, opts ...grpc.DialOption) ([]grpc.ClientConnInterface, error) //1
|
||||
GetConn(ctx context.Context, serviceName string, opts ...grpc.DialOption) (grpc.ClientConnInterface, error) //2
|
||||
GetSelfConnTarget() string //3
|
||||
AddOption(opts ...grpc.DialOption) //4
|
||||
CloseConn(conn *grpc.ClientConn) //5
|
||||
// do not use this method for call rpc
|
||||
}
|
||||
type SvcDiscoveryRegistry interface {
|
||||
Conn
|
||||
Register(serviceName, host string, port int, opts ...grpc.DialOption) error //6
|
||||
UnRegister() error //7
|
||||
Close()
|
||||
GetUserIdHashGatewayHost(ctx context.Context, userId string) (string, error) //
|
||||
}
|
||||
|
||||
var _ SvcDiscoveryRegistry = (*DiscoveryRegistry)(nil)
|
||||
|
||||
type DiscoveryRegistry struct {
|
||||
}
|
||||
|
||||
func (x *DiscoveryRegistry) RegisterService(desc *grpc.ServiceDesc, impl any) {
|
||||
fmt.Println("RegisterService", desc, impl)
|
||||
}
|
||||
|
||||
func (x *DiscoveryRegistry) GetConns(ctx context.Context, serviceName string, opts ...grpc.DialOption) ([]grpc.ClientConnInterface, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (x *DiscoveryRegistry) GetConn(ctx context.Context, serviceName string, opts ...grpc.DialOption) (grpc.ClientConnInterface, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (x *DiscoveryRegistry) GetSelfConnTarget() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *DiscoveryRegistry) AddOption(opts ...grpc.DialOption) {}
|
||||
|
||||
func (x *DiscoveryRegistry) CloseConn(conn *grpc.ClientConn) {
|
||||
_ = conn.Close()
|
||||
}
|
||||
|
||||
func (x *DiscoveryRegistry) Register(serviceName, host string, port int, opts ...grpc.DialOption) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *DiscoveryRegistry) UnRegister() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *DiscoveryRegistry) Close() {}
|
||||
|
||||
func (x *DiscoveryRegistry) GetUserIdHashGatewayHost(ctx context.Context, userId string) (string, error) {
|
||||
return "", nil
|
||||
}
|
14
pkg/service/service.go
Normal file
14
pkg/service/service.go
Normal file
@ -0,0 +1,14 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type GrpcServer struct {
|
||||
}
|
||||
|
||||
func (x *GrpcServer) RegisterService(desc *grpc.ServiceDesc, impl any) {
|
||||
fmt.Println("RegisterService", desc, impl)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user