当前位置: 首页>>代码示例>>Python>>正文


Python rpc.ClusterRpcProxy方法代码示例

本文整理汇总了Python中nameko.standalone.rpc.ClusterRpcProxy方法的典型用法代码示例。如果您正苦于以下问题:Python rpc.ClusterRpcProxy方法的具体用法?Python rpc.ClusterRpcProxy怎么用?Python rpc.ClusterRpcProxy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nameko.standalone.rpc的用法示例。


在下文中一共展示了rpc.ClusterRpcProxy方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from nameko.standalone import rpc [as 别名]
# 或者: from nameko.standalone.rpc import ClusterRpcProxy [as 别名]
def post(self):
        if not user_authenticated():
            return 'Please log in', 401

        email = session['email']
        data = request.get_json(force=True)

        try:
            message = data['message']
        except KeyError:
            return 'No message given', 400

        with ClusterRpcProxy(config) as rpc:
            rpc.message_service.save_message(email, message)

        return '', 204 
开发者ID:PacktPublishing,项目名称:Python-Programming-Blueprints,代码行数:18,代码来源:web_server.py

示例2: get

# 需要导入模块: from nameko.standalone import rpc [as 别名]
# 或者: from nameko.standalone.rpc import ClusterRpcProxy [as 别名]
def get(self):
        with ClusterRpcProxy(config) as rpc:
            messages = rpc.message_service.get_all_messages()

        return jsonify(messages) 
开发者ID:PacktPublishing,项目名称:Python-Programming-Blueprints,代码行数:7,代码来源:web_server.py

示例3: test_peopledata_persist

# 需要导入模块: from nameko.standalone import rpc [as 别名]
# 或者: from nameko.standalone.rpc import ClusterRpcProxy [as 别名]
def test_peopledata_persist():
    with ClusterRpcProxy(config) as cluster_rpc:
        out = cluster_rpc.people_data_persistence.save.call_async('people.csv')
        print(out.result()) 
开发者ID:PacktPublishing,项目名称:Mastering-Python-Design-Patterns-Second-Edition,代码行数:6,代码来源:test_service_second.py

示例4: _get_nameko_connection

# 需要导入模块: from nameko.standalone import rpc [as 别名]
# 或者: from nameko.standalone.rpc import ClusterRpcProxy [as 别名]
def _get_nameko_connection(self):
        proxy = ClusterRpcProxy(
            self._config,
            timeout=self._config.get('RPC_TIMEOUT', None)
        )
        return proxy.start() 
开发者ID:jessepollak,项目名称:flask-nameko,代码行数:8,代码来源:proxies.py

示例5: __init__

# 需要导入模块: from nameko.standalone import rpc [as 别名]
# 或者: from nameko.standalone.rpc import ClusterRpcProxy [as 别名]
def __init__(self, pool, config):
            self._pool = weakref.proxy(pool)
            self._proxy = ClusterRpcProxy(config, context_data=copy.deepcopy(pool.context_data), timeout=pool.timeout)
            self._rpc = None
            self._enable_rpc_call = False 
开发者ID:and3rson,项目名称:django-nameko,代码行数:7,代码来源:rpc.py

示例6: rpc_get_news

# 需要导入模块: from nameko.standalone import rpc [as 别名]
# 或者: from nameko.standalone.rpc import ClusterRpcProxy [as 别名]
def rpc_get_news(news_type, news_id):
    with ClusterRpcProxy(CONFIG_RPC) as rpc:
        if news_type == 'famous':
            news = rpc.query_famous.get_news(news_id)
        elif news_type == 'sports':
            news = rpc.query_sports.get_news(news_id)
        elif news_type == 'politics':
            news = rpc.query_politics.get_news(news_id)
        else:
            return erro_response('Invalid News type', 400)
        return {
            'status': 'success',
            'news': json.loads(news)
        } 
开发者ID:PacktPublishing,项目名称:Microservice-Patterns-and-Best-Practices,代码行数:16,代码来源:views.py

示例7: rpc_get_all_news

# 需要导入模块: from nameko.standalone import rpc [as 别名]
# 或者: from nameko.standalone.rpc import ClusterRpcProxy [as 别名]
def rpc_get_all_news(news_type, num_page, limit):
    with ClusterRpcProxy(CONFIG_RPC) as rpc:
        if news_type == 'famous':
            news = rpc.query_famous.get_all_news(num_page, limit)
        elif news_type == 'sports':
            news = rpc.query_sports.get_all_news(num_page, limit)
        elif news_type == 'politics':
            news = rpc.query_politics.get_all_news(num_page, limit)
        else:
            return erro_response('Invalid News type', 400)
        return {
            'status': 'success',
            'news': json.loads(news)
        } 
开发者ID:PacktPublishing,项目名称:Microservice-Patterns-and-Best-Practices,代码行数:16,代码来源:views.py

示例8: rpc_command

# 需要导入模块: from nameko.standalone import rpc [as 别名]
# 或者: from nameko.standalone.rpc import ClusterRpcProxy [as 别名]
def rpc_command(news_type, data):
    with ClusterRpcProxy(CONFIG_RPC) as rpc:
        if news_type == 'famous':
            news = rpc.command_famous.add_news(data)
        elif news_type == 'sports':
            news = rpc.command_sports.add_news(data)
        elif news_type == 'politics':
            news = rpc.command_politics.add_news(data)
        else:
            return erro_response('Invalid News type', 400)
        return {
            'status': 'success',
            'news': news,
        } 
