def start(self): if not StorageServer.started: StorageServer.started = True storage_sever = server.SocketRpcServer(self.port) storage_sever.registerService(MongoDBStorageServiceImpl()) print 'Start storage server on port', self.port storage_sever.run()
def __init__(self, port, exception=None): threading.Thread.__init__(self) if exception is None: self.test_service = fake.TestServiceImpl() else: self.test_service = fake.TestServiceImpl(exception=exception) self.server = server.SocketRpcServer(port) self.server.registerService(self.test_service) self.setDaemon(True)
def setUp(self): # Define some arbitrary values to satisfy the interface self.client_addr = 'here' self.server_addr = 'there' # Define a simple service request self.service_request = test_pb2.Request() self.service_request.str_data = 'The lord giveth' self.serialized_request = self.service_request.SerializeToString() # Define an RPC request with the service request as payload self.rpc_request = rpc_pb2.Request() self.rpc_request.request_proto = self.serialized_request self.testserver = server.SocketRpcServer(8090)
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. ''' run_server.py - A simple front-end to demo the RPC server implementation. Author: Eric Saunders ([email protected]) Jan Dittberner ([email protected]) May 2009, Nov 2010 ''' # Add main protobuf module to classpath import sys sys.path.append('../../../..') # Import required RPC modules import hello_world_pb2 import protobuf.socketrpc.server as server import HelloWorldServiceImpl as impl # Create and register the service # Note that this is an instantiation of the implementation class, # *not* the class defined in the proto file. hello_world_service = impl.HelloWorldImpl() server = server.SocketRpcServer(8090) server.registerService(hello_world_service) # Start the server print 'Serving on port 8090' server.run()
def main(): control_service = impl_ctl.ImplCtl() srv = server.SocketRpcServer(10021, host='0.0.0.0') srv.registerService(control_service) srv.run()
def setUp(self): self.port = 8090 self.server = server.SocketRpcServer(self.port)