huskar_api/api/long_polling.py
def post(self):
        """Subscribes changes of service, switch or config via HTTP long
        polling connection.

        This API accepts requests in following schema::

            {
              "service": {        # "service" / "switch" / "config"
                "base.foo": [     # the application name
                  "cluster-bar",  # the cluster name
                ]
              }
            }

        Put it in your request body and set ``Content-Type: application/json``
        in the request header, you will receive event stream in the response
        body as ``\\n`` splited JSON fragments.

        The events in all clusters will be subscribed, if the cluster list is
        empty.

        The placeholder of cluster name accepts "intent" also, if you enables
        the route mode via the HTTP header ``X-SOA-Mode``. See also
        :ref:`Traffic Control <traffic_control>`.

        The types of event messages in response are described in
        :ref:`long-polling-message-types`.

        :query trigger: Optional. Passing ``1`` will let us dump all existed
                        data in the connection initial. Default is ``1``.
        :query life_span: Optional. How many seconds before the stream end.
                          Default is ``3600``.
        :<header Authorization: Huskar Token (See :ref:`token`)
        :<header Content-Type: :mimetype:`application/json`
        :<header X-SOA-Mode: The SOA mode of service consumer
                             (See :ref:`SOA route <traffic_control_route>`)
        :<header X-Cluster-Name: The cluster name of service consumer
                                 (See :ref:`SOA route <traffic_control_route>`)
        :status 400: The request schema is invalid.
        :status 200: Subscription is okay. You could read the event stream from
                     response body now.
        """
        trigger = request.args.get('trigger', type=int, default=1)
        life_span = request.args.get('life_span', type=int, default=0)
        request_data = self.get_request_data()

        tree_watcher = tree_hub.make_watcher(
            with_initial=bool(trigger),
            life_span=get_life_span(max(life_span, 0)),
            from_application_name=g.application_name,
            from_cluster_name=g.cluster_name,
            metrics_tag_from=g.auth.username,
        )

        # TODO Add timing metrics here
        request_data, tree_watcher_decorator = self.learn_and_hijack_route(
            request_data, tree_watcher)
        response_iterator = self.perform(
            request_data, tree_watcher, tree_watcher_decorator)

        # Wait for being started
        next(response_iterator)

        return Response(stream_with_context(response_iterator))
Subscribes changes of service, switch or config via HTTP long
        polling connection.

        This API accepts requests in following schema::

            {
              "service": {        # "service" / "switch" / "config"
                "base.foo": [     # the application name
                  "cluster-bar",  # the cluster name
                ]
              }
            }

        Put it in your request body and set ``Content-Type: application/json``
        in the request header, you will receive event stream in the response
        body as ``\\n`` splited JSON fragments.

        The events in all clusters will be subscribed, if the cluster list is
        empty.

        The placeholder of cluster name accepts "intent" also, if you enables
        the route mode via the HTTP header ``X-SOA-Mode``. See also
        :ref:`Traffic Control <traffic_control>`.

        The types of event messages in response are described in
        :ref:`long-polling-message-types`.

        :query trigger: Optional. Passing ``1`` will let us dump all existed
                        data in the connection initial. Default is ``1``.
        :query life_span: Optional. How many seconds before the stream end.
                          Default is ``3600``.
        :<header Authorization: Huskar Token (See :ref:`token`)
        :<header Content-Type: :mimetype:`application/json`
        :<header X-SOA-Mode: The SOA mode of service consumer
                             (See :ref:`SOA route <traffic_control_route>`)
        :<header X-Cluster-Name: The cluster name of service consumer
                                 (See :ref:`SOA route <traffic_control_route>`)
        :status 400: The request schema is invalid.
        :status 200: Subscription is okay. You could read the event stream from
                     response body now.
        
Subscribes changes of service, switch or config via HTTP long
polling connection.

This API accepts requests in following schema:.





The events in all clusters will be subscribed, if the cluster list is
empty.