开发者ID:PacktPublishing,项目名称:Microservice-Patterns-and-Best-Practices,代码行数:16,代码来源:views.py

示例9: rpc_get_news

# 需要导入模块: from nameko.standalone import rpc [as 别名]
# 或者: from nameko.standalone.rpc import ClusterRpcProxy [as 别名]
def rpc_get_news(news_type, news_id):
    with ClusterRpcProxy(BROKER_CONFIG) as rpc:
        if news_type == 'famous':
            news = rpc.query_famous.get_news(news_id)
        elif news_type == 'sports':
            news = rpc.query_sports.get_news(news_id)
        elif news_type == 'politics':
            news = rpc.query_politics.get_news(news_id)
        else:
            return error_response('Invalid News type', 400)
        return {
            'status': 'success',
            'news': json.loads(news)
        } 
开发者ID:PacktPublishing,项目名称:Microservice-Patterns-and-Best-Practices,代码行数:16,代码来源:views.py

示例10: rpc_get_all_news

# 需要导入模块: from nameko.standalone import rpc [as 别名]
# 或者: from nameko.standalone.rpc import ClusterRpcProxy [as 别名]
def rpc_get_all_news(news_type, num_page, limit):
    with ClusterRpcProxy(BROKER_CONFIG) as rpc:
        if news_type == 'famous':
            news = rpc.query_famous.get_all_news(num_page, limit)
        elif news_type == 'sports':
            news = rpc.query_sports.get_all_news(num_page, limit)
        elif news_type == 'politics':
            news = rpc.query_politics.get_all_news(num_page, limit)
        else:
            return error_response('Invalid News type', 400)
        return {
            'status': 'success',
            'news': json.loads(news)
        } 
开发者ID:PacktPublishing,项目名称:Microservice-Patterns-and-Best-Practices,代码行数:16,代码来源:views.py

示例11: rpc_get_news

# 需要导入模块: from nameko.standalone import rpc [as 别名]
# 或者: from nameko.standalone.rpc import ClusterRpcProxy [as 别名]
def rpc_get_news(news_type, news_id):
    with ClusterRpcProxy(BROKER_CONFIG) as rpc:
        if news_type == 'famous':
            news = rpc.query_famous.get_news(news_id)
        elif news_type == 'sports':
            news = rpc.query_sports.get_news(news_id)
        elif news_type == 'politics':
            news = rpc.query_politics.get_news(news_id)
        else:
            return erro_response('Invalid News type', 400)
        return {
            'status': 'success',
            'news': json.loads(news)
        } 
开发者ID:PacktPublishing,项目名称:Microservice-Patterns-and-Best-Practices,代码行数:16,代码来源:views.py

示例12: rpc_get_all_news

# 需要导入模块: from nameko.standalone import rpc [as 别名]
# 或者: from nameko.standalone.rpc import ClusterRpcProxy [as 别名]
def rpc_get_all_news(news_type, num_page, limit):
    with ClusterRpcProxy(BROKER_CONFIG) as rpc:
        if news_type == 'famous':
            news = rpc.query_famous.get_all_news(num_page, limit)
        elif news_type == 'sports':
            news = rpc.query_sports.get_all_news(num_page, limit)
        elif news_type == 'politics':
            news = rpc.query_politics.get_all_news(num_page, limit)
        else:
            return erro_response('Invalid News type', 400)
        return {
            'status': 'success',
            'news': json.loads(news)
        } 
开发者ID:PacktPublishing,项目名称:Microservice-Patterns-and-Best-Practices,代码行数:16,代码来源:views.py

示例13: rpc_command

# 需要导入模块: from nameko.standalone import rpc [as 别名]
# 或者: from nameko.standalone.rpc import ClusterRpcProxy [as 别名]
def rpc_command(news_type, data):
    with ClusterRpcProxy(BROKER_CONFIG) as rpc:
        if news_type == 'famous':
            news = rpc.command_famous.add_news(data)
        elif news_type == 'sports':
            news = rpc.command_sports.add_news(data)
        elif news_type == 'politics':
            news = rpc.command_politics.add_news(data)
        else:
            return erro_response('Invalid News type', 400)
        return {
            'status': 'success',
            'news': news,
        } 
开发者ID:PacktPublishing,项目名称:Microservice-Patterns-and-Best-Practices,代码行数:16,代码来源:views.py

示例14: rpc_command

# 需要导入模块: from nameko.standalone import rpc [as 别名]
# 或者: from nameko.standalone.rpc import ClusterRpcProxy [as 别名]
def rpc_command(news_type, data):
    with ClusterRpcProxy(BROKER_CONFIG) as rpc:
        if news_type == 'famous':
            news = rpc.command_famous.add_news(data)
        elif news_type == 'sports':
            news = rpc.command_sports.add_news(data)
        elif news_type == 'politics':
            news = rpc.command_politics.add_news(data)
        else:
            return error_response('Invalid News type', 400)
        return {
            'status': 'success',
            'news': news,
        } 
开发者ID:PacktPublishing,项目名称:Microservice-Patterns-and-Best-Practices,代码行数:16,代码来源:views.py


注:本文中的nameko.standalone.rpc.ClusterRpcProxy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。