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.
17 ==================================================================================
29 type MangosMessage struct {
39 type MangosProtocolInfo struct {
46 // Mangos Listener Stub
48 type MangosListener struct {
51 func (l MangosListener) Listen() error {
55 func (l MangosListener) Close() error {
59 func (l MangosListener) Address() string {
63 func (l MangosListener) SetOption(s string, i interface{}) error {
67 func (l MangosListener) GetOption(s string) (interface{}, error) {
73 type MangosDialer struct {
76 func (d MangosDialer) Open() error {
80 func (d MangosDialer) Close() error {
84 func (d MangosDialer) Address() string {
88 func (d MangosDialer) SetOption(s string, i interface{}) error {
92 func (d MangosDialer) GetOption(s string) (interface{}, error) {
96 // Mangos Context Stub
98 type MangosContext struct {
101 func (c MangosContext) Close() error {
105 func (c MangosContext) SetOption(s string, i interface{}) error {
109 func (c MangosContext) GetOption(s string) (interface{}, error) {
113 func (c MangosContext) Send(b []byte) error {
117 func (c MangosContext) Recv() ([]byte, error) {
118 return make([]byte, 0), nil
121 func (c MangosContext) SendMsg(*MangosMessage) error {
125 func (c MangosContext) RecvMsg() (*MangosMessage, error) {
131 type MangosPipe struct {
134 func (p MangosPipe) ID() uint32 {
138 func (p MangosPipe) Listener() MangosListener {
139 return MangosListener{}
142 func (p MangosPipe) Dialer() MangosDialer {
143 return MangosDialer{}
146 func (p MangosPipe) Close() error {
150 func (p MangosPipe) Address() string {
154 func (p MangosPipe) GetOption(s string) (interface{}, error) {
158 // Mangos PipeEventHook Stub
160 type PipeEventHook func(int, MangosPipe)
162 // Mangos Socket Stub
164 type MangosSocket struct {
165 GenerateSocketCloseError bool
166 GenerateSocketSendError bool
167 GenerateSocketDialError bool
168 GenerateSocketListenError bool
171 func (s MangosSocket) Info() MangosProtocolInfo {
172 return MangosProtocolInfo{}
175 func (s MangosSocket) Close() error {
176 if s.GenerateSocketCloseError {
177 return errors.New("stub generated Socket Close error")
182 func (s MangosSocket) Send(b []byte) error {
183 if s.GenerateSocketSendError {
184 return errors.New("stub generated Socket Send error")
189 func (s MangosSocket) Recv() ([]byte, error) {
190 return make([]byte, 0), nil
193 func (s MangosSocket) SendMsg(*MangosMessage) error {
197 func (s MangosSocket) RecvMsg() (*MangosMessage, error) {
201 func (s MangosSocket) Dial(t string) error {
202 if s.GenerateSocketDialError {
203 return errors.New("stub generated Socket Dial error")
208 func (s MangosSocket) DialOptions(t string, m map[string]interface{}) error {
209 if err := s.Dial(t); err != nil {
215 func (s MangosSocket) NewDialer(t string, m map[string]interface{}) (MangosDialer, error) {
216 return MangosDialer{}, nil
219 func (s MangosSocket) Listen(t string) error {
220 if s.GenerateSocketListenError {
221 return errors.New("stub generated Socket Listen error")
226 func (s MangosSocket) ListenOptions(t string, m map[string]interface{}) error {
230 func (s MangosSocket) NewListener(t string, m map[string]interface{}) (MangosListener, error) {
231 return MangosListener{}, nil
234 func (s MangosSocket) SetOption(t string, i interface{}) error {
238 func (s MangosSocket) GetOption(t string) (interface{}, error) {
242 func (s MangosSocket) OpenContext() (MangosContext, error) {
243 return MangosContext{}, nil
246 func (s MangosSocket) SetPipeEventHook(p PipeEventHook) PipeEventHook {
250 // Mangos ProtocolPipe Stub
252 type MangosProtocolPipe struct {
255 func (p MangosProtocolPipe) ID() uint32 {
259 func (p MangosProtocolPipe) Close() error {
263 func (p MangosProtocolPipe) SendMsg(m *MangosMessage) error {
267 func (p MangosProtocolPipe) RecvMsg() *MangosMessage {
271 // Mangos ProtocolContext Stub
273 type MangosProtocolContext struct {
276 func (p MangosProtocolContext) Close() error {
280 func (p MangosProtocolContext) SendMsg(m *MangosMessage) error {
284 func (p MangosProtocolContext) RecvMsg() (*MangosMessage, error) {
288 func (p MangosProtocolContext) GetOption(s string) (interface{}, error) {
292 func (p MangosProtocolContext) SetOption(s string, i interface{}) error {
296 // Mangos ProtocolBase Stub
298 type MangosProtocolBase struct {
299 MangosProtocolContext
302 func (p MangosProtocolBase) Info() MangosProtocolInfo {
303 return MangosProtocolInfo{}
306 func (p MangosProtocolBase) AddPipe(t MangosProtocolPipe) error {
310 func (p MangosProtocolBase) RemovePipe(MangosProtocolPipe) {
314 func (p MangosProtocolBase) OpenContext() (MangosProtocolContext, error) {
315 return MangosProtocolContext{}, nil