huskar_api/api/long_polling.py
def perform(self, request_data, tree_watcher, tree_watcher_decorator):
        """Performs long polling session as an iterator.

        The iterator returned by this method will always generate a ``None``
        in the first time. It indicates that the watcher is started and we
        could put the iterator into a response stream now.

        .. note:: You should never touch the database (SQLAlchemy session)
                  here or the connection may be leaked. The request context
                  has been finalized here.

        .. note:: The returned iterator is not thread safe. Do not try to use
                  it in different greenlets.
        """
        self.declare_upstream_from_request(request_data)

        # TODO Add timing metrics here
        for type_name, application_names in request_data.items():
            for application_name, cluster_names in application_names.items():
                tree_watcher.watch(application_name, type_name)
                for cluster_name in cluster_names:
                    tree_watcher.limit_cluster_name(
                        application_name, type_name, cluster_name)

        yield

        tree_watcher = tree_watcher_decorator(tree_watcher)
        for message, body in tree_watcher:
            line = json.dumps({'message': message, 'body': body}) + '\n'
            yield line
Performs long polling session as an iterator.

        The iterator returned by this method will always generate a ``None``
        in the first time. It indicates that the watcher is started and we
        could put the iterator into a response stream now.

        .. note:: You should never touch the database (SQLAlchemy session)
                  here or the connection may be leaked. The request context
                  has been finalized here.

        .. note:: The returned iterator is not thread safe. Do not try to use
                  it in different greenlets.
        
Performs long polling session as an iterator.
The iterator returned by this method will always generate a ``None``
in the first time. It indicates that the watcher is started and we
could put the iterator into a response stream now.

: You should never touch the database (SQLAlchemy session)
here or the connection may be leaked. The request context
has been finalized here.

: The returned iterator is not thread safe. Do not try to use
it in different greenlets.
Performs long polling session as an iterator . The iterator returned by this method will always generate a ` ` None ` ` in the first time . It indicates that the watcher is started and we could put the iterator into a response stream now . : You should never touch the database ( SQLAlchemy session ) here or the connection may be leaked . The request context has been finalized here . : The returned iterator is not thread safe . Do not try to use it in different greenlets .
def perform(self, request_data, tree_watcher, tree_watcher_decorator):
        self.declare_upstream_from_request(request_data)
        for type_name, application_names in request_data.items():
            for application_name, cluster_names in application_names.items():
                tree_watcher.watch(application_name, type_name)
                for cluster_name in cluster_names:
                    tree_watcher.limit_cluster_name(
                        application_name, type_name, cluster_name)
        yield
        tree_watcher = tree_watcher_decorator(tree_watcher)
        for message, body in tree_watcher:
            line = json.dumps({'message': message, 'body': body}) + '\n'
            yield line
def perform ( self , request_data , tree_watcher , tree_watcher_decorator ) : self . declare_upstream_from_request ( request_data ) for type_name , application_names in request_data . items ( ) : for application_name , cluster_names in application_names . items ( ) : tree_watcher . watch ( application_name , type_name ) for cluster_name in cluster_names : tree_watcher . limit_cluster_name ( application_name , type_name , cluster_name ) yield tree_watcher = tree_watcher_decorator ( tree_watcher ) for message , body in tree_watcher : line = json . dumps ( { 'message' : message , 'body' : body } ) + '\n' yield line
Performs long polling session as an iterator.
Performs long polling session as an iterator .
"""Performs long polling session as an iterator.

        The iterator returned by this method will always generate a ``None``
        in the first time. It indicates that the watcher is started and we
        could put the iterator into a response stream now.

        .. note:: You should never touch the database (SQLAlchemy session)
                  here or the connection may be leaked. The request context
                  has been finalized here.

        .. note:: The returned iterator is not thread safe. Do not try to use
                  it in different greenlets.
        """ # TODO Add timing metrics here
self
request_data
tree_watcher
tree_watcher_decorator