Skip to content

The project provides a complete solution, including web server, async rpc call, and rpc server.

Notifications You must be signed in to change notification settings

kikyoo/async-tornado

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

async-tornado

Thrift(C++) for network communication, tornado as web server, while greenlet makes (async) rpc look like function call.

GET, POST

Simple example:

route.proto

message Ping {
  required int64 id = 1;
  required string ping = 2;
}

message Pong {
  required int64 id = 1;
  required string pong = 2;
}


user/server.py

class Server(CPython):
    def __init__(self, *args):
        pass

    def recv_module_call_Ping(self, ping):
        pong = pb.Pong()
        pong.id = ping.id + 1
        pong.pong = 'pong!'
        return pong

    def recv_hash_call_Ping(self, key, ping):
        pong = pb.Pong()
        pong.id = ping.id + 1
        pong.pong = 'pong!!'
        return pong

    def recv_module_msg_Ping(self, ping):
        pass

    def recv_hash_msg_Ping(self, key, ping):
        pass


http/server.py

class HelloHandler(BaseHandler):
    def do_GET(self):
        ping = pb.Ping()
        ping.id = 1
        ping.ping = 'ping'
        pong = self.hash_call('user', 'key', ping)
        self.write(pong.pong)

class WorldHandler(BaseHandler):
    def do_POST(self):
        self.write('post handler')

To Do

    1. 自旋锁?
    1. 一致性 hash

About

The project provides a complete solution, including web server, async rpc call, and rpc server.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published