Route generation fix
[ric-plt/rtmgr.git] / pkg / stub / mangos.go
1 /*
2 ==================================================================================
3   Copyright (c) 2019 AT&T Intellectual Property.
4   Copyright (c) 2019 Nokia
5
6    Licensed under the Apache License, Version 2.0 (the "License");
7    you may not use this file except in compliance with the License.
8    You may obtain a copy of the License at
9
10        http://www.apache.org/licenses/LICENSE-2.0
11
12    Unless required by applicable law or agreed to in writing, software
13    distributed under the License is distributed on an "AS IS" BASIS,
14    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15    See the License for the specific language governing permissions and
16    limitations under the License.
17 ==================================================================================
18 */
19 /*
20   Mnemonic:     mangos.go
21   Abstract:
22   Date:         3 May 2019
23 */
24
25 package stub
26
27 import "errors"
28
29 type MangosMessage struct {
30         Header []byte
31         Body   []byte
32         Pipe   MangosPipe
33         bbuf   []byte
34         hbuf   []byte
35         bsize  int
36         pool   interface{}
37 }
38
39 type MangosProtocolInfo struct {
40         Self     uint16
41         Peer     uint16
42         SelfName string
43         PeerName string
44 }
45
46 // Mangos Listener Stub
47
48 type MangosListener struct {
49 }
50
51 func (l MangosListener) Listen() error {
52         return nil
53 }
54
55 func (l MangosListener) Close() error {
56         return nil
57 }
58
59 func (l MangosListener) Address() string {
60         return ""
61 }
62
63 func (l MangosListener) SetOption(s string, i interface{}) error {
64         return nil
65 }
66
67 func (l MangosListener) GetOption(s string) (interface{}, error) {
68         return nil, nil
69 }
70
71 // Mangos Dialer Stub
72
73 type MangosDialer struct {
74 }
75
76 func (d MangosDialer) Open() error {
77         return nil
78 }
79
80 func (d MangosDialer) Close() error {
81         return nil
82 }
83
84 func (d MangosDialer) Address() string {
85         return ""
86 }
87
88 func (d MangosDialer) SetOption(s string, i interface{}) error {
89         return nil
90 }
91
92 func (d MangosDialer) GetOption(s string) (interface{}, error) {
93         return nil, nil
94 }
95
96 // Mangos Context Stub
97
98 type MangosContext struct {
99 }
100
101 func (c MangosContext) Close() error {
102         return nil
103 }
104
105 func (c MangosContext) SetOption(s string, i interface{}) error {
106         return nil
107 }
108
109 func (c MangosContext) GetOption(s string) (interface{}, error) {
110         return nil, nil
111 }
112
113 func (c MangosContext) Send(b []byte) error {
114         return nil
115 }
116
117 func (c MangosContext) Recv() ([]byte, error) {
118         return make([]byte, 0), nil
119 }
120
121 func (c MangosContext) SendMsg(*MangosMessage) error {
122         return nil
123 }
124
125 func (c MangosContext) RecvMsg() (*MangosMessage, error) {
126         return nil, nil
127 }
128
129 // Mangos Pipe Stub
130
131 type MangosPipe struct {
132 }
133
134 func (p MangosPipe) ID() uint32 {
135         return 0
136 }
137
138 func (p MangosPipe) Listener() MangosListener {
139         return MangosListener{}
140 }
141
142 func (p MangosPipe) Dialer() MangosDialer {
143         return MangosDialer{}
144 }
145
146 func (p MangosPipe) Close() error {
147         return nil
148 }
149
150 func (p MangosPipe) Address() string {
151         return ""
152 }
153
154 func (p MangosPipe) GetOption(s string) (interface{}, error) {
155         return nil, nil
156 }
157
158 // Mangos PipeEventHook Stub
159
160 type PipeEventHook func(int, MangosPipe)
161
162 // Mangos Socket Stub
163
164 type MangosSocket struct {
165         GenerateSocketCloseError  bool
166         GenerateSocketSendError   bool
167         GenerateSocketDialError   bool
168         GenerateSocketListenError bool
169 }
170
171 func (s MangosSocket) Info() MangosProtocolInfo {
172         return MangosProtocolInfo{}
173 }
174
175 func (s MangosSocket) Close() error {
176         if s.GenerateSocketCloseError {
177                 return errors.New("stub generated Socket Close error")
178         }
179         return nil
180 }
181
182 func (s MangosSocket) Send(b []byte) error {
183         if s.GenerateSocketSendError {
184                 return errors.New("stub generated Socket Send error")
185         }
186         return nil
187 }
188
189 func (s MangosSocket) Recv() ([]byte, error) {
190         return make([]byte, 0), nil
191 }
192
193 func (s MangosSocket) SendMsg(*MangosMessage) error {
194         return nil
195 }
196
197 func (s MangosSocket) RecvMsg() (*MangosMessage, error) {
198         return nil, nil
199 }
200
201 func (s MangosSocket) Dial(t string) error {
202         if s.GenerateSocketDialError {
203                 return errors.New("stub generated Socket Dial error")
204         }
205         return nil
206 }
207
208 func (s MangosSocket) DialOptions(t string, m map[string]interface{}) error {
209         if err := s.Dial(t); err != nil {
210                 return err
211         }
212         return nil
213 }
214
215 func (s MangosSocket) NewDialer(t string, m map[string]interface{}) (MangosDialer, error) {
216         return MangosDialer{}, nil
217 }
218
219 func (s MangosSocket) Listen(t string) error {
220         if s.GenerateSocketListenError {
221                 return errors.New("stub generated Socket Listen error")
222         }
223         return nil
224 }
225
226 func (s MangosSocket) ListenOptions(t string, m map[string]interface{}) error {
227         return nil
228 }
229
230 func (s MangosSocket) NewListener(t string, m map[string]interface{}) (MangosListener, error) {
231         return MangosListener{}, nil
232 }
233
234 func (s MangosSocket) SetOption(t string, i interface{}) error {
235         return nil
236 }
237
238 func (s MangosSocket) GetOption(t string) (interface{}, error) {
239         return nil, nil
240 }
241
242 func (s MangosSocket) OpenContext() (MangosContext, error) {
243         return MangosContext{}, nil
244 }
245
246 func (s MangosSocket) SetPipeEventHook(p PipeEventHook) PipeEventHook {
247         return nil
248 }
249
250 // Mangos ProtocolPipe Stub
251
252 type MangosProtocolPipe struct {
253 }
254
255 func (p MangosProtocolPipe) ID() uint32 {
256         return 0
257 }
258
259 func (p MangosProtocolPipe) Close() error {
260         return nil
261 }
262
263 func (p MangosProtocolPipe) SendMsg(m *MangosMessage) error {
264         return nil
265 }
266
267 func (p MangosProtocolPipe) RecvMsg() *MangosMessage {
268         return nil
269 }
270
271 // Mangos ProtocolContext Stub
272
273 type MangosProtocolContext struct {
274 }
275
276 func (p MangosProtocolContext) Close() error {
277         return nil
278 }
279
280 func (p MangosProtocolContext) SendMsg(m *MangosMessage) error {
281         return nil
282 }
283
284 func (p MangosProtocolContext) RecvMsg() (*MangosMessage, error) {
285         return nil, nil
286 }
287
288 func (p MangosProtocolContext) GetOption(s string) (interface{}, error) {
289         return nil, nil
290 }
291
292 func (p MangosProtocolContext) SetOption(s string, i interface{}) error {
293         return nil
294 }
295
296 // Mangos ProtocolBase Stub
297
298 type MangosProtocolBase struct {
299         MangosProtocolContext
300 }
301
302 func (p MangosProtocolBase) Info() MangosProtocolInfo {
303         return MangosProtocolInfo{}
304 }
305
306 func (p MangosProtocolBase) AddPipe(t MangosProtocolPipe) error {
307         return nil
308 }
309
310 func (p MangosProtocolBase) RemovePipe(MangosProtocolPipe) {
311
312 }
313
314 func (p MangosProtocolBase) OpenContext() (MangosProtocolContext, error) {
315         return MangosProtocolContext{}, nil
316 }