2 ==================================================================================
3 Copyright (c) 2019 AT&T Intellectual Property.
4 Copyright (c) 2019 Nokia
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
10 http://www.apache.org/licenses/LICENSE-2.0
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.
18 This source code is part of the near-RT RIC (RAN Intelligent Controller)
19 platform project (RICP).
21 ==================================================================================
33 type MangosMessage struct {
43 type MangosProtocolInfo struct {
50 // Mangos Listener Stub
52 type MangosListener struct {
55 func (l MangosListener) Listen() error {
59 func (l MangosListener) Close() error {
63 func (l MangosListener) Address() string {
67 func (l MangosListener) SetOption(s string, i interface{}) error {
71 func (l MangosListener) GetOption(s string) (interface{}, error) {
77 type MangosDialer struct {
80 func (d MangosDialer) Open() error {
84 func (d MangosDialer) Close() error {
88 func (d MangosDialer) Address() string {
92 func (d MangosDialer) SetOption(s string, i interface{}) error {
96 func (d MangosDialer) GetOption(s string) (interface{}, error) {
100 // Mangos Context Stub
102 type MangosContext struct {
105 func (c MangosContext) Close() error {
109 func (c MangosContext) SetOption(s string, i interface{}) error {
113 func (c MangosContext) GetOption(s string) (interface{}, error) {
117 func (c MangosContext) Send(b []byte) error {
121 func (c MangosContext) Recv() ([]byte, error) {
122 return make([]byte, 0), nil
125 func (c MangosContext) SendMsg(*MangosMessage) error {
129 func (c MangosContext) RecvMsg() (*MangosMessage, error) {
135 type MangosPipe struct {
138 func (p MangosPipe) ID() uint32 {
142 func (p MangosPipe) Listener() MangosListener {
143 return MangosListener{}
146 func (p MangosPipe) Dialer() MangosDialer {
147 return MangosDialer{}
150 func (p MangosPipe) Close() error {
154 func (p MangosPipe) Address() string {
158 func (p MangosPipe) GetOption(s string) (interface{}, error) {
162 // Mangos PipeEventHook Stub
164 type PipeEventHook func(int, MangosPipe)
166 // Mangos Socket Stub
168 type MangosSocket struct {
169 GenerateSocketCloseError bool
170 GenerateSocketSendError bool
171 GenerateSocketDialError bool
172 GenerateSocketListenError bool
175 func (s MangosSocket) Info() MangosProtocolInfo {
176 return MangosProtocolInfo{}
179 func (s MangosSocket) Close() error {
180 if s.GenerateSocketCloseError {
181 return errors.New("stub generated Socket Close error")
186 func (s MangosSocket) Send(b []byte) error {
187 if s.GenerateSocketSendError {
188 return errors.New("stub generated Socket Send error")
193 func (s MangosSocket) Recv() ([]byte, error) {
194 return make([]byte, 0), nil
197 func (s MangosSocket) SendMsg(*MangosMessage) error {
201 func (s MangosSocket) RecvMsg() (*MangosMessage, error) {
205 func (s MangosSocket) Dial(t string) error {
206 if s.GenerateSocketDialError {
207 return errors.New("stub generated Socket Dial error")
212 func (s MangosSocket) DialOptions(t string, m map[string]interface{}) error {
213 if err := s.Dial(t); err != nil {
219 func (s MangosSocket) NewDialer(t string, m map[string]interface{}) (MangosDialer, error) {
220 return MangosDialer{}, nil
223 func (s MangosSocket) Listen(t string) error {
224 if s.GenerateSocketListenError {
225 return errors.New("stub generated Socket Listen error")
230 func (s MangosSocket) ListenOptions(t string, m map[string]interface{}) error {
234 func (s MangosSocket) NewListener(t string, m map[string]interface{}) (MangosListener, error) {
235 return MangosListener{}, nil
238 func (s MangosSocket) SetOption(t string, i interface{}) error {
242 func (s MangosSocket) GetOption(t string) (interface{}, error) {
246 func (s MangosSocket) OpenContext() (MangosContext, error) {
247 return MangosContext{}, nil
250 func (s MangosSocket) SetPipeEventHook(p PipeEventHook) PipeEventHook {
254 // Mangos ProtocolPipe Stub
256 type MangosProtocolPipe struct {
259 func (p MangosProtocolPipe) ID() uint32 {
263 func (p MangosProtocolPipe) Close() error {
267 func (p MangosProtocolPipe) SendMsg(m *MangosMessage) error {
271 func (p MangosProtocolPipe) RecvMsg() *MangosMessage {
275 // Mangos ProtocolContext Stub
277 type MangosProtocolContext struct {
280 func (p MangosProtocolContext) Close() error {
284 func (p MangosProtocolContext) SendMsg(m *MangosMessage) error {
288 func (p MangosProtocolContext) RecvMsg() (*MangosMessage, error) {
292 func (p MangosProtocolContext) GetOption(s string) (interface{}, error) {
296 func (p MangosProtocolContext) SetOption(s string, i interface{}) error {
300 // Mangos ProtocolBase Stub
302 type MangosProtocolBase struct {
303 MangosProtocolContext
306 func (p MangosProtocolBase) Info() MangosProtocolInfo {
307 return MangosProtocolInfo{}
310 func (p MangosProtocolBase) AddPipe(t MangosProtocolPipe) error {
314 func (p MangosProtocolBase) RemovePipe(MangosProtocolPipe) {
318 func (p MangosProtocolBase) OpenContext() (MangosProtocolContext, error) {
319 return MangosProtocolContext{}, nil