那个文章说:
REST表示的是描述性状态传递(representational state transfer),REST整个就是关于 客户端和服务端之间的关系的,其中服务端要提供格式简单的描述性数据,经常使用的是JSON和XML。
不知道和osi7层的表示层有关系没
html
找了个django-microservice例子python
订单服务调用邮件服务
git
邮件服务是经过url暴漏的, 经过post方式收到参数,发出邮件
github
hostA hostB f1 f2 tcp:A:port f1 参数
注: 不须要安装zeromqdjango
import zerorpc class Cooler(object): """ Various convenience methods to make things cooler. """ def add_man(self, sentence): """ End a sentence with ", man!" to make it sound cooler, and return the result. """ return sentence + ", man!" def add_42(self, n): """ Add 42 to an integer argument to make it cooler, and return the result. """ return n + 42 def boat(self, sentence): """ Replace a sentence with "I'm on a boat!", and return that, because it's cooler. """ return "I'm on a boat!" s = zerorpc.Server(Cooler()) s.bind("tcp://0.0.0.0:4242") s.run()
模拟远程调用api
$ zerorpc -j tcp://localhost:4242 add_42 1 43
服务端写了个类: 暴露了个端口,将这个类经过tcp抛出去
框架
客户端访问服务端的函数
tcp