Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e62a705

Browse files
committed
Define a channel interface
We are in python so it's merely a way to document the code. - requires a channel to accept timeouts on operations directly - expose few useful properties
1 parent 44dbb89 commit e62a705

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

zerorpc/channel_base.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# -*- coding: utf-8 -*-
2+
# Open Source Initiative OSI - The MIT License (MIT):Licensing
3+
#
4+
# The MIT License (MIT)
5+
# Copyright (c) 2014 François-Xavier Bourlet ([email protected])
6+
#
7+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
8+
# this software and associated documentation files (the "Software"), to deal in
9+
# the Software without restriction, including without limitation the rights to
10+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
11+
# of the Software, and to permit persons to whom the Software is furnished to do
12+
# so, subject to the following conditions:
13+
#
14+
# The above copyright notice and this permission notice shall be included in all
15+
# copies or substantial portions of the Software.
16+
#
17+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
# SOFTWARE.
24+
25+
26+
class ChannelBase(object):
27+
28+
@property
29+
def context(self):
30+
raise NotImplementedError()
31+
32+
@property
33+
def recv_is_supported(self):
34+
raise NotImplementedError()
35+
36+
@property
37+
def emit_is_supported(self):
38+
raise NotImplementedError()
39+
40+
def close(self):
41+
raise NotImplementedError()
42+
43+
def new_event(self, name, args, xheader=None):
44+
raise NotImplementedError()
45+
46+
def emit_event(self, event, timeout=None):
47+
raise NotImplementedError()
48+
49+
def emit(self, name, args, xheader=None, timeout=None):
50+
event = self.new_event(name, args, xheader)
51+
return self.emit_event(event, timeout)
52+
53+
def recv(self, timeout=None):
54+
raise NotImplementedError()

0 commit comments

Comments
 (0)