The placeholder of cluster name accepts "intent" also, if you enables
the route mode via the HTTP header ``X-SOA-Mode``. See also
Subscribes changes of service switch or config via HTTP long polling connection . This API accepts requests in following schema : . The events in all clusters will be subscribed if the cluster list is empty . The placeholder of cluster name accepts " intent " also if you enables the route mode via the HTTP header ` ` X - SOA - Mode ` ` . See also
def post(self):
        trigger = request.args.get('trigger', type=int, default=1)
        life_span = request.args.get('life_span', type=int, default=0)
        request_data = self.get_request_data()
        tree_watcher = tree_hub.make_watcher(
            with_initial=bool(trigger),
            life_span=get_life_span(max(life_span, 0)),
            from_application_name=g.application_name,
            from_cluster_name=g.cluster_name,
            metrics_tag_from=g.auth.username,
        )
        request_data, tree_watcher_decorator = self.learn_and_hijack_route(
            request_data, tree_watcher)
        response_iterator = self.perform(
            request_data, tree_watcher, tree_watcher_decorator)
        next(response_iterator)
        return Response(stream_with_context(response_iterator))
def post ( self ) : trigger = request . args . get ( 'trigger' , type = int , default = 1 ) life_span = request . args . get ( 'life_span' , type = int , default = 0 ) request_data = self . get_request_data ( ) tree_watcher = tree_hub . make_watcher ( with_initial = bool ( trigger ) , life_span = get_life_span ( max ( life_span , 0 ) ) , from_application_name = g . application_name , from_cluster_name = g . cluster_name , metrics_tag_from = g . auth . username , ) request_data , tree_watcher_decorator = self . learn_and_hijack_route ( request_data , tree_watcher ) response_iterator = self . perform ( request_data , tree_watcher , tree_watcher_decorator ) next ( response_iterator ) return Response ( stream_with_context ( response_iterator ) )
Subscribes changes of service, switch or config via HTTP long
polling connection.
Subscribes changes of service switch or config via HTTP long polling connection .
"""Subscribes changes of service, switch or config via HTTP long
        polling connection.

        This API accepts requests in following schema::

            {
              "service": {        # "service" / "switch" / "config"
                "base.foo": [     # the application name
                  "cluster-bar",  # the cluster name
                ]
              }
            }

        Put it in your request body and set ``Content-Type: application/json``
        in the request header, you will receive event stream in the response
        body as ``\\n`` splited JSON fragments.

        The events in all clusters will be subscribed, if the cluster list is
        empty.

        The placeholder of cluster name accepts "intent" also, if you enables
        the route mode via the HTTP header ``X-SOA-Mode``. See also
        :ref:`Traffic Control <traffic_control>`.

        The types of event messages in response are described in
        :ref:`long-polling-message-types`.

        :query trigger: Optional. Passing ``1`` will let us dump all existed
                        data in the connection initial. Default is ``1``.
        :query life_span: Optional. How many seconds before the stream end.
                          Default is ``3600``.
        :<header Authorization: Huskar Token (See :ref:`token`)
        :<header Content-Type: :mimetype:`application/json`
        :<header X-SOA-Mode: The SOA mode of service consumer
                             (See :ref:`SOA route <traffic_control_route>`)
        :<header X-Cluster-Name: The cluster name of service consumer
                                 (See :ref:`SOA route <traffic_control_route>`)
        :status 400: The request schema is invalid.
        :status 200: Subscription is okay. You could read the event stream from
                     response body now.
        """ # TODO Add timing metrics here # Wait for being started
self
ref
`Traffic Control `.
The types of event messages in response are described in
` Traffic Control ` . The types of event messages in response are described in
ref
None
query
Optional. Passing ``1`` will let us dump all existed
data in the connection initial.
Optional . Passing ` ` 1 ` ` will let us dump all existed data in the connection initial .
query
Optional. How many seconds before the stream end.
Optional . How many seconds before the stream end .
<header
Huskar Token (See :ref:`token`)
Huskar Token ( See : ref : ` token ` )
<header
None
<header
The SOA mode of service consumer
(See :ref:`SOA route `)
The SOA mode of service consumer ( See : ref : ` SOA route ` )
<header
The cluster name of service consumer
(See :ref:`SOA route `)
The cluster name of service consumer ( See : ref : ` SOA route ` )
status
The request schema is invalid.
The request schema is invalid .
status
Subscription is okay. You could read the event stream from
response body now.
Subscription is okay . You could read the event stream from response body now .