github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/internal/mock/conn.go (about) 1 package mock 2 3 import ( 4 "context" 5 "time" 6 7 "google.golang.org/grpc" 8 9 "github.com/ydb-platform/ydb-go-sdk/v3/internal/conn" 10 "github.com/ydb-platform/ydb-go-sdk/v3/internal/endpoint" 11 ) 12 13 type Conn struct { 14 PingErr error 15 AddrField string 16 LocationField string 17 NodeIDField uint32 18 State conn.State 19 LocalDCField bool 20 } 21 22 func (c *Conn) Invoke( 23 ctx context.Context, 24 method string, 25 args interface{}, 26 reply interface{}, 27 opts ...grpc.CallOption, 28 ) error { 29 panic("not implemented in mock") 30 } 31 32 func (c *Conn) NewStream(ctx context.Context, 33 desc *grpc.StreamDesc, method string, 34 opts ...grpc.CallOption, 35 ) (grpc.ClientStream, error) { 36 panic("not implemented in mock") 37 } 38 39 func (c *Conn) Endpoint() endpoint.Endpoint { 40 return &Endpoint{ 41 AddrField: c.AddrField, 42 LocalDCField: c.LocalDCField, 43 LocationField: c.LocationField, 44 NodeIDField: c.NodeIDField, 45 } 46 } 47 48 func (c *Conn) LastUsage() time.Time { 49 panic("not implemented in mock") 50 } 51 52 func (c *Conn) Park(ctx context.Context) (err error) { 53 panic("not implemented in mock") 54 } 55 56 func (c *Conn) Ping(ctx context.Context) error { 57 return c.PingErr 58 } 59 60 func (c *Conn) IsState(states ...conn.State) bool { 61 panic("not implemented in mock") 62 } 63 64 func (c *Conn) GetState() conn.State { 65 return c.State 66 } 67 68 func (c *Conn) SetState(ctx context.Context, state conn.State) conn.State { 69 c.State = state 70 71 return c.State 72 } 73 74 func (c *Conn) Unban(ctx context.Context) conn.State { 75 c.SetState(ctx, conn.Online) 76 77 return conn.Online 78 } 79 80 type Endpoint struct { 81 AddrField string 82 LocationField string 83 NodeIDField uint32 84 LocalDCField bool 85 } 86 87 func (e *Endpoint) Choose(bool) { 88 } 89 90 func (e *Endpoint) NodeID() uint32 { 91 return e.NodeIDField 92 } 93 94 func (e *Endpoint) Address() string { 95 return e.AddrField 96 } 97 98 func (e *Endpoint) LocalDC() bool { 99 return e.LocalDCField 100 } 101 102 func (e *Endpoint) Location() string { 103 return e.LocationField 104 } 105 106 func (e *Endpoint) LastUpdated() time.Time { 107 panic("not implemented in mock") 108 } 109 110 func (e *Endpoint) LoadFactor() float32 { 111 panic("not implemented in mock") 112 } 113 114 func (e *Endpoint) String() string { 115 panic("not implemented in mock") 116 } 117 118 func (e *Endpoint) Copy() endpoint.Endpoint { 119 c := *e 120 121 return &c 122 } 123 124 func (e *Endpoint) Touch(opts ...endpoint.Option) { 125 }