コード例 #1
0
 def test_allows_passing_host_port_and_timeout(self):
     with closing(
             connection.SerfConnection(host='foo', port=455,
                                       timeout=500)) as rpc:
         assert rpc.host == 'foo'
         assert rpc.port == 455
         assert rpc.timeout == 500
コード例 #2
0
 def test_connection_to_bad_socket_throws_exception(self):
     with closing(connection.SerfConnection(port=40000)) as rpc:
         with pytest.raises(
                 connection.SerfConnectionError) as exceptionInfo:
             rpc.handshake()
         assert 'connecting localhost:40000. Connection refused.' \
             in str(exceptionInfo)
コード例 #3
0
 def rpc(self):
     return connection.SerfConnection()
コード例 #4
0
import json
from serfclient import connection
from serfclient.client import SerfClient

client = SerfClient()
con = connection.SerfConnection()
con.handshake()
result = con.call('members')


def get_members():
    return result.body.get('Members')
コード例 #5
0
 def rpc(self):
     with closing(connection.SerfConnection()) as conn:
         yield conn