當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。