Ejemplo n.º 1
0
 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()
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
    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()
Ejemplo n.º 5
0
def main():
    control_service = impl_ctl.ImplCtl()
    srv = server.SocketRpcServer(10021, host='0.0.0.0')
    srv.registerService(control_service)
    srv.run()
Ejemplo n.º 6
0
 def setUp(self):
     self.port = 8090
     self.server = server.SocketRpcServer(self.port)