|
Project Information
Featured
Downloads
Links
|
Google ProtoRPC is made of two primary components. The first component is a collection of libraries for decoratively describing messages and services for exchanging information over the web. Message and service description is done in-language in way analogous to using a Protocol Buffer .proto file. The implementation of this component will be specific for each supported language. The second component is a set of standards and accompanying library for making RPC via HTTP using various underlying message protocols. This standard allows for the transmission of multiple underlying protocol formats and supplies implementations for JSON, URL encoded forms and Protocol Buffers. The standard includes service and message type discover-ability so that it is easy for developers to export their services and a form based interface so that it is not necessary to build a client in order to experiment with the service. A primary goal of this project is to make it very easy for developers to get started defining services for their web based applications but allow them to evolve to become highly scalable implementations over time. The ProtoRPC Python implementation is built in to Google App Engine. Here is an example of a very simple service definition: from google.appengine.ext.webapp import util
from protorpc import messages
from protorpc.wsgi import service
from protorpc import remote
package = 'hello'
# Create the request string containing the user's name
class HelloRequest(messages.Message):
my_name = messages.StringField(1, required=True)
# Create the response string
class HelloResponse(messages.Message):
hello = messages.StringField(1, required=True)
# Create the RPC service to exchange messages
class HelloService(remote.Service):
@remote.method(HelloRequest, HelloResponse)
def hello(self, request):
return HelloResponse(hello='Hello there, %s!' %
request.my_name)
# Map the RPC service and path (/hello)
hello_service = service.service_mapping(HelloService, '/hello.*')
def main():
util.run_wsgi_app(hello_service)
if __name__ == '__main__':
main()See the ProtoRPC overview to try it out! By default, App Engine uses the built-in version of ProtoRPC will be used in your application. For instructions on how to use a custom version of ProtoRPC, please see here. |