DRb method access

∥☆過路亽.° 提交于 2020-01-05 07:34:19

问题


I am writing a simple distributed system in DRb.

I have all the peers, and one server to do the bootstrapping. In that server, I have a few methods like "suggest_peer", and "start_service" and "stop_service".

When a peer connects to the server, he is able to call all three methods. I want him to be able to call only the first one.

Also, I have a file that initializes the server, and has a little cmd line so I can start the service, debug, log and all that. I want that cmd line to be able to call the second and third methods, as well as the first one.

How can I do that? How can I prevent peers from stopping the service?
If I put the service methods as private, I can't call them from the cmd line.


回答1:


This is what I got.

Thread.current['DRb']['client'].peeraddr

This returns a little array with 4 items. first one is the protocol, second is the port, third is host(name) and forth is the address(same as host if no name).

Thanks to Brian Candler from http://www.ruby-forum.com/topic/1962357



来源:https://stackoverflow.com/questions/6401982/drb-method-access

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!