e795c9f3473ecff19dd7d9c7996fdd39677070db
[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    This source code is part of the near-RT RIC (RAN Intelligent Controller)
19    platform project (RICP).
20
21 ==================================================================================
22 */
23 /*
24   Mnemonic:     mangos.go
25   Abstract:
26   Date:         3 May 2019
27 */
28
29 package stub
30
31 import "errors"
32
33 type MangosMessage struct {
34         Header []byte
35         Body   []byte
36         Pipe   MangosPipe
37         bbuf   []byte
38         hbuf   []byte
39         bsize  int
40         pool   interface{}
41 }
42
43 type MangosProtocolInfo struct {
44         Self     uint16
45         Peer     uint16
46         SelfName string
47         PeerName string
48 }
49
50 // Mangos Listener Stub
51
52 type MangosListener struct {
53 }
54
55 func (l MangosListener) Listen() error {
56         return nil
57 }
58
59 func (l MangosListener) Close() error {
60         return nil
61 }
62
63 func (l MangosListener) Address() string {
64         return ""
65 }
66
67 func (l MangosListener) SetOption(s string, i interface{}) error {
68         return nil
69 }
70
71 func (l MangosListener) GetOption(s string) (interface{}, error) {
72         return nil, nil
73 }
74
75 // Mangos Dialer Stub
76
77 type MangosDialer struct {
78 }
79
80 func (d MangosDialer) Open() error {
81         return nil
82 }
83
84 func (d MangosDialer) Close() error {
85         return nil
86 }
87
88 func (d MangosDialer) Address() string {
89         return ""
90 }
91
92 func (d MangosDialer) SetOption(s string, i interface{}) error {
93         return nil
94 }
95
96 func (d MangosDialer) GetOption(s string) (interface{}, error) {
97         return nil, nil
98 }
99
100 // Mangos Context Stub
101
102 type MangosContext struct {
103 }
104
105 func (c MangosContext) Close() error {
106         return nil
107 }
108
109 func (c MangosContext) SetOption(s string, i interface{}) error {
110         return nil
111 }
112
113 func (c MangosContext) GetOption(s string) (interface{}, error) {
114         return nil, nil
115 }
116
117 func (c MangosContext) Send(b []byte) error {
118         return nil
119 }
120
121 func (c MangosContext) Recv() ([]byte, error) {
122         return make([]byte, 0), nil
123 }
124
125 func (c MangosContext) SendMsg(*MangosMessage) error {
126         return nil
127 }
128
129 func (c MangosContext) RecvMsg() (*MangosMessage, error) {
130         return nil, nil
131 }
132
133 // Mangos Pipe Stub
134
135 type MangosPipe struct {
136 }
137
138 func (p MangosPipe) ID() uint32 {
139         return 0
140 }
141
142 func (p MangosPipe) Listener() MangosListener {
143         return MangosListener{}
144 }
145
146 func (p MangosPipe) Dialer() MangosDialer {
147         return MangosDialer{}
148 }
149
150 func (p MangosPipe) Close() error {
151         return nil
152 }
153
154 func (p MangosPipe) Address() string {
155         return ""
156 }
157
158 func (p MangosPipe) GetOption(s string) (interface{}, error) {
159         return nil, nil
160 }
161
162 // Mangos PipeEventHook Stub
163
164 type PipeEventHook func(int, MangosPipe)
165
166 // Mangos Socket Stub
167
168 type MangosSocket struct {
169         GenerateSocketCloseError  bool
170         GenerateSocketSendError   bool
171         GenerateSocketDialError   bool
172         GenerateSocketListenError bool
173 }
174
175 func (s MangosSocket) Info() MangosProtocolInfo {
176         return MangosProtocolInfo{}
177 }
178
179 func (s MangosSocket) Close() error {
180         if s.GenerateSocketCloseError {
181                 return errors.New("stub generated Socket Close error")
182         }
183         return nil
184 }
185
186 func (s MangosSocket) Send(b []byte) error {
187         if s.GenerateSocketSendError {
188                 return errors.New("stub generated Socket Send error")
189         }
190         return nil
191 }
192
193 func (s MangosSocket) Recv() ([]byte, error) {
194         return make([]byte, 0), nil
195 }
196
197 func (s MangosSocket) SendMsg(*MangosMessage) error {
198         return nil
199 }
200
201 func (s MangosSocket) RecvMsg() (*MangosMessage, error) {
202         return nil, nil
203 }
204
205 func (s MangosSocket) Dial(t string) error {
206         if s.GenerateSocketDialError {
207                 return errors.New("stub generated Socket Dial error")
208         }
209         return nil
210 }
211
212 func (s MangosSocket) DialOptions(t string, m map[string]interface{}) error {
213         if err := s.Dial(t); err != nil {
214                 return err
215         }
216         return nil
217 }
218
219 func (s MangosSocket) NewDialer(t string, m map[string]interface{}) (MangosDialer, error) {
220         return MangosDialer{}, nil
221 }
222
223 func (s MangosSocket) Listen(t string) error {
224         if s.GenerateSocketListenError {
225                 return errors.New("stub generated Socket Listen error")
226         }
227         return nil
228 }
229
230 func (s MangosSocket) ListenOptions(t string, m map[string]interface{}) error {
231         return nil
232 }
233
234 func (s MangosSocket) NewListener(t string, m map[string]interface{}) (MangosListener, error) {
235         return MangosListener{}, nil
236 }
237
238 func (s MangosSocket) SetOption(t string, i interface{}) error {
239         return nil
240 }
241
242 func (s MangosSocket) GetOption(t string) (interface{}, error) {
243         return nil, nil
244 }
245
246 func (s MangosSocket) OpenContext() (MangosContext, error) {
247         return MangosContext{}, nil
248 }
249
250 func (s MangosSocket) SetPipeEventHook(p PipeEventHook) PipeEventHook {
251         return nil
252 }
253
254 // Mangos ProtocolPipe Stub
255
256 type MangosProtocolPipe struct {
257 }
258
259 func (p MangosProtocolPipe) ID() uint32 {
260         return 0
261 }
262
263 func (p MangosProtocolPipe) Close() error {
264         return nil
265 }
266
267 func (p MangosProtocolPipe) SendMsg(m *MangosMessage) error {
268         return nil
269 }
270
271 func (p MangosProtocolPipe) RecvMsg() *MangosMessage {
272         return nil
273 }
274
275 // Mangos ProtocolContext Stub
276
277 type MangosProtocolContext struct {
278 }
279
280 func (p MangosProtocolContext) Close() error {
281         return nil
282 }
283
284 func (p MangosProtocolContext) SendMsg(m *MangosMessage) error {
285         return nil
286 }
287
288 func (p MangosProtocolContext) RecvMsg() (*MangosMessage, error) {
289         return nil, nil
290 }
291
292 func (p MangosProtocolContext) GetOption(s string) (interface{}, error) {
293         return nil, nil
294 }
295
296 func (p MangosProtocolContext) SetOption(s string, i interface{}) error {
297         return nil
298 }
299
300 // Mangos ProtocolBase Stub
301
302 type MangosProtocolBase struct {
303         MangosProtocolContext
304 }
305
306 func (p MangosProtocolBase) Info() MangosProtocolInfo {
307         return MangosProtocolInfo{}
308 }
309
310 func (p MangosProtocolBase) AddPipe(t MangosProtocolPipe) error {
311         return nil
312 }
313
314 func (p MangosProtocolBase) RemovePipe(MangosProtocolPipe) {
315
316 }
317
318 func (p MangosProtocolBase) OpenContext() (MangosProtocolContext, error) {
319         return MangosProtocolContext{}, nil
320 